Porting OpenWRT to Milk-V Duo (CVITEK CV1800b), Problem met

Hello, I'm new to OpenWRT and is working on a RISC-V board Milk-V Duo with CVITEK CV1800B, the board can be found on https://milkv.io/duo .
kernel and boot.sd comes from https://github.com/milkv-duo/duo-buildroot-sdk/tree/develop/linux_5.10

working fork repository: https://github.com/luyanaa/openwrt/tree/cv1800b

Problem: can boot to the kernel, but directly goes into failsafe mode without any response, and dmesg reports no error except into failsafe mode.

log: https://paste.xinu.at/xufIxn/

You are not in failsafe, for this you need to press "f". That's the usual boot message telling you how to enter failsafe. And the messages already come from userspace, it's stuck somewhere in the init process.

I have tried to dig further.

The /etc/preinit script has exited with success (confirmed by logging at the end of it), and the non-preinit version of procd doesn't seem to be executed at all (confirmed by replacing it with a script to logging and exec the real binary)

It seems that when entering failsafe mode, the shell was launched within preinit phase (the last step of /etc/preinit, boot_run_hook preinit_main), so it never leaves the preinit phase. But during a regular boot, initd is supposed to launch procd afterwards (according to https://github.com/openwrt/procd/blob/master/initd/preinit.c, spawn_procd is supposed to be the callback of preinit_proc which should be a fork of initd itself?).

I'll try to contact OP for a kernel configured with init_debug=4 so that I could gain knowledge of what's happening inside of initd.

1 Like

I cant get it to compile ?

make[3] -C toolchain/kernel-headers compile
ERROR: toolchain/kernel-headers failed to build.
make -r world: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on
make: *** [/home/user/riscv/a/openwrt/include/toplevel.mk:232: world] Error 1

Error message is providing guidance, on how to proceed.

sure go ahead

Hi,

Patches against mainline kernels have evolved enough by now to give this SoC a try on 6.6 with backporting some of them. Basic booting is achieved, along with compiling a working bootloader for it and building the whole stuff from OpenWrt. Next step is to see if ethernet and USB can be backported, stay tuned.

milkv_duo# bootm ${uImage_addr}#config-1
## Loading kernel from FIT Image at 81400000 ...
   Using 'config-1' configuration
   Trying 'kernel-1' kernel subimage
     Description:  RISCV OpenWrt Linux-6.6.35
     Type:         Kernel Image
     Compression:  lzma compressed
     Data Start:   0x814000e8
     Data Size:    3847997 Bytes = 3.7 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x80200000
     Entry Point:  0x80200000
     Hash algo:    crc32
     Hash value:   7f2849c5
     Hash algo:    sha1
     Hash value:   c97e6c1dd334e79f11719dd2d8c1e615b9acbc74
   Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading fdt from FIT Image at 81400000 ...
   Using 'config-1' configuration
   Trying 'fdt-1' fdt subimage
     Description:  RISCV OpenWrt milkv_duo device tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x817ab964
     Data Size:    6397 Bytes = 6.2 KiB
     Architecture: RISC-V
     Hash algo:    crc32
     Hash value:   7a89c088
     Hash algo:    sha1
     Hash value:   84fa414f462a7390623213eeabaf42949d2edb8c
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Booting using the fdt blob at 0x817ab964
Working FDT set to 817ab964
   Uncompressing Kernel Image to 80200000
   Loading Device Tree to 0000000082676000, end 000000008267a8fc ... OK
Working FDT set to 82676000

Starting kernel ...

[    0.000000] Linux version 6.6.35 (wigyori@build01) (riscv64-openwrt-linux-musl-gcc (OpenWrt GCC 13.3.0 r26775+6-8e1316f3f6) 13.3.0, GNU ld (GNU Binutils) 2.42) #0 SMP Fri Jun 28 15:13:52 2024
[    0.000000] Machine model: Milk-V Duo
[    0.000000] SBI specification v2.0 detected
[    0.000000] SBI implementation ID=0x1 Version=0x10004
[    0.000000] SBI TIME extension detected
[    0.000000] SBI IPI extension detected
[    0.000000] SBI RFENCE extension detected
[    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000] printk: bootconsole [sbi0] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] OF: reserved mem: 0x0000000080000000..0x000000008003ffff (256 KiB) nomap non-reusable mmode_resv1@80000000
[    0.000000] OF: reserved mem: 0x0000000080040000..0x000000008005ffff (128 KiB) nomap non-reusable mmode_resv0@80040000
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080000000-0x0000000083f3ffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x000000008005ffff]
[    0.000000]   node   0: [mem 0x0000000080060000-0x0000000083f3ffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x0000000083f3ffff]
[    0.000000] SBI HSM extension detected
[    0.000000] riscv: base ISA extensions acdfim
[    0.000000] riscv: ELF capabilities acdfim
[    0.000000] percpu: Embedded 17 pages/cpu s29544 r8192 d31896 u69632
[    0.000000] pcpu-alloc: s29544 r8192 d31896 u69632 alloc=17*4096
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Kernel command line: console=ttyS0,115200 earlycon=sbi loglevel=9 riscv.fwsz=0x80000 root=/dev/mmcblk0p2 rootwait
[    0.000000] Dentry cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 15939
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 46744K/64768K available (5756K kernel code, 4842K rwdata, 2048K rodata, 2143K init, 321K bss, 18024K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, 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=8 to nr_cpu_ids=1.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    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=1
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] riscv-intc: 64 local interrupts mapped
[    0.000000] plic: interrupt-controller@70000000: mapped 101 interrupts with 1 handlers for 2 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: 0x5c40939b5, max_idle_ns: 440795202646 ns
[    0.000001] sched_clock: 64 bits at 25MHz, resolution 40ns, wraps every 4398046511100ns
[    0.008615] Console: colour dummy device 80x25
[    0.013201] Calibrating delay loop (skipped), value calculated using timer frequency.. 50.00 BogoMIPS (lpj=250000)
[    0.023949] pid_max: default: 32768 minimum: 301
[    0.040815] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.048269] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.067897] RCU Tasks Trace: Setting shift to 0 and lim to 1 rcu_task_cb_adjust=1.
[    0.076181] ASID allocator using 16 bits (65536 entries)
[    0.082009] rcu: Hierarchical SRCU implementation.
[    0.086942] rcu:     Max phase no-delay instances is 1000.
[    0.093153] EFI services will not be available.
[    0.098275] smp: Bringing up secondary CPUs ...
[    0.102894] smp: Brought up 1 node, 1 CPU
[    0.113820] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.123991] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.140587] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.147759] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.155099] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.223384] cpu0: Ratio of byte access time to unaligned word access is 4.33, unaligned accesses are fast
[    0.257329] SCSI subsystem initialized
[    0.261885] libata version 3.00 loaded.
[    0.266479] usbcore: registered new interface driver usbfs
[    0.272154] usbcore: registered new interface driver hub
[    0.277795] usbcore: registered new device driver usb
[    0.283227] pps_core: LinuxPPS API ver. 1 registered
[    0.288333] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.297830] PTP clock support registered
[    0.301943] EDAC MC: Ver: 3.0.0
[    0.308871] clocksource: Switched to clocksource riscv_clocksource
[    0.333844] NET: Registered PF_INET protocol family
[    0.339319] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.352179] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.360837] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.368879] TCP established hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.376716] TCP bind hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.384150] TCP: Hash tables configured (established 512 bind 512)
[    0.390742] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.397477] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.405986] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.415558] workingset: timestamp_bits=46 max_order=14 bucket_order=0
[    0.453933] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.463046] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.621013] io scheduler mq-deadline registered
[    0.625637] io scheduler kyber registered
[    0.820870] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.836346] printk: console [ttyS0] disabled
[    0.842711] 4140000.serial: ttyS0 at MMIO 0x4140000 (irq = 16, base_baud = 1562500) is a 16550A
[    0.852161] printk: console [ttyS0] enabled
[    0.852161] printk: console [ttyS0] enabled
[    0.861026] printk: bootconsole [sbi0] disabled
[    0.861026] printk: bootconsole [sbi0] disabled
[    0.886618] usbcore: registered new interface driver usb-storage
[    0.897538] dw_wdt 3010000.watchdog: No valid TOPs array specified
[    0.907401] sdhci: Secure Digital Host Controller Interface driver
[    0.914092] sdhci: Copyright(c) Pierre Ossman
[    0.919000] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.931145] NET: Registered PF_INET6 protocol family
[    0.951419] Segment Routing with IPv6
[    0.955657] In-situ OAM (IOAM) with IPv6
[    0.960813] NET: Registered PF_PACKET protocol family
[    0.966361] 8021q: 802.1Q VLAN Support v1.8
[    1.151688] clk: Disabling unused clocks
[    1.162535] dw-apb-uart 4140000.serial: forbid DMA for kernel console
[    1.182678] mmc0: SDHCI controller on 4310000.mmc [4310000.mmc] using ADMA 64-bit
[    1.191939] Waiting for root device /dev/mmcblk0p2...
[    1.253662] mmc0: new high speed SDHC card at address 0001
[    1.266201] mmcblk0: mmc0:0001 SD16G 14.5 GiB
[    1.278743]  mmcblk0: p1 p2
[    1.330640] EXT4-fs (mmcblk0p2): mounted filesystem ff313567-e9f1-5a5d-9895-3ba130b4a864 ro with ordered data mode. Quota mode: disabled.
[    1.344046] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    1.359314] Freeing unused kernel image (initmem) memory: 2140K
[    1.365810] Run /sbin/init as init process
[    1.370301]   with arguments:
[    1.373408]     /sbin/init
[    1.376219]   with environment:
[    1.379580]     HOME=/
[    1.382062]     TERM=linux
[    1.948035] init: Console is alive
[    1.954011] init: - watchdog -
[    2.261117] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    2.281795] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    2.294433] init: - preinit -
[   13.539107] random: crng init done
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[   16.971437] mount_root: mounting /dev/root with options
[   17.014083] EXT4-fs (mmcblk0p2): re-mounted ff313567-e9f1-5a5d-9895-3ba130b4a864 r/w. Quota mode: disabled.
[   17.125563] urandom-seed: Seed file not found (/etc/urandom.seed)
[   17.250878] procd: - early -
[   17.254993] procd: - watchdog -
[   20.057234] procd: - watchdog -
[   20.064923] procd: - ubus -
[   20.250995] procd: - init -
Please press Enter to activate this console.
[   23.391154] urngd: v1.0.2 started.
[   23.917897] kmodloader: loading kernel modules from /etc/modules.d/*
[   25.081608] PPP generic driver version 2.4.2
[   25.098678] NET: Registered PF_PPPOX protocol family
[   25.149895] kmodloader: done loading kernel modules from /etc/modules.d/*



BusyBox v1.36.1 (2024-06-24 22:54:34 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r26775+11-8e1316f3f6
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/#

4 Likes