本文作者:卜居
转载请保留作者信息。原文网址(http://blog.csdn.net/kkk584520/article/details/47220575)。
本文工程可到我的资源下载(http://download.csdn.net/detail/kkk584520/8978623)。
Xilinx 7月20号发布了SDSoC 2015.2软件,这是具有里程碑意义的FPGA(或者更准确说是ARM + FPGA SoC系统)集成开发工具,加快了应用发布的速度。
直接通过网页从官网下载速度超慢而且容易中断,尝试了几次不成功,于是改用阿里云主机下载,这个速度超快(有时能达到1MB/s),然后从云主机通过OSS方式下载到本地,解压安装(系统为Windows8 64bit),安装前要确认你的系统也是64位的,硬盘容量空出15GB左右,装起来比较快,看了下安装目录,SDSoC目录结构如下:
可见内置了Vivado ,Vivado_HLS,SDK三个开发工具,无需另外安装。另外也包含了arm-xilinx-linux-gnueabi交叉编译工具,可完成Linux下的应用开发。
可参考这篇EETOP文章来安装license。
安装完成,双击桌面上的SDSoC图标:
启动画面:
Welcome界面(如果未显示,则点击菜单 Help -> Welcome进行显示:
点击Create SDSoC Project,创建一个SDSoC工程,弹出对话框如下:
输入工程名字test,工程路径默认,硬件平台选zed,操作系统选Linux,其余都不做修改,点Next:
这里选矩阵乘加的例子,点Finish,进入主界面如下:
用过Vivado HLS的能看出,二者工程界面基本布局相差不大。
直接点击Project -> Build All,经过几分钟,完成了编译、综合、生成bitstream、打包,在工程目录下可以看到生成的SD卡镜像文件:
将这些文件拷入空白的FAT32文件系统的SD卡即可查看运行情况。
从上面步骤看出,使用SDSoC开发Zynq应用,相当于使用IDE进行软件开发,再也不用在多个软件、工具之间来回跳转,只要一个集成开发环境就能完成所有必须的开发工作,从而提高了开发效率。
后面会深入研究如何进行程序优化,将PS上较为耗时的软件模块offload到PL中实现加速。
--------------------------------------------------------------------------------------------------------------------------------------------
2015-8-8添加
--------------------------------------------------------------------------------------------------------------------------------------------
几天前试验,将SDDebug/sd_card/下的文件拷贝到SD卡,插入ZED Board后无法启动,一直怀疑是开发过程有问题。今天又尝试了下以前的旧镜像,居然也无法启动!看来是SD卡有问题。想起来之前安装Fedora 21时用这个SD卡做的镜像,有可能在起始扇区加入了一些不该有的东西。想到这里,就迅速切到Linux系统,用Disks工具对SD卡执行了低级格式化,将所有扇区都擦写了一遍,然后格式化为FAT文件系统,拷贝SDSoC镜像,插入板卡,居然启动成功了。。。
启动信息如下:
U-Boot 2014.07-00004-g19e1bb2 (Nov 19 2014 - 09:35:12) Board: Xilinx Zynq I2C: ready DRAM: ECC disabled 512 MiB MMC: zynq_sdhci: 0 spi_setup_slave: No QSPI device detected based on MIO settings SF: Failed to set up slave *** Warning - spi_flash_probe() failed, using default environment In: serial Out: serial Err: serial Net: Gem.e000b000 Hit any key to stop autoboot: 0 Device: zynq_sdhci Manufacturer ID: 12 OEM: 3456 Name: F0F0F Tran Speed: 50000000 Rd Block Len: 512 SD version 3.0 High Capacity: Yes Capacity: 3.7 GiB Bus Width: 4-bit reading uEnv.txt ** Unable to read file uEnv.txt ** Copying Linux from SD to RAM... reading uImage 3488184 bytes read in 308 ms (10.8 MiB/s) reading devicetree.dtb 9283 bytes read in 16 ms (566.4 KiB/s) reading uramdisk.image.gz 5044192 bytes read in 442 ms (10.9 MiB/s) ## Booting kernel from Legacy Image at 02080000 ... Image Name: Linux-3.19.0-xilinx-apf Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 3488120 Bytes = 3.3 MiB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK ## Loading init Ramdisk from Legacy Image at 04000000 ... Image Name: Image Type: ARM Linux RAMDisk Image (gzip compressed) Data Size: 5044128 Bytes = 4.8 MiB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK ## Flattened Device Tree blob at 02000000 Booting using the fdt blob at 0x2000000 Loading Kernel Image ... OK Loading Ramdisk to 1e855000, end 1ed247a0 ... OK Loading Device Tree to 1e84f000, end 1e854442 ... OK Starting kernel ... Booting Linux on physical CPU 0x0 Linux version 3.19.0-xilinx-apf (yogeshc@xsjpsgv105) (gcc version 4.9.1 (Sourcery CodeBench Lite 2014.11-30) ) #22 SMP PREEMPT Mon Jul 6 17:59:10 PDT 2015 CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache Machine model: Zynq Zed Development Board cma: Reserved 256 MiB at 0x0e800000 Memory policy: Data cache writealloc PERCPU: Embedded 9 pages/cpu @5fb5c000 s8128 r8192 d20544 u36864 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 Kernel command line: console=ttyPS0,115200 root=/dev/ram rw earlyprintk PID hash table entries: 2048 (order: 1, 8192 bytes) Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) Memory: 244952K/524288K available (4708K kernel code, 251K rwdata, 1644K rodata, 220K init, 250K bss, 17192K reserved, 262144K cma-reserved, 0K highmem) Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xffc00000 - 0xfff00000 (3072 kB) vmalloc : 0x60800000 - 0xff000000 (2536 MB) lowmem : 0x40000000 - 0x60000000 ( 512 MB) pkmap : 0x3fe00000 - 0x40000000 ( 2 MB) modules : 0x3f000000 - 0x3fe00000 ( 14 MB) .text : 0x40008000 - 0x4063c614 (6354 kB) .init : 0x4063d000 - 0x40674000 ( 220 kB) .data : 0x40674000 - 0x406b2f20 ( 252 kB) .bss : 0x406b2f20 - 0x406f1ab8 ( 251 kB) Preemptible hierarchical RCU implementation. RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2. RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 NR_IRQS:16 nr_irqs:16 16 L2C-310 erratum 769419 enabled L2C-310 enabling early BRESP for Cortex-A9 L2C-310 full line of zeros enabled for Cortex-A9 L2C-310 ID prefetch enabled, offset 1 lines L2C-310 dynamic clock gating enabled, standby mode enabled L2C-310 cache controller enabled, 8 ways, 512 kB L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76360001 slcr mapped to 60804000 zynq_clock_init: clkc starts at 60804100 Zynq clock init sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 3298534883328ns timer #0 at 60806000, irq=17 Console: colour dummy device 80x30 Calibrating delay loop... 1332.01 BogoMIPS (lpj=6660096) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) CPU: Testing write buffer coherency: ok CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 Setting up static identity map for 0x475660 - 0x4756b8 CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 Brought up 2 CPUs SMP: Total of 2 processors activated (2664.03 BogoMIPS). CPU: All CPU(s) started in SVC mode. devtmpfs: initialized VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 NET: Registered protocol family 16 DMA: preallocated 256 KiB pool for atomic coherent allocations cpuidle: using governor ladder cpuidle: using governor menu hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers. hw-breakpoint: maximum watchpoint size is 4 bytes. zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0x60880000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb phy0 supply vcc not found, using dummy regulator media: Linux media interface: v0.10 Linux video capture interface: v2.00 pps_core: LinuxPPS API ver. 1 registered pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]> PTP clock support registered EDAC MC: Ver: 3.0.0 Advanced Linux Sound Architecture Driver Initialized. Switched to clocksource arm_global_timer NET: Registered protocol family 2 TCP established hash table entries: 4096 (order: 2, 16384 bytes) TCP bind hash table entries: 4096 (order: 3, 32768 bytes) TCP: Hash tables configured (established 4096 bind 4096) TCP: reno registered UDP hash table entries: 256 (order: 1, 8192 bytes) UDP-Lite hash table entries: 256 (order: 1, 8192 bytes) NET: Registered protocol family 1 RPC: Registered named UNIX socket transport module. RPC: Registered udp transport module. RPC: Registered tcp transport module. RPC: Registered tcp NFSv4.1 backchannel transport module. Trying to unpack rootfs image as initramfs... Freeing initrd memory: 4928K (5e855000 - 5ed25000) hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available futex hash table entries: 512 (order: 3, 32768 bytes) jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc. io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330 dma-pl330 f8003000.dmac: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16 e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 142, base_baud = 3125000) is a xuartps console [ttyPS0] enabled xdevcfg f8007000.devcfg: ioremap 0xf8007000 to 6086c000 [drm] Initialized drm 1.1.0 20060810 brd: module loaded loop: module loaded m25p80 spi0.0: unrecognized JEDEC id bytes: 00, 0, 0 CAN device driver interface libphy: MACB_mii_bus: probed macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 144 (00:0a:35:00:01:22) macb e000b000.ethernet eth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.etherne:00, irq=-1) e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k e1000e: Copyright(c) 1999 - 2014 Intel Corporation. ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ehci-pci: EHCI PCI platform driver usbcore: registered new interface driver usb-storage e0002000.usb supply vbus not found, using dummy regulator ci_hdrc ci_hdrc.0: EHCI Host Controller ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1 ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00 hub 1-0:1.0: USB hub found hub 1-0:1.0: 1 port detected mousedev: PS/2 mouse device common for all mice i2c /dev entries driver zynq-edac f8006000.memory-controller: ecc not enabled Xilinx Zynq CpuIdle Driver started Driver 'mmcblk' needs updating - please use bus_type methods sdhci: Secure Digital Host Controller Interface driver sdhci: Copyright(c) Pierre Ossman sdhci-pltfm: SDHCI platform and OF driver helper sdhci-arasan e0100000.sdhci: No vmmc regulator found sdhci-arasan e0100000.sdhci: No vqmmc regulator found mmc0: Invalid maximum block size, assuming 512 bytes mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA ledtrig-cpu: registered to indicate activity on CPUs usbcore: registered new interface driver usbhid usbhid: USB HID core driver xlnk major 245 xlnk driver loaded xlnk_pdev is not null TCP: cubic registered NET: Registered protocol family 17 can: controller area network core (rev 20120528 abi 9) NET: Registered protocol family 29 can: raw protocol (rev 20120528) can: broadcast manager protocol (rev 20120528 t) can: netlink gateway (rev 20130117) max_hops=1 Registering SWP/SWPB emulation handler drivers/rtc/hctosys.c: unable to open rtc device (rtc0) ALSA device list: No soundcards found. Freeing unused kernel memory: 220K (4063d000 - 40674000) INIT: mmc0: new high speed SDHC card at address b368 mmcblk0: mmc0:b368 F0F0F 3.71 GiB mmcblk0: p1 version 2.88 booting mkdir: can't create directory '/run/media/mmcblk0p1': No such file or directory mount: mounting /dev/mmcblk0p1 on /run/media/mmcblk0p1 failed: No such file or directory Creating /dev/flash/* device nodes random: dd urandom read with 1 bits of entropy available starting Busybox inet Daemon: inetd... done. update-rc.d: /etc/init.d/run-postinsts exists during rc.d purge (continuing) Removing any system startup links for run-postinsts ... /etc/rcS.d/S99run-postinsts INIT: Entering runlevel: 5 Configuring network interfaces... udhcpc (v1.23.1) started Sending discover... Sending discover... Sending discover... No lease, forking to background done. Starting Dropbear SSH server: Generating key, this may take a while... Public key portion is: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC018PRFi//28KVSia0kIY6/NyjxpooJLA8lHweuq8cpXl/1c7mbC+9bc2mBnT5GUJEno/hb/AlYjsD+8YDahmVWgQlk+knOFW8/J2hg7foJHUeUuSBryfcw7lNcdWMld1iSMXpyHig68WQX2UpkGBLAhuWNFQWJGAJfj3XYHdqowmSIV1U3qb5V/7xv1uuP+pVc6z4gQDvC7Mwvs1dD+AzB6wjaVDAUlJs4KOkwZu/GerhGT0lWSLFHqZ0gEBKAp2nM2Q8dHhSXUdIBO1yfQl1ILipwoAhMIXmNyf/4qN47DOFVAwfyARJ4hdyY89a+Ht43d3T5BgMS6K+c4c1Qhi5 root@bsp Fingerprint: md5 8c:7a:47:88:3a:ae:9b:cd:0a:bb:80:74:4a:ca:17:6b dropbear. Starting tcf-agent: OK sh-4.3# ls bin dev home lib mnt root sbin tmp var boot etc init media proc run sys usr
sh-4.3# cd /mnt sh-4.3# ls BOOT.BIN _sds test.elf uramdisk.image.gz README.txt boot.bif test.elf.bit.bin Xilinx_XPS_uLinux devicetree.dtb uImage sh-4.3# chmod 755 test.elf sh-4.3# ls BOOT.BIN _sds test.elf uramdisk.image.gz README.txt boot.bif test.elf.bit.bin Xilinx_XPS_uLinux devicetree.dtb uImage sh-4.3# ./test.elf Testing with A_NROWS = A_NCOLS = B_NCOLS = B_NROWS = 32 Testing mmult .. Average SW cycles: 975045 Average HW cycles: 1246660 TEST PASSED