ZedBoardにダウンロードするために、SDカードのイメージを作成する。 まずはSDカードを用意するところからだ。僕の場合はUbuntu LinuxをVirtualBox上で動かしているので、VirtualBox上でSDカードを認識させるところから初める。 dmesgをすると/dev/sdbに認識されているようだった。
で、fdiskを使ってパーティションを作成して、成功のメッセージは出るのだが、何故だかうまくパーティションが作成できていないようだった (lsblkで確認してもsdb1とsdb2が作成されていない)。 変だなと思って、一度SDカードをWindowsでフォーマットしようとしたが、Windows上でフォーマットに失敗する。これはSDカードが壊れたかな? と思って、別のBUFFALOのツールを使ってフォーマットするとうまくいった。何だったんだ。。。
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 96G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 4G 0 part [SWAP] sdb 8:16 1 15G 0 disk ├─sdb1 8:17 1 500M 0 part /media/masayuki/ZED_BOOT └─sdb2 8:18 1 14.5G 0 part /media/masayuki/ROOT_FS sr0 11:0 1 1024M 0 rom
再度fdiskにかけてFATパーティション(ブート用)とEXT3パーティション(ファイルシステム用)を作成する。 これで書き込み用のパーティションが作成された。
それぞれに書き込み用のファイルシステムとマウントポイントを作成する。 (下記のコマンドについて、FPGAマガジンの記事は誤植があった。ROOT_FSをsdb1に作成するようになっていた)。
sudo mkfs.msdos -n ZED_BOOT /dev/sdb1 sudo mkfs.ext4 -L ROOT_FS /dev/sdb2 sudo mount /dev/sdb1 /mnt/ZED_BOOT sudo mount /dev/sdb2 /mnt/ROOT_FS
そして必要なファイルをどんどんコピーしていき、最後にumountしてSDディスクの作成完了。
sudo umount /mnt/ZED_BOOT /mnt/ROOT_FS
$ sudo -i # sudo mount /dev/sdb2 /mnt/ROOT_FS/; sudo mount /dev/sdb1 /mnt/ZED_BOOT/ # cd /mnt/ZED_BOOT/ # ls -1 BOOT.BIN devicetree.dtb uImage # cd ../ROOT_FS/ # ls -1 bin boot core-image-minimal-zedboard-zynq7.tar.gz dev etc home lib lost+found media mnt proc run sbin sys tmp usr var /mnt/ROOT_FS# exit ログアウト $ sudo umount /mnt/ZED_BOOT /mnt/ROOT_FS $
これをZedBoadに差して、TeraTermからシリアルコンソールを使ってブートの様子を見た。
U-Boot 2014.01 (Feb 10 2015 - 02:14:41) I2C: ready Memory: ECC disabled DRAM: 512 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
今回は自分でブートさせなければいけないらしい。
fatload mmc 0 0x3000000 uImage fatload mmc 0 0x2A00000 devicetree.dtb bootm 0x3000000 - 0x2A00000
zynq-uboot> fatload mmc 0 0x3000000 uImage reading uImage 3249528 bytes read in 283 ms (11 MiB/s) zynq-uboot> fatload mmc 0 0x2A00000 devicetree.dtb reading devicetree.dtb 24058 bytes read in 17 ms (1.3 MiB/s) zynq-uboot> bootm 0x3000000 - 0x2A00000 ## Booting kernel from Legacy Image at 03000000 ... Image Name: Linux-3.14.2-xilinx Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 3249464 Bytes = 3.1 MiB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK ## Flattened Device Tree blob at 02a00000 Booting using the fdt blob at 0x2a00000 Loading Kernel Image ... OK Loading Device Tree to 1fb26000, end 1fb2edf9 ... OK Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 3.14.2-xilinx (masayuki@ubuntu) (gcc version 4.9.1 (GCC) ) #1 SMP PREEMPT Tue Feb 10 03:06:19 JST 2015 [ 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] Machine model: ZedBoard [ 0.000000] Memory policy: Data cache writealloc [ 0.000000] PERCPU: Embedded 8 pages/cpu @dfbe1000 s9024 r8192 d15552 u32768 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 [ 0.000000] Kernel command line: console=ttyPS0,115200 earlyprintk root=/dev/ram rw [ 0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes) [ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) [ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) [ 0.000000] Memory: 513216K/524288K available (4390K kernel code, 237K rwdata, 1400K rodata, 196K init, 193K bss, 11072K reserved, 0K highmem) [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB) [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) [ 0.000000] vmalloc : 0xe0800000 - 0xff000000 ( 488 MB) [ 0.000000] lowmem : 0xc0000000 - 0xe0000000 ( 512 MB) [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB) [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB) [ 0.000000] .text : 0xc0008000 - 0xc05afd20 (5792 kB) [ 0.000000] .init : 0xc05b0000 - 0xc05e1340 ( 197 kB) [ 0.000000] .data : 0xc05e2000 - 0xc061d680 ( 238 kB) [ 0.000000] .bss : 0xc061d68c - 0xc064dd60 ( 194 kB) [ 0.000000] Preemptible hierarchical RCU implementation. [ 0.000000] RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 [ 0.000000] NR_IRQS:16 nr_irqs:16 16 [ 0.000000] ps7-slcr mapped to e0802000 [ 0.000000] zynq_clock_init: clkc starts at e0802100 [ 0.000000] Zynq clock init [ 0.000012] sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 3298534883328ns [ 0.000286] ps7-ttc #0 at e0804000, irq=43 [ 0.000611] Console: colour dummy device 80x30 [ 0.000640] Calibrating delay loop... 1332.01 BogoMIPS (lpj=6660096) [ 0.090177] pid_max: default: 32768 minimum: 301 [ 0.090366] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.090383] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.093135] CPU: Testing write buffer coherency: ok [ 0.093424] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 [ 0.093477] Setting up static identity map for 0x42c448 - 0x42c4a0 [ 0.093635] L310 cache controller enabled [ 0.093652] l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72760000, Cache size: 512 kB [ 0.150900] CPU1: Booted secondary processor [ 0.240154] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 [ 0.240270] Brought up 2 CPUs [ 0.240287] SMP: Total of 2 processors activated. [ 0.240296] CPU: All CPU(s) started in SVC mode. [ 0.240887] devtmpfs: initialized [ 0.243184] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 [ 0.244283] regulator-dummy: no parameters [ 0.244805] NET: Registered protocol family 16 [ 0.246027] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.248158] cpuidle: using governor ladder [ 0.248170] cpuidle: using governor menu [ 0.251098] syscon f8000000.ps7-slcr: regmap [mem 0xf8000000-0xf8000fff] registered [ 0.259665] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers. [ 0.259677] hw-breakpoint: maximum watchpoint size is 4 bytes. [ 0.259778] zynq-ocm f800c000.ps7-ocmc: ZYNQ OCM pool: 256 KiB @ 0xe0880000 [ 0.278287] bio: create slab <bio-0> at 0 [ 0.279239] VCCPINT: 1000 mV [ 0.279909] vgaarb: loaded [ 0.280595] SCSI subsystem initialized [ 0.281492] usbcore: registered new interface driver usbfs [ 0.281659] usbcore: registered new interface driver hub [ 0.281887] usbcore: registered new device driver usb [ 0.282626] EDAC MC: Ver: 3.0.0 [ 0.284666] Switched to clocksource arm_global_timer [ 0.305273] NET: Registered protocol family 2 [ 0.305822] TCP established hash table entries: 4096 (order: 2, 16384 bytes) [ 0.305878] TCP bind hash table entries: 4096 (order: 3, 32768 bytes) [ 0.305955] TCP: Hash tables configured (established 4096 bind 4096) [ 0.305997] TCP: reno registered [ 0.306012] UDP hash table entries: 256 (order: 1, 8192 bytes) [ 0.306042] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes) [ 0.306239] NET: Registered protocol family 1 [ 0.306544] RPC: Registered named UNIX socket transport module. [ 0.306555] RPC: Registered udp transport module. [ 0.306563] RPC: Registered tcp transport module. [ 0.306571] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 0.306915] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available [ 0.308893] futex hash table entries: 512 (order: 3, 32768 bytes) [ 0.308967] audit: initializing netlink subsys (disabled) [ 0.309003] audit: type=2000 audit(0.299:1): initialized [ 0.310825] jffs2: version 2.2. (NAND) (SUMMARY) c 2001-2006 Red Hat, Inc. [ 0.310988] msgmni has been set to 1002 [ 0.311556] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 0.311570] io scheduler noop registered [ 0.311579] io scheduler deadline registered [ 0.311615] io scheduler cfq registered (default) [ 0.313448] dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-267056 [ 0.313466] dma-pl330 f8003000.ps7-dma: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16 [ 0.314528] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.316954] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82, base_baud = 3124999) is a xuartps [ 0.849173] console [ttyPS0] enabled [ 0.853413] xdevcfg f8007000.ps7-dev-cfg: ioremap 0xf8007000 to e0866000 [ 0.863791] brd: module loaded [ 0.872524] loop: module loaded [ 0.880195] m25p80 spi32764.0: found s25fl256s1, expected n25q128 [ 0.886412] m25p80 spi32764.0: s25fl256s1 (32768 Kbytes) [ 0.891670] 5 ofpart partitions found on MTD device spi32764.0 [ 0.897479] Creating 5 MTD partitions on "spi32764.0": [ 0.902579] 0x000000000000-0x000000100000 : "qspi-fsbl-uboot" [ 0.909835] 0x000000100000-0x000000600000 : "qspi-linux" [ 0.916479] 0x000000600000-0x000000620000 : "qspi-device-tree" [ 0.923623] 0x000000620000-0x000000c00000 : "qspi-rootfs" [ 0.930397] 0x000000c00000-0x000001000000 : "qspi-bitstream" [ 0.940019] CAN device driver interface [ 0.945333] libphy: MACB_mii_bus: probed [ 0.949177] mdio_bus e000b000.ps7-eth: /amba@0/ps7-ethernet@e000b000/mdio has invalid PHY address [ 0.958099] mdio_bus e000b000.ps7-eth: scan phy mdio at address 0 [ 0.964589] mdio_bus e000b000.ps7-eth: scan phy mdio at address 1 [ 0.970759] mdio_bus e000b000.ps7-eth: scan phy mdio at address 2 [ 0.976850] mdio_bus e000b000.ps7-eth: scan phy mdio at address 3 [ 0.982918] mdio_bus e000b000.ps7-eth: scan phy mdio at address 4 [ 0.989016] mdio_bus e000b000.ps7-eth: scan phy mdio at address 5 [ 0.995108] mdio_bus e000b000.ps7-eth: scan phy mdio at address 6 [ 1.001180] mdio_bus e000b000.ps7-eth: scan phy mdio at address 7 [ 1.007288] mdio_bus e000b000.ps7-eth: scan phy mdio at address 8 [ 1.013358] mdio_bus e000b000.ps7-eth: scan phy mdio at address 9 [ 1.019545] mdio_bus e000b000.ps7-eth: scan phy mdio at address 10 [ 1.025733] mdio_bus e000b000.ps7-eth: scan phy mdio at address 11 [ 1.031890] mdio_bus e000b000.ps7-eth: scan phy mdio at address 12 [ 1.038069] mdio_bus e000b000.ps7-eth: scan phy mdio at address 13 [ 1.044224] mdio_bus e000b000.ps7-eth: scan phy mdio at address 14 [ 1.050407] mdio_bus e000b000.ps7-eth: scan phy mdio at address 15 [ 1.056574] mdio_bus e000b000.ps7-eth: scan phy mdio at address 16 [ 1.062730] mdio_bus e000b000.ps7-eth: scan phy mdio at address 17 [ 1.068911] mdio_bus e000b000.ps7-eth: scan phy mdio at address 18 [ 1.075077] mdio_bus e000b000.ps7-eth: scan phy mdio at address 19 [ 1.081226] mdio_bus e000b000.ps7-eth: scan phy mdio at address 20 [ 1.087401] mdio_bus e000b000.ps7-eth: scan phy mdio at address 21 [ 1.093552] mdio_bus e000b000.ps7-eth: scan phy mdio at address 22 [ 1.099727] mdio_bus e000b000.ps7-eth: scan phy mdio at address 23 [ 1.105888] mdio_bus e000b000.ps7-eth: scan phy mdio at address 24 [ 1.112040] mdio_bus e000b000.ps7-eth: scan phy mdio at address 25 [ 1.118214] mdio_bus e000b000.ps7-eth: scan phy mdio at address 26 [ 1.124366] mdio_bus e000b000.ps7-eth: scan phy mdio at address 27 [ 1.130540] mdio_bus e000b000.ps7-eth: scan phy mdio at address 28 [ 1.136703] mdio_bus e000b000.ps7-eth: scan phy mdio at address 29 [ 1.142854] mdio_bus e000b000.ps7-eth: scan phy mdio at address 30 [ 1.149028] mdio_bus e000b000.ps7-eth: scan phy mdio at address 31 [ 1.155269] macb e000b000.ps7-ethernet eth0: Cadence GEM at 0xe000b000 irq 54 (00:0a:35:00:01:22) [ 1.164056] macb e000b000.ps7-ethernet eth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ps7-eth:00, irq=-1) [ 1.177149] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 1.183754] ehci-pci: EHCI PCI platform driver [ 1.188623] ULPI transceiver vendor/product ID 0x0451/0x1507 [ 1.194196] Found TI TUSB1210 ULPI transceiver. [ 1.198743] ULPI integrity check: passed. [ 1.202964] zynq-ehci zynq-ehci.0: Xilinx Zynq USB EHCI Host Controller [ 1.209565] zynq-ehci zynq-ehci.0: new USB bus registered, assigned bus number 1 [ 1.244700] zynq-ehci zynq-ehci.0: irq 53, io mem 0x00000000 [ 1.264690] zynq-ehci zynq-ehci.0: USB 2.0 started, EHCI 1.00 [ 1.271331] hub 1-0:1.0: USB hub found [ 1.275047] hub 1-0:1.0: 1 port detected [ 1.279592] usbcore: registered new interface driver usb-storage [ 1.286477] mousedev: PS/2 mouse device common for all mice [ 1.292417] i2c /dev entries driver [ 1.297791] zynq-edac f8006000.ps7-ddrc: ecc not enabled [ 1.303703] Xilinx Zynq CpuIdle Driver started [ 1.308570] sdhci: Secure Digital Host Controller Interface driver [ 1.314681] sdhci: Copyright(c) Pierre Ossman [ 1.319005] sdhci-pltfm: SDHCI platform and OF driver helper [ 1.324839] mmc0: no vqmmc regulator found [ 1.328851] mmc0: no vmmc regulator found [ 1.364693] mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA [ 1.377390] usbcore: registered new interface driver usbhid [ 1.382899] usbhid: USB HID core driver [ 1.398162] TCP: cubic registered [ 1.401399] NET: Registered protocol family 17 [ 1.407889] can: controller area network core (rev 20120528 abi 9) [ 1.414043] NET: Registered protocol family 29 [ 1.418434] can: raw protocol (rev 20120528) [ 1.422662] can: broadcast manager protocol (rev 20120528 t) [ 1.428332] can: netlink gateway (rev 20130117) max_hops=1 [ 1.433923] Registering SWP/SWPB emulation handler [ 1.434508] mmc0: new high speed SDHC card at address b368 [ 1.435132] mmcblk0: mmc0:b368 SDC 14.9 GiB [ 1.436337] mmcblk0: p1 p2 [ 1.452148] regulator-dummy: disabling [ 1.461228] List of all partitions: [ 1.464784] 1f00 1024 mtdblock0 (driver?) [ 1.469776] 1f01 5120 mtdblock1 (driver?) [ 1.474845] 1f02 128 mtdblock2 (driver?) [ 1.479820] 1f03 6016 mtdblock3 (driver?) [ 1.484878] 1f04 4096 mtdblock4 (driver?) [ 1.489889] b300 15685632 mmcblk0 driver: mmcblk [ 1.495219] b301 512000 mmcblk0p1 00000000-01 [ 1.500479] b302 15172608 mmcblk0p2 00000000-02 [ 1.505769] No filesystem could mount root, tried: ext3 ext2 ext4 vfat msdos [ 1.512891] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0) [ 1.521138] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.14.2-xilinx #1 [ 1.527675] [<c001540c>] (unwind_backtrace) from [<c001170c>] (show_stack+0x10/0x14) [ 1.535382] [<c001170c>] (show_stack) from [<c0427d80>] (dump_stack+0x80/0xc0) [ 1.542581] [<c0427d80>] (dump_stack) from [<c0425fd0>] (panic+0x9c/0x1e4) [ 1.549440] [<c0425fd0>] (panic) from [<c05b10a0>] (mount_block_root+0x21c/0x230) [ 1.556901] [<c05b10a0>] (mount_block_root) from [<c05b12a8>] (mount_root+0x108/0x110) [ 1.564799] [<c05b12a8>] (mount_root) from [<c05b1440>] (prepare_namespace+0x190/0x1d4) [ 1.572785] [<c05b1440>] (prepare_namespace) from [<c05b0ce0>] (kernel_init_freeable+0x1c8/0x1d8) [ 1.581639] [<c05b0ce0>] (kernel_init_freeable) from [<c0423970>] (kernel_init+0x8/0xe8) [ 1.589712] [<c0423970>] (kernel_init) from [<c000e4b8>] (ret_from_fork+0x14/0x3c) [ 1.597260] CPU1: stopping [ 1.599952] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.14.2-xilinx #1 [ 1.606473] [<c001540c>] (unwind_backtrace) from [<c001170c>] (show_stack+0x10/0x14) [ 1.614193] [<c001170c>] (show_stack) from [<c0427d80>] (dump_stack+0x80/0xc0) [ 1.621394] [<c0427d80>] (dump_stack) from [<c0013da0>] (ipi_cpu_stop+0x58/0x68) [ 1.628771] [<c0013da0>] (ipi_cpu_stop) from [<c00143e8>] (handle_IPI+0x68/0x78) [ 1.636149] [<c00143e8>] (handle_IPI) from [<c000850c>] (gic_handle_irq+0x58/0x5c) [ 1.643702] [<c000850c>] (gic_handle_irq) from [<c0012240>] (__irq_svc+0x40/0x70) [ 1.651159] Exception stack(0xdf489f50 to 0xdf489f98) [ 1.656197] 9f40: df489f98 3b9aca00 5eed3485 00000000 [ 1.664358] 9f60: c0615948 c0615948 dfbea0e8 00000000 5ec5a25d 00000000 df488000 00000000 [ 1.672516] 9f80: 00000018 df489f98 00000008 c0338328 00000013 ffffffff [ 1.679124] [<c0012240>] (__irq_svc) from [<c0338328>] (cpuidle_enter_state+0x54/0xe4) [ 1.687017] [<c0338328>] (cpuidle_enter_state) from [<c033846c>] (cpuidle_idle_call+0xb4/0x14c) [ 1.695695] [<c033846c>] (cpuidle_idle_call) from [<c000f00c>] (arch_cpu_idle+0x8/0x38) [ 1.703687] [<c000f00c>] (arch_cpu_idle) from [<c0060860>] (cpu_startup_entry+0x104/0x150) [ 1.711926] [<c0060860>] (cpu_startup_entry) from [<000085a4>] (0x85a4)
これでLinuxのブートは始まったが、途中でカーネルパニックを起こす。 (Linuxのブートが出来るようになるまでも10回以上SDカードを書き直したが…)
調べてみると、FPGAマガジンの記事を書かれた方も同様の問題にぶつかっていたようだ。
これ、どうやって解決すればいいんだろう。。。とりあえず今日はここまで。