Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ralim/IronOS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen V. Brown <5425387+Ralim@users.noreply.github.com>2022-06-16 14:39:53 +0300
committerGitHub <noreply@github.com>2022-06-16 14:39:53 +0300
commit078b8f5626aae409190c4748588dd5f018f01e7c (patch)
treec3d521b4686d6e7ce5edc8c88910f825db44ce88
parent165a9952c2766718d18bff9d836e2b3f58e4368d (diff)
DeviceID (#1314)
* Ability to print hex * Add device ID getter * Refactor debug menu * No longer need patch * Update make_translation.py * Fix typo * Fix hex drawing
-rwxr-xr-xTranslations/make_translation.py26
-rw-r--r--source/Core/BSP/BSP.h3
-rw-r--r--source/Core/BSP/MHP30/BSP.cpp4
-rw-r--r--source/Core/BSP/Miniware/BSP.cpp8
-rw-r--r--source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h3
-rw-r--r--source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c18
-rw-r--r--source/Core/BSP/Pine64/BSP.cpp3
-rw-r--r--source/Core/Drivers/OLED.cpp7
-rw-r--r--source/Core/Drivers/OLED.hpp5
-rw-r--r--source/Core/Threads/GUIThread.cpp55
-rw-r--r--source/Makefile8
-rw-r--r--source/patch.specs2
12 files changed, 104 insertions, 38 deletions
diff --git a/Translations/make_translation.py b/Translations/make_translation.py
index c2c61590..5c5478ec 100755
--- a/Translations/make_translation.py
+++ b/Translations/make_translation.py
@@ -120,9 +120,6 @@ def get_constants(build_version: str) -> List[Tuple[str, str]]:
def get_debug_menu() -> List[str]:
return [
datetime.today().strftime("%d-%m-%y"),
- "HW G ",
- "HW M ",
- "HW P ",
"Time ",
"Move ",
"RTip ",
@@ -131,7 +128,11 @@ def get_debug_menu() -> List[str]:
"Vin ",
"ACC ",
"PWR ",
+ "ID ",
"Max ",
+ "HW G ",
+ "HW M ",
+ "HW P ",
"Hall ",
]
@@ -429,7 +430,24 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer
def get_forced_first_symbols() -> List[str]:
- forced_first_symbols = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ forced_first_symbols = [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "a",
+ "b",
+ "c",
+ "d",
+ "e",
+ "f",
+ ]
return forced_first_symbols
diff --git a/source/Core/BSP/BSP.h b/source/Core/BSP/BSP.h
index 6060f5f0..dd41bc7f 100644
--- a/source/Core/BSP/BSP.h
+++ b/source/Core/BSP/BSP.h
@@ -74,6 +74,9 @@ void log_system_state(int32_t PWMWattsx10);
// Returns true if the tip is disconnected
bool isTipDisconnected();
+// Return hardware unique ID if possible
+uint64_t getDeviceID();
+
// Status LED controls
enum StatusLED {
diff --git a/source/Core/BSP/MHP30/BSP.cpp b/source/Core/BSP/MHP30/BSP.cpp
index c1feab5c..32c6ffb4 100644
--- a/source/Core/BSP/MHP30/BSP.cpp
+++ b/source/Core/BSP/MHP30/BSP.cpp
@@ -471,3 +471,7 @@ void setStatusLED(const enum StatusLED state) {
setBuzzer(false);
}
}
+uint64_t getDeviceID() {
+ //
+ return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
+} \ No newline at end of file
diff --git a/source/Core/BSP/Miniware/BSP.cpp b/source/Core/BSP/Miniware/BSP.cpp
index d40a7e17..2e86af22 100644
--- a/source/Core/BSP/Miniware/BSP.cpp
+++ b/source/Core/BSP/Miniware/BSP.cpp
@@ -282,5 +282,9 @@ bool isTipDisconnected() {
return tipTemp > tipDisconnectedThres;
}
-void setStatusLED(const enum StatusLED state) {}
-uint8_t preStartChecks() { return 0; } \ No newline at end of file
+void setStatusLED(const enum StatusLED state) {}
+uint8_t preStartChecks() { return 0; }
+uint64_t getDeviceID() {
+ //
+ return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
+}
diff --git a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
index 2bb753ce..2cd99b27 100644
--- a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
+++ b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
@@ -310,6 +310,9 @@ void HAL_ResumeTick(void);
uint32_t HAL_GetHalVersion(void);
uint32_t HAL_GetREVID(void);
uint32_t HAL_GetDEVID(void);
+uint32_t HAL_GetUIDw0(void);
+uint32_t HAL_GetUIDw1(void);
+uint32_t HAL_GetUIDw2(void);
void HAL_DBGMCU_EnableDBGSleepMode(void);
void HAL_DBGMCU_DisableDBGSleepMode(void);
void HAL_DBGMCU_EnableDBGStopMode(void);
diff --git a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
index 4e8304d1..cb32ffdf 100644
--- a/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
+++ b/source/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
@@ -514,6 +514,24 @@ void HAL_GetUID(uint32_t *UID) {
}
/**
+ * @brief Returns first word of the unique device identifier (UID based on 96 bits)
+ * @retval Device identifier
+ */
+uint32_t HAL_GetUIDw0(void) { return (READ_REG(*((uint32_t *)UID_BASE))); }
+
+/**
+ * @brief Returns second word of the unique device identifier (UID based on 96 bits)
+ * @retval Device identifier
+ */
+uint32_t HAL_GetUIDw1(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 4U)))); }
+
+/**
+ * @brief Returns third word of the unique device identifier (UID based on 96 bits)
+ * @retval Device identifier
+ */
+uint32_t HAL_GetUIDw2(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 8U)))); }
+
+/**
* @}
*/
diff --git a/source/Core/BSP/Pine64/BSP.cpp b/source/Core/BSP/Pine64/BSP.cpp
index 2c7de076..3b8df2eb 100644
--- a/source/Core/BSP/Pine64/BSP.cpp
+++ b/source/Core/BSP/Pine64/BSP.cpp
@@ -91,4 +91,5 @@ bool isTipDisconnected() {
void setStatusLED(const enum StatusLED state) {}
-uint8_t preStartChecks() { return 0; } \ No newline at end of file
+uint8_t preStartChecks() { return 0; }
+uint64_t getDeviceID() { return dbg_id_get(); }
diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp
index 260af607..ab436e0e 100644
--- a/source/Core/Drivers/OLED.cpp
+++ b/source/Core/Drivers/OLED.cpp
@@ -423,6 +423,13 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) {
}
}
}
+void OLED::drawHex(uint32_t x, FontStyle fontStyle) {
+ // print number to hex
+ for (uint_fast8_t i = 0; i < 8; i++) {
+ uint16_t value = (x >> (4 * (7 - i))) & 0b1111;
+ drawChar(value + 2, fontStyle);
+ }
+}
// maximum places is 5
void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) {
char buffer[7] = {0};
diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp
index ee322815..0d6f790c 100644
--- a/source/Core/Drivers/OLED.hpp
+++ b/source/Core/Drivers/OLED.hpp
@@ -89,6 +89,7 @@ public:
// Draws a checkbox
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
static void debugNumber(int32_t val, FontStyle fontStyle);
+ static void drawHex(uint32_t x, FontStyle fontStyle);
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
@@ -104,8 +105,8 @@ public:
private:
static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
static void setFramebuffer(uint8_t *buffer);
- static uint8_t * firstStripPtr; // Pointers to the strips to allow for buffer having extra content
- static uint8_t * secondStripPtr; // Pointers to the strips
+ static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
+ static uint8_t *secondStripPtr; // Pointers to the strips
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
static bool initDone;
static DisplayState displayState;
diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp
index be7ee864..d0a863fc 100644
--- a/source/Core/Threads/GUIThread.cpp
+++ b/source/Core/Threads/GUIThread.cpp
@@ -691,46 +691,34 @@ void showDebugMenu(void) {
case 0: // Just prints date
break;
case 1:
- // High water mark for GUI
- OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
- break;
- case 2:
- // High water mark for the Movement task
- OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
- break;
- case 3:
- // High water mark for the PID task
- OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
- break;
- case 4:
// system up time stamp
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL);
break;
- case 5:
+ case 2:
// Movement time stamp
OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL);
break;
- case 6:
+ case 3:
// Raw Tip
{ OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); }
break;
- case 7:
+ case 4:
// Temp in C
OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL);
break;
- case 8:
+ case 5:
// Handle Temp
OLED::printNumber(getHandleTemperature(0), 6, FontStyle::SMALL);
break;
- case 9:
+ case 6:
// Voltage input
printVoltage();
break;
- case 10:
+ case 7:
// Print ACC type
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
break;
- case 11:
+ case 8:
// Power negotiation status
{
int sourceNumber = 0;
@@ -766,12 +754,32 @@ void showDebugMenu(void) {
OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL);
}
break;
- case 12:
+ case 9:
+ // Print device ID Numbers
+ {
+ uint64_t id = getDeviceID();
+ OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL);
+ OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL);
+ }
+ break;
+ case 10:
// Max deg C limit
OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL);
break;
-#ifdef HALL_SENSOR
+ case 11:
+ // High water mark for GUI
+ OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
+ break;
+ case 12:
+ // High water mark for the Movement task
+ OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
+ break;
case 13:
+ // High water mark for the PID task
+ OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
+ break;
+#ifdef HALL_SENSOR
+ case 14:
// Print raw hall effect value if availabe, none if hall effect disabled.
{
int16_t hallEffectStrength = getRawHallEffect();
@@ -781,6 +789,7 @@ void showDebugMenu(void) {
}
break;
#endif
+
default:
break;
}
@@ -792,9 +801,9 @@ void showDebugMenu(void) {
else if (b == BUTTON_F_SHORT) {
screen++;
#ifdef HALL_SENSOR
- screen = screen % 14;
+ screen = screen % 15;
#else
- screen = screen % 13;
+ screen = screen % 14;
#endif
}
GUIDelay();
diff --git a/source/Makefile b/source/Makefile
index 0de50fbf..0d7a78a4 100644
--- a/source/Makefile
+++ b/source/Makefile
@@ -1,5 +1,5 @@
ifndef model
-model:=TS100
+model:=Pinecil
endif
ALL_MINIWARE_MODELS=TS100 TS80 TS80P
@@ -161,7 +161,7 @@ bootldr_size=0x0
CPUFLAGS= -march=rv32imac \
-mabi=ilp32 \
-mcmodel=medany -fsigned-char -fno-builtin -nostartfiles
-DEV_LDFLAGS=-nostartfiles --specs=patch.specs
+DEV_LDFLAGS=-nostartfiles
DEV_AFLAGS=
DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
DEV_CFLAGS=
@@ -192,10 +192,10 @@ $(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
# code optimisation ------------------------------------------------------------
-OPTIM=-Os -flto -finline-small-functions -fshort-wchar -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
+OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
# global defines ---------------------------------------------------------------
-GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
+GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar
DEBUG=-g3
ifdef swd_enable
diff --git a/source/patch.specs b/source/patch.specs
deleted file mode 100644
index 312b1d49..00000000
--- a/source/patch.specs
+++ /dev/null
@@ -1,2 +0,0 @@
-*link:
-%(nano_link) %:replace-outfile(-lm_nano -lm) \ No newline at end of file