Changes

Jump to: navigation, search
Example #1: HelloWorld application
<pre>maxcpus=${nr_cpus}</pre>: sets maximum Linux cores to 1
 
====Example #2: RPMsg-based application====
As stated before, this example shows a more sophisticated approach that allows for:
* using a standardized communication channel between the two cores
* exploiting a standardized mechanism to load the firmware of second core.
The example performs IRQ latency measurements on FreeRTOS side by using a hardware timer. These measures are collected by the counterpart application running on Linux side and shown on console. Plese follow the steps listed below:
* Place all the binary files into the host tftp directory:
** Kernel: uImage
** Device Tree: bora.dtb
** First stage bootloader: bora_FSBL.bin
** FPGA bitstream: bora_design_wrapper.bin
** FreeRTOS application: freertos
* Start the Bora system
* From the U-Boot shell, update the FSBL with the following commands:
<pre>
run load_fsbl
run update_fsbl
</pre>
* Reset the board to reboot with the new FSBL
* Add the following U-Boot environment variables (1) (2):
<pre>
setenv addcons 'setenv bootargs ${bootargs} console=${console},115200n8 cma=16M debug'
setenv addmem 'setenv bootargs ${bootargs} mem=$(kernel_mem)'
setenv kernel_mem 496M
setenv net_nfs 'run program_fpga; run loadk nfsargs addip addcons addmem; bootm ${loadaddr_kern} - ${loadaddr_ftd}'
setenv freertos_addr 0x3F000000
setenv fpga_file BELK/bora_design_wrapper.bin
</pre>
* Boot the system running the following command:
run net_nfs
 
When booting, the Linux kernel will print out the following message to indicate it has been relocated to address 0x10000000:
<pre>
[ 0.000000] Machine: Xilinx Zynq Platform, model: Bora
[ 0.000000] Change memory bank to 10000000-2fffffff
[ 0.000000] cma: CMA: reserved 16 MiB at 2f000000
</pre>
To start the example, please enter the following commands on Linux side to load the required modules:
<pre>
insmod drivers/virtio/virtio.ko
insmod drivers/virtio/virtio_ring.ko
insmod drivers/rpmsg/virtio_rpmsg_bus.ko
insmod net/rpmsg/rpmsg_proto.ko
insmod drivers/remoteproc/remoteproc.ko
insmod drivers/remoteproc/zynq_remoteproc.ko
insmod drivers/rpmsg/rpmsg_freertos_statistic.ko
</pre>
Linux kernel will print these messages, informing that the communication between the two cores has been established:
[ 17.966158] NET: Registered protocol family 41
[ 18.036698] CPU1: shutdown
[ 18.045287] remoteproc0: 0.remoteproc-test is available
[ 18.050522] remoteproc0: Note: remoteproc is still under development and considered experimental.
[ 18.059554] remoteproc0: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn't yet guaranteed.
[ 18.077341] remoteproc0: powering up 0.remoteproc-test
[ 18.082668] remoteproc0: Booting fw image freertos, size 2357682
[ 18.103607] remoteproc0: remote processor 0.remoteproc-test is now up
[ 18.113339] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 18.118795] remoteproc0: registered virtio0 (type 7)
[ 18.124417] virtio_rpmsg_bus virtio0: creating channel rpmsg-timer-statistic addr 0x50
[ 18.151586] rpmsg_freertos_statistic rpmsg0: new channel: 0x400 -> 0x50!
Then run the <code>latencystat</code> application as shown below. The typical output will look like this:
<pre>
root@bora:~# ./latencystat -b
Linux FreeRTOS AMP Demo.
0: Command 0 ACKed
1: Command 1 ACKed
Waiting for samples...
2: Command 2 ACKed
3: Command 3 ACKed
4: Command 4 ACKed
-----------------------------------------------------------
Histogram Bucket Values:
Bucket 323 ns (36 ticks) had 38 frequency
Bucket 341 ns (38 ticks) had 299 frequency
Bucket 512 ns (57 ticks) had 1 frequency
Bucket 746 ns (83 ticks) had 1 frequency
-----------------------------------------------------------
Histogram Data:
min: 323 ns (36 ticks)
avg: 332 ns (37 ticks)
max: 746 ns (83 ticks)
out of range: 0
total samples: 339
-----------------------------------------------------------
</pre>
This application is extremely useful for evaluating how CPU load on first core affects IRQ latency. In case latency does not satisfy real-time requirements, it may be necessary to adjust arbitration priorities of processor's interconnect subsystem. For further details, please refer to chapter ''Interconnect'' of Zynq Technical Reference Manual.
 
N.B. prior to launching the latencystat application, '''make sure that the governor is set to <code>performance</code>''' with the following command:
<pre>
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
</pre>
 
(1) <code>program_fpga</code>: Loads FPGA binary from TFTP and programs the bitstream
 
<code>load_freertos</code>: Loads freertos application binary from TFTP and writes application start address for core #2
 
(2) Please note that, using the RPMsg mechanism, it's not required to set the maxcpus=${nr_cpus} variable.
 
=== Additional resources ===
* http://www.wiki.xilinx.com/Multi-OS+Support+%28AMP+%26+Hypervisor%29
* http://www.xilinx.com/support/documentation/sw_manuals/petalinux2013_04/ug978-petalinux-zynq-amp.pdf
4,650
edits

Navigation menu