ひでみのアイデア帳

くだらないことなんだけど、忘れないために・・・

ZYBO Z7 ブート不具合

技術書典3向けの新刊を作成しているんだけど、原稿の内容と整合性を合わせるためにデバッグを進めながら執筆している。

そのなか、BOOT.BINを作成しているところで思わぬ不具合に遭遇した。

真面目に環境を作成し始めたわけなのであるが・・・

普段はu-bootのsplでboot.binを作成するんだけど、起動すると文字化けが発生するのである。

実は単純な動作検証ではZ-Turn用のBOOT.BINを使用していた。

クロックの調査

ZYBO Z7でプロジェクトを作成し、PSを配置する。

「Run Block Automation」でPSの自動設定を行う。

これでI/Fにチェックがつく。

さて、クロックを調べよう。

33.3MHzで問題なし。

問題ない。

ZYBOの場合

同じようにPSのみ配置。

クロックを見ると、50MHz

Zedの場合

おまけでZedも作ってみた。

Hardware Export

問題点はu-bootの文字化けなのでps_init_gpl.c/hを中心に洗い出すことにした。

次の3つのHardware Exportファイルを作成し確認した。

  • ZYBO Z7
  • ZYBO
  • Zed

問題はなさぞう。

IPブロックはこんな感じにして、PS7のみ・・・

周波数的や逓倍には間違いが無いようだ。

Z-Turnのboot.binを使ってみる

たまたま、Z-Turn(7020)のu-bootもあったのでboot.binとu-boot.imgを組みわせてみよう。

実はZ-TurnとZYBO Z7って周波数やDDR周辺が同じ設定で使用できるのだ。

No boot.bin u-image.img 結果
1 ZYBO Z7 ZYBO Z7 ×
1 Z-Turn ZYBO Z7 ×
1 ZYBO Z7 Z-Turn
1 Z-Turn Z-Turn

△はBOOT.BINのメッセージで文字化け。

と、いうことは行き着く先はu-boot本体の設定である。

つまり、.configなのでは?ってことでu-boot-xlnxの設定を見ると・・・

UARTのボーレートが入っていない。

これぇ〜?

いやいや、これじゃないよ。

いや、マジで原因不明・・・

マジでお手上げなのだ!

ここまで原因がわからないのも久しぶりである。

本家u-boot

ここまで使ってたu-bootはXilinxのu-boot-xlnxだったので本家u-bootを使ってみることにした。

成功すれば次のように出るはずだ。

実は動く環境がひとつだけあるのである。

U-Boot SPL 2017.05-rc1 (Oct 03 2017 - 11:40:23)
mmc boot
Trying to boot from MMC1
reading system.dtb
spl_load_image_fat_os: error reading image system.dtb, err - -1
reading u-boot.img
reading u-boot.img

U-Boot 2017.05-rc1 (Oct 03 2017 - 11:40:23 +0900)

Model: Zynq ZYBO Development Board
Board: Xilinx Zynq
I2C:   ready
DRAM:  ECC disabled 512 MiB
MMC:   sdhci@e0100000: 0
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 1B
*** Warning - bad CRC, using default environment

In:    serial@e0001000
Out:   serial@e0001000
Err:   serial@e0001000
Model: Zynq ZYBO Development Board
Board: Xilinx Zynq
Net:   ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id
I2C EEPROM MAC address read failed

Warning: ethernet@e000b000 (eth0) using random MAC address - fa:6c:09:bb:2a:ec
eth0: ethernet@e000b000
Hit any key to stop autoboot:  0
reading ZTurn_wrapper.bit
4045678 bytes read in 250 ms (15.4 MiB/s)
  design filename = "system_wrapper;UserID=0XFFFFFFFF;Version=2017.2_sdx"
  part number = "7z020clg400"
  date = "2017/09/22"
  time = "16:51:08"
  bytes in bitstream = 4045564
zynq_align_dma_buffer: Align buffer at 1000072 to ffff80(swap 1)
reading zImage
3935432 bytes read in 236 ms (15.9 MiB/s)
reading zynq-zturn.dtb
8082 bytes read in 17 ms (463.9 KiB/s)
## Flattened Device Tree blob at 00000100
   Booting using the fdt blob at 0x000100
   Loading Device Tree to 1eb29000, end 1eb2df91 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.10.17-xil (gcc version 67
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instructie
[    0.000000] OF: fdt:Machine model: Zynq ZYBO Development Board
[    0.000000] earlycon: cdns0 at MMIO 0xe0001000 (options '115200n8')
[    0.000000] bootconsole [cdns0] enabled
[    0.000000] cma: Reserved 16 MiB at 0x1f000000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] percpu: Embedded 14 pages/cpu @debcc000 s25932 r8192 d23220 u5734
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pa8
[    0.000000] Kernel command line: ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwan
[    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: 493024K/524288K available (6144K kernel code, 221K rwdat)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 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 - 0xc0700000   (7136 kB)
[    0.000000]       .init : 0xc0900000 - 0xc0a00000   (1024 kB)
[    0.000000]       .data : 0xc0a00000 - 0xc0a37440   ( 222 kB)
[    0.000000]        .bss : 0xc0a37440 - 0xc0a7142c   ( 232 kB)
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  Build-time adjustment of leaf fanout to 32.
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] slcr mapped to e0800000
[    0.000000] L2C: platform modifies aux control register: 0x02060000 -> 0x0240
[    0.000000] L2C: DT/platform modifies aux control register: 0x02060000 -> 0x0
[    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 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 0x46460001
[    0.000000] zynq_clock_init: clkc starts at e0800100
[    0.000000] Zynq clock init
[    0.000011] sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398s
[    0.007822] clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycls
[    0.018816] Switching to timer-based delay loop, resolution 3ns
[    0.024763] clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, ms
[    0.033782] timer #0 at e0808000, irq=17
[    0.038072] Console: colour dummy device 80x30
[    0.042329] console [tty0] enabled
[    0.045700] bootconsole [cdns0] disabled
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.10.17-xilinx (gcc version 67
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instructie
[    0.000000] OF: fdt:Machine model: Zynq ZYBO Development Board
[    0.000000] earlycon: cdns0 at MMIO 0xe0001000 (options '115200n8')
[    0.000000] bootconsole [cdns0] enabled
[    0.000000] cma: Reserved 16 MiB at 0x1f000000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] percpu: Embedded 14 pages/cpu @debcc000 s25932 r8192 d23220 u5734
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pa8
[    0.000000] Kernel command line: ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwan
[    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: 493024K/524288K available (6144K kernel code, 221K rwdat)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 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 - 0xc0700000   (7136 kB)
[    0.000000]       .init : 0xc0900000 - 0xc0a00000   (1024 kB)
[    0.000000]       .data : 0xc0a00000 - 0xc0a37440   ( 222 kB)
[    0.000000]        .bss : 0xc0a37440 - 0xc0a7142c   ( 232 kB)
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  Build-time adjustment of leaf fanout to 32.
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] slcr mapped to e0800000
[    0.000000] L2C: platform modifies aux control register: 0x02060000 -> 0x0240
[    0.000000] L2C: DT/platform modifies aux control register: 0x02060000 -> 0x0
[    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 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 0x46460001
[    0.000000] zynq_clock_init: clkc starts at e0800100
[    0.000000] Zynq clock init
[    0.000011] sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398s
[    0.007822] clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycls
[    0.018816] Switching to timer-based delay loop, resolution 3ns
[    0.024763] clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, ms
[    0.033782] timer #0 at e0808000, irq=17
[    0.038072] Console: colour dummy device 80x30
[    0.042329] console [tty0] enabled
[    0.045700] bootconsole [cdns0] disabled
[    0.049628] Calibrating delay loop (skipped), value calculated using timer f)
[    0.049662] pid_max: default: 32768 minimum: 301
[    0.049807] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.049832] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.050506] CPU: Testing write buffer coherency: ok
[    0.050726] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.077777] Setting up static identity map for 0x100000 - 0x100058
[    0.147755] smp: Bringing up secondary CPUs ...
[    0.218096] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.218182] smp: Brought up 1 node, 2 CPUs
[    0.218217] SMP: Total of 2 processors activated (1333.33 BogoMIPS).
[    0.218236] CPU: All CPU(s) started in SVC mode.
[    0.219110] devtmpfs: initialized
[    0.221662] VFP support v0.3: implementor 41 architecture 3 part 30 variant 4
[    0.221920] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, ms
[    0.221958] futex hash table entries: 512 (order: 3, 32768 bytes)
[    0.222930] pinctrl core: initialized pinctrl subsystem
[    0.223850] NET: Registered protocol family 16
[    0.225759] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.248135] cpuidle: using governor menu
[    0.259191] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint.
[    0.259221] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.259398] zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
[    0.310074] SCSI subsystem initialized
[    0.310398] usbcore: registered new interface driver usbfs
[    0.310502] usbcore: registered new interface driver hub
[    0.310590] usbcore: registered new device driver usb
[    0.310772] phy0 supply vcc not found, using dummy regulator
[    0.311085] media: Linux media interface: v0.10
[    0.311173] Linux video capture interface: v2.00
[    0.311251] pps_core: LinuxPPS API ver. 1 registered
[    0.311279] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giom>
[    0.311348] PTP clock support registered
[    0.311421] EDAC MC: Ver: 3.0.0
[    0.318431] FPGA manager framework
[    0.318693] Advanced Linux Sound Architecture Driver Initialized.
[    0.319779] clocksource: Switched to clocksource arm_global_timer
[    0.330946] NET: Registered protocol family 2
[    0.331728] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.331819] TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
[    0.331917] TCP: Hash tables configured (established 4096 bind 4096)
[    0.331991] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.332042] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.332227] NET: Registered protocol family 1
[    0.342681] RPC: Registered named UNIX socket transport module.
[    0.342722] RPC: Registered udp transport module.
[    0.342747] RPC: Registered tcp transport module.
[    0.342771] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.343384] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 countee
[    0.345293] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.346067] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
[    0.346306] ntfs: driver 2.1.32 [Flags: R/W].
[    0.346374] jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
[    0.347336] io scheduler noop registered (default)
[    0.349245] dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
[    0.349293] dma-pl330 f8003000.dmac:         DBUFF-128x8bytes Num_Chans-8 Nu6
[    0.350758] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.352049] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 142, base_bauds
[    0.990760] console [ttyPS0] enabled
[    0.994909] [drm] Initialized
[    0.999603] brd: module loaded
[    1.009887] loop: module loaded
[    1.014764] libphy: Fixed MDIO Bus: probed
[    1.022387] CAN device driver interface
[    1.027102] libphy: MACB_mii_bus: probed
[    1.032296] RTL8211E Gigabit Ethernet e000b000.etherne:00: attached PHY driv)
[    1.046035] macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe00)
[    1.056921] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.063594] usbcore: registered new interface driver usb-storage
[    1.069824] e0002000.usb supply vbus not found, using dummy regulator
[    1.089809] ci_hdrc ci_hdrc.0: EHCI Host Controller
[    1.094648] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[    1.129810] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[    1.135968] hub 1-0:1.0: USB hub found
[    1.139685] hub 1-0:1.0: 1 port detected
[    1.144787] udc-core: couldn't find an available UDC - added [zero] to list s
[    1.153775] mousedev: PS/2 mouse device common for all mice
[    1.159730] i2c /dev entries driver
[    1.164927] EDAC MC: ECC not enabled
[    1.168593] Xilinx Zynq CpuIdle Driver started
[    1.173476] sdhci: Secure Digital Host Controller Interface driver
[    1.179598] sdhci: Copyright(c) Pierre Ossman
[    1.183952] Synopsys Designware Multimedia Card Interface Driver
[    1.190065] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.250860] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using A
[    1.258505] ledtrig-cpu: registered to indicate activity on CPUs
[    1.264764] usbcore: registered new interface driver usbhid
[    1.270305] usbhid: USB HID core driver
[    1.276374] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
[    1.283921] oprofile: using arm/armv7-ca9
[    1.288401] NET: Registered protocol family 10
[    1.293809] Segment Routing with IPv6
[    1.297484] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    1.304167] NET: Registered protocol family 17
[    1.308571] NET: Registered protocol family 15
[    1.312995] can: controller area network core (rev 20120528 abi 9)
[    1.319220] NET: Registered protocol family 29
[    1.323633] can: raw protocol (rev 20120528)
[    1.327847] can: broadcast manager protocol (rev 20161123 t)
[    1.333526] can: netlink gateway (rev 20130117) max_hops=1
[    1.339038] 8021q: 802.1Q VLAN Support v1.8
[    1.343460] ThumbEE CPU extension supported.
[    1.347674] Registering SWP/SWPB emulation handler
[    1.353205] hctosys: unable to open rtc device (rtc0)
[    1.358404] ALSA device list:
[    1.361331]   No soundcards found.
[    1.365043] Waiting for root device /dev/mmcblk0p2...

最新版でするとこんな感じで黙りこむ・・・

U-Boot SPL 2017.11-rc1-dirty (Oct 03 2017 - 11:44:37)
mmc boot
Trying to boot from MMC1

をいをい・・・

ふむふむ、じゃぁ、唯一動作するu-bootのソースコードを使ってZYBO Z7のhdfを入れてみると・・・

普通に動く・・・

どうも、u-bootのなにかが変わったために不具合に見えているようだ。

あれこれやっているとu-boot-xlnxの不具合ということに落ち着いた。

そこかよ〜。

まとめ

バージョン
u-boot-xlnx 2017.01
本家u-boot 2017.11-rc1
唯一動作u-boot 2017.05-rc1

まぁ、動作するのを持ってるからいっかぁ・・・(^-^;

いろいろやってると結局、u-boot 2017.9、Linux Kernel 4.13.4で動作することができました。

いろいろ罠があって面倒だったけど、お疲れ様でしたぁ〜