Loading Application Files via UART |
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$ pwd Create a simple "Hello, world" C application: [host] $ cd /tmp Build the application for the Cortex-M target: [host] $ arm-uclinuxeabi-gcc -o test test.c -I ${INSTALL_ROOT}/A2F/root/usr/include -mcpu=cortex-m3 -mthumb Encode the application binary into an ASCII-only presentation so that the file can be transmitted over a serial line: [host] $ uuencode test < test > test.encoded You will require the uudecode application on the target in order to convert the ASCII-only file back into the application binary. Go to your project directory and enable uudecode in the target busybox: [host] $ cd /home/vlad/test/linux-cortexm-1.12.1/projects/networking/ Go to Coreutils and enable uudecode: Build the updated project: [host] $ make Load the resultant uImage (networking.uImage in the above example) to the target as described in http://www.emcraft.com/stm32f429discovery/loading-linux-images-over-uart. On the host, make sure that the serial port you use for the target console is configured for 115.2 Bps: [host] $ stty -F /dev/ttyUSB1 Start the target console: [host] $ ./console-stm32f429.script From the target, run the following to read a file from the serial console: ~ # cat > /test < /dev/ttyS0 Exit the target console (Ctrl-\ and then q in kermit). On the host, send the encoded ASCII file to the serial port used for the target console: [host] $ cd /tmp When the transfer command finishes, enter the target console again: [host] $ ./console-stm32f429.script Type Ctrl-C to interrupt the cat command: ^C Run uudecode to convert the ASCII file back to the binary file: ~ # busybox uudecode /test.encoded Change mode to allow running the application binary: ~ # chmod u+x test Finally, run the application: ~ # ./test |