さて、前回まででCortex-A9向けのLinuxとブート用のバイナリが揃ったので、今度はRISC-V向けのLinuxバイナリを用意しよう。
これもダウンロードするだけで良い。簡単!
$ make fetch-riscv-linux-deliver mkdir -p deliver_output/riscv curl https://s3-us-west-1.amazonaws.com/riscv.org/fpga-zynq-files/root.bin > deliver_output/riscv/root.bin % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 64.0M 100 64.0M 0 0 1268k 0 0:00:51 0:00:51 --:--:-- 1406k curl https://s3-us-west-1.amazonaws.com/riscv.org/fpga-zynq-files/vmlinux > deliver_output/riscv/vmlinux % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2878k 100 2878k 0 0 472k 0 0:00:06 0:00:06 --:--:-- 627k $ ls -lt ./deliver_output/ 合計 13228 drwxrwxr-x 2 masayuki masayuki 4096 2月 23 23:34 riscv -rw-rw-r-- 1 masayuki masayuki 5985405 2月 23 23:28 uramdisk.image.gz -rw-rw-r-- 1 masayuki masayuki 9243 2月 23 23:26 devicetree.dtb -rw-rw-r-- 1 masayuki masayuki 3395816 2月 23 23:22 uImage -rw-rw-r-- 1 masayuki masayuki 4133440 2月 23 22:55 boot.bin -rw-rw-r-- 1 masayuki masayuki 281 2月 23 22:55 output.bif masayuki@ubuntu:~/riscv-hw/rocket-chip/fpga-zynq/zedboard$ ls -lt ./deliver_output/riscv/ 合計 68416 -rw-rw-r-- 1 masayuki masayuki 2947475 2月 23 23:34 vmlinux -rw-rw-r-- 1 masayuki masayuki 67108864 2月 23 23:34 root.bin
ここまででdeliver_outputは上記のようになっているはずだ。 さらに下は http://riscv.org/download.html#tab_zynqfpga より抜粋。
SD_ROOT/ |-> riscv/ |-> root.bin |-> vmlinux |-> boot.bin |-> devicetree.dtb |-> uImage |-> uramdisk.image.gz
いよいよここからはSDカードにこれらのバイナリをコピーする。
正直ブート用SDカードの作りかたは自信が無いのだが、Yocto Linuxの時を思いだしてとりあえずSDカードのフォーマットと、マウントしてコピーをやってみた。 まずはdmesgでどこにデバイスが認識されているのかを確認する。やっているのは Ubuntu 14.04 LTS on VirtualBox だ。
$ dmesg | ag sdb ... [134696.633051] sd 9:0:0:0: [sdb] 7626752 512-byte logical blocks: (3.90 GB/3.63 GiB) [134696.656725] sd 9:0:0:0: [sdb] Write Protect is off [134696.656733] sd 9:0:0:0: [sdb] Mode Sense: 03 00 00 00 [134696.681154] sd 9:0:0:0: [sdb] No Caching mode page found [134696.681159] sd 9:0:0:0: [sdb] Assuming drive cache: write through [134696.846924] sd 9:0:0:0: [sdb] No Caching mode page found [134696.846932] sd 9:0:0:0: [sdb] Assuming drive cache: write through [134696.871149] sdb: sdb1 [134697.012391] sd 9:0:0:0: [sdb] No Caching mode page found [134697.012403] sd 9:0:0:0: [sdb] Assuming drive cache: write through [134697.012412] sd 9:0:0:0: [sdb] Attached SCSI removable disk
fdiskを使って、とりあえずFAT16のパーティションを1つ作って、そこに全部投げ込むことにする。 詳細についてはInterface 2015年3月号を参照(ステマじゃないよ)。
$ sudo fdisk /dev/sdb # FAT16パーティションを作成。ログ取り忘れた... $ sudo mkfs.msdos -n ZED_BOOT /dev/sdb1 $ sudo mount /dev/sdb1 /mnt/SD_CARD
そして、/mnt/SD_CARD に、上記のファイル群をコピーする。これらな。
SD_ROOT/ |-> riscv/ |-> root.bin |-> vmlinux |-> boot.bin |-> devicetree.dtb |-> uImage |-> uramdisk.image.gz
アンマウントして、Zynqボードに差して実行してみよう。
$ sudo umount /mnt/SD_CARD
※ 下記の成功画面を出すまでに、いろいろ失敗して1時間以上悩んでいる...
ちなみに、コンソールを観察する方法としては、TeraTermから見る方法と、LinuxなどからScreenで見る方法がある。RISC-VのページはScreenの方法で書いてあったが、ちょっと手順が違うっぽい?
TeraTermは、通信速度さえ合わせれば簡単に接続できる(実際にはscreenで大奮闘した後だから簡単だったのかも...)
screenでやる場合は、上記ページでは、
$ screen /dev/tty.usbmodem1411 115200,cs8,-parenb,-cstopb
と書いてあるが、/dev/tty.usbmodem1411 が見付からない。dmesgを見ていると、なんだか /tty/devACM0というデバイスが怪しい。
$ screen /dev/ttyACM0 115200,cs8,-parenb,-cstopb
何故かPermission Deniedと言われた。sudoしても一緒。 どうも調べると、これはttyACM0の権限を変えないといけないらしい。
enthusiastick coding: Arduinoはじめます。UbuntuにIDEその他インストール
ほほー。
$ sudo chmod a+rw /dev/ttyACM0
という訳で、再度screenで接続すると、立ち上がった!
以降はTeraTermで取得したログ。
LinuxがCortex-A9上で立ち上がったぜ!
U-Boot 2014.07-dirty (Feb 23 2015 - 22:57:56) Board: Xilinx Zynq I2C: ready DRAM: ECC disabled 256 MiB MMC: zynq_sdhci: 0 SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB *** Warning - bad CRC, using default environment In: serial Out: serial Err: serial Net: Gem.e000b000 Hit any key to stop autoboot: 0 Device: zynq_sdhci Manufacturer ID: 2 OEM: 544d Name: SA04G Tran Speed: 50000000 Rd Block Len: 512 SD version 3.0 High Capacity: Yes Capacity: 3.6 GiB Bus Width: 4-bit reading uEnv.txt ** Unable to read file uEnv.txt ** Copying Linux from SD to RAM... reading uImage 3395816 bytes read in 305 ms (10.6 MiB/s) reading devicetree.dtb 9243 bytes read in 18 ms (501 KiB/s) reading uramdisk.image.gz 5985405 bytes read in 521 ms (11 MiB/s) ## Booting kernel from Legacy Image at 02080000 ... Image Name: Linux-3.15.0-xilinx-06044-g6fd59 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 3395752 Bytes = 3.2 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: 5985341 Bytes = 5.7 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 0e76f000, end 0ed2443d ... OK Loading Device Tree to 0e769000, end 0e76e41a ... OK Starting kernel ... Booting Linux on physical CPU 0x0 Linux version 3.15.0-xilinx-06044-g6fd59fe (masayuki@ubuntu) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-23) ) #1 SMP PREEMPT Mon Feb 23 23:22:19 JST 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: CMA: reserved 128 MiB at 06400000 Memory policy: Data cache writealloc PERCPU: Embedded 8 pages/cpu @cfda1000 s9088 r8192 d15488 u32768 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024 Kernel command line: console=ttyPS0,115200 root=/dev/ram rw earlyprintk PID hash table entries: 1024 (order: 0, 4096 bytes) Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) Memory: 115728K/262144K available (4627K kernel code, 234K rwdata, 1568K rodata, 196K init, 196K bss, 146416K reserved, 0K highmem) Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) vmalloc : 0xd0800000 - 0xff000000 ( 744 MB) lowmem : 0xc0000000 - 0xd0000000 ( 256 MB) pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB) modules : 0xbf000000 - 0xbfe00000 ( 14 MB) .text : 0xc0008000 - 0xc0614f84 (6196 kB) .init : 0xc0615000 - 0xc0646380 ( 197 kB) .data : 0xc0648000 - 0xc0682820 ( 235 kB) .bss : 0xc068282c - 0xc06b3a4c ( 197 kB) Preemptible hierarchical RCU implementation. Dump stacks of tasks blocking RCU-preempt GP. 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 slcr mapped to d0802000 zynq_clock_init: clkc starts at d0802100 Zynq clock init sched_clock: 16 bits at 54kHz, resolution 18432ns, wraps every 1207951633ns timer #0 at d0804000, irq=43 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 0x460b00 - 0x460b58 L310 cache controller enabled l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72760000, Cache size: 512 kB CPU1: Booted secondary processor CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 Brought up 2 CPUs SMP: Total of 2 processors activated. CPU: All CPU(s) started in SVC mode. devtmpfs: initialized VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 regulator-dummy: no parameters 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 @ 0xd0880000 VCCPINT: 1000 mV vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb 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 ttc_clocksource NET: Registered protocol family 2 TCP established hash table entries: 2048 (order: 1, 8192 bytes) TCP bind hash table entries: 2048 (order: 2, 16384 bytes) TCP: Hash tables configured (established 2048 bind 2048) 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: 5844K (ce76f000 - ced24000) 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) c 2001-2006 Red Hat, Inc. msgmni has been set to 493 io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-2364208 dma-pl330 f8003000.dmac: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16 xuartps e0001000.serial: clock name 'aper_clk' is deprecated. xuartps e0001000.serial: clock name 'ref_clk' is deprecated. e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82, base_baud = 3125000) is a xuartps console [ttyPS0] enabled xdevcfg f8007000.devcfg: ioremap 0xf8007000 to d0868000 [drm] Initialized drm 1.1.0 20060810 brd: module loaded loop: module loaded m25p80 spi0.0: found s25fl256s1, expected n25q128 m25p80 spi0.0: s25fl256s1 (32768 Kbytes) 5 ofpart partitions found on MTD device spi0.0 Creating 5 MTD partitions on "spi0.0": 0x000000000000-0x000000100000 : "qspi-fsbl-uboot" 0x000000100000-0x000000600000 : "qspi-linux" 0x000000600000-0x000000620000 : "qspi-device-tree" 0x000000620000-0x000000c00000 : "qspi-rootfs" 0x000000c00000-0x000001000000 : "qspi-bitstream" libphy: MACB_mii_bus: probed macb e000b000.ethernet eth0: Cadence GEM at 0xe000b000 irq 54 (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. uio_pdrv_genirq 43c00000.htif: failed to get IRQ uio_pdrv_genirq: probe of 43c00000.htif failed with error -22 ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ehci-pci: EHCI PCI platform driver ULPI transceiver vendor/product ID 0x0451/0x1507 Found TI TUSB1210 ULPI transceiver. ULPI integrity check: passed. zynq-ehci zynq-ehci.0: Xilinx Zynq USB EHCI Host Controller zynq-ehci zynq-ehci.0: new USB bus registered, assigned bus number 1 zynq-ehci zynq-ehci.0: irq 53, io mem 0x00000000 zynq-ehci zynq-ehci.0: USB 2.0 started, EHCI 1.00 hub 1-0:1.0: USB hub found hub 1-0:1.0: 1 port detected usbcore: registered new interface driver usb-storage mousedev: PS/2 mouse device common for all mice i2c /dev entries driver cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at d086e000 with timeout 10s zynq-edac f8006000.memory-controller: ecc not enabled cpufreq: __cpufreq_add_dev: CPU0: Running at unlisted freq: 666666 KHz cpufreq: __cpufreq_add_dev: CPU0: Unlisted initial frequency changed to: 666667 KHz Xilinx Zynq CpuIdle Driver started sdhci: Secure Digital Host Controller Interface driver sdhci: Copyright(c) Pierre Ossman sdhci-pltfm: SDHCI platform and OF driver helper mmc0: no vqmmc regulator found mmc0: no vmmc regulator found mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA usbcore: registered new interface driver usbhid usbhid: USB HID core driver TCP: cubic registered NET: Registered protocol family 17 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: 196K (c0615000 - c0646000) mmc0: new high speed SDHC card at address 1234 mmcblk0: p10:1234 SA04G 3.63 GiB INIT: version 2.88 booting Starting Bootlog daemon: bootlogd. Creating /dev/flash/* device nodes random: dd urandom read with 10 bits of entropy available FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. Configuring network interfaces... done. starting Busybox inet Daemon: inetd... done. INIT: Entering runlevel: 5 Starting Dropbear SSH server: dropbear. Stopping Bootlog daemon: bootlogd. Starting tcf-agent: OK _____ _ _ _ | ___ \ | | | | (_) | |_/ / ___ | |_ __ _ | | _ _ __ _ _ __ __ | __/ / _ \| __| / _` || | | || '_ \ | | | |\ \/ / | | | __/| |_ | (_| || |____| || | | || |_| | > < \_| \___| \__| \__,_|\_____/|_||_| |_| \__,_|/_/\_\ PetaLinux v2013.10 (Yocto 1.4) zynq ttyPS0 zynq login:
ログインする。ログイン名はroot。パスワードもroot。
_____ _ _ _ | ___ \ | | | | (_) | |_/ / ___ | |_ __ _ | | _ _ __ _ _ __ __ | __/ / _ \| __| / _` || | | || '_ \ | | | |\ \/ / | | | __/| |_ | (_| || |____| || | | || |_| | > < \_| \___| \__| \__,_|\_____/|_||_| |_| \__,_|/_/\_\ PetaLinux v2013.10 (Yocto 1.4) zynq ttyPS0 zynq login: root Password: login[818]: root login on `ttyPS0'
フロントエンドからテスト。
root@zynq:~# ./fesvr-zynq pk hello hello!
SDカードからLinuxをダウンロードし、PL上のRocketで実行する。
root@zynq:~# mkdir /sdcard root@zynq:~# mount /dev/mmcblk0p1 /sdcard root@zynq:~# ./fesvr-zynq +disk=/sdcard/riscv/root.bin /sdcard/riscv/vmlinux [ 0.000000] Linux version 3.14.13-g91d31d7-dirty (skarandikar@s141) (gcc version 4.6.1 (GCC) ) #5 Tue Jul 22 13:11:42 PDT 2014 [ 0.000000] Detected 0x10000000 bytes of physical memory [ 0.000000] Zone ranges: [ 0.000000] Normal [mem 0x00000000-0x0fffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x00000000-0x0fffffff] [ 0.000000] On node 0 totalpages: 32768 [ 0.000000] free_area_init_node: node 0, pgdat ffffffff80249ef8, node_mem_map ffffffff8028c000 [ 0.000000] Normal zone: 224 pages used for memmap [ 0.000000] Normal zone: 0 pages reserved [ 0.000000] Normal zone: 32768 pages, LIFO batch:7 [ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 [ 0.000000] pcpu-alloc: [0] 0 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32544 [ 0.000000] Kernel command line: root=/dev/htifbd0 debug [ 0.000000] PID hash table entries: 1024 (order: 0, 8192 bytes) [ 0.000000] Dentry cache hash table entries: 32768 (order: 5, 262144 bytes) [ 0.000000] Inode-cache hash table entries: 16384 (order: 4, 131072 bytes) [ 0.000000] Memory: 257304K/262144K available (1772K kernel code, 133K rwdata, 368K rodata, 67K init, 248K bss, 4840K reserved) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] NR_IRQS:8 [ 0.000000] console [htifcons0] enabled [ 0.150000] Calibrating delay using timer specific routine.. 201.83 BogoMIPS (lpj=1009173) [ 0.150000] pid_max: default: 32768 minimum: 301 [ 0.150000] Mount-cache hash table entries: 1024 (order: 0, 8192 bytes) [ 0.150000] Mountpoint-cache hash table entries: 1024 (order: 0, 8192 bytes) [ 0.160000] devtmpfs: initialized [ 0.160000] NET: Registered protocol family 16 [ 0.170000] htifcons: detected console with ID 1 [ 0.170000] bio: create slab <bio-0> at 0 [ 0.170000] Switched to clocksource riscv_clocksource [ 0.180000] NET: Registered protocol family 2 [ 0.180000] TCP established hash table entries: 2048 (order: 1, 16384 bytes) [ 0.180000] TCP bind hash table entries: 2048 (order: 1, 16384 bytes) [ 0.180000] TCP: Hash tables configured (established 2048 bind 2048) [ 0.180000] TCP: reno registered [ 0.180000] UDP hash table entries: 256 (order: 0, 8192 bytes) [ 0.180000] UDP-Lite hash table entries: 256 (order: 0, 8192 bytes) [ 0.180000] NET: Registered protocol family 1 [ 0.180000] futex hash table entries: 256 (order: -1, 6144 bytes) [ 0.190000] io scheduler noop registered [ 0.190000] io scheduler cfq registered (default) [ 0.440000] TCP: cubic registered [ 0.440000] htifbd: detected disk with ID 2 [ 0.440000] htifbd: adding htifbd0 [ 0.450000] VFS: Mounted root (ext2 filesystem) readonly on device 254:0. [ 0.470000] devtmpfs: mounted [ 0.470000] Freeing unused kernel memory: 64K (ffffffff80002000 - ffffffff80012000) init started: BusyBox v1.22.1 (2014-07-19 16:30:20 PDT) starting pid 18, tty '': '/bin/busybox mount -t proc proc /proc' starting pid 19, tty '': '/bin/busybox mount -t tmpfs tmpfs /tmp' starting pid 20, tty '': '/bin/busybox mount -o remount,rw /dev/htifbd0 /' [ 0.740000] EXT2-fs (htifbd0): warning: mounting unchecked fs, running e2fsck is recommended starting pid 21, tty '': '/bin/busybox --install -s' starting pid 22, tty '/dev/console': '-/bin/ash ' BusyBox v1.22.1 (2014-07-19 16:30:20 PDT) built-in shell (ash) Enter 'help' for a list of built-in commands. / # ls bin etc lost+found sbin usr dev lib proc tmp