Page 1 of 1

Send files from terminal to microcontroller.

Posted: Tue Jun 22, 2021 3:10 pm
by Kisen
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.?

Re: Send files from terminal to microcontroller.

Posted: Tue Jun 22, 2021 3:43 pm
by Steve-Matrix
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.

Re: Send files from terminal to microcontroller.

Posted: Tue Jun 22, 2021 4:52 pm
by Kisen
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?

Re: Send files from terminal to microcontroller.

Posted: Tue Jun 22, 2021 5:24 pm
by Steve-Matrix
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.

Re: Send files from terminal to microcontroller.

Posted: Tue Jun 22, 2021 6:36 pm
by mnfisher
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