MPFS-DISCO-KIT 向け Ubuntu 22.04 の構築(SD-Card 起動編)


## はじめに

MPFS-DISCO-KIT(Microchip PolarFire SoC FPGA Discovery Kit) で動作する Ubuntu 22.04 を構築する方法をいくつかの記事に分けて説明します。

 * [イントロ編](https://qiita.com/ikwzm/items/1866dc3bb5292fd1f6e1)
 * [HSS(Hart Software Services)編](https://qiita.com/ikwzm/items/3d6d0a645dd60aba90d2)
 * [U-Boot 標準編](https://qiita.com/ikwzm/items/8b6e78e1c5599d9d375d)
 * [U-Boot bootmenu 改造編](https://qiita.com/ikwzm/items/72f75ec704dd227f9cbd)
 * [Linux Kernel linux4microchip+fpga-2024.09 編](https://qiita.com/ikwzm/items/0ca6aea057a3696bd5f0)
 * [Linux Kernel mpfs-fpga-first 編](https://qiita.com/ikwzm/items/d7405466ed7391d4dd73)
 * [Ubuntu 22.04 Root File System 編](https://qiita.com/ikwzm/items/a3d1d5a1a9640b400872)
 * [SD-Card 作成編](https://qiita.com/ikwzm/items/19af3dd7a34ea5364683)
 * __SD-Card 起動編 (この記事)__

上記の記事で構築した MPFS-DISCO-KIT 向け Ubuntu 22.04 Root File System、Linux Kernel、Boot Loader は次の URL にて公開しています。なお、これらはオフシャルなものではなく、筆者の魔改造がはいっています。ご使用の際はこの点にご留意してください。

 * https://github.com/ikwzm/MPFS-FPGA-Ubuntu22.04
 * https://github.com/ikwzm/MPFS-FPGA-Linux-Kernel-6.6
 * https://github.com/ikwzm/MPFS-DISCO-KIT-U-Boot


この記事では、[『SD-Card 作成編』](https://qiita.com/ikwzm/items/19af3dd7a34ea5364683) で作成した SD-Card を使って実機で Ubuntu22.04 を起動した例と、起動しなかった場合のトラブルシューティングを解説します。

## 必要な環境

 * MPFS-DISCO-KIT(Microchip PolarFire SoC FPGA Discovery Kit)
 * [『SD-Card 作成編』](https://qiita.com/ikwzm/items/19af3dd7a34ea5364683) で作成した SD-Card
 * USB-C ケーブル
 * ターミナル用 PC    
   筆者は ターミナル用 PC として Windows10 の PC、ターミナルソフトとして TeraTerm を使っています。

## 起動成功例

MPFS-DISCO-KIT に SD-Card を入れて、USB-C ケーブルで PC と繋ぎます。
電源を USB からとっている場合、即座に MPFS-DISCO-KIT が起動します。

接続した PC のターミナルソフトからは４つの シリアルポートが新たに見えます。筆者の場合は、TeraTerm に COM12、COM13、COM14、COM15 が見えました。

![Fig.1 新しい接続](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F3ce14aa9-a23d-4bea-de5f-9d7bebb6a151.png)

そのうち、COM14(３番目のシリアルポート)が U-Boot/Linux 、COM13(２番目のシリアルポート)が HSS のターミナルになると思います。

COM14 と接続すると、ほどなく次のようなメニューが表示されます。
なお、このメニューが表示される時間は、[SD-Card 作成編](https://qiita.com/ikwzm/items/19af3dd7a34ea5364683) で説明した uEnv.txt の bootdelay 変数で指定されます。MPFS-DISCO-KIT の電源を USB からとっている場合、USB ケーブルを PC に接続してからすぐにターミナルソフトを起動しないと、このメニュー画面を通り越してデフォルトでブートします。

![Fig.2 COM14 U-Boot Boot Menu](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2Fcf28faca-da41-e853-53fe-c91320ec2945.png)

タイムアウトまで待つか、リターンキーを押してデフォルトでブートすると、Ubunt22.04 が起動します。

![Fig.3 COM14 Ubuntu Login](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F920d8745-48a9-31a0-37c0-58dc77e205cb.png)

電源投入後から Ubunt22.04 が起動するまでのターミナルのログを以下に示します。

<details><summary>Ubuntu22.04 Boot Log(長いので折りたたみ)</summary>

```console
DDR training ... Passed ( 3078 ms)
[3.167214] DDR-Lo size is   32 MiB
[3.171892] DDR-Hi size is  888 MiB

OpenSBI v1.2
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : Microchip PolarFire(R) SoC
Platform Features         : medeleg
Platform HART Count       : 5
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 1000000Hz
Platform Console Device   : mmuart
Platform HSM Device       : mpfs_hsm
Platform PMU Device       : ---
Platform Reboot Device    : mpfs_reset
Platform Shutdown Device  : mpfs_reset
Firmware Base             : 0xa000000
Firmware Size             : 124 KB
Runtime SBI Version       : 1.0

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 1,2,3,4
Domain0 Region00          : 0x0000000002008000-0x000000000200bfff (I)
Domain0 Region01          : 0x0000000002000000-0x0000000002007fff (I)
Domain0 Region02          : 0x000000000a000000-0x000000000a01ffff ()
Domain0 Region03          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000000000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Domain1 Name              : u-boot.bin
Domain1 Boot HART         : 1
Domain1 HARTs             : 1*,2*,3*,4*
Domain1 Region00          : 0x000000000a000000-0x000000000a01ffff ()
Domain1 Region01          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain1 Next Address      : 0x0000000080200000
Domain1 Next Arg1         : 0x0000000000000000
Domain1 Next Mode         : S-mode
Domain1 SysReset          : yes

Boot HART ID              : 1
Boot HART Domain          : u-boot.bin
Boot HART Priv Version    : v1.10
Boot HART Base ISA        : rv64imafdc
Boot HART ISA Extensions  : none
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 36
Boot HART MHPM Count      : 2
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2023.07.02-linux4microchip+fpga-2024.09 (Dec 03 2024 - 14:31:59 +0900)

CPU:   rv64imafdc
Model: Microchip PolarFire-SoC Discovery Kit
DRAM:  1 GiB (effective 1.8 GiB)
Core:  48 devices, 10 uclasses, devicetree: separate
MMC:   mmc@20008000: 0
Loading Environment from FAT... OK
In:    serial@20106000
Out:   serial@20106000
Err:   serial@20106000
Net:   eth0: ethernet@20110000
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
3315 bytes read in 31 ms (103.5 KiB/s)
No EFI system partition
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables


  *** U-Boot Boot Menu ***

      Boot Default
      Boot linux-6.6.51-mpfs-fpga-first
      mmc 0:1
      mmc 0:3
      U-Boot console


  Press UP/DOWN to move, ENTER to select, ESC to quit













Running uenvcmd...
19728384 bytes read in 859 ms (21.9 MiB/s)
18075 bytes read in 35 ms (503.9 KiB/s)
Working FDT set to 8a000000
## Flattened Device Tree blob at 8a000000
   Booting using the fdt blob at 0x8a000000
Working FDT set to 8a000000
   Loading Device Tree to 000000008fff8000, end 000000008ffff69a ... OK
Working FDT set to 8fff8000

Starting kernel ...

[    0.000000] Linux version 6.6.51-mpfs-fpga-first (ichiro@Jabberwock) (riscv64-unknown-linux-gnu-gcc (g04696df0963) 14.2.0, GNU ld (GNU Binutils) 2.43.1) #1 SMP Thu Dec 12 21:42:15 JST 2024
[    0.000000] Machine model: Microchip PolarFire-SoC Discovery Kit
[    0.000000] SBI specification v1.0 detected
[    0.000000] SBI implementation ID=0x8 Version=0x10002
[    0.000000] SBI TIME extension detected
[    0.000000] SBI IPI extension detected
[    0.000000] SBI RFENCE extension detected
[    0.000000] SBI SRST extension detected
[    0.000000] efi: UEFI not found.
[    0.000000] Reserved memory: created DMA memory pool at 0x00000000c4000000, size 64 MiB
[    0.000000] OF: reserved mem: initialized node non-cached-low-buffer, compatible id shared-dma-pool
[    0.000000] OF: reserved mem: 0x00000000c4000000..0x00000000c7ffffff (65536 KiB) nomap non-reusable non-cached-low-buffer
[    0.000000] Reserved memory: created DMA memory pool at 0x0000001412000000, size 256 MiB
[    0.000000] OF: reserved mem: initialized node non-cached-high-buffer, compatible id shared-dma-pool
[    0.000000] OF: reserved mem: 0x0000001412000000..0x0000001421ffffff (262144 KiB) nomap non-reusable non-cached-high-buffer
[    0.000000] OF: reserved mem: 0x0000000084000000..0x0000000087ffffff (65536 KiB) nomap non-reusable region@84000000
[    0.000000] Reserved memory: created DMA memory pool at 0x0000000088000000, size 32 MiB
[    0.000000] OF: reserved mem: initialized node buffer@88000000, compatible id shared-dma-pool
[    0.000000] OF: reserved mem: 0x0000000088000000..0x0000000089ffffff (32768 KiB) nomap non-reusable buffer@88000000
[    0.000000] Reserved memory: created DMA memory pool at 0x00000000c8000000, size 32 MiB
[    0.000000] OF: reserved mem: initialized node buffer@c8000000, compatible id shared-dma-pool
[    0.000000] OF: reserved mem: 0x00000000c8000000..0x00000000c9ffffff (32768 KiB) nomap non-reusable buffer@c8000000
[    0.000000] Reserved memory: created DMA memory pool at 0x00000000d8000000, size 32 MiB
[    0.000000] OF: reserved mem: initialized node buffer@d8000000, compatible id shared-dma-pool
[    0.000000] OF: reserved mem: 0x00000000d8000000..0x00000000d9ffffff (32768 KiB) nomap non-reusable buffer@d8000000
[    0.000000] Reserved memory: created DMA memory pool at 0x000000103fc00000, size 2 MiB
[    0.000000] OF: reserved mem: initialized node hss-buffer@103fc00000, compatible id shared-dma-pool
[    0.000000] OF: reserved mem: 0x000000103fc00000..0x000000103fdfffff (2048 KiB) nomap non-reusable hss-buffer@103fc00000
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080000000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x0000001421ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x0000000083ffffff]
[    0.000000]   node   0: [mem 0x000000008a000000-0x0000000091ffffff]
[    0.000000]   node   0: [mem 0x00000000c4000000-0x00000000c9ffffff]
[    0.000000]   node   0: [mem 0x0000001022000000-0x000000103fbfffff]
[    0.000000]   node   0: [mem 0x000000103fc00000-0x000000103fdfffff]
[    0.000000]   node   0: [mem 0x000000103fe00000-0x000000103fffffff]
[    0.000000]   node   0: [mem 0x0000001412000000-0x0000001421ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x0000001421ffffff]
[    0.000000] On node 0, zone DMA32: 24576 pages in unavailable ranges
[    0.000000] On node 0, zone DMA32: 40960 pages in unavailable ranges
[    0.000000] On node 0, zone Normal: 32768 pages in unavailable ranges
[    0.000000] On node 0, zone Normal: 8192 pages in unavailable ranges
[    0.000000] On node 0, zone Normal: 24576 pages in unavailable ranges
[    0.000000] SBI HSM extension detected
[    0.000000] CPU with hartid=0 is not available
[    0.000000] riscv: base ISA extensions acdfim
[    0.000000] riscv: ELF capabilities acdfim
[    0.000000] percpu: Embedded 18 pages/cpu s35880 r8192 d29656 u73728
[    0.000000] Kernel command line: root=/dev/mmcblk0p3 rw rootwait uio_pdrv_genirq.of_id=generic-uio
[    0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 258560
[    0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[    0.000000] software IO TLB: area num 4.
[    0.000000] software IO TLB: mapped [mem 0x000000008bff8000-0x000000008fff8000] (64MB)
[    0.000000] Memory: 559388K/1048576K available (6370K kernel code, 4821K rwdata, 4096K rodata, 2156K init, 376K bss, 489188K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=4.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] riscv-intc: 64 local interrupts mapped
[    0.000000] plic: interrupt-controller@c000000: mapped 186 interrupts with 4 handlers for 9 contexts.
[    0.000000] riscv: providing IPIs using SBI IPI extension
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
[    0.000003] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns
[    0.000386] Console: colour dummy device 80x25
[    0.000411] printk: console [tty0] enabled
[    0.002112] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=4000)
[    0.002182] pid_max: default: 32768 minimum: 301
[    0.002523] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.002658] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.004968] CPU node for /cpus/cpu@0 exist but the possible cpu range is :0-3
[    0.008065] RCU Tasks Trace: Setting shift to 2 and lim to 1 rcu_task_cb_adjust=1.
[    0.008485] riscv: ELF compat mode unsupported
[    0.008505] ASID allocator disabled (0 bits)
[    0.008922] rcu: Hierarchical SRCU implementation.
[    0.008962] rcu:     Max phase no-delay instances is 1000.
[    0.009683] EFI services will not be available.
[    0.010757] smp: Bringing up secondary CPUs ...
[    0.036238] cpu1: Ratio of byte access time to unaligned word access is 0.01, unaligned accesses are slow
[    0.064322] cpu2: Ratio of byte access time to unaligned word access is 0.01, unaligned accesses are slow
[    0.092406] cpu3: Ratio of byte access time to unaligned word access is 0.01, unaligned accesses are slow
[    0.092701] smp: Brought up 1 node, 4 CPUs
[    0.095549] devtmpfs: initialized
[    0.103105] DMA: default coherent area is set
[    0.103168] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.103240] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.105982] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.106751] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.106892] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.132594] cpu0: Ratio of byte access time to unaligned word access is 0.01, unaligned accesses are slow
[    0.133490] CCACHE: 4 banks, 16 ways, sets/bank=512, bytes/block=64
[    0.133541] CCACHE: Index of the largest way enabled: 11
[    0.152073] SCSI subsystem initialized
[    0.153134] usbcore: registered new interface driver usbfs
[    0.153244] usbcore: registered new interface driver hub
[    0.153344] usbcore: registered new device driver usb
[    0.153643] pps_core: LinuxPPS API ver. 1 registered
[    0.153681] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.153766] PTP clock support registered
[    0.154151] FPGA manager framework
[    0.155925] vgaarb: loaded
[    0.156255] clocksource: Switched to clocksource riscv_clocksource
[    0.176284] NET: Registered PF_INET protocol family
[    0.177280] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.181810] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear)
[    0.181942] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.182003] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.182534] TCP bind hash table entries: 8192 (order: 6, 262144 bytes, linear)
[    0.184138] TCP: Hash tables configured (established 8192 bind 8192)
[    0.184998] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.185186] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.185650] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.185785] PCI: CLS 0 bytes, default 64
[    0.188803] workingset: timestamp_bits=62 max_order=18 bucket_order=0
[    0.189946] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    0.190008] io scheduler mq-deadline registered
[    0.190041] io scheduler kyber registered
[    0.190112] io scheduler bfq registered
[    0.191578] mpfs_irq_mux 20002000.syscon:interrupt-controller@54: mux configuration 0
[    0.197017] irq: IRQ51: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.197166] irq: IRQ52: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.197295] irq: IRQ53: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.197441] irq: IRQ54: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.197582] irq: IRQ55: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.197710] irq: IRQ56: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.197835] irq: IRQ57: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.197973] irq: IRQ58: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.198101] irq: IRQ59: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.198255] irq: IRQ60: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.198387] irq: IRQ61: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.198524] irq: IRQ62: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.198650] irq: IRQ63: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.198775] irq: IRQ64: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.198924] irq: IRQ65: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199053] irq: IRQ66: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199179] irq: IRQ67: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199304] irq: IRQ68: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199463] irq: IRQ69: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199594] irq: IRQ70: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199720] irq: IRQ71: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199859] irq: IRQ72: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.199995] irq: IRQ73: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.200124] irq: IRQ74: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.200309] irq: IRQ75: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.200455] irq: IRQ76: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.200586] irq: IRQ77: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.200713] irq: IRQ78: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.200851] irq: IRQ79: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.200978] irq: IRQ80: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.201116] irq: IRQ81: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.201243] irq: IRQ82: trimming hierarchy from :soc:interrupt-controller@c000000
[    0.326690] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.331890] 20100000.serial: ttyS0 at MMIO 0x20100000 (irq = 83, base_baud = 9375000) is a 16550A
[    0.334189] 20106000.serial: ttyS1 at MMIO 0x20106000 (irq = 84, base_baud = 9375000) is a 16550A
[    0.334296] printk: console [ttyS1] enabled
[    1.471849] loop: module loaded
[    1.479146] microchip-corespi 20108000.spi: Registered SPI controller 0
[    1.487056] microchip-corespi 20109000.spi: Registered SPI controller 1
[    1.496201] CAN device driver interface
[    1.505666] macb 20110000.ethernet eth0: Cadence GEM rev 0x0107010c at 0x20110000 irq 87 (00:04:a3:c6:61:5b)
[    1.517934] mpfs_rtc 20124000.rtc: prescaler set to: 999999
[    1.524572] mpfs_rtc 20124000.rtc: registered as rtc0
[    1.529756] mpfs_rtc 20124000.rtc: setting system clock to 1970-01-01T00:00:00 UTC (0)
[    1.537889] i2c_dev: i2c /dev entries driver
[    1.542568] sdhci: Secure Digital Host Controller Interface driver
[    1.548818] sdhci: Copyright(c) Pierre Ossman
[    1.553281] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.561436] usbcore: registered new interface driver usbhid
[    1.567180] usbhid: USB HID core driver
[    1.572063] mpfs-mailbox 37020800.mailbox: Registered MPFS mailbox controller driver
[    1.580940] NET: Registered PF_INET6 protocol family
[    1.588938] Segment Routing with IPv6
[    1.592868] In-situ OAM (IOAM) with IPv6
[    1.597094] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    1.604355] NET: Registered PF_PACKET protocol family
[    1.609491] can: controller area network core
[    1.614101] NET: Registered PF_CAN protocol family
[    1.618127] mmc0: SDHCI controller on 20008000.mmc [20008000.mmc] using ADMA 64-bit
[    1.618940] can: raw protocol
[    1.629695] can: broadcast manager protocol
[    1.633968] can: netlink gateway - max_hops=1
[    1.677075] random: crng init done
[    1.680618] mpfs-rng mpfs-rng: Registered MPFS hwrng
[    1.697532] mpfs-sys-controller syscontroller: Registered MPFS system controller
[    1.705906] clk: Disabling unused clocks
[    1.711217] Waiting for root device /dev/mmcblk0p3...
[    1.723729] mmc0: new high speed SDHC card at address 59b4
[    1.731589] mmcblk0: mmc0:59b4 SD    29.4 GiB
[    1.747320]  mmcblk0: p1 p2 p3
[    1.786531] EXT4-fs (mmcblk0p3): mounted filesystem 510195aa-f438-468c-8678-d61ed238d92c r/w with ordered data mode. Quota mode: disabled.
[    1.799191] VFS: Mounted root (ext4 filesystem) on device 179:3.
[    1.806819] devtmpfs: mounted
[    1.820783] Freeing unused kernel image (initmem) memory: 2156K
[    1.826949] Run /sbin/init as init process
[    2.385777] systemd[1]: System time before build time, advancing clock.
[    2.430173] systemd[1]: Failed to find module 'autofs4'
[    2.488807] systemd[1]: systemd 249.11-0ubuntu3.12 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
[    2.520954] systemd[1]: Detected architecture riscv64.

Welcome to Ubuntu 22.04.5 LTS!

[    2.549704] systemd[1]: Hostname set to <ubuntu-fpga>.
[    3.138641] block mmcblk0: the capability attribute has been deprecated.
[    3.528070] systemd[1]: Configuration file /run/systemd/system/netplan-ovs-cleanup.service is marked world-inaccessible. This has no effect as configuration data is accessible via APIs without restrictions. Proceeding anyway.
[    3.978107] systemd[1]: Queued start job for default target Graphical Interface.
[    3.991281] systemd[1]: Created slice Slice /system/modprobe.
[  OK  ] Created slice Slice /system/modprobe.
[    4.014301] systemd[1]: Created slice Slice /system/serial-getty.
[  OK  ] Created slice Slice /system/serial-getty.
[    4.037376] systemd[1]: Created slice User and Session Slice.
[  OK  ] Created slice User and Session Slice.
[    4.060764] systemd[1]: Started ntp-systemd-netif.path.
[  OK  ] Started ntp-systemd-netif.path.
[    4.080895] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Dispatch Password …ts to Console Directory Watch.
[    4.108809] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Started Forward Password R…uests to Wall Directory Watch.
[    4.132989] systemd[1]: Condition check resulted in Arbitrary Executable File Formats File System Automount Point being skipped.
[    4.145036] systemd[1]: Reached target Local Encrypted Volumes.
[  OK  ] Reached target Local Encrypted Volumes.
[    4.169048] systemd[1]: Reached target Remote File Systems.
[  OK  ] Reached target Remote File Systems.
[    4.192511] systemd[1]: Reached target Slice Units.
[  OK  ] Reached target Slice Units.
[    4.212651] systemd[1]: Reached target Swaps.
[  OK  ] Reached target Swaps.
[    4.232613] systemd[1]: Reached target Local Verity Protected Volumes.
[  OK  ] Reached target Local Verity Protected Volumes.
[    4.257549] systemd[1]: Listening on Syslog Socket.
[  OK  ] Listening on Syslog Socket.
[    4.277002] systemd[1]: Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on initctl Compatibility Named Pipe.
[    4.318023] systemd[1]: Condition check resulted in Journal Audit Socket being skipped.
[    4.327479] systemd[1]: Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket (/dev/log).
[    4.353549] systemd[1]: Listening on Journal Socket.
[  OK  ] Listening on Journal Socket.
[    4.374669] systemd[1]: Listening on udev Control Socket.
[  OK  ] Listening on udev Control Socket.
[    4.397299] systemd[1]: Listening on udev Kernel Socket.
[  OK  ] Listening on udev Kernel Socket.
[    4.421395] systemd[1]: Condition check resulted in Huge Pages File System being skipped.
[    4.448976] systemd[1]: Mounting POSIX Message Queue File System...
         Mounting POSIX Message Queue File System...
[    4.478679] systemd[1]: Mounting Kernel Debug File System...
         Mounting Kernel Debug File System...
[    4.501680] systemd[1]: Condition check resulted in Kernel Trace File System being skipped.
[    4.537639] systemd[1]: Starting Journal Service...
         Starting Journal Service...
[    4.566048] systemd[1]: Starting Set the console keyboard layout...
         Starting Set the console keyboard layout...
[    4.589043] systemd[1]: Condition check resulted in Create List of Static Device Nodes being skipped.
[    4.629834] systemd[1]: Starting Load Kernel Module configfs...
         Starting Load Kernel Module configfs...
[    4.660847] systemd[1]: Starting Load Kernel Module drm...
         Starting Load Kernel Module drm...
[    4.689581] systemd[1]: Starting Load Kernel Module efi_pstore...
         Starting Load Kernel Module efi_pstore...
[    4.724197] systemd[1]: Starting Load Kernel Module fuse...
         Starting Load Kernel Module fuse...
[    4.752418] systemd[1]: Started Nameserver information manager.
[  OK  ] Started Nameserver information manager.
[    4.795505] systemd[1]: Reached target Preparation for Network.
[  OK  ] Reached target Preparation for Network.
[    4.853584] systemd[1]: Starting Load Kernel Modules...
         Starting Load Kernel Modules...
[    4.884557] systemd[1]: Starting Remount Root and Kernel File Systems...
         Starting Remount Root and Kernel File Systems...
[    4.916873] systemd[1]: Starting Coldplug All udev Devices...
         Starting Coldplug All udev Devices...
[    4.951332] systemd[1]: Started Journal Service.
[  OK  ] Started Journal Service.
[  OK  ] Mounted POSIX Message Queue File System.
[  OK  ] Mounted Kernel Debug File System.
[  OK  ] Finished Load Kernel Module configfs.
[  OK  ] Finished Load Kernel Module drm.
[  OK  ] Finished Load Kernel Module efi_pstore.
[  OK  ] Finished Load Kernel Module fuse.
[  OK  ] Finished Load Kernel Modules.
[  OK  ] Finished Remount Root and Kernel File Systems.
         Mounting Kernel Configuration File System...
         Starting Flush Journal to Persistent Storage...
         Starting Load/Save Random Seed...
[    5.241995] systemd-journald[98]: Received client request to flush runtime journal.
         Starting Apply Kernel Variables...
[    5.269681] systemd-journald[98]: File /var/log/journal/54a6581c98b448df8c682e715abb751b/system.journal corrupted or uncleanly shut down, renaming and replacing.
         Starting Create System Users...
[  OK  ] Finished Set the console keyboard layout.
[  OK  ] Mounted Kernel Configuration File System.
[  OK  ] Finished Load/Save Random Seed.
[  OK  ] Finished Apply Kernel Variables.
[  OK  ] Finished Create System Users.
         Starting Create Static Device Nodes in /dev...
[  OK  ] Finished Coldplug All udev Devices.
[  OK  ] Finished Create Static Device Nodes in /dev.
[  OK  ] Reached target Preparation for Local File Systems.
         Mounting /config...
         Starting Rule-based Manage…for Device Events and Files...
[  OK  ] Finished Flush Journal to Persistent Storage.
[  OK  ] Mounted /config.
[  OK  ] Reached target Local File Systems.
         Starting Set console font and keymap...
         Starting Create Volatile Files and Directories...
[  OK  ] Finished Set console font and keymap.
         Starting Load Kernel Module efi_pstore...
         Starting Load Kernel Module fuse...
[  OK  ] Started Rule-based Manager for Device Events and Files.
[  OK  ] Finished Create Volatile Files and Directories.
[  OK  ] Finished Load Kernel Module efi_pstore.
[  OK  ] Finished Load Kernel Module fuse.
[  OK  ] Started Entropy Daemon based on the HAVEGE algorithm.
         Starting Network Name Resolution...
         Starting Record System Boot/Shutdown in UTMP...
[  OK  ] Found device /dev/ttyS1.
[  OK  ] Finished Record System Boot/Shutdown in UTMP.
[  OK  ] Reached target System Initialization.
[  OK  ] Started resolvconf-pull-resolved.path.
[  OK  ] Started Daily apt download activities.
[  OK  ] Started Daily apt upgrade and clean activities.
[  OK  ] Started Daily dpkg database backup timer.
[  OK  ] Started Periodic ext4 Onli…ata Check for All Filesystems.
[  OK  ] Started Discard unused blocks once a week.
[  OK  ] Started Daily rotation of log files.
[  OK  ] Started Message of the Day.
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Reached target Path Units.
[  OK  ] Reached target Timer Units.
[  OK  ] Listening on Avahi mDNS/DNS-SD Stack Activation Socket.
[  OK  ] Reached target Socket Units.
[  OK  ] Reached target Basic System.
[  OK  ] Listening on D-Bus System Message Bus Socket.
         Starting Avahi mDNS/DNS-SD Stack...
[  OK  ] Started Regular background program processing daemon.
[  OK  ] Started D-Bus System Message Bus.
         Starting Network Manager...
[  OK  ] Started Save initial kernel messages after boot.
         Starting Remove Stale Onli…t4 Metadata Check Snapshots...
         Starting Dispatcher daemon for systemd-networkd...
[  OK  ] Started ntp-systemd-netif.service.
         Starting System Logging Service...
         Starting User Login Management...
[  OK  ] Started Avahi mDNS/DNS-SD Stack.
[  OK  ] Started System Logging Service.
[  OK  ] Started Network Name Resolution.
[  OK  ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.
[  OK  ] Started User Login Management.
[  OK  ] Started Network Manager.
[  OK  ] Reached target Network.
[  OK  ] Reached target Host and Network Name Lookups.
         Starting Network Manager Wait Online...
         Starting Network Time Service...
         Starting resolvconf-pull-resolved.service...
         Starting OpenBSD Secure Shell server...
         Starting Hostname Service...
         Starting Permit User Sessions...
[  OK  ] Started Dispatcher daemon for systemd-networkd.
[  OK  ] Finished Permit User Sessions.
[  OK  ] Started Serial Getty on ttyS1.
         Starting Set console scheme...
[  OK  ] Finished Set console scheme.
[  OK  ] Finished resolvconf-pull-resolved.service.
[  OK  ] Created slice Slice /system/getty.
[  OK  ] Started Getty on tty1.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started Network Time Service.
[  OK  ] Started OpenBSD Secure Shell server.
[  OK  ] Started Hostname Service.
         Starting Network Manager Script Dispatcher Service...
[  OK  ] Started Network Manager Script Dispatcher Service.

Ubuntu 22.04.5 LTS ubuntu-fpga ttyS1

ubuntu-fpga login:
```

</details>

## 起動失敗例その１

MPFS-DISCO-KIT に SD-Card を入れて、USB-C ケーブルで PC と繋いだ後、COM14(３番目のシリアルポート、U-Boot/Linux用) になにも表示されず、キー入力しても反応が無い場合があります。あるいは次のような画面が表示された後、同様にキー入力しても反応が無い場合があります。

![Fig.4 COM14 Freeze 1](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F6de88f1b-9412-cde6-20aa-3de1c702ed0f.png)

この場合、HSS(Hart Software Services) から SD-Card が認識されなかった可能性があります。
そこで COM13(２番目のシリアルポート、HSS用) をひらいてみます。

![Fig.5 COM13 HSS Log 1](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2Fe75b0274-88ed-1753-13d6-0ca4e4b36a11.png)

上のような画面があれば、それが HSS と接続しています。
ここでリターンキーを押すと ```>>``` というプロンプトが出て HSS とインタラクティブに対話できます。
試しに、```HELP``` と入力すると次のような画面になります。

![Fig.6 COM13 HSS Help](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F4093be21-1fe6-9b5e-bc79-42520341eab5.png)

ここで ```RESET``` と入力すると、MPFS-DISCO-KIT がハードウェア的に再起動します。

![Fig.7 COM13 HSS Log 1](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F0338c244-36d7-360a-96b4-d84a7fd1e66d.png)
![Fig.8 COM13 HSS Log 2](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2Fadae34dc-2936-ab1b-dc15-7878aa3ff9ad.png)
![Fig.9 COM13 HSS Log 3](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F9c055637-e6a0-06a1-1228-2b6549f9d5f7.png)

最後のところで、'Attempting to select SDCARD ... Failed' と出ています。
これは SDCARD が HSS から認識されなかったことを示します。

この場合は、SD-Card を再び挿しなおして、HSS から RESET してみてください。
ブートに成功することがあります。
もしブートしなかったら、 MPFS-DISCO-KIT か SD-Card に問題があるのかもしれません。


## 起動失敗例その２

MPFS-DISCO-KIT に SD-Card を入れて、USB-C ケーブルで PC と繋いだ後、COM14(３番目のシリアルポート、U-Boot/Linux用) が次のようになっている場合があります。

![Fig.10 COM13 U-Boot Prompt](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F98c65503-84b4-4b95-4fad-416ba44dff8b.png)

これは U-Boot のコマンド入力画面です。ここで ```reset``` と入力すると MPFS-DISCO-KIT がハードウェア的に再起動します。

![Fig.11 COM13 U-Boot Log 1](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F3d571f9e-5cef-2b72-be44-4c1d64bc577f.png)
![Fig.12 COM13 U-Boot Log 2](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2Fe700beb1-0069-4816-bef7-8dcb4bfb7855.png)
![Fig.13 COM13 U-Boot Log 3](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2Fdd3d3252-c39d-95c8-2feb-c9dee97003cd.png)

途中で、'Loading Environment from FAT... ** No partition table - mmc 0 **' と出ています。
これは uboot.img が uboot.env のロードに失敗したことを示しています。
さらに `No partition table - mmc 0 ` と出ているので、どういうわけかパーティションテーブルが読めなかったようです。

この場合、SD-Card を別のものに交換すると成功することがあります。

### 参考

また、[「FPGA の部屋」](https://marsee101.blog.fc2.com/) でも同様に SD-Card によっては上手くいなかったみたいです。

 * [『ikwzm/MPFS-FPGA-Ubuntu22.04 をやってみよう2』@FPGAの部屋](https://marsee101.blog.fc2.com/blog-entry-6483.html)
 * [『ikwzm/MPFS-FPGA-Ubuntu22.04 をやってみよう3』@FPGAの部屋](https://marsee101.blog.fc2.com/blog-entry-6486.html)
 * [『ikwzm/MPFS-FPGA-Ubuntu22.04 をやってみよう3』@FPGAの部屋](https://marsee101.blog.fc2.com/blog-entry-6490.html)

| メーカー   | 商品名                             | サイズ | 価格    |  結果    |
|:----------|:----------------------------------|-------:|-------:|:--------:|
| SanDisk   | Extreme microSDHC UHS-I           |  32GB  | 1394円 |  Fail    |
| SanDisk   | Ultra microSDHC UHS-I             |  32GB  | 1191円 |  Fail    |
| Verbatim  | ?                                 |  32GB  |      ? |  Success |
| Transcend | ?                                 |  32GB  |      ? |  Success |


### 筆者の実験結果

筆者の方でも、いくつか microSD を購入して試してみました。と言っても本格的に調べたわけではなく、近所の家電とかで目についたのを適当に購入しただけです。購入したのは以下の通り。

| メーカー   | 商品名                             | サイズ | 価格    |  結果    |
|:----------|:----------------------------------|-------:|-------:|:--------:|
| SanDisk   | Ultra microSDHC UHS-I             |  32GB  | 2640円 |  Success |
| KIOXIA    | EXCERIA BASIC microSDHC UHS-I     |  32GB  | 1000円 |  Fail    |
| ADATA     | microSDXC Card with Adapter UHS-I |  64GB  |  940円 |  Success |
| SmartBuy? | ?                                 |  32GB  |  670円 |  Fail    |


#### SanDisk Ultra microSDHC UHS-I 32GB

「FPGA の部屋」ではダメだった SanDisk Ultra ですが、筆者のところではうまくいきました。

![Fig.14 COM13 SanDisk Ultra microSDHC UHS-I 32GB](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2Facdf3e91-fceb-d79a-79ea-1f763f6db887.png)

#### KIOXIA EXCERIA BASIC microSDHC UHS-I 32GB

「FPGA の部屋」ではダメだった KIOXIA ですが、筆者のところでもダメでした。
途中で、'Loading Environment from FAT... ** No partition table - mmc 0 **' と出ています。

![Fig.15 COM13 KIOXIA EXCERIA BASIC microSDHC UHS-I 32GB](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F80ff4c79-9662-3c4c-7bfc-bd6e683ce2a7.png)

#### ADATA microSDXC Card with Adapter UHS-I 64GB

microSDXC でも動くか心配でしたが、意外とすんなり動きました。
ちなみに、起動成功例で使った microSD も ADATA の 32GB です。これは昔、某パソコンショップで単価500円程度だった時に大量に購入しておいたものです。

![Fig.16 ADATA microSDXC Card with Adapter UHS-I 64GB](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F9a9d1f6a-6d01-fffa-c7b1-ebb73063539b.png)

#### SmartBuy? 32GB

最後に某百均ショップで買って来た microSD 32GB。ブランドはなんか表面に SmartBuy って書いてありました。
起動してみたら、、、お〜 Linux Kernel が起動した〜。こいつ動くぞ。と思ったら途中で Buffer I/O error で Kernel Panic。残念でした。

![Fig.17 SmartBuy? 32GB](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0%2F24981%2F0c0474f2-ce91-608c-d524-8866f2056edc.png)

### 所感

この原因は現在不明です。筆者のハードウェア固有の問題なのか、SD-Card 固有の問題なのか、MPFS-DISCO-KIT の問題なのか、U-Boot の mmc ドライバの問題なのか、情報を募集中です。