-
The LED 0 blinks at 1hz for 5 seconds and the system waits for update message. If no single byte is received from FDTI chip (USART1) within the 5seconds, it looks to the memory location at 0x0802_0000. If the data is 0xFFFFFFFF (erased value) at the location, the system halts in a while loop and LED 1 turns on, else it starts excuting code from that location.
-
If a byte is received wihin the 5 seconds, it loops in a program state machine until it receives program done ID frame from serial port application.
-
on board CH340 driver does not work with Linux serial port so I change USART1 pins to PB6 PB7 and use FDTI chip to talk to /dev/ttyUSB0
-
This program only takes bin size smaller than 128k (a sector for STM32H743). Update size does not have to be aligned to a flash word (256bits), software will auto-fill up with 0xFF if not aligned. Max PAYLOAD of update byte is 256 bytes per frame.
-
Now the program only erases and updates Bank 1 Sector 1 (0x802_0000), it needs further improvemnet for flexible sector update.
-
versioning are MAJOR.MINOR.PATCH. each is represented by 1 byte value (0 ~ 255) e.g. v2.0.23 (update_info.version[0]=0x02, update_info.version[1]=0x00, update_info.version[2]=0x17)
-
the update struct (update address,firmware version, checksum) taken from desktop serial app is not stored into the flash nor the eeprom. if they are stored in EEPROM, checksum can be checked before the jump at every boot-up.
-
For STM32H7, a flash word = 8 word * 32bit = 256bits
|-SOF-|-Frame_ID-|-Len-|-Data-|-FrameChecksum-|-EOF-|
|--1--|----1-----|--2--|---n--|------1--------|--1--|
- #define BL_START_OF_FRAME 0x55
- #define BL_END_OF_FRAME 0xFF
- FrameChecksum: 2"s complement of all Data added together
|-SOF-|-BL_HEADER-|-Len-|-Address-|-Size-|-Version-|-FirmwareChecksum-|-FrameChecksum-|-EOF-|
|- 1 -|----1------|--2--|---4-----|--4---|---3-----|--------4---------|------4--------|--1--|
- #define BL_HEADER 0x01 //sends info about firmware: size , version
- sent by desktop app
- #define BL_STATUS_CHECK 0x02 //not used yet
- #define BL_START_UPDATE 0x03 //not used yet
|-SOF-|-Frame_ID-|-Len-|-Data-|-FrameChecksum-|-EOF-|
|--1--|----1-----|--2--|---n--|------1--------|--1--|
- #define BL_PAYLOAD 0x04
- sent by desktop app
|-SOF-|-BL_UPDATE_DONE-|-Len-|-FrameChecksum-|-EOF-|
|--1--|--------1-------|--2--|-------1-------|--1--|
- #define BL_UPDATE_DONE 0x05
- sent by desktop app.the legnth is 0.
|-SOF-|-BL_ACK_FRAME-|-Len-|-FrameChecksum-|-EOF-|
|--1--|------1-------|--2--|--------1------|--1--|
- #define BL_ACK_FRAME 0x06
- sent by uC. There is no data for this frame so the length is always 0.
|-SOF-|-BL_NACK_FRAME-|-Len-|-ErrorFlag-|-FrameChecksum-|-EOF-|
|--1--|-------1-------|--2--|----4------|-------1-------|--1--|
- #define BL_NACK_FRAME 0x07
- sent by uC.the legnth is 4, 4byte Error Flag MSB first
-
this stm32H743zi bootloader program project was generated by STM32CubeMX makefile project. Using VScode IDE with Cortex-Debug, C/C++extension and Makefile Tools. (The project compiles with -Og if DEBUG == 1)
-
Jlink EDU Mini debugger/ FT232 USB UART Mini Board
-
stm32h743 schematic:
-
compiler: arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 (release)