How to run eCos on Enclustra’s Mercury ZX1 Zynq module

Published:

Mercury ZX1 is a high-performance processing module designed by Enclustra built around the Xilinx Zynq-7000 series SoC. Just like their other ZX series products, it combines the flexibility of an FPGA with the power of Cortex-A9 CPU in a small form-factor, power-efficient embedded solution.

Mercury ZX1

Mercury ZX1 has a lot to offer – a PCIe x4/x8 interface and large-capacity Zynq 7030, 7035 and 7045 FPGA fabrics.

We have been asked if the free and open source eCos RTOS that we work with for many customer projects (and which we earlier ported to another of Enclustra’s modules – Mars ZX3) can be run on the module – the answer is: of course!

Below you will find a brief but complete step-by-step description of how to run eCos on Mercury ZX1.

Prerequisites

Clone the eCos repository with:

git clone https://github.com/antmicro/ecos.git

Clone ecos-tools, a small toolset for compiling eCos apps from Antmicro:

git clone https://github.com/antmicro/ecos-tools.git

Preparing the configuration

To build eCos for Mercury ZX1 it is required to prepare an eCos configuration file (ecc). To do so a few steps are required:

  • Run configtool from ecos-tools
  • From the Build menu choose Repository and set the proper path to the eCos source repository (the packages/ directory)
  • From the Build menu choose Templates
  • From Templates choose the Enclustra Mercury ZX1 hardware and the appropriate package set (in our example we’re basing on the net packages)
  • Do some additional system configuration:
    • Disable routing diagnostic output to debug channel:
      eCos HAL -> Platform-independent HAL options -> Route diagnostic output to debug channel [uncheck]
    • Disable ROM monitor
      eCos HAL -> ROM Monitor support -> Work with ROM monitor [uncheck]

    • Set diagnostic output to UART0
      ARM architecture -> Xilinx XC7Z020 -> Diagnostic serial port [set 0]

    • Add support for KSZ9030 Ethernet PHY
      I/O subsystem -> Common Ethernet support -> Ethernet transceiver (PHY) support -> Micrel KSZ90x1 [check]

    • Set building of Ethernet tests
      Basic Networking framework -> Testing options -> Build hardware networking tests (demo programs) [check]

This will create a configuration required to build the eCos kernel for the Mercury ZX1 board. Remember to save the ecc file.

Building eCos

Build eCos according to the instructions from the ecos-tools README file (i.e. create a config file, set the toolchain path etc). In our example we are using the ping_test from networking demo programs. To build the eCos demos, run the ecos-tools make script with the –tests switch:

./make.sh --tests --config=<your-config>

Running the ping test on Mercury ZX1

In this example we are using a JTAG connection to download and run eCos application on the Mercury ZX1 module. To do so the Xilinx Platform Cable, Xilinx microprocessor debugger (xmd) and GNU debugger (gdb) software are required.

In order to run the example ping_test application follow these steps:

  • Connect the power supply, Ethernet cable, USB UART, and Xilinx Platform cable to the Mercury board.
  • Run the Xilinx microprocessor debugger (xmd) and connect to the board
connect arm hw
  • Run the ARM GNU debugger (e.g. arm-none-eabi-gdb) and do the following:
target remote :1234
file </path/to/application/binary>
load
continue

Note: 1234 is a default listening port of xmd – this may vary

Note: The default location of the ping_test application is: install/tests/net/common/current/tests/ping_test

If everything went OK something like the log below should be printed on the serial output:

[cyg_net_init] Init: mbinit(0x00000000)
[cyg_net_init] Init: cyg_net_init_devs(0x00000000)
Init device 'zynq_eth1'
Init device 'zynq_eth0'
[cyg_net_init] Init: loopattach(0x00000000)
[cyg_net_init] Init: ifinit(0x00000000)
[cyg_net_init] Init: domaininit(0x00000000)
[cyg_net_init] Init: cyg_net_add_domain(0x00548174)
New domain internet at 0x00000000
[cyg_net_init] Init: cyg_net_add_domain(0x00547e44)
New domain route at 0x00000000
[cyg_net_init] Init: call_route_init(0x00000000)
[cyg_net_init] Done
Start PING test
BOOTP[eth0] op: REQUEST
       htype: Ethernet
        hlen: 6
        hops: 0
         xid: 0xde60125
        secs: 0
       flags: 0x8000
       hw_addr: 00:0a:35:00:01:25
     client IP: 0.0.0.0
         my IP: 192.168.1.25
     server IP: 192.168.1.1
    gateway IP: 0.0.0.0
          file: pxelinux.0
  options:
        DHCP message: 3 REQUEST
        DHCP server id: 192.168.1.1
        DHCP time 51: 259200
        subnet mask: 255.255.255.0
            gateway: 192.168.1.1
      domain server: 192.168.1.1
        DHCP option: 37/55.9: 54 51 58 59 1 3 6 15 28
        DHCP option: 39/57.2: 576
        DHCP requested ip: 192.168.1.25
SIOCSIFADDR: Device not configured
BOOTP/DHCP failed on eth1
PING server 192.168.1.1
64 bytes from 192.168.1.1: icmp_seq=0, time=20ms
310 bytes from 192.168.1.1: icmp_seq=1, time=10ms
556 bytes from 192.168.1.1: icmp_seq=2, time=20ms
802 bytes from 192.168.1.1: icmp_seq=3, time=10ms
1048 bytes from 192.168.1.1: icmp_seq=4, time=20ms
1294 bytes from 192.168.1.1: icmp_seq=5, time=20ms
1540 bytes from 192.168.1.1: icmp_seq=6, time=20ms
1786 bytes from 192.168.1.1: icmp_seq=7, time=20ms
2032 bytes from 192.168.1.1: icmp_seq=8, time=30ms
2278 bytes from 192.168.1.1: icmp_seq=9, time=20ms
2524 bytes from 192.168.1.1: icmp_seq=10, time=30ms
2770 bytes from 192.168.1.1: icmp_seq=11, time=40ms
3016 bytes from 192.168.1.1: icmp_seq=12, time=20ms
3262 bytes from 192.168.1.1: icmp_seq=13, time=50ms
3508 bytes from 192.168.1.1: icmp_seq=14, time=50ms
3754 bytes from 192.168.1.1: icmp_seq=15, time=50ms
Sent 16 packets, received 16 OK, 0 bad
PING server 192.168.1.33
recvfrom: Operation timed out
recvfrom: Operation timed out
recvfrom: Operation timed out
recvfrom: Operation timed out
recvfrom: Operation timed out
recvfrom: Operation timed out
sendto: Host is down
sendto: Host is down
sendto: Host is down
sendto: Host is down
sendto: Host is down
sendto: Host is down
sendto: Host is down
sendto: Host is down
sendto: Host is down
sendto: Host is down
Sent 16 packets, received 0 OK, 0 bad
PASS:
<Ping test OK>
EXIT:<done>

Note: The eCos ping test is trying to ping the server and then a machine with the server IP address + 32. If such a machine does not exist in the local network there will be no answer, thus the second part of the test will fail – as in the example.

Note: By default the network subsytem is configured to obtain an IP address via DHCP. This can be easly changed in configtool in Basic networking framework -> Initialization for ethX