Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

    Code Block
    bash-3.2$$ . ./ACTIVATE.sh
    -bash-3.2$$
  2. Create a simple "Hello, world" C application:

    Code Block
    [host] $ cd /tmp
    [host] $ vi test.c
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
    printf("Hello, i.MX RTxxxx\n");
    return 0;
    }
  3. Build the application for the Cortex-M target:

    Code Block
    [host] $ ${CROSS_COMPILE_APPS}gcc -o test test.c
  4. If you have no uuencode installed in your system, then install it:

    Code Block
    [host] $ sudo apt-get install sharutils
  5. Encode the application binary into an ASCII-only presentation so that the file can be transmitted over a serial line:

    Code Block
    [host] $ uuencode test < test > test.encoded

    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.

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

    Code Block
    [host] $ stty -F /dev/ttyACM0 115200 raw -echo -echoe -echoctl -echok
  7. If you have no picocom installed in your system, the install it:

    Code Block
    [host] $ sudo apt-get install picocom
  8. Start the target console:

    Code Block
    [host] $ picocom -b 115200 /dev/ttyACM0

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

    Code Block
    ~ # cat > /test.encoded < /dev/ttyLP0
  9. On the host, exit the target console (Ctrl-A and then Ctrl-X in picocom).

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

    Code Block
    [host] $ cat /tmp/test.encoded > /dev/ttyACM0
  11. When the transfer command finishes, enter the target console again:

    Code Block
    [host] $ picocom -b 115200 /dev/ttyACM0
  12. Type Ctrl-C to interrupt the cat command:

    Code Block
    ^C
    / #
  13. Run uudecode to convert the ASCII file back to the binary file:

    Code Block
    ~ # uudecode /test.encoded -o /test
  14. Change mode to allow running the application binary:

    Code Block
    ~ # chmod a+x /test
  15. Finally, run the application:

    Code Block
    ~ # /test
    Hello, i.MX RTxxxx
    ~ #