Skip to content

Commit 4d4336a

Browse files
committed
fixes/improvements
- fixed uploader offset (i just wrote a bad python scipt (forgot flash_base, and it must be hex())) - fixed platformio-build.py dependency (by using the newest stm32duino core version, which includes fixes). See stm32duino/Arduino_Core_STM32#2135 - cleaned up some minor stuff
1 parent 5a08598 commit 4d4336a

File tree

9 files changed

+54
-912
lines changed

9 files changed

+54
-912
lines changed

Diff for: README.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ Jumping to the user program takes about ~1.5ms if using 'leave_LSE_same' (asin
99

1010
Usage: (see example project)
1111
- (to compile the example script, copy the whole library into the lib folder of that project)
12-
- replace the platformio-build.py script in .platformio\packages\framework-arduinoststm32\tools\platformio with the one in patches\ (this makes setting a VECT_TAB_OFFSET possible)
13-
- in the platformio.ini file, there are 2 targets. One is for uploading bootloader code and the other is for uploading application code. (Note: currently, my ST-links are overwriting the bootloader when uploading user-applications. Very annoying, will fix soon).
14-
- Upload the user-app (by selecting the 'OTA_z_STM32WB55' target)
12+
- in the platformio.ini file, there are 2 targets. One is for uploading bootloader code and the other is for uploading application code.
13+
- Upload the user-app (by selecting the 'OTA_z_STM32WB55' target) (Note: if your uploader offset settings are correct, this should not overwrite bootloaders)
1514
- then upload the bootloader (by selecting the 'BOOTL_STM32WB55' target)
1615
- watch the serial monitor show it booting twice
1716

1817

1918
current problems i'm trying to solve:
20-
- patching the platformio-build.py script automatically (and perhaps more eligantly than just replacing it)
21-
- test bluetooth before and after jump
22-
- add some basic watchdog suggestions
23-
- add some basic flash/backup-domain flag suggestions
24-
- (work on the full BLE OTA code that relies on this stuff)
19+
- find a way to perform SHCI_C2_Reinit() (from the STM32duinoBLE library, but without importing the whole library), or perhaps a more universal CPU2 reset
20+
- add some basic watchdog example code
21+
- add some basic flash/backup-domain flag example code
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## this script is used to help indicate when the bootloader is too large.
2+
## NOTE: this script does not check the size itself, but rather updates the believed max flash size, which platformIO shows after compiling
3+
4+
Import("env")
5+
# print("bootloader_size_check.py has ran") # basic debug
6+
config = env.GetProjectConfig() # access the overall project
7+
PROGRAM_START_str : str = config.get("TOTALB", "PROGRAM_START") # fetch variable from other env
8+
PROGRAM_START = int(PROGRAM_START_str, 16 if (PROGRAM_START_str.startswith("0x")) else 10) # convert to int
9+
# print("PROGRAM_START:", PROGRAM_START_str, PROGRAM_START)
10+
flash_base : int = 0x08000000 # TODO: retrieve automatically (instead of hardcoding like this)
11+
# print("flash_base + PROGRAM_START:", hex(flash_base + PROGRAM_START), type(flash_base))
12+
board_config = env.BoardConfig() # fetch board configuration of current env
13+
board_config.update("upload.offset_address", hex(flash_base + PROGRAM_START)) # indicate where to start uploading the new program
14+
board_config.update("build.flash_offset", PROGRAM_START) # tell platformio-build.py to tell the compiler & linker to offset flash.
15+
## NOTE: from STM32duino version 2.7.0 onwards, platformio-build will (finally) set LD_FLASH_OFFSET flag and define VECT_TAB_OFFSET based on build.flash_offset

Diff for: examples/STM32WB55_custom_arduino_bootloader_platformIO_example/application_upload_offset.py

-10
This file was deleted.

Diff for: examples/STM32WB55_custom_arduino_bootloader_platformIO_example/apply_patches.py

-26
This file was deleted.

Diff for: examples/STM32WB55_custom_arduino_bootloader_platformIO_example/bootloader_size_check.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44
Import("env")
55
# print("bootloader_size_check.py has ran") # basic debug
66
config = env.GetProjectConfig() # access the overall project
7-
PROGRAM_START_str : str = config.get("TOTALB", "PROGRAM_START") # fetch variable from other env
8-
# print("PROGRAM_START:", PROGRAM_START_str, int(PROGRAM_START_str, 16 if (PROGRAM_START_str.startswith("0x")) else 10))
7+
maxSize : str = config.get("TOTALB", "PROGRAM_START") # fetch variable from other env
8+
# print("PROGRAM_START:", maxSize, int(maxSize, 16 if (maxSize.startswith("0x")) else 10))
9+
maxSize : int = int(maxSize, 16 if (maxSize.startswith("0x")) else 10) # convert str to int
10+
try:
11+
comm_area = config.get("TOTALB", "BOOTLOADER_COMM_SIZE")
12+
# print("BOOTLOADER_COMM_SIZE:", comm_area, int(comm_area, 16 if (comm_area.startswith("0x")) else 10))
13+
comm_area = int(comm_area, 16 if (comm_area.startswith("0x")) else 10) # convert str to int
14+
maxSize -= comm_area
15+
except:
16+
# print("BOOTLOADER_COMM_SIZE not found") # just to let the user know (not actually an issue)
17+
doNothing = 0
918
board_config = env.BoardConfig() # fetch board configuration of current env
10-
board_config.update("upload.maximum_size", int(PROGRAM_START_str, 16 if (PROGRAM_START_str.startswith("0x")) else 10)) # update max size (to show bootloader size limit)
19+
board_config.update("upload.maximum_size", maxSize) # update max size (to show bootloader size limit)

0 commit comments

Comments
 (0)