stm32f4-uart-bootloader

Simple UART bootloader for STM32F4 MCU's
git clone git://git.mdnr.space/stm32f4-uart-bootloader
Log | Files | Refs | Submodules | README | LICENSE

README.md (3012B)


      1 # UART Bootloader for STM32F4 MCU
      2 
      3 This is a simple UART bootloader written for STM32f4 MCUs based on the libopencm3 library.
      4 
      5 ## Building
      6 
      7 clone this repo, build and setup the submodules and run make.
      8 ```
      9 git clone git@github.com:mdnr/stm32f4-uart-bootloader.git --recurse-submodules --shallow-submodules
     10 cd stm32f4-uart-bootloader
     11 make -C src/shared/opencm3/ TARGETS=stm32/f4
     12 cp configs/FreeRTOSConfig.h src/app/freertos/include/
     13 make
     14 ```
     15 The versioning of the build output is done automatically based on the latest tag and commit hash.
     16 (tag format must be `v<MAJOR>.<MINOR>`, e.g. `v0.1`)
     17 
     18 ## Memory layout
     19 
     20 Currently the flash memory of the MCU is divided as below:
     21 
     22  ```
     23  ****************************************
     24  0x0800000: Flash base  / Bootloader start
     25  Bootloader: 16KB
     26  ****************************************
     27  0x0804000: Bootloader end / Parameters start
     28  Parameters: 8KB (Config and application settings based on user's needs)
     29  ----------------------------------------
     30  0x8002000: Parameters end / Diagnostic area start
     31  Doggy litter box: 8KB  (Watchdog register dump area)
     32  ****************************************
     33  0x0808000: Application start
     34  Aplication Vector table
     35  ----------------------------------------
     36  Firmware info (Version, size, etc)
     37  ----------------------------------------
     38  Application code
     39  ****************************************
     40   ```
     41   The root directory Makefile takes care of compiling both binaries
     42   for bootloader and application and flashing them in the corresponding addresses.
     43   
     44  -  `make all`: compile both application and bootloader binaries
     45  -  `make app`: compile application binary
     46  -  `make bl`: compile bootloader binary
     47  -  `make flash`: flash both application and bootloader to MCU
     48  -  `make flash-bl`: flash bootloader only without touching the application
     49  -  `make flash-app`: flash application only without touching the bootloader
     50   
     51   Also there are 2 debug targets `(make fw-debug and make bl-debug)` for debugging the bootlaoder and application
     52   remotely on the target.
     53   
     54   ## Using the bootloader
     55   
     56   Run the python script from the root directory to connect to the serial port using a usb-serial converter
     57   ```
     58   ./bootloader.py
     59   ```
     60   Specify the port connected to the MCU board (e.g. `/dev/ttyUSB0`) and choose one of 
     61   the actions listed:
     62   1. `Read parameters`: Read current parameters stored in the MCU's parameter section
     63   2. `Update parameters`: Write new parameters to the flash without touching application code
     64   3. `Read firmware info`: Read firmware verison, size, etc.
     65   4. `Reset the core`: Send reboot command ans start bootloader process.
     66   5. `Lock serial line`: Lock the UART line in case it's used by the application
     67   6. `UnLock serial line`: Release the UART lock
     68   7. `Read diagnostics`: Read the dumped diagnostic data from corresponding section
     69   8. `Abort`: Quit the bootlaoder
     70 
     71 ## TODO
     72  
     73 - Adding GSM layer to support OTA update
     74 - Rewriting `bootloader.py` in C perhaps and adding proper UI to it
     75 - Adding Encryption