Open dzid26 opened 2 years ago
Is 64k flash too limited for an UDS bootloader over CAN? For example https://github.com/LittleBasdart/UdsBootloader
@OxygenLiu I think it could work. It's hard to see though how much memory it uses. I see that it expects adjustable 4k payloads, so that's RAM.
First issue is the drivers are made for Stm32L4 registers.
Second it would need to be well integrated, for example SysTick needs to be either not used by delay.c or it should share this resource nicely. This is valid for any resource that is shared and becomes a little more complicated when a bootloader does more things than just loading the new program.
:+1: Hopefully it will support OTA upgrade using A/B partitions.
The current firmware is about 29k bytes, seems a bit bulky. Assuming the bootloader takes 20k, the remaining 44k shall accomendate 20k A and 20K B partitions.
I looked into the size stuff using this useful tool.
Platformio also has something similar.
Here is a report from mbed-os-linker-report
Remarks:
.text
section - which is code - not sure if the size is adequate for the amount of the code..-g
option that was adding .debuginfo
sections. (This section doesn't go to the firmware, just ELF and is useful with tools like StmStufio or Stmmonitor).-Os -flto
reduces size to 24kb, but LTO for some reason removes debug symbols, which is fine board_build.ldscript = ./src/APP/STM32F103C8_DEFAULT.ld
in platformio.ini
uses STM linker file. Otherwise platformio compiles using gcc's internal linker. It can be verified by building with -Wl,--verbose
option. Weirdly, using an internal linker uses 24kb or 25kb with LTO. I guess the solution to save ROM, if necessary, will be using -Os -flto
and removing unnecessary code.
Edit: Extra 1kB can be saved by storing both parameters and CalData in the same Page (separated by some offset) since I made it much smaller than it used to be.
There is certainly some unnecessary code in .text
, such as BSP/display.c
, which is about 2.89%.
Two interesting implementations of CAN bootloader for STM32F103,
PreSystemInit
call
CANbus programming shall be enabled by magic packet/on a specific CAN message id and when motor is not off (essentially when
A4950_Enabled == false
)Implementations: https://github.com/feaser/openblt - has built in XCP, supports CAN dongles on the host, uses ST HAL https://github.com/Arksine/CanBoot https://github.com/UberLambda/CANnuccia https://github.com/madprogrammer/stm32-can-bootloader https://stackoverflow.com/questions/61243660/stm32103-custom-bootloader-jump-to-main-firmware-issue
Todo:
/firmware
.platformio run
) for the firmware and CAN uploading using panda