From 9a0ea8e7f9a2f72983beccbb460096e59493dc04 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 13 Feb 2024 22:06:52 +1100 Subject: [PATCH 1/4] Add S60P bootloader offsets --- Makefile | 25 +++++++----- build_all.sh | 5 +++ src/config.h | 6 +-- src/oled.h | 42 ++++++++++---------- src/stm32f103_runtime_s60p.ld | 73 +++++++++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+), 34 deletions(-) create mode 100644 src/stm32f103_runtime_s60p.ld diff --git a/Makefile b/Makefile index 1c08f67..e6392fb 100644 --- a/Makefile +++ b/Makefile @@ -4,18 +4,23 @@ build_type ?= runtime model ?= unknown ifeq ($(build_type), runtime) - ifeq ($(model), S60) - VECTOR_TABLE_OFFSET := 0x4400 - SRC_LD = src/stm32f103_runtime_s60.ld + ifeq ($(model), S60P) + VECTOR_TABLE_OFFSET := 0x5000 + SRC_LD = src/stm32f103_runtime_s60p.ld else -# For MHP30 override the runtime to offset to 32k - ifeq ($(model),"MHP30") - VECTOR_TABLE_OFFSET := 0x8000 - SRC_LD = stm32f103_32k_runtime.ld + ifeq ($(model), S60) + VECTOR_TABLE_OFFSET := 0x4400 + SRC_LD = src/stm32f103_runtime_s60.ld else - - VECTOR_TABLE_OFFSET := 0x4000 - SRC_LD = src/stm32f103_runtime.ld + # For MHP30 override the runtime to offset to 32k + ifeq ($(model),"MHP30") + VECTOR_TABLE_OFFSET := 0x8000 + SRC_LD = stm32f103_32k_runtime.ld + else + + VECTOR_TABLE_OFFSET := 0x4000 + SRC_LD = src/stm32f103_runtime.ld + endif endif endif BIN = runtime diff --git a/build_all.sh b/build_all.sh index 178089b..4ea3e23 100755 --- a/build_all.sh +++ b/build_all.sh @@ -20,3 +20,8 @@ make -j build_type=bootloader model=MHP30 rm -rf build/*.o build/*.d make -j build_type=runtime model=MHP30 rm -rf build/*.o build/*.d + +make -j build_type=bootloader model=S60P +rm -rf build/*.o build/*.d +make -j build_type=runtime model=S60P +rm -rf build/*.o build/*.d diff --git a/src/config.h b/src/config.h index 94ce01f..e2f62dc 100644 --- a/src/config.h +++ b/src/config.h @@ -36,11 +36,11 @@ #define FLASH_SIZE_KB 128 #define FLASH_BOOTLDR_SIZE_KB 16 #define FLASH_BOOTLDR_PAYLOAD_SIZE_KB 112 -#elif MODEL_S60 +#elif MODEL_S60 || MODEL_S60P #define GPIO_DFU_BOOT_PORT GPIOB #define GPIO_DFU_BOOT_PIN 0 -#define GPIO_DP_PULLUP_PORT GPIOA -#define GPIO_DP_PULLUP_PIN 8 +#define GPIO_DP_PULLUP_PORT GPIOA +#define GPIO_DP_PULLUP_PIN 8 #define FLASH_SIZE_KB 128 #define FLASH_BOOTLDR_SIZE_KB 17 #define FLASH_BOOTLDR_PAYLOAD_SIZE_KB 111 diff --git a/src/oled.h b/src/oled.h index 6a020e8..227b874 100644 --- a/src/oled.h +++ b/src/oled.h @@ -5,28 +5,28 @@ #define DEVICEADDR_OLED (0x3c << 1) -#ifdef MODEL_S60 - // TODO; for now just cropping in on the screen from 128x32 to 96x16 - #define OLED_WIDTH 96 - #define OLED_HEIGHT 16 - #define OLED_GRAM_START 0x10 // Should be 0x00 when we have full width - #define OLED_GRAM_END 0x6F // Should be 0x7F when we have full width - #define OLED_VCOM_LAYOUT 0x12 - #define OLED_SEGMENT_MAP 0xA1 +#if MODEL_S60 || MODEL_S60P +// TODO; for now just cropping in on the screen from 128x32 to 96x16 +#define OLED_WIDTH 96 +#define OLED_HEIGHT 16 +#define OLED_GRAM_START 0x10 // Should be 0x00 when we have full width +#define OLED_GRAM_END 0x6F // Should be 0x7F when we have full width +#define OLED_VCOM_LAYOUT 0x12 +#define OLED_SEGMENT_MAP 0xA1 #else - #define OLED_WIDTH 96 - #define OLED_HEIGHT 16 - #define OLED_VCOM_LAYOUT 0x02 - - #ifdef OLED_FLIP - #define OLED_GRAM_START 0 // Should be 0x00 when we have full width - #define OLED_GRAM_END 95 - #define OLED_SEGMENT_MAP 0xA1 - #else - #define OLED_GRAM_START 0x20 // Should be 0x00 when we have full width - #define OLED_GRAM_END 0x7F - #define OLED_SEGMENT_MAP 0xA0 - #endif +#define OLED_WIDTH 96 +#define OLED_HEIGHT 16 +#define OLED_VCOM_LAYOUT 0x02 + +#ifdef OLED_FLIP +#define OLED_GRAM_START 0 // Should be 0x00 when we have full width +#define OLED_GRAM_END 95 +#define OLED_SEGMENT_MAP 0xA1 +#else +#define OLED_GRAM_START 0x20 // Should be 0x00 when we have full width +#define OLED_GRAM_END 0x7F +#define OLED_SEGMENT_MAP 0xA0 +#endif #endif #define FRAMEBUFFER_START 17 diff --git a/src/stm32f103_runtime_s60p.ld b/src/stm32f103_runtime_s60p.ld new file mode 100644 index 0000000..9aeaccd --- /dev/null +++ b/src/stm32f103_runtime_s60p.ld @@ -0,0 +1,73 @@ +/* + * This file is part of the libopenstm32 project. + * + * Copyright (C) 2010 Thomas Otto + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* Define memory regions. */ +MEMORY +{ + rom (rx) : ORIGIN = 0x08005000, LENGTH = 8K + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8k +} + +/* Enforce emmition of the vector table. */ +EXTERN (vector_table) + +/* Define the entry point of the output file. */ +ENTRY(reset_handler) + +/* Define sections. */ +SECTIONS +{ + .text : { + *(.vectors) /* Vector table */ + *(.text*) /* Program code */ + . = ALIGN(4); + *(.rodata*) /* Read-only data */ + . = ALIGN(4); + } >rom + + _etext = .; + + .data : { + _data = .; + *(.data*) /* Read-write initialized data */ + . = ALIGN(4); + _edata = .; + } >ram AT >rom + _data_loadaddr = LOADADDR(.data); + + .bss : { + *(.bss*) /* Read-write zero initialized data */ + *(COMMON) + . = ALIGN(4); + _ebss = .; + } >ram + + /* + * The .eh_frame section appears to be used for C++ exception handling. + * You may need to fix this if you're using C++. + */ + /DISCARD/ : { *(.eh_frame) } + + . = ALIGN(4); + end = .; +} + +PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram)); + + From 6098465a7433a4a00595cb4c228d1a348a1a23a2 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 13 Feb 2024 22:07:55 +1100 Subject: [PATCH 2/4] Update CI --- .github/workflows/push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1528635..0f7d3e9 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -9,7 +9,7 @@ jobs: image: alpine:3.15 strategy: matrix: - model: ["TS100", "TS80", "TS80P", "MHP30"] + model: ["TS100", "TS80", "TS80P", "MHP30", "S60P", "S60"] fail-fast: true steps: - name: Install dependencies (apk) @@ -18,7 +18,7 @@ jobs: - name: Install dependencies (py) run: pip3 install IntelHex - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true @@ -38,7 +38,7 @@ jobs: run: cp build/*.hex build/*.dfu /tmp/${{ matrix.model }} - name: Archive artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ matrix.model }} path: | From e524e29bd5ce9410012729ab7cae84fb5e4d8739 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 13 Feb 2024 22:11:50 +1100 Subject: [PATCH 3/4] Update BackUp.md --- docs/BackUp.md | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/docs/BackUp.md b/docs/BackUp.md index ca31ab4..6fb01f5 100644 --- a/docs/BackUp.md +++ b/docs/BackUp.md @@ -16,18 +16,26 @@ The Iron will show a IronOS logo and then show the text "DFU" with its version n ## Step 2: Use dfu-util to read out your current bootloader -``` -For TS80,TS80P,TS100 -sudo dfu-util -d 28e9:0189 -U backup.bin -s 0x08000000:0x4000 -OR for MHP30 -sudo dfu-util -d 28e9:0189 -U backup.bin -s 0x08000000:0x8000 - -``` - Run this command with the iron connected via USB, and it will create a file called backup.bin in the current folder. this will be a copy of your bootloader for you to keep should you wish to return. Due to this being copright Miniware, the bootloader files will _NOT_ be hosted in this repo. However, we will publish known checksums of the backups so you can check if yours is a known one or not. +### TS80,TS80P,TS100 + +`sudo dfu-util -d 28e9:0189 -U backup.bin -s 0x08000000:0x4000` + +### S60 + +`sudo dfu-util -d 28e9:0189 -U backup.bin -s 0x08000000:0x4400` + +### S60P + +`sudo dfu-util -d 28e9:0189 -U backup.bin -s 0x08000000:0x5000` + +### MHP30 + +`sudo dfu-util -d 28e9:0189 -U backup.bin -s 0x08000000:0x8000` + If it works, our output should look like this: ``` @@ -54,14 +62,13 @@ If you have lost your backup, and you need one; if you contact @ralim really nic Known recorded MD5 checksums: -| Device | DFU Version | MD5 | -|:-------|:------------:|----------------------------------| -| TS100 | 3.42 | CD1038179B3FDA32E75D6F300D153CB3 | -| TS100 | 3.43 | F67879424D73345E4BDDCA69A4F9C75C | -| TS100 | 3.45 | 17FFF8A9D561B226D1DDC2D19BA2198E | -| TS80P | 3.50 | 1805EC83F64C74DD89F87A1B57B7E631 | -| TS80 | 3.45 | FADAE45B4249D4F156C30B7D4B0A853E | - +| Device | DFU Version | MD5 | +| :----- | :---------: | -------------------------------- | +| TS100 | 3.42 | CD1038179B3FDA32E75D6F300D153CB3 | +| TS100 | 3.43 | F67879424D73345E4BDDCA69A4F9C75C | +| TS100 | 3.45 | 17FFF8A9D561B226D1DDC2D19BA2198E | +| TS80P | 3.50 | 1805EC83F64C74DD89F87A1B57B7E631 | +| TS80 | 3.45 | FADAE45B4249D4F156C30B7D4B0A853E | In the mean time, you can validate if your backup looks valid by loading it into [hexed.it](https://hexed.it/). From e9afff53c1a127a2c78b64e5de0ced4d5af0dc77 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 14 Feb 2024 19:47:11 +1100 Subject: [PATCH 4/4] Update Bootloader.md --- docs/Bootloader.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/Bootloader.md b/docs/Bootloader.md index 2b8402b..fe7d5e5 100644 --- a/docs/Bootloader.md +++ b/docs/Bootloader.md @@ -4,8 +4,16 @@ This software can be used to replace the bootloader built into your device from This DFU loader replaces the often troubled usb-disk method with the well known dfu-util. This is the same method used on the Pinecil, and lets all your devices enjoy more stable updating. +## Notice -**Please note: There has been a report that TS100 units shipping with DFU 3.48 may have the lock bits set. If you have this DFU version its reccomended to have a cheap st-link or other SWD programmer in case recovery is needed. #9** +There has been a report that TS100 units shipping with DFU 3.48 may have the lock bits set. If you have this DFU version its reccomended to have a cheap st-link or other SWD programmer in case recovery is needed. +It has also been noted that TS101 units, some MHP30 units and some newer TS80P units may also have the lock bits set. +On **all** Sequre parts the lock bits are set, so a programmer is required. +On these devices, flashing the runtime will work fine, so you can backup your bootloader. However if you use the runtime to flash the main bootloader it will not work and your device will loose its bootloader. +To work around this, the best action is to use a cheap SWD programmer to connect to the device and remove the lock bits. You can then flash your old bootloader or this new one at will. + +On Miniware devices, the newer ones have the SWD pins wired up to D+/D-. +On Sequre devices the pads are under the OLED but are clearly labeled (V=3.3V,C=SWCLK,D=SWDIO,G=GND). ## Flashing this bootloader