Getting started - a ZPU hello world program

The ZPU comes with a standard GCC toolchain and an instruction set simulator. This allows compiling, running & debugging simple test programs. The Simulator has some very basic peripherals defined: counter, timer interrupt and a debug output port.

Installing

  1. Install Cygwin. http://www.cygwin.com
  2. Install Java
  3. Start Cygwin bash
  4. cd zpu/sw
  5. sh setup.sh
  6. /tmp/zpu/install/bin now has the .exe files for the GCC toolchain & GDB
  7. Optionally you may set up PATH variables to point to /tmp/zpu/install/bin
    source env.sh

Hello world example

The ZPU toolchain comes with newlib & libstdc++ support which means that many C/C++ programs can be compiled without modification.

cd zpu/sw/helloworld
../install/bin/zpu-elf-gcc -phi hello.c -o hello.elf

Running the hello world example in GDB

  1. cd zpu/sw/helloworld
  2. Launch the simulator from a seperate bash shell:

    java -classpath ../simulator/zpusim.jar -Xmx512m com.zylin.zpu.simulator.Phi 4444

  3. Launch GDB:

    ../install/bin/zpu-elf-gdb hello.elf

  4. Connect to target, load and run application:

    (gdb) target remote localhost:4444
    (gdb) load
    (gdb) continue