2021-04-06 09:00 PM
Hi All,
I am currently designing a few products and would like the ability to update firmware at a later date should it be required. CAN is most appropriate for our situation. I have not needed to deal with the bootloader in the past, so I'd just like to see if anyone has criticisms here about my approach below.
An STLINK-V3SET's MB1440 CN5 can be used as the middleman between PC and CAN port on the target device/s. A custom computer application will be written building on the STLINK-V3-BRIDGE API, talking to the end device/s and gathering information via custom CAN messages such as system ID and firmware revision while providing a basic GUI. A quick look at the source code has led me to believe this should be possible, as functions are provided for all manner of CAN initialisation and data transfer.
The target device/s will be idly listening for specific command messages over CAN bus. Programmer sends a start message and the desired target responds accordingly over CAN. Programmer begins waiting for a set amount of time while the target starts shutting down all necessary peripherals as described in AN2606. Once de-initialised and ready, the target device jumps to bootloader system memory.
The Programmer's wait period finishes and sends a CAN frame, something simple like the Get ID message to ensure the target device is stable. Run an erase memory message loop. Run a Write Memory message loop. Send GO command targeting main. Host sends a custom check message, waiting for target to respond with a custom implemented CAN ACK, repeating after a small delay if necessary. Once it does, we can be safe in assuming the new firmware has loaded successfully and alert the user of completion.