Step 1. Type in the following program in text editor like gedit or kedit and
save it as hello.c
#include <nuttx/config.h>
#include <stdio.h>
int app_main(int argc, char *argv[])
{
printf("Hello, World!!\n");
return 0;
}
Step 2. Open a terminal, switch to the folder containing the C file and compile it using the following command.
$ flags=$(nuttx-config --cflags --libs zkit-arm-1769)
$ arm-none-eabi-gcc hello.c $flags -o hello.elf
$ arm-none-eabi-objcopy hello.elf --target=ihex hello.hex
Step 3. Fix the errors, if any and check the folder for the executable file
hello.hex
Step 4. Connect the development kit to the PC, through the USB-UART
mini
connector. Press the PROG
button, to switch into Programming
Mode. (PROG
LED On)
Step 5. The board will be detected as a USB serial device. The device file
name can be obtained from dmesg
. The device file name is usually
/dev/ttyUSB0
or /dev/ttyUSB1
.
The .hex
can be flashed using the lpc21isp
command. The general
syntax of the command is given below.
lpc21isp -control <hex-file> <serial-device> <baudrate> <osc-freq>
The command for programming the hello.hex
file onto to the
ZKit-ARM-1769 board is given below.
$ lpc21isp -control hello.hex /dev/ttyUSB0 115200 12000
Step 6. Press the PROG
button, to switch into Serial Communication
Mode. (PROG
LED Off)
Open picocom
, and specify 115200 baudrate, 8 data bits, no parity, 1
stop bit, using the following command. When done, use Ctrl-A Ctrl-X
to exit picocom
.
$ picocom -b 115200 /dev/ttyUSB0
Press the RESET
button, to execute the downloaded program. The
"Hello World" message should get displayed on the serial terminal.