2. GNU/Linux

The programs can be compiled using an SDCC/GCC wrapper script called zcc. The general syntax is shown below.

zcc <board> <filename>

For example to compile hello.c for zkit-51-v664, the command would be

$ zcc zkit-51-v664 hello.c

There also an alterate method to compile programs using SDCC or GCC directly. The script zdev-config generates the compiler and linker options and the above example could be acheived using the following command. The advantage of this method is that it allows additional options to be passed to the compiler and the linker.

$ sdcc $(zdev-config --cflags --libs zkit-51-v664) hello.c

Similarly, while compiling for ARM processors using GCC, the following command sequence can be used.

$ flags=$(zdev-config --cflags --libs zkit-arm-1343)
$ arm-none-eabi-gcc $flags hello.c -o hello.elf ❶
$ arm-none-eabi-objcopy hello.elf -O binary hello.bin ❷
$ lpc-crc hello.bin 

The arm-none-eabi-gcc is the cross-compiler, that builds the program and genarates the executable in ELF file format.

The arm-none-eabi-objcopy command is used to convert from ELF file format to the BIN file format, which is the format expected by the micro-controller.

The lpc-crc command is used to add a CRC, that is used by the micro-controller to validate the code.