Loading Application Files via UART (uClinux)

This note explains how to load files such as binary applications from Linux running on the target via UART. This is a useful procedure for those targets that do not provide an Ethernet link and have the serial console as the only communication channel.

On the host, activate the Cortex-M cross-development environment:

-bash-3.2$ . ./ACTIVATE.sh -bash-3.2$

Create a simple "Hello, world" C application:

[host] $ cd /tmp [host] $ vi test.c #include <stdio.h> int main(int argc, char *argv[]) { printf("Hello, STM32H7-SOM\n"); return 0; }

Build the application for the Cortex-M target:

[host] $ ${CROSS_COMPILE_APPS}gcc -o test test.c

If you have no uuencode installed in your system, then install it:

Encode the application binary into an ASCII-only presentation so that the file can be transmitted over a serial line:

The uudecode application on the target (in order to convert the ASCII-only file back into the application binary) is provided with busybox by default in the rootfs project.

On the host, make sure that the serial port you use for the target console is configured for 115200 bps:

If you have no picocom installed in your system, the install it:

Start the target console:

From the target, run the following to read a file from the serial console:

On the host, exit the target console (Ctrl-A and then Ctrl-X in picocom).

On the host, send the encoded ASCII file to the serial port used for the target console:

When the transfer command finishes, enter the target console again:

Type Ctrl-C to interrupt the cat command:

Run uudecode to convert the ASCII file back to the binary file:

Change mode to allow running the application binary:

Finally, run the application: