A bootloader shall be small and concise. I very much like bootloaders which do not need a ‘special’ program on the host, so I prefer a simple terminal for this. While porting my serial bootloader to the NXP FRDM-K64F board, I have found RealTerm which offers a lot of cool features:
The RealTerm terminal program can be downloaded from SourceForge here: http://realterm.sourceforge.net/. (download page: https://sourceforge.net/projects/realterm/files/). I’m using the version 2.0.00.70.
Loading S-Record Files
In my serial bootloader, I use the shell command
BL load s19
to load a S19 (S-Record) file. The bootloader expects a normal S19 ASCII file, so I could type that file in if I wish ;-).
Much easier is to use the ability to send that file from the terminal. The problem is usually as the bootloader is only using RX and TX, there is no hardware flow control. A solution would be to use software flow control (XON/XOFF), but my experience is that this did not work out great.
What worked very well is to have the ability to slow down the sending with delays. And here RealTerm has two settings: A delay (ms) for each character sent, and a delay for each line:
Of course there are more advanced ways to deal with the missing flow control problem, but this approach is very simple and does not need any overhead in the bootloader.
FRDM-K64F Bootloader
The original bootloader (see “Serial Bootloader for the Freedom Board with Processor Expert“) is now ported to Kinetis Design Studio and FRDM-K64F board. It uses now a simple buffering for a flash page to cut programming time.
If you want to have a look at the updated serial bootloader for the NXP K64F (FRDM-K64F board), it is on GitHub.
You can try the bootloader with the example blinky project wich is in GitHub.
💡 If using a OpenSDA USB CDC connection (Serial over USB), make sure you use the latest OpenSDA firmware, e.g. Segger J-Link OpenSDA Firmware with Virtual MSD. Earlier OpenSDA firmware has the issue that characters might be lost during transmission.
Summary
RealTerm is a powerful open source terminal program suitable for serial bootloaders. It has many features, and I love the most the ability to configure the file sending functionality.
Happy Loading 🙂
Links
- RealTerm Terminal Program: http://realterm.sourceforge.net/
- FRDM-K64F Bootloader: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-K64F120M/FRDM_K64F_Bootloader
- FRDM-K64F Bootloader example application: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-K64F120M/FRDM-K64F_Bootloader_Test
- Serial Bootloader for FRDM-KL25Z: Serial Bootloader for the Freedom Board with Processor Expert
I would really like to implement this on the KV31F, but many of the included components do not support it. Do you have any suggestions for how I could go about this?
LikeLike
Hi Lee,
another phrasing of the problem is that the SDK breaks the compatibility with existing components. It is very frustrating to catch up with all the SDK API changes :-(. I don’t think it makes much sense to use the SDK v1.3, as NXP has moved to the V2.0 of the SDK. I have started using the following approach with the SDK v2.0: https://mcuoneclipse.com/2016/05/15/mother-of-components-processor-expert-with-nxp-kinetis-sdk-v2-0-projects/
Not everything is in place, but maybe this would be an approach for you?
LikeLike
Unfortunately, last I checked (admittedly a few weeks ago), the KV31F is still not supported on SDK v2.0.
I have been trying to absorb that post; I’ll keep at it and will see if I can make something work.
LikeLike
I checked today, and only SDK v1.3 supports the FRDM-KV31F board.
LikeLike
Hi Erich
There is a little bug on function _CLS1_IterateTable.I have changed it
{
uint8_t res = ERR_FAILED;
if (parserTable==NULL) { /* no table??? */
return ERR_FAILED;
}
if (io==NULL) { /* no IO handler??? */
return ERR_FAILED;
}
/* iterate through all parser functions in table */
while(*parserTable!=NULL) {
if ((*parserTable)(cmd, handled, io)==ERR_OK) {
res = ERR_OK;
}
parserTable++;
}
return res;
}
LikeLike
Hmm, what is the use case which causes a problem for you? maybe I don’t see it?
I have the following:
uint8_t res = ERR_OK;
if (parserTable==NULL) { /* no table??? */
return ERR_FAILED;
}
if (io==NULL) { /* no IO handler??? */
return ERR_FAILED;
}
/* iterate through all parser functions in table */
while(*parserTable!=NULL) {
if ((*parserTable)(cmd, handled, io)!=ERR_OK) {
res = ERR_FAILED;
}
parserTable++;
}
return res;
It returns an error code (ERR_FAILED) if at least on of the parsers returned an error. The fact that no parser is handling the command is checked with the ‘handled’ parameter.
I’m missing somehing?
Thanks,
Erich
LikeLike
Hi Erich,
This is the output with your previous code:
Boot> help
————————————————————–
My Project Name
————————————————————–
CLS1 ; Group of CLS1 commands
help|status ; Print help or status information
echo (on|off) ; Turn echo on or off
BL ; Group of Bootloader commands
help|status ; Print help or status information
erase ; Erase application flash blocks
restart ; Restart application with jump to reset vector
load s19 ; Load S19 file
*** Failed or unknown command: help
*** Type help to get a list of available commands
Boot>
Boot> BL erase
Erasing application flash blocks…done!
*** Failed or unknown command: BL erase
*** Type help to get a list of available commands
Boot>
LikeLike
I cannot reproduce this on my side. Just to confirm: are you using my latest components from https://sourceforge.net/projects/mcuoneclipse/files/PEx%20Components/? I have not touched that part of the shell code for a long time, so not sure why it happens for you.
LikeLike
Pingback: Getting Started: ROM Bootloader on the NXP FRDM-KL03Z Board | MCU on Eclipse