BELK-TN-005: Running PYNQ on Bora

From DAVE Developer's Wiki
Revision as of 07:45, 19 September 2018 by U0001 (talk | contribs) (Introduction)

Jump to: navigation, search
Info Box
Bora5-small.jpg Applies to Bora
BORA Xpress.png Applies to BORA Xpress

History[edit | edit source]

Version Date Notes
1.0.0 September 2018 First public release

Introduction[edit | edit source]

As stated in the official documentation, Python Productivity for Zynq (Pynq)'s main goal is ...

... to make it easier for designers of embedded systems to exploit the unique benefits of APSoCs in their applications. Specifically, PYNQ enables architects, engineers and programmers who design embedded systems to use Zynq APSoCs, without having to use ASIC-style design tools to design programmable logic circuits.

PYNQ achieves this goal in three ways:

- Programmable logic circuits are presented as hardware libraries called overlays. These overlays are analogous to software libraries. A software engineer can select the overlay that best matches their application. The overlay can be accessed through an application programming interface (API). Creating a new overlay still requires engineers with expertise in designing programmable logic circuits. The key difference however, is the build once, re-use many times paradigm. Overlays, like software libraries, are designed to be configurable and re-used as often as possible in many different applications.

- PYNQ uses Python for programming both the embedded processors and the overlays. Python is a “productivity-level” language. To date, C or C++ are the most common, embedded programming languages. In contrast, Python raises the level of programming abstraction and programmer productivity. These are not mutually-exclusive choices, however. PYNQ uses CPython which is written in C, and integrates thousands of C libraries and can be extended with optimized code written in C. Wherever practical, the more productive Python environment should be used, and whenever efficiency dictates, lower-level C code can be used.

- PYNQ is an open-source project that aims to work on any computing platform and operating system. This goal is achieved by adopting a web-based architecture, which is also browser agnostic. We incorporate the open-source Jupyter notebook infrastructure to run an Interactive Python (IPython) kernel and a web server directly on the ARM Cortex A9 of the Zynq device. The web server brokers access to the kernel via a suite of browser-based tools that provide a dashboard, bash terminal, code editors and Jupyter notebooks. The browser tools are implemented with a combination of JavaScript, HTML and CSS and run on any modern browser.

source: https://pynq.readthedocs.io

This Technical Note shows hot to run PYNQ on Bora platform. It is worth remembering that, even though the procedure was tested on Bora, it should work on BoraX as well without any modification.

To see PYN in action, please see this clip.

Testbed's hardware and software configuration[edit | edit source]

As stated before, the procedure was tested on Bora/BoraEVB hardware platform.

With regard to the software configuration, the following versions were used:

Original root file system included several kernel drivers built as modules. The Linux kernel used for this test was different than the kernel released along with the PYNQ's root file system, however. Consequently, these modules were not compatible with the kernel running on Bora. To overcome this issue, these drivers were linked statically into the kernel image.

Setting up the board[edit | edit source]

U-Boot environment was configured in order to retrieve kernel image and device tree blob via TFTP protocol. Also, it was configured to make the kernel to mount the root file system over NFS.

The following box shows the full boot process (clock on the "Expand" box):

U-Boot 2014.07-04967-g7b885e1-dirty (Feb 20 2015 - 17:01:27) [belk-2.1.0]

Board:  BORA
I2C:   ready
DRAM:  ECC disabled 1 GiB
NAND:  1024 MiB
MMC:   zynq_sdhci: 0
SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB
In:    serial
Out:   serial
Err:   serial
Net:   Gem.e000b000
Hit any key to stop autoboot:  0 
Gem.e000b000 Waiting for PHY auto negotiation to complete...... done
Using Gem.e000b000 device
TFTP from server 192.168.2.10; our IP address is 192.168.2.11
Filename 'bora/uImage'.
Load address: 0x2080000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###################
         6.8 MiB/s
done
Bytes transferred = 4082664 (3e4be8 hex)
Using Gem.e000b000 device
TFTP from server 192.168.2.10; our IP address is 192.168.2.11
Filename 'bora/bora.dtb'.
Load address: 0x2000000
Loading: #
         3.4 MiB/s
done
Bytes transferred = 10634 (298a hex)
Unknown command 'configid' - try 'help'
## Booting kernel from Legacy Image at 02080000 ...
   Image Name:   Linux-4.14.0-xilinx-00008-ge79ec
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4082600 Bytes = 3.9 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 02000000
   Booting using the fdt blob at 0x2000000
   Loading Kernel Image ... OK
   Loading Device Tree to 1effa000, end 1efff989 ... OK
Switching to NAND storage before starting Linux

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.0-xilinx-00008-ge79ecef-dirty (sysadmin@stage-OptiPlex-7010) (gcc version 7.2.1 20171011 (Linaro G8
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Bora
[    0.000000] bootconsole [earlycon0] enabled
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Reserved 16 MiB at 0x3f000000
[    0.000000] On node 0 totalpages: 262144
[    0.000000] free_area_init_node: node 0, pgdat c0a3d840, node_mem_map ef6f7000
[    0.000000]   Normal zone: 1728 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 196608 pages, LIFO batch:31
[    0.000000]   HighMem zone: 65536 pages, LIFO batch:15
[    0.000000] random: fast init done
[    0.000000] percpu: Embedded 16 pages/cpu @ef6cd000 s35340 r8192 d22004 u65536
[    0.000000] pcpu-alloc: s35340 r8192 d22004 u65536 alloc=16*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 260416
[    0.000000] Kernel command line: root=/dev/nfs rw nfsroot=192.168.2.10:/home/sysadmin/nfs_server,tcp ip=192.168.2.11:192.168.2.10)
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Memory: 1011672K/1048576K available (6144K kernel code, 298K rwdata, 1616K rodata, 1024K init, 255K bss, 20520K reser)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0700000   (7136 kB)
[    0.000000]       .init : 0xc0900000 - 0xc0a00000   (1024 kB)
[    0.000000]       .data : 0xc0a00000 - 0xc0a4aa40   ( 299 kB)
[    0.000000]        .bss : 0xc0a506d4 - 0xc0a904ec   ( 256 kB)
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.000000]  Tasks RCU enabled.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] efuse mapped to f0802000
[    0.000000] slcr mapped to f0804000
[    0.000000] L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
[    0.000000] L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
[    0.000000] L2C-310 erratum 769419 enabled
[    0.000000] L2C-310 enabling early BRESP for Cortex-A9
[    0.000000] L2C-310 full line of zeros enabled for Cortex-A9
[    0.000000] L2C-310 ID prefetch enabled, offset 1 lines
[    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
[    0.000000] L2C-310 cache controller enabled, 8 ways, 512 kB
[    0.000000] L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76760001
[    0.000000] zynq_clock_init: clkc starts at f0804100
[    0.000000] Zynq clock init
[    0.000000] ps_clk frequency not specified, using 33 MHz.
[    0.000011] sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398046511103ns
[    0.007864] clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x4ce07af025, max_idle_ns: 440795209040 ns
[    0.018882] Switching to timer-based delay loop, resolution 3ns
[    0.024887] clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
[    0.033938] timer #0 at f080c000, irq=17
[    0.038270] Console: colour dummy device 80x30
[    0.042606] Calibrating delay loop (skipped), value calculated using timer frequency.. 666.66 BogoMIPS (lpj=3333333)
[    0.053110] pid_max: default: 32768 minimum: 301
[    0.057905] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.064395] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.072131] CPU: Testing write buffer coherency: ok
[    0.077108] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.118017] Setting up static identity map for 0x100000 - 0x100060
[    0.124196] Hierarchical SRCU implementation.
[    0.167975] smp: Bringing up secondary CPUs ...
[    0.218351] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.218477] smp: Brought up 1 node, 2 CPUs
[    0.228179] SMP: Total of 2 processors activated (1333.33 BogoMIPS).
[    0.234489] CPU: All CPU(s) started in SVC mode.
[    0.240198] devtmpfs: initialized
[    0.246231] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.254021] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.263716] futex hash table entries: 512 (order: 3, 32768 bytes)
[    0.270996] pinctrl core: initialized pinctrl subsystem
[    0.277617] NET: Registered protocol family 16
[    0.290120] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.298475] cpuidle: using governor ladder
[    0.302483] cpuidle: using governor menu
[    0.313247] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.321201] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.327075] zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0xf0880000
[    0.334026] zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
[    0.340275] e0000000.serial: ttyPS1 at MMIO 0xe0000000 (irq = 27, base_baud = 3125000) is a xuartps
[    0.349721] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 28, base_baud = 3125000) is a xuartps
[    0.358739] console [ttyPS0] enabled
[    0.365786] bootconsole [earlycon0] disabled
[    0.391897] vgaarb: loaded
[    0.394904] SCSI subsystem initialized
[    0.399005] usbcore: registered new interface driver usbfs
[    0.404474] usbcore: registered new interface driver hub
[    0.410962] usbcore: registered new device driver usb
[    0.416144] pps_core: LinuxPPS API ver. 1 registered
[    0.421071] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.430215] PTP clock support registered
[    0.439206] clocksource: Switched to clocksource arm_global_timer
[    0.456406] NET: Registered protocol family 2
[    0.461666] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
[    0.468746] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
[    0.475282] TCP: Hash tables configured (established 8192 bind 8192)
[    0.482089] UDP hash table entries: 512 (order: 2, 16384 bytes)
[    0.487962] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
[    0.494500] NET: Registered protocol family 1
[    0.499167] RPC: Registered named UNIX socket transport module.
[    0.505054] RPC: Registered udp transport module.
[    0.509716] RPC: Registered tcp transport module.
[    0.514377] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.520846] PCI: CLS 0 bytes, default 64
[    0.525293] hw perfevents: no interrupt-affinity property for /pmu@f8891000, guessing.
[    0.533370] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
[    0.542975] workingset: timestamp_bits=14 max_order=18 bucket_order=4
[    0.550214] jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
[    0.558624] bounce: pool size: 64 pages
[    0.562560] io scheduler noop registered
[    0.566398] io scheduler deadline registered
[    0.570771] io scheduler cfq registered (default)
[    0.575391] io scheduler mq-deadline registered
[    0.579931] io scheduler kyber registered
[    0.585789] dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
[    0.592466] dma-pl330 f8003000.dmac:  DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
[    0.611411] brd: module loaded
[    0.622226] loop: module loaded
[    0.626772] libphy: Fixed MDIO Bus: probed
[    0.632104] CAN device driver interface
[    0.638058] libphy: MACB_mii_bus: probed
[    0.739956] macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 30 (00:50:c2:1e:af:b2)
[    0.749735] Micrel KSZ9031 Gigabit PHY e000b000.ethernet-ffffffff:07: attached PHY driver [Micrel KSZ9031 Gigabit PHY] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:07, irq=POLL)
[    0.765859] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[    0.771636] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.778467] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.784968] ehci-pci: EHCI PCI platform driver
[    0.789502] usbcore: registered new interface driver usb-storage
[    0.795672] chipidea-usb2 e0002000.usb: e0002000.usb supply vbus not found, using dummy regulator
[    0.804778] ULPI transceiver vendor/product ID 0x0424/0x0006
[    0.810376] Found SMSC USB331x ULPI transceiver.
[    0.814957] ULPI integrity check: passed.
[    0.830928] i2c /dev entries driver
[    0.838363] rtc-ds3232 0-0068: rtc core: registered ds3232 as rtc0
[    0.844584] cdns-i2c e0004000.i2c: 100 kHz mmio e0004000 irq 24
[    0.850741] IR NEC protocol handler initialized
[    0.855190] IR RC5(x/sz) protocol handler initialized
[    0.860245] IR RC6 protocol handler initialized
[    0.864737] IR JVC protocol handler initialized
[    0.869320] IR Sony protocol handler initialized
[    0.873851] IR SANYO protocol handler initialized
[    0.878538] IR Sharp protocol handler initialized
[    0.883246] IR MCE Keyboard/mouse protocol handler initialized
[    0.889040] IR XMP protocol handler initialized
[    0.894822] ina2xx 0-0041: power monitor ina226 (Rshunt = 10000 uOhm)
[    0.902946] cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at f098f000 with timeout 10s
[    0.911449] Xilinx Zynq CpuIdle Driver started
[    0.916232] sdhci: Secure Digital Host Controller Interface driver
[    0.922353] sdhci: Copyright(c) Pierre Ossman
[    0.926669] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.999271] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
[    1.008137] usbcore: registered new interface driver usbhid
[    1.015697] usbhid: USB HID core driver
[    1.020813] nand: device found, Manufacturer ID: 0x01, Chip ID: 0xd3
[    1.027139] nand: AMD/Spansion S34ML08G1
[    1.031052] nand: 1024 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    1.042261] Bad block table found at page 524224, version 0x01
[    1.049007] Bad block table found at page 524160, version 0x01
[    1.055488] 8 ofpart partitions found on MTD device pl35x-nand
[    1.061255] Creating 8 MTD partitions on "pl35x-nand":
[    1.066363] 0x000000000000-0x000000040000 : "nand-SPL"
[    1.072821] 0x000000040000-0x000000100000 : "nand-uboot"
[    1.079178] 0x000000100000-0x000000140000 : "nand-uboot-env1"
[    1.086061] 0x000000140000-0x000000180000 : "nand-uboot-env2"
[    1.091854] mmc0: new SDHC card at address 0001
[    1.096784] mmcblk0: mmc0:0001 SD16G 14.6 GiB 
[    1.098576]  mmcblk0: p1 p2
[    1.105146] 0x000000180000-0x000000780000 : "nand-bitstream"
[    1.111979] 0x000000780000-0x000000800000 : "nand-device-tree"
[    1.118790] 0x000000800000-0x000001000000 : "nand-linux"
[    1.125199] 0x000001000000-0x000020000000 : "nand-rootfs"
[    1.136702] NET: Registered protocol family 17
[    1.141185] can: controller area network core (rev 20170425 abi 9)
[    1.147347] NET: Registered protocol family 29
[    1.151750] can: raw protocol (rev 20170425)
[    1.155961] can: broadcast manager protocol (rev 20170425 t)
[    1.161799] can: netlink gateway (rev 20170425) max_hops=1
[    1.167598] Registering SWP/SWPB emulation handler
[    1.178968] rtc-ds3232 0-0068: hctosys: unable to read the hardware clock
[    5.319523] macb e000b000.ethernet eth0: link up (1000/Full)
[    5.379226] IP-Config: Complete:
[    5.382373]      device=eth0, hwaddr=00:50:c2:1e:af:b2, ipaddr=192.168.2.11, mask=255.255.255.0, gw=192.168.2.254
[    5.392632]      host=bora, domain=, nis-domain=(none)
[    5.397730]      bootserver=192.168.2.10, rootserver=192.168.2.10, rootpath=
[    5.421541] VFS: Mounted root (nfs filesystem) on device 0:12.
[    5.427672] devtmpfs: mounted
[    5.433737] Freeing unused kernel memory: 1024K
[    5.589676] systemd[1]: System time before build time, advancing clock.
[    5.634991] systemd[1]: Mounting cgroup to /sys/fs/cgroup/debug of type cgroup with options debug.
[    5.644893] systemd[1]: Mounting cgroup to /sys/fs/cgroup/cpu,cpuacct of type cgroup with options cpu,cpuacct.
[    5.655853] systemd[1]: Mounting cgroup to /sys/fs/cgroup/net_cls,net_prio of type cgroup with options net_cls,net_prio.
[    5.667567] systemd[1]: Mounting cgroup to /sys/fs/cgroup/pids of type cgroup with options pids.
[    5.677166] systemd[1]: Mounting cgroup to /sys/fs/cgroup/memory of type cgroup with options memory.
[    5.687181] systemd[1]: Mounting cgroup to /sys/fs/cgroup/blkio of type cgroup with options blkio.
[    5.697090] systemd[1]: Mounting cgroup to /sys/fs/cgroup/cpuset of type cgroup with options cpuset.
[    5.707072] systemd[1]: Mounting cgroup to /sys/fs/cgroup/devices of type cgroup with options devices.
[    5.717153] systemd[1]: Mounting cgroup to /sys/fs/cgroup/perf_event of type cgroup with options perf_event.
[    5.727750] systemd[1]: Mounting cgroup to /sys/fs/cgroup/rdma of type cgroup with options rdma.
[    5.830891] systemd-getty-generator[691]: Automatically adding serial getty for /dev/ttyPS0.
[    5.849188] systemd-rc-local-generator[692]: Automatically adding rc-local.service.
[    5.859815] systemd-gpt-auto-generator[698]: Neither root nor /usr file system are on a (single) block device.
[    5.881532] systemd-fstab-generator[699]: Parsing /etc/fstab
[    5.892952] systemd-fstab-generator[699]: Found entry what=/var/swap where=none type=swap nofail=no noauto=no
[    5.899832] systemd-sysv-generator[690]: Looking for unit files in (higher priority first):
[    5.899847] systemd-sysv-generator[690]:  /etc/systemd/system
[    5.899858] systemd-sysv-generator[690]:  /run/systemd/system
[    5.899869] systemd-sysv-generator[690]:  /usr/local/lib/systemd/system
[    5.899879] systemd-sysv-generator[690]:  /lib/systemd/system
[    5.899888] systemd-sysv-generator[690]:  /usr/lib/systemd/system
[    5.900359] systemd-sysv-generator[690]: Looking for SysV init scripts in:
[    5.900373] systemd-sysv-generator[690]:  /etc/init.d
[    5.900553] systemd-sysv-generator[690]: Looking for SysV rcN.d links in:
[    5.900566] systemd-sysv-generator[690]:  /etc
[    5.964211] systemd-fstab-generator[699]: Swap not supported, ignoring fstab swap entry for /var/swap.
[    5.998886] systemd-sysv-ge: 132 output lines suppressed due to ratelimiting
[    6.797327] systemd-journald[705]: Fixed min_use=1.0M max_use=50.2M max_size=6.2M min_size=512.0K keep_free=75.3M n_max_files=100
[    6.821668] systemd-journald[705]: Reserving 11434 entries in hash table.
[    6.830624] systemd-journald[705]: Vacuuming...
[    6.835181] systemd-journald[705]: Vacuuming done, freed 0B of archived journals on disk.
[    6.844639] systemd-journald[705]: Flushing /dev/kmsg...
[    6.849977] systemd-journald[705]: systemd-journald running as pid 705
[    6.866614] systemd-journald[705]: Compressed data object 537 -> 288 using XZ
[    6.910862] systemd-journald[705]: Sent READY=1 notification.
[    6.916579] systemd-journald[705]: Sent WATCHDOG=1 notification.
[    6.927315] systemd-journald[705]: Successfully sent stream file descriptor to service manager.
[   10.657105] systemd[1]: Accepted new private connection.
[   10.686808] systemd[1]: Got disconnect on private connection.
[   10.719384] systemd[1]: sysinit.target changed dead -> active
[   10.779432] systemd[1]: paths.target changed dead -> active
[   10.832142] systemd[1]: systemd-tmpfiles-clean.timer: Changed dead -> waiting
[   11.657192] random: crng init done
[   12.688449] systemd-journald[705]: Successfully sent stream file descriptor to service manager.

Testing the PYNQ framework[edit | edit source]

The following image shows the PYNQ processes running.

Running processes ordered by memory occupation