轉載請保留做者信息。原文網址(http://blog.csdn.net/kkk584520/article/details/47220575)。html
本文project可到個人資源下載(http://download.csdn.net/detail/kkk584520/8978623)。node
Xilinx 7月20號公佈了SDSoC 2015.2軟件。這是具備里程碑意義的FPGA(或者更準確說是ARM + FPGA SoC系統)集成開發工具,加快了應用公佈的速度。linux
直接經過網頁從官網下載速度超慢而且easy中斷,嘗試了幾回不成功。因而改用阿里雲主機下載,這個速度超快(有時能達到1MB/s),而後從雲主機經過OSS方式下載到本地,解壓安裝(系統爲Windows8 64bit)。安裝前要確認你的系統也是64位的。硬盤容量空出15GB左右,裝起來比較快,看了下安裝文件夾。SDSoC文件夾結構例如如下:git
可見內置了Vivado ,Vivado_HLS,SDK三個開發工具,無需另外安裝。另外也包括了arm-xilinx-linux-gnueabi交叉編譯工具。可完畢Linux下的應用開發。app
可參考這篇EETOP文章來安裝license。dom
安裝完畢,雙擊桌面上的SDSoC圖標:ssh
啓動畫面:socket
Welcome界面(假設未顯示。則點擊菜單 Help -> Welcome進行顯示:tcp
點擊Create SDSoC Project,建立一個SDSoCproject,彈出對話框例如如下:ide
輸入project名字test,project路徑默認。硬件平臺選zed,操做系統選Linux,其他都不作改動,點Next:
這裏選矩陣乘加的樣例,點Finish,進入主界面例如如下:
用過Vivado HLS的能看出,兩者project界面基本佈局相差不大。
直接點擊Project -> Build All,通過幾分鐘,完畢了編譯、綜合、生成bitstream、打包,在project文件夾下可以看到生成的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 <giometti@linux.it> 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
進入/mnt 文件夾。執行test.elf,輸出例如如下:
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
硬件加速效果很差。有待優化。