The repository contains the code of the bootloader for Sinapse Devices based on stm32 chips
This project covers the development and testing of the generic bootloader for Sinapse Devices based on several chips of the STM32 family. The Readme of the project works as a technical requirements document and like a contract in case of subcontracting parts of the project.
Bootloader : Little and stable program that is executed in each microcontroller start and after finish continue with the execution of the main program
Main program : Business application executed by a Sinapse Device. Each Sinapse Device has its own main program but the bootloader is the same fo each device
Sinapse Device : HW Device designed & manufactured by Sinapse Energía equipped with a microcontroller from the STM32 family
Configuration File (CF): Header of the Bootloader where are defined the particularities of each bootloader. The Bootloader is generic but in this file are defined the partcularities of each device. For example, the folder (in ftp server) that contains the upgraded versions, the gprs configuration or the limitations of a particular micro, like the maximum available memory.
ATOLLIC TrueSTUDIO for ARM: Complete IDE to development firmware under C/C++ language and over a lot of microcontrollers, generic ARM and STM32Fxx devices.
STM32CubeMX: to generate all HAL drivers needed and integrate into ATOLLIC TrueSTUDIO.
STLink Utility: to program HEX files into STM32Fxx devices.
GNU Tools ARM Embedded : GCC compiler and more tools.
Sinapse Devices: Devices running with STM32Fxx processor where BOOTLOADER firmware will be loaded. They are also the devices under test (DUT): Basically devices with STM32F030CC, STM32F405VG processor and STM32F030K6T6 processor.
The generic bootloader for Sinapse Devices it is a little program that will be executed at the start / restart of any Sinapse device and will check if there is a new version of the Main program in a FTP server. If there is a new version, the bootloader should download the new main program, check its validity, check if there is enough space in the flash memory to install the program and then remove the current main program and install the new one and perform the execution handover to the new main program. If there is not a new version, the bootloader should realise the execution handover to the main program.
For more information about a global view of how a generic bootloader should works, it is possible to consult the following url: http://blog.atollic.com/how-to-develop-and-debug-bootloader-application-systems-on-arm-cortex-m-devices
A basic FTP client over GPRS and WIFI/ETH should be developed.
GPRS: The peripheral used includes native support for FTP. It is only necessary to encapsulate the AT commands in some C functions in order to connect / download / disconnect from FTP server
ETH / WIFI: The peripheral used for WIFI / ETH connection does not have native FTP support but provides a transparent transmission TCP protocol mode over UART. In this case is necessary to create the FTP packages and send it directly to the UART where USR device is connected, the answers will be received also over the UART.
The workflow of the bootloader should be the following one:
Here are explained the technical requirements that should be covered by the Sinapse Generic Bootloader. The technical requirements aims to be almost unitary and testable. Each technical requirement should be tested as OK in order to give it as a valid
The requirements are divided by flow diagram elements
Note: Each device should check 2 FTP folders.
So Bootloader program have to contain Device ID. Folders routes have to be generical and easily modificable. Will be setup as described below:
ftp root/DEVICE_CODE_FW/
ftp root/DEVICE_CODE_FW/DEVICE_ID/
FWNAME: No limitations, end with
VxpY: FW version i.e. V1p4 = V1.4
ddmmyy: Release Date
*Note The actual stored version and date are saved in the first positions of the first page of the flash memory. The bootloader from fabric has these values set to: "last_update = date_installation" and "version = Vp, for example 14 -> V1p4"
If answer in previous process was NEW_AVAILABLE_FIRMWARE, jump to Download new FW
Check if VxpY and ddmmyy are higher that actual stored version and date
If yes, jump to "Process - Download new FW".
If answer was different we jump to "Process - Execution handover to main program"
1) From 0x08000000 - 0x80027FF BOOTLOADER 2) From 0x08002800 - (0x8002800+MAX_SIZE_APPLICATION_PROGRAM-1) APPLICATION PROGRAM 3) From (0x8002800+MAX_SIZE_APPLICATION_PROGRAM) - (0x8002800+2 *(MAX_SIZE_APPLICATION_PROGRAM)-1) UPGRADE PROGRAM
IMPORTANT NOTE It is supposed that three sections are completely independent into FLASH. It means that one erase operation in one section DO NOT erase another sector. It must been verified in three microcontrollers: STM32F030CC, STM32F405VG STM32F030K6T6 processor. If not possible three sections must be separate minimal enough space to became in different sectors.
1) Is good idea to inform FTP server in some file status of all process? - > RAE : I think YES, TODO 2) Is good idea to do retries?. In this flowchart there is not specification of some retrie if something goes wrong. -> ALREADY Explained
Each function should contains a unit test verifying the correct behavior of each use case
Several integration tests should be performed in order to verify the correct behaviour of the Bootloader in the most common situations. These tests should be executed in ALL the available Sinapse Devices
Device start
Bootloader connect to HTTP server (over WiFi)
Bootloader download the code of the client App
Bootloader check the client App and is correct
Bootloader install the client App
Bootloader perform handover to the client App
Result: The LED blinks each second
Device start
Bootloader connect to HTTP server (over WiFi)
Bootloader download the code of the client App
The connection is lost (External)
Bootloader check the client App and is NOT correct
Bootloader does not install the client App
Device does not have any client App installed
Bootloader is not able to perform handover
Bootloader start again and this time the connection is OK. It should work as is explained in test 1.
Result: The LED blinks each second
Device start
Bootloader connect to HTTP server (over WiFi)
Bootloader download the code of the client App
Bootloader check the client App and is correct
Bootloader start to install but the device is restarted
Bootloader start again and this time the whole process is OK. It should work as is explained in test 1.
Result: The LED blinks each second
Device start
Bootloader connect to HTTP server (over WiFi)
Bootloader download the code of the client App
Bootloader check the client App and is correct
Bootloader install the client App
Device restart
Bootloader connect to HTTP server (over WiFi)
Bootloader check the version but the installed version is the last one
Bootloader does not download the program
Bootloader perform the handover to the client App
Result: The LED blinks each second
Device start
Bootloader connect to HTTP server (over GPRS)
Bootloader download the code of the client App
Bootloader check the client App and is correct
Bootloader install the client App
Bootloader perform handover to the client App
Result: The LED blinks each second
Device start
Bootloader connect to HTTP server (over GPRS)
Bootloader download the code of the client App
The connection is lost (External)
Bootloader check the client App and is NOT correct
Bootloader does not install the client App
Device does not have any client App installed
Bootloader is not able to perform handover
Bootloader start again and this time the connection is OK. It should work as is explained in test 5.
Result: The LED blinks each second
Device start
Bootloader connect to HTTP server (over GPRS)
Bootloader download the code of the client App
Bootloader check the client App and is correct
Bootloader start to install but the device is restarted
Bootloader start again and this time the whole process is OK. It should work as is explained in test 5.
Result: The LED blinks each second
TODO
TODO
To validate and close the project it is necessary to provide the following documentation and results, as well as the code: