petalinuxをBuildrootでビルドする


関連記事
[EBAZ4205を使って、FPGAを使ったシステム開発の環境を構築する](https://qiita.com/GeekMasahiro/items/6bdb8886fb5c32c332cb)
[EBAZ4205でLinuxを動かして見る](https://qiita.com/GeekMasahiro/items/bb411ab40bb2e80e4c2a)
[petalinuxをBuildrootでビルドする](https://qiita.com/GeekMasahiro/items/7ce3d4fe108f2cfe49a3)

# はじめに

Zinqを使ったボードでNervesを動作させる事を目指しています。

その前段階として、petalinuxをbuildrootでビルドする方法を調査し、作成できるか試してみます。

# 使用するハードウエア

Zinqの評価boardを使うのがお手軽ですが、今回は次の理由から、ebaz4205を使う事にします。

- ebaz4205は、マイニングマシーンに使われていたコントローラの中古販売品で価格が安い。
- 必要最低限のハードウエアで、自身でハードウエアを作る場合もほぼ同等の構成になりそう。
- 評価boardと違い、開発環境が整ってないので、大変だが、開発に必要な事を一通り経験できる

# 参考サイト

petalinuxについては、[この記事](https://qiita.com/GeekMasahiro/items/bb411ab40bb2e80e4c2a)で、実際に動作する事を確認しました。

Nervesを動作させるためには、buildrootでビルドする必要があるので、petalinuxをbuildrootでビルドしている事例がないか調査しました。

以下のコンテンツが見つかりました。

https://github.com/embed-me/ebaz4205_buildroot

これを参考に、ebaz4205をbuildrootでビルドする事を試みます。

# dtsファイル

Linuxからみたハードウエアの情報は、dtsファイルに記述されています。

本来は、FPGAの中身を開発した上で、dtsファイルを作成する必要がありますが、ebaz4205_buildrootで使われているdtsファイルを使って、buildrootの構築方法を習得する事にします。

petalinuxのビルドした結果にsystem.dtbは作成されていました。
このあたりの成果物から、ebaz4205_buildrootのdtsファイルを作成する事ができるのではないかと想定しています。
今後の課題です。

# ビルド手順

```bash
cd /home/masa/ebaz4205
git clone https://github.com/buildroot/buildroot.git
git clone https://github.com/embed-me/ebaz4205_buildroot
cd buildroot/
make BR2_EXTERNAL=../ebaz4205_buildroot zynq_ebaz4205_defconfig
make 2>&1 | tee build.log
```

この手順でbuildしてみましたが、カーネルのコンパイル過程でエラーが発生しました。
どうやら、```ebaz4205_buildroot```が想定しているbuildrootが古く、最新のbuildrootとは合わないようです。

# 設定ファイルの修正

zynq_ebaz4205_defconfigのKernelの設定では、4.19を指定しています。これはいかにも古そうです。

```:zynq_ebaz4205_defconfig
BR2_LINUX_KERNEL_VERSION="4.19"
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
```

できるだけ、公式（Xilinx）のリポジトリを使うようにしたいです。次のように修正してみました。

```:zynq_ebaz4205_defconfig
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/Xilinx/linux-xlnx.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="xlnx_rebase_v5.15_LTS"
```

U-bootも独自のものを使用しているようです。

```
BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/embed-me/u-boot.git"
```

これもpetalinuxのビルドと同じものを使うように修正したいですが、今回はこのままで進めます。今後の課題とします。

修正後のzyng_ebaz4205_defconfigは次のようになりました。

```:zynq_ebaz4205_defconfig
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyPS0"
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_EMBEDME_EBAZ4205_PATH)/ebaz4205/fs-overlay"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/Xilinx/linux-xlnx.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="xlnx_rebase_v5.15_LTS"
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
BR2_LINUX_KERNEL_UIMAGE=y
BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x8000"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y
BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_EMBEDME_EBAZ4205_PATH)/ebaz4205/dts/ebaz4205-zynq7.dts $(BR2_EXTERNAL_EMBEDME_EBAZ4205_PATH)/ebaz4205/dts/ebaz4205-board.dtsi $(BR2_EXTERNAL_EMBEDME_EBAZ4205_PATH)/ebaz4205/dts/ebaz4205-pl.dtsi"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_EMBEDME_EBAZ4205_PATH)/ebaz4205/linux/linux.config"
BR2_TARGET_ROOTFS_CPIO=y
BR2_TARGET_ROOTFS_CPIO_GZIP=y
BR2_TARGET_ROOTFS_CPIO_UIMAGE=y
BR2_TARGET_UBOOT=y
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
BR2_TARGET_UBOOT_CUSTOM_GIT=y
BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/embed-me/u-boot.git"
BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="v2019.07-ebaz4205"
BR2_TARGET_UBOOT_BOARD_DEFCONFIG="zynq_ebaz4205"
BR2_TARGET_UBOOT_NEEDS_DTC=y
BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
BR2_TARGET_UBOOT_FORMAT_IMG=y
BR2_TARGET_UBOOT_SPL=y
BR2_TARGET_UBOOT_SPL_NAME="spl/boot.bin"
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y
BR2_TARGET_GENERIC_ROOT_PASSWD="root"
BR2_TARGET_GENERIC_HOSTNAME="ebaz4205"
BR2_PACKAGE_LINUX_TOOLS_GPIO=y
BR2_PACKAGE_MTD=y
BR2_PACKAGE_MTD_MKFSUBIFS=y
BR2_PACKAGE_STRACE=y
BR2_PACKAGE_COREUTILS=y
BR2_PACKAGE_DROPBEAR=y
```

# ビルド再開

この修正によりビルド成功しました。

```ebaz4205_buildroot```の説明に従って、FATでフォーマットしたSDカードに、成果物をコピーして、ebaz4205に挿入して起動してみました。

bitstreamのファイル(Vivadoで作成)は、ファイル名が、ebaz4205_wrapper.bitでドキュメントと異なったので、uEnv.txtの内容も修正しました。

```
machine_name=ebaz4205-zynq7
kernel_image=uImage
loadkernel=load mmc 0 ${kernel_load_address} ${kernel_image}
devicetree_image=ebaz4205-zynq7.dtb
loaddtb=load mmc 0 ${devicetree_load_address} ${devicetree_image}
ramdisk_image=rootfs.cpio.uboot
loadramdisk=load mmc 0 ${ramdisk_load_address} ${ramdisk_image}
bootargs=earlyprintk console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait
bitstream_image=ebaz4205_wrapper.bit
bitstream_type=load
fpga_config=fpga ${bitstream_type} 0 ${bitstream_load_address} ${filesize}
sdboot=if mmcinfo; then run leds_bootstate_0;run uenvboot;echo Copying Linux from SD to RAM...;run mmc_loadfpga && run mmc_loadkernel && run mmc_loaddtb && run mmc_loadramdisk && run leds_bootstate_1; echo Configure FPGA...; run fpga_config && run leds_bootstate_2; echo Handoff to Linux kernel...;bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}; fi
```

SDカードにコピーしたファイル
```
-a----        2024/11/26     20:33          11520 ebaz4205-zynq7.dtb
-a----        2024/11/26      6:11          89448 boot.bin
-a----        2024/11/26     20:33        9637844 rootfs.cpio.uboot
-a----        2024/11/26      6:11         571980 u-boot.img
-a----        2024/11/26      6:11         571916 u-boot.bin
-a----        2024/11/26     20:33       10760768 uImage
-a----        2024/11/28     20:42            895 uEnv.txt
-a----        2024/11/28      8:32        2083852 ebaz4205_wrapper.bit
```

起動してみると、
次のような結果でした。

```
U-Boot SPL 2019.07 (Nov 26 2024 - 06:11:10 +0900)
mmc boot
Trying to boot from MMC1
spl_load_image_fat_os: error reading image system.dtb, err - -2


U-Boot 2019.07 (Nov 26 2024 - 06:11:10 +0900)

CPU:   Zynq 7z010
Silicon: v3.1
DRAM:  ECC disabled 256 MiB
MMC:   mmc@e0100000: 0
Loading Environment from SPI Flash... Invalid bus 0 (err=-19)
*** Warning - spi_flash_probe_bus_cs() failed, using default environment

In:    serial@e0001000
Out:   serial@e0001000
Err:   serial@e0001000
Net:   ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id

Warning: ethernet@e000b000 (eth0) using random MAC address - 02:ef:31:36:51:ea
eth0: ethernet@e000b000
895 bytes read in 15 ms (57.6 KiB/s)
Importing environment from SD ...
Hit any key to stop autoboot:  0
gpio: pin 20 (gpio 20) value is 0
Device: mmc@e0100000
Manufacturer ID: 2
OEM: 544d
Name: SA16G
Bus Speed: 20000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
gpio: pin 54 (gpio 54) value is 0
gpio: pin 55 (gpio 55) value is 0
895 bytes read in 15 ms (57.6 KiB/s)
Loaded environment from uEnv.txt
Importing environment from SD ...
Copying Linux from SD to RAM...
2083852 bytes read in 233 ms (8.5 MiB/s)
10760768 bytes read in 1152 ms (8.9 MiB/s)
11520 bytes read in 17 ms (661.1 KiB/s)
9637844 bytes read in 1039 ms (8.8 MiB/s)
gpio: pin 54 (gpio 54) value is 0
gpio: pin 55 (gpio 55) value is 1
   Warning: value of pin is still 0
Configure FPGA...
zynq_validate_bitstream: Bitstream is not validated yet (diff 70)
fpga - loadable FPGA image support

Usage:
fpga [operation type] [device number] [image address] [image size]
fpga operations:
  dump  [dev] [address] [size]  Load device to memory buffer
  info  [dev]                   list known device information
  load  [dev] [address] [size]  Load device from memory buffer
  loadp [dev] [address] [size]  Load device from memory buffer with partial bitstream
  loadb [dev] [address] [size]  Load device from bitstream buffer (Xilinx only)
  loadbp        [dev] [address] [size]  Load device from bitstream buffer with partial bitstream(Xilinx only)
Load device from filesystem (FAT by default) (Xilinx only)
  loadfs [dev] [address] [image size] [blocksize] <interface>
        [<dev[:part]>] <filename>
  loadmk [dev] [address]        Load device generated with mkimage
        For loadmk operating on FIT format uImage address must include
        subimage unit name in the form of addr:<subimg_uname>
Handoff to Linux kernel...
## Booting kernel from Legacy Image at 02080000 ...
   Image Name:   Linux-6.11.10
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    10760704 Bytes = 10.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 (uncompressed)
   Data Size:    9637780 Bytes = 9.2 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 0e208000, end 0eb38f94 ... OK
   Loading Device Tree to 0e202000, end 0e207cff ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 6.11.10 (masa@wsl-elixir) (arm-buildroot-linux-gnueabihf-gcc.br_real (Buildroot 2024.11-rc2-6-ged590a22e2) 13.3.0, GNU ld (GNU Binutils) 2.42) #1 SMP Tue Nov 26 13:07:02 JST 2024
[    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] OF: fdt: Machine model: xlnx,zynq-7000
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 64 MiB at 0x0a000000 on node -1
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000000000-0x000000000fffffff]
[    0.000000]   Normal   empty
[    0.000000]   HighMem  empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000000fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000000fffffff]
[    0.000000] percpu: Embedded 17 pages/cpu s40076 r8192 d21364 u69632
[    0.000000] Kernel command line: earlyprintk console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait
[    0.000000] Unknown kernel command line parameters "earlyprintk", will be passed to user space.
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 65536
[    0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] trace event string verifier disabled
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=2.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] slcr mapped to (ptrval)
[    0.000000] L2C: platform modifies aux control register: 0x02060000 -> 0x02460000
[    0.000000] L2C: DT/platform modifies aux control register: 0x02060000 -> 0x02460000
[    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] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] zynq_clock_init: clkc starts at (ptrval)
[    0.000000] Zynq clock init
[    0.000000] ps_clk frequency not specified, using 33 MHz.
[    0.000002] sched_clock: 64 bits at 167MHz, resolution 6ns, wraps every 4398046511103ns
[    0.000025] clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x26703d7dd8, max_idle_ns: 440795208065 ns
[    0.000058] Switching to timer-based delay loop, resolution 6ns
[    0.001079] Console: colour dummy device 80x30
[    0.001130] Calibrating delay loop (skipped), value calculated using timer frequency.. 333.33 BogoMIPS (lpj=1666666)
[    0.001149] CPU: Testing write buffer coherency: ok
[    0.001185] CPU0: Spectre v2: using BPIALL workaround
[    0.001195] pid_max: default: 32768 minimum: 301
[    0.001342] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001360] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.002193] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.003276] Setting up static identity map for 0x300000 - 0x3000ac
[    0.003988] rcu: Hierarchical SRCU implementation.
[    0.003997] rcu:     Max phase no-delay instances is 1000.
[    0.004321] Timer migration: 1 hierarchy levels; 8 children per group; 1 crossnode level
[    0.005557] EFI services will not be available.
[    0.005775] smp: Bringing up secondary CPUs ...
[    0.006685] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.006710] CPU1: Spectre v2: using BPIALL workaround
[    0.006878] smp: Brought up 1 node, 2 CPUs
[    0.006894] SMP: Total of 2 processors activated (666.66 BogoMIPS).
[    0.006906] CPU: All CPU(s) started in SVC mode.
[    0.007314] Memory: 155436K/262144K available (15360K kernel code, 2274K rwdata, 6164K rodata, 2048K init, 412K bss, 39796K reserved, 65536K cma-reserved, 0K highmem)
[    0.007766] devtmpfs: initialized
[    0.011276] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.011539] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.011563] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.015298] pinctrl core: initialized pinctrl subsystem
[    0.017112] DMI not present or invalid.
[    0.017929] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.021289] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.023478] thermal_sys: Registered thermal governor 'step_wise'
[    0.023553] cpuidle: using governor menu
[    0.027643] platform axi: Fixed dependency cycle(s) with /axi/interrupt-controller@f8f01000
[    0.032293] platform replicator: Fixed dependency cycle(s) with /axi/etb@f8801000
[    0.032398] amba f8801000.etb: Fixed dependency cycle(s) with /replicator
[    0.032649] platform replicator: Fixed dependency cycle(s) with /axi/tpiu@f8803000
[    0.032743] amba f8803000.tpiu: Fixed dependency cycle(s) with /replicator
[    0.033006] platform replicator: Fixed dependency cycle(s) with /axi/funnel@f8804000
[    0.033100] amba f8804000.funnel: Fixed dependency cycle(s) with /axi/ptm@f889d000
[    0.033123] amba f8804000.funnel: Fixed dependency cycle(s) with /axi/ptm@f889c000
[    0.033144] amba f8804000.funnel: Fixed dependency cycle(s) with /replicator
[    0.033392] amba f8804000.funnel: Fixed dependency cycle(s) with /axi/ptm@f889c000
[    0.033498] amba f889c000.ptm: Fixed dependency cycle(s) with /axi/funnel@f8804000
[    0.033742] amba f8804000.funnel: Fixed dependency cycle(s) with /axi/ptm@f889d000
[    0.033831] amba f889d000.ptm: Fixed dependency cycle(s) with /axi/funnel@f8804000
[    0.034776] No ATAGs?
[    0.034878] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
[    0.034892] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.038074] Serial: AMBA PL011 UART driver
[    0.038896] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 26, base_baud = 6249999) is a xuartps
[    0.038982] printk: legacy console [ttyPS0] enabled
[    0.651588] iommu: Default domain type: Translated
[    0.656382] iommu: DMA domain TLB invalidation policy: strict mode
[    0.663956] SCSI subsystem initialized
[    0.668269] usbcore: registered new interface driver usbfs
[    0.673836] usbcore: registered new interface driver hub
[    0.679193] usbcore: registered new device driver usb
[    0.685032] pps_core: LinuxPPS API ver. 1 registered
[    0.689991] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.699150] PTP clock support registered
[    0.703239] EDAC MC: Ver: 3.0.0
[    0.708994] vgaarb: loaded
[    0.713930] clocksource: Switched to clocksource arm_global_timer
[    0.740888] NET: Registered PF_INET protocol family
[    0.745980] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.754129] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.762540] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.770300] TCP established hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.777976] TCP bind hash table entries: 2048 (order: 3, 32768 bytes, linear)
[    0.785186] TCP: Hash tables configured (established 2048 bind 2048)
[    0.791618] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.798184] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.805331] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.820604] RPC: Registered named UNIX socket transport module.
[    0.826528] RPC: Registered udp transport module.
[    0.831252] RPC: Registered tcp transport module.
[    0.835953] RPC: Registered tcp-with-tls transport module.
[    0.841454] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.847896] PCI: CLS 0 bytes, default 64
[    0.853042] Initialise system trusted keyrings
[    0.857819] workingset: timestamp_bits=30 max_order=16 bucket_order=0
[    0.864675] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.870867] Trying to unpack rootfs image as initramfs...
[    0.901328] NFS: Registering the id_resolver key type
[    0.906487] Key type id_resolver registered
[    0.910723] Key type id_legacy registered
[    0.914915] Key type asymmetric registered
[    0.919015] Asymmetric key parser 'x509' registered
[    0.923998] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 247)
[    0.931411] io scheduler mq-deadline registered
[    0.935940] io scheduler kyber registered
[    0.962856] zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
[    1.012599] dma-pl330 f8003000.dma-controller: Loaded driver for PL330 DMAC-241330
[    1.020183] dma-pl330 f8003000.dma-controller:       DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
[    1.103138] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    1.113746] msm_serial: driver initialized
[    1.118210] SuperH (H)SCI(F) driver initialized
[    1.123009] STMicroelectronics ASC driver initialized
[    1.144937] brd: module loaded
[    1.154649] loop: module loaded
[    1.167350] CAN device driver interface
[    1.903344] Freeing initrd memory: 9412K
[    2.407680] macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 37 (02:ef:31:36:51:ea)
[    2.417847] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded
[    2.424482] e1000e: Intel(R) PRO/1000 Network Driver
[    2.429482] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    2.435443] igb: Intel(R) Gigabit Ethernet Network Driver
[    2.440858] igb: Copyright (c) 2007-2014 Intel Corporation.
[    2.449277] pegasus: Pegasus/Pegasus II USB Ethernet driver
[    2.454891] usbcore: registered new interface driver pegasus
[    2.460598] usbcore: registered new interface driver asix
[    2.466020] usbcore: registered new interface driver ax88179_178a
[    2.472155] usbcore: registered new interface driver cdc_ether
[    2.478035] usbcore: registered new interface driver smsc75xx
[    2.483806] usbcore: registered new interface driver smsc95xx
[    2.489591] usbcore: registered new interface driver net1080
[    2.495283] usbcore: registered new interface driver cdc_subset
[    2.501250] usbcore: registered new interface driver zaurus
[    2.506865] usbcore: registered new interface driver cdc_ncm
[    2.515926] usbcore: registered new interface driver usb-storage
[    2.524085] input: buttons as /devices/soc0/buttons/input/input0
[    2.533374] i2c_dev: i2c /dev entries driver
[    2.546310] cpufreq: cpufreq_online: CPU0: Running at unlisted initial frequency: 666666 KHz, changing to: 666667 KHz
[    2.557775] Xilinx Zynq CpuIdle Driver started
[    2.562811] sdhci: Secure Digital Host Controller Interface driver
[    2.569006] sdhci: Copyright(c) Pierre Ossman
[    2.576016] Synopsys Designware Multimedia Card Interface Driver
[    2.584277] sdhci-pltfm: SDHCI platform and OF driver helper
[    2.600385] ledtrig-cpu: registered to indicate activity on CPUs
[    2.607386] clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
[    2.616693] timer #0 at (ptrval), irq=39
[    2.621032] usbcore: registered new interface driver usbhid
[    2.626679] usbhid: USB HID core driver
[    2.636348] armv7-pmu f8891000.pmu: hw perfevents: no interrupt-affinity property, guessing.
[    2.645394] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
[    2.654915] NET: Registered PF_INET6 protocol family
[    2.661536] Segment Routing with IPv6
[    2.665327] In-situ OAM (IOAM) with IPv6
[    2.669337] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    2.672927] mmc0: SDHCI controller on e0100000.mmc [e0100000.mmc] using ADMA
[    2.676035] NET: Registered PF_PACKET protocol family
[    2.687399] can: controller area network core
[    2.691807] NET: Registered PF_CAN protocol family
[    2.696626] can: raw protocol
[    2.699598] can: broadcast manager protocol
[    2.703784] can: netlink gateway - max_hops=1
[    2.708553] Key type dns_resolver registered
[    2.713127] ThumbEE CPU extension supported.
[    2.717427] Registering SWP/SWPB emulation handler
[    2.725865] mmc0: new high speed SDHC card at address 1234
[    2.732170] mmcblk0: mmc0:1234 SA16G 14.4 GiB
[    2.734770] Loading compiled-in X.509 certificates
[    2.746671]  mmcblk0: p1 p2
[    2.760083] clk: Disabling unused clocks
[    2.764157] PM: genpd: Disabling unused power domains
[    2.772170] Freeing unused kernel image (initmem) memory: 2048K
[    2.778839] Run /init as init process
mount: mounting /dev/mmcblk0p1 on /media/mmcblk0p1 failed: No such file or directory
Saving 256 bits of non-creditable seed for next boot
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting network: [    3.004867] macb e000b000.ethernet eth0: validation of  with support 00,00000000,00000000,00006000 and advertisement 00,00000000,00000000,00000000 failed: -EINVAL
[    3.019551] macb e000b000.ethernet eth0: Could not attach PHY (-22)
ip: SIOCSIFFLAGS: Invalid argument
FAIL
Starting crond: OK
Starting dropbear sshd: OK

Welcome to Buildroot
ebaz4205 login: root
Password:
root@ebaz4205:~# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@ebaz4205:~# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 02:EF:31:36:51:EA
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:37 Base address:0xb000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@ebaz4205:~# [   49.284048] random: crng init done
```

起動しました！

この検証で、rootfsの構築や、デフォルトのU-bootの起動設定で起動しない点は課題ですが、U-bootの起動や、Kernelの起動はできることがわかりました。

U-Bootで、fpgaコマンドの実行で失敗している事や、LANポートはデバイスドライバーはロードされていて、デバイスとしては存在しているんですが、PHYが見つからないというエラーが出ているので、まだハードウエア周りがうまくいっていないようです。
この点は、次の課題として、検証していきたいと思います。

# まとめ

- この調査で、完全ではありませんが、動作するBuildrootの設定を得る事ができました。
- この設定を元にNervesのポーティングを試してみたいと思います。


関連記事
[EBAZ4205を使って、FPGAを使ったシステム開発の環境を構築する](https://qiita.com/GeekMasahiro/items/6bdb8886fb5c32c332cb)
[EBAZ4205でLinuxを動かして見る](https://qiita.com/GeekMasahiro/items/bb411ab40bb2e80e4c2a)
[petalinuxをBuildrootでビルドする](https://qiita.com/GeekMasahiro/items/7ce3d4fe108f2cfe49a3)