Hi,
I am working on a bootloader that can take data from a terminal, like teraterm or similar.
I plan to have the microcontroller respod to a command, "LOAD" for example. The microcontroller will then wait and listen for incoming data.
In the terminal i will then send a file, for the uC to receive.
There was intention to send the xxxx.hex file that flowcode outputs. That was until i realised it wont send the hex data as hex, but each letter as a byte of its own in ascii.
I am reading that the file should be sent as binary!!!
So heres my issue. In HEX format i can store this in external flash memory and then knowing the HEX format, i can break it up in the bootloader and program that to the uC Flash memory.
In binary, im not sure how this works. Does it have a structure?, or is it just a stream of bytes that are programmed to uC flash sequentially?
If i do send the file in binary, is there any way to visualise it, so that i know during development, that i am sending and receiving the correct data.?
Send files from terminal to microcontroller.
-
- Posts: 12
- http://meble-kuchenne.info.pl
- Joined: Sun Jun 20, 2021 11:55 am
- Has thanked: 2 times
- Been thanked: 1 time
-
- Matrix Staff
- Posts: 1551
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 214 times
- Been thanked: 362 times
Re: Send files from terminal to microcontroller.
I think dealing with the ASCII encoded HEX file is safer for many reasons, so I'd personally avoid a binary file.
For example, a binary file might have a few issues such at identification of the end of file, and the program may contain thousands of essentially blank locations that will also need to be transmitted. So a HEX file might be smaller and quicker to transmit.
You'll need to decode the HEX file at the other end, but that should be relatively easy. The HEX file would also support different sections of the chip (program area, eeprom, config bits, etc.) and you'd probably need to send these separately if sending as binary.
There is another issue in that end-of-line formats can be different in different OSes. When sending a text file as text in a terminal app between OSes, you might find the line ends get altered, so you may need to be aware of that when you receive the file.
HTH,
Steve.
For example, a binary file might have a few issues such at identification of the end of file, and the program may contain thousands of essentially blank locations that will also need to be transmitted. So a HEX file might be smaller and quicker to transmit.
You'll need to decode the HEX file at the other end, but that should be relatively easy. The HEX file would also support different sections of the chip (program area, eeprom, config bits, etc.) and you'd probably need to send these separately if sending as binary.
There is another issue in that end-of-line formats can be different in different OSes. When sending a text file as text in a terminal app between OSes, you might find the line ends get altered, so you may need to be aware of that when you receive the file.
HTH,
Steve.
Re: Send files from terminal to microcontroller.
Hi Steve,
Using the Hex data does make sense. I am beginning to see how this will work.
When you refer to the line end, are you referring to the checksum value?
Using the Hex data does make sense. I am beginning to see how this will work.
When you refer to the line end, are you referring to the checksum value?
-
- Matrix Staff
- Posts: 1551
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 214 times
- Been thanked: 362 times
Re: Send files from terminal to microcontroller.
No, I mean the combination of non-printable characters that are used to denote the end of a line. On Windows, this is the special characters CR and LF (hex values 0x0D and 0x0A), but in other operating systems it is usually just LF (0x0A).
For your purpose, you can probably react to the ":" character denoting the start of each HEX line and ignore all of the non-printable characters.
For your purpose, you can probably react to the ":" character denoting the start of each HEX line and ignore all of the non-printable characters.
-
- Valued Contributor
- Posts: 1632
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: Send files from terminal to microcontroller.
I posted a 'simple' sender and receiver here: viewtopic.php?f=3&t=440 - which deals with end of file etc which might be helpful??
Martin
Martin