NickCao / nixos-riscv

MIT License
64 stars 11 forks source link

Support for Duo 256M #14

Closed mcdonc closed 8 months ago

mcdonc commented 8 months ago

EDIT: I solved the automatic boot problem described here in a hacky way, see https://github.com/NickCao/nixos-riscv/pull/14#issuecomment-1945544836

Currently the Duo 256M boots but not automatically. It gets through stage 1 and then fails to find /mnt-root/init when it tries to start stage 2 (see https://github.com/NickCao/nixos-riscv/issues/12). But if I stop the boot, and change the boot args to point it at the right nixos system stage 2 init in the nix store, stage 2 completes and the system comes up.

I'm wondering if anyone has any suggestions about what to change to make it boot automatically (mabe Nick)? It seems to be related to https://github.com/NixOS/nixpkgs/blob/release-23.11/nixos/modules/system/boot/stage-2.nix#L79 but I'm not sure why that would need to be different than the Duo 64.

Here's the boot console log for a successful boot (note me stopping the boot and changing the boot args)

Although the transcript shows swap not working, a later commit fixed this.

SBL Jb2829:g0e0b8efb5:2024-02-14T09:23:41+00:00
st_on_reason=d0000
st_off_reason=0
P2S/0x1000/0xc00a200.
SD/0x9200/0x1000/0x1000/0.P2E.
DPS/0xa200/0x2000.
SD/0xa200/0x2000/0x2000/0.DPE.
cv181x DDR init.
ddr_param[0]=0x78075562.
pkg_type=5
D1_3_2
DDR3-2G-QFN
Data rate=1866.
DDR BIST PASS
PLLS/OD.
C2S/0x0/0x0/0x0.
No C906L image.
MS/0xc200/0x80000000/0x1b000.
SD/0xc200/0x1b000/0x1b000/0.ME.
L2/0x27200.
SD/0x27200/0x200/0x200/0.L2/0x414d3342/0xcafe1232/0x80200000/0x37400/0x37400
COMP/1.
SD/0x27200/0x37400/0x37400/0.DCP/0x80200020/0x1000000/0x81900020/0x37400/1.
DCP/0x73ee7/0.
Loader_2nd loaded.
Use internal 32k
Jump to monitor at 0x80000000.
OPENSBI: next_addr=0x80200020 arg1=0x80080000
OpenSBI v0.9
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : Milk-V Duo256M
Platform Features         : mfdeleg
Platform HART Count       : 1
Platform IPI Device       : clint
Platform Timer Device     : clint
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform SysReset Device  : ---
Firmware Base             : 0x80000000
Firmware Size             : 132 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000074000000-0x000000007400ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200020
Domain0 Next Arg1         : 0x0000000080080000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcvsux
Boot HART Features        : scounteren,mcounteren,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4096
Boot HART PMP Address Bits: 38
Boot HART MHPM Count      : 8
Boot HART MHPM Count      : 8
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109

U-Boot 2021.10 (Feb 14 2024 - 09:23:21 +0000) cvitek_cv181x

DRAM:  254 MiB
gd->relocaddr=0x8b0c8000. offset=0xaec8000
MMC:   cv-sd@4310000: 0
Loading Environment from nowhere... OK
In:    serial
Out:   serial
Err:   serial
Net:   
Warning: ethernet@4070000 (eth0) using random MAC address - 36:0d:f3:23:6f:3d
eth0: ethernet@4070000

======== me stopping the autoboot and changing the bootargs ========
Hit any key to stop autoboot:  0 
cv181x_c906# setenv othbootargs ${othbootargs} init=/nix/store/17nm8d69jwihgp16i5ys60wlklc9443b-nixos-system-nixos-24.05.20240215.69c9919/init
cv181x_c906# boot
====================================================================

Boot from SD ...
switch to partitions #0, OK
mmc0 is current device
17247684 bytes read in 766 ms (21.5 MiB/s)
## Loading kernel from FIT Image at 81800000 ...
   Using 'config-cv1812cp_milkv_duo256m_sd' configuration
   Trying 'kernel-1' kernel subimage
     Description:  kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x818000e4
     Data Size:    7770112 Bytes = 7.4 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x80200000
     Entry Point:  0x80200000
     Hash algo:    crc32
     Hash value:   c9fc343c
   Verifying Hash Integrity ... crc32+ OK
## Loading ramdisk from FIT Image at 81800000 ...
   Using 'config-cv1812cp_milkv_duo256m_sd' configuration
   Trying 'ramdisk-1' ramdisk subimage
     Description:  ramdisk
     Type:         RAMDisk Image
     Compression:  uncompressed
     Data Start:   0x81f691c4
     Data Size:    9454959 Bytes = 9 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x00000000
     Entry Point:  0x00000000
   Verifying Hash Integrity ... OK
## Loading fdt from FIT Image at 81800000 ...
   Using 'config-cv1812cp_milkv_duo256m_sd' configuration
   Trying 'fdt-1' fdt subimage
     Description:  flat_dt
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x8286d7d4
     Data Size:    20620 Bytes = 20.1 KiB
     Architecture: RISC-V
     Hash algo:    sha256
     Hash value:   e4fbd3deb2b01ef4c69d50c17975879762c29ef531ef19eee07b0880b6e12562
   Verifying Hash Integrity ... sha256+ OK
   Booting using the fdt blob at 0x8286d7d4
   Loading Kernel Image
   Decompressing 7770112 bytes used 8ms
   Loading Ramdisk to 89e7b000, end 8a77f56f ... OK
   Loading Device Tree to 0000000089e72000, end 0000000089e7a08b ... OK

Starting kernel ...

[    0.000000] Linux version 5.10.4 (nixbld@localhost) (riscv64-unknown-linux-gnu-gcc (GCC) 13.2.0, GNU ld (GNU Binutils) 2.40) #1-NixOS PREEMPT Tue Jan 1 00:00:00 UTC 1980
[    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000] printk: bootconsole [sbi0] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] Initial ramdisk at: 0x(____ptrval____) (9457664 bytes)
[    0.000000] Ion: Ion memory setup at 0x000000008b300000 size 75 MiB
[    0.000000] OF: reserved mem: initialized node ion, compatible id ion-region
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080000000-0x000000008fdfffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x000000008fdfffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x000000008fdfffff]
[    0.000000] On node 0 totalpages: 65024
[    0.000000]   DMA32 zone: 889 pages used for memmap
[    0.000000]   DMA32 zone: 0 pages reserved
[    0.000000]   DMA32 zone: 65024 pages, LIFO batch:15
[    0.000000] SBI specification v0.3 detected
[    0.000000] SBI implementation ID=0x1 Version=0x9
[    0.000000] SBI v0.2 TIME extension detected
[    0.000000] SBI v0.2 IPI extension detected
[    0.000000] SBI v0.2 RFENCE extension detected
[    0.000000] riscv: ISA extensions acdfimsuv
[    0.000000] riscv: ELF capabilities acdfimv
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 64135
[    0.000000] Kernel command line: root=/dev/mmcblk0p2 rootwait rw console=ttyS0,115200 earlycon=sbi riscv.fwsz=0x80000 loglevel=9 init=/nix/store/17nm8d69jwihgp16i5ys60wlklc9443b-nixos-sys
tem-nixos-24.05.20240215.69c9919/init
[    0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.000000] Sorting __ex_table...
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 159856K/260096K available (4101K kernel code, 493K rwdata, 2784K rodata, 144K init, 202K bss, 100240K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000]  Trampoline variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    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] random: get_random_bytes called from start_kernel+0x2f4/0x448 with crng_init=0
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x5c40939b5, max_idle_ns: 440795202646 ns
[    0.000007] sched_clock: 64 bits at 25MHz, resolution 40ns, wraps every 4398046511100ns
[    0.008403] Calibrating delay loop (skipped), value calculated using timer frequency.. 50.00 BogoMIPS (lpj=100000)
[    0.019119] pid_max: default: 4096 minimum: 301
[    0.023993] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.031392] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.040849] ASID allocator initialised with 65536 entries
[    0.046518] rcu: Hierarchical SRCU implementation.
[    0.051828] EFI services will not be available.
[    0.056833] devtmpfs: initialized
[    0.064807] early_time_log: do_initcalls: 43117256us
[    0.070418] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.080457] futex hash table entries: 16 (order: -4, 384 bytes, linear)
[    0.087451] pinctrl core: initialized pinctrl subsystem
[    0.093128] NET: Registered protocol family 16
[    0.098056] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.105356] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.113973] thermal_sys: Registered thermal governor 'step_wise'
[    0.125845] OF: /gpio@03020000/gpio-controller@0: could not find phandle
[    0.139038] OF: /gpio@03021000/gpio-controller@1: could not find phandle
[    0.146030] OF: /gpio@03022000/gpio-controller@2: could not find phandle
[    0.153017] OF: /gpio@03023000/gpio-controller@3: could not find phandle
[    0.160005] OF: /gpio@05021000/gpio-controller@4: could not find phandle
[    0.168519] clk reset: nr_reset=64 resource_size=8
[    0.173941] get audio clk=24576000
[    0.177457] cvitek-i2s-subsys 4108000.i2s_subsys: Set clk_sdma_aud0~3 to 24576000
[    0.196167] dw_dmac 4330000.dma: CVITEK DMA Controller, 8 channels, probe done!
[    0.204498] SCSI subsystem initialized
[    0.208727] usbcore: registered new interface driver usbfs
[    0.214453] usbcore: registered new interface driver hub
[    0.220003] usbcore: registered new device driver usb
[    0.226723] Ion: ion_parse_dt_heap_common: id 0 type 2 name carveout align 1000
[    0.234699] Ion: rmem_ion_device_init: heap carveout base 0x000000008b300000 size 0x0000000004b00000 dev (____ptrval____)
[    0.245970] ion_carveout_heap_create, size=0x4b00000
[    0.251268] cvi_get_rtos_ion_size, rtos ion_size get:0x1600000
[    0.257247] ion_carveout_heap_create, size(exclusion of rtos_ion_size)=0x3500000
[    0.474268] platform carveout: [ion] add heap id 0, type 2, base 0x8b300000, size 0x4b00000
[    0.483139] Advanced Linux Sound Architecture Driver Initialized.
[    0.490450] clocksource: Switched to clocksource riscv_clocksource
[    0.498388] NET: Registered protocol family 2
[    0.503699] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.512364] TCP established hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.520370] TCP bind hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.527814] TCP: Hash tables configured (established 2048 bind 2048)
[    0.534588] UDP hash table entries: 128 (order: 0, 4096 bytes, linear)
[    0.541342] UDP-Lite hash table entries: 128 (order: 0, 4096 bytes, linear)
[    0.548733] NET: Registered protocol family 1
[    0.553747] RPC: Registered named UNIX socket transport module.
[    0.559861] RPC: Registered udp transport module.
[    0.564739] RPC: Registered tcp transport module.
[    0.569660] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.577650] Unpacking initramfs...
[    1.456959] Freeing initrd memory: 9232K
[    1.461690] Initialise system trusted keyrings
[    1.466399] workingset: timestamp_bits=62 max_order=16 bucket_order=0
[    1.478131] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    1.484927] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    1.491993] NET: Registered protocol family 38
[    1.496555] Key type asymmetric registered
[    1.500829] Asymmetric key parser 'x509' registered
[    1.510581] cvi_rtos_cmdqu_init
[    1.513941] cvi_rtos_cmdqu_probe start ---
[    1.518125] name=1900000.rtos_cmdqu
[    1.521962] res-reg: start: 0x1900000, end: 0x1900fff, virt-addr(ffffffd005bcc000).
[    1.529849] RTOS_CMDQU_INIT
[    1.532770] mbox_reg=(____ptrval____)
[    1.536616] mbox_done_reg=(____ptrval____)
[    1.540916] mailbox_context=(____ptrval____)
[    1.545430] cvi_rtos_cmdqu_probe DONE
[    1.549366] cvi_rtos_cmdqu_init done
[    1.553032] [cvi_spinlock_init] success
[    1.557278] Serial: 8250/16550 driver, 5 ports, IRQ sharing disabled
[    1.565380] printk: console [ttyS0] disabled
[    1.578889] printk: console [ttyS0] enabledx4140000 (irq = 15, base_baud = 1562500) is a 16550A
[    1.578889] printk: console [ttyS0] enabled
[    1.587479] printk: bootconsole [sbi0] disabled
[    1.587479] printk: bootconsole [sbi0] disabled
[    1.598066] zram: Added device: zram0
[    1.605165] libphy: Fixed MDIO Bus: probed
[    1.609838] bm-dwmac 4070000.ethernet: IRQ eth_wake_irq not found
[    1.616184] bm-dwmac 4070000.ethernet: IRQ eth_lpi not found
[    1.622139] bm-dwmac 4070000.ethernet: Hash table entries set to unexpected value 0
[    1.630179] bm-dwmac 4070000.ethernet: no reset control found
[    1.636356] bm-dwmac 4070000.ethernet: User ID: 0x10, Synopsys ID: 0x37
[    1.643255] bm-dwmac 4070000.ethernet:       DWMAC1000
[    1.648147] bm-dwmac 4070000.ethernet: DMA HW capability register supported
[    1.655364] bm-dwmac 4070000.ethernet: RX Checksum Offload Engine supported
[    1.662581] bm-dwmac 4070000.ethernet: COE Type 2
[    1.667466] bm-dwmac 4070000.ethernet: TX Checksum insertion supported
[    1.674234] bm-dwmac 4070000.ethernet: Normal descriptors
[    1.679836] bm-dwmac 4070000.ethernet: Ring mode enabled
[    1.685351] bm-dwmac 4070000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    1.693109] bm-dwmac 4070000.ethernet: device MAC address 36:0d:f3:23:6f:3d
[    1.723328] libphy: stmmac: probed
[    1.727104] CVITEK CV182XA stmmac-0:00: attached PHY driver [CVITEK CV182XA] (mii_bus:phy_addr=stmmac-0:00, irq=POLL)
[    1.738173] CVITEK CV182XA stmmac-0:01: attached PHY driver [CVITEK CV182XA] (mii_bus:phy_addr=stmmac-0:01, irq=POLL)
[    1.750168] bm-dwmac 4070000.ethernet: Cannot get clk_500m_eth!
[    1.756397] bm-dwmac 4070000.ethernet: Cannot get gate_clk_axi4!
[    1.763527] dwc2 4340000.usb: axi clk installed
[    1.768274] dwc2 4340000.usb: apb clk installed
[    1.772985] dwc2 4340000.usb: 125m clk installed
[    1.777786] dwc2 4340000.usb: 33k clk installed
[    1.782531] dwc2 4340000.usb: 12m clk installed
[    1.787323] dwc2 4340000.usb: EPs: 8, dedicated fifos, 3072 entries in SPRAM
[    1.795081] dwc2 4340000.usb: DWC OTG Controller
[    1.799932] dwc2 4340000.usb: new USB bus registered, assigned bus number 1
[    1.807190] dwc2 4340000.usb: irq 34, io mem 0x04340000
[    1.813355] hub 1-0:1.0: USB hub found
[    1.817347] hub 1-0:1.0: 1 port detected
[    1.822197] usbcore: registered new interface driver usb-storage
[    1.828934] mousedev: PS/2 mouse device common for all mice
[    1.835005] i2c /dev entries driver
[    1.839740] sdhci: Secure Digital Host Controller Interface driver
[    1.846187] sdhci: Copyright(c) Pierre Ossman
[    1.850713] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.856784] cvi:sdhci_cvi_probe
[    1.906461] mmc0: SDHCI controller on 4310000.cv-sd [4310000.cv-sd] using ADMA 64-bit
[    1.914613] cvi_proc_init cvi_host 0x(____ptrval____)
[    1.920384] usbcore: registered new interface driver usbhid
[    1.930463] usbhid: USB HID core driver
[    1.935506] cvitek-i2s 4100000.i2s: cvi_i2s_probe
[    1.940942] cvitek-i2s 4130000.i2s: cvi_i2s_probe
[    1.950786] cviteka-adc sound_adc: cviteka_adc_probe, dev name=sound_adc
[    1.957849] cviteka-adc sound_adc: cviteka_adc_probe start devm_snd_soc_register_card
[    1.966358] cvitekaadc 300a100.adc: cvitekaadc_probe
[    1.978954] cviteka-dac sound_dac: cviteka_dac_probe, dev name=sound_dac
[    1.986242] cvitekadac 300a000.dac: cvitekadac_probe
[    1.991656] cvitekadac_probe gpio_is_valid mute_pin_l
[    1.997448] NET: Registered protocol family 17
[    2.002286] Loading compiled-in X.509 certificates
[    2.009075] i2c_designware 4010000.i2c: running with gpio recovery mode! scl,sda
[    2.017566] i2c_designware 4020000.i2c: running with gpio recovery mode! scl,sda
[    2.026003] i2c_designware 4030000.i2c: running with gpio recovery mode! scl,sda
[    2.034290] cviteka-adc sound_adc: cviteka_adc_probe, dev name=sound_adc
[    2.041326] cviteka-adc sound_adc: cviteka_adc_probe start devm_snd_soc_register_card
[    2.054401] cviteka-dac sound_dac: cviteka_dac_probe, dev name=sound_dac
[    2.078082] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    2.093230] mmc0: new high speed SDHC card at address aaaa
[    2.100971] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    2.108560] mmcblk0: mmc0:aaaa SC32G 29.7 GiB 
[    2.113365] ALSA device list:
[    2.116729] dw-apb-uart 4140000.serial: forbid DMA for kernel console
[    2.124109] cfg80211: failed to load regulatory.db
[    2.129764] Freeing unused kernel memory: 144K
[    2.134598] Kernel memory protection not selected by kernel config.
[    2.141273] Run /init as init process
[    2.145230]   with arguments:
[    2.148426]     /init
[    2.150935]  mmcblk0: p1 p2
[    2.154035]   with environment:
[    2.157920]     HOME=/
[    2.160438]     TERM=linux
[    2.163305] early_time_log: run_init_process: 45215756us

<<< NixOS Stage 1 >>>

running udev...
[    2.334622] stage-1-init: [Thu Jan  1 00:00:02 UTC 1970] running udev...
Starting systemd-udevd version 255.2
[    2.431687] stage-1-init: [Thu Jan  1 00:00:02 UTC 1970] Starting systemd-udevd version 255.2
[    3.073742] bm-dwmac 4070000.ethernet end0: renamed from eth0
kbd_mode: KDSKBMODE: Inappropriate ioctl for device
Gloadkmap: can't open console[    3.420210] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] kbd_mode: KDSKBMODE: Inappropriate ioctl for device

starting device mapper and LVM...
[    3.451459] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] loadkmap: can't open console
[    3.460698] random: lvm: uninitialized urandom read (4 bytes read)
[    3.479185] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] starting device mapper and LVM...
  Failed to set up async io, using sync io.
[    3.506015] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] Failed to set up async io, using sync io.
checking /dev/disk/by-label/NIXOS_SD...
fsck (busybox 1.36.1)
[fsck.ext4 (1) -- /mnt-root/] [    3.611876] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] checking /dev/disk/by-label/NIXOS_SD...
fsck.ext4 -a /dev/disk/by-label/NIXOS_SD
NIXOS_SD: recovering journal[    3.641156] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] fsck (busybox 1.36.1)

[    3.660222] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] [fsck.ext4 (1) -- /mnt-root/] fsck.ext4 -a /dev/disk/by-label/NIXOS_SD
NIXOS_SD: clean, 47600/59904 fil[    3.681258] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] NIXOS_SD: recovering journal
es, 223262/231995 blocks
mounting /dev/disk/by-label/NIXOS_SD on /...
[    3.708176] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] NIXOS_SD: clean, 47600/59904 files, 223262/231995 blocks
[    3.725897] stage-1-init: [Thu Jan  1 00:00:03 UTC 1970] mounting /dev/disk/by-label/NIXOS_SD on /...
[    3.737981] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    3.752022] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)

<<< NixOS Stage 2 >>>

[    4.319189] random: fast init done
[    4.387626] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    4.395465] booting system configuration /nix/store/17nm8d69jwihgp16i5ys60wlklc9443b-nixos-system-nixos-24.05.20240215.69c9919
running activation script...[    4.639771] stage-2-init: running activation script...

[    4.807081] random: perl: uninitialized urandom read (4 bytes read)
[    4.869987] random: perl: uninitialized urandom read (4 bytes read)
[    6.423093] random: perl: uninitialized urandom read (4 bytes read)
setting up /etc...[    6.511808] stage-2-init: setting up /etc...

[    6.535983] random: perl: uninitialized urandom read (4 bytes read)
[    6.543190] random: perl: uninitialized urandom read (4 bytes read)
++ /nix/store/i3fzyrygyl2an6r5kk[    7.808368] stage-2-init: ++ /nix/store/i3fzyrygyl2an6r5kkjnkjx3d3fynwhr-util-linux-riscv64-unknown-linux-gnu-2.39.3-bin/bin/findmnt -n -o SOURCE /
jnkjx3d3fynwhr-util-linux-riscv64-unknown-linux-gnu-2.39.3-bin/bin/findmnt -n -o SOURCE /
+ rootPart=/dev/disk/by-label/NI[    7.836357] stage-2-init: + rootPart=/dev/disk/by-label/NIXOS_SD
XOS_SD
++ lsblk -npo PKNAME /de[    7.844421] stage-2-init: ++ lsblk -npo PKNAME /dev/disk/by-label/NIXOS_SD
v/disk/by-label/NIXOS_SD
+ bootDevice=/dev/mmcblk0[    7.868874] stage-2-init: + bootDevice=/dev/mmcblk0

++ lsblk -npo MAJ:MIN /dev/disk/[    7.880018] stage-2-init: ++ lsblk -npo MAJ:MIN /dev/disk/by-label/NIXOS_SD
by-label/NIXOS_SD
++ /nix/store/sqaqqbznigm68ankng8inf48pq158hwi-gawk-riscv64-unknown-linux-gnu-5.2.2/bin/awk -F: '{print $2}'
[    7.904143] stage-2-init: ++ /nix/store/sqaqqbznigm68ankng8inf48pq158hwi-gawk-riscv64-unknown-linux-gnu-5.2.2/bin/awk -F: '{print $2}'
+ partNum='2  '[    7.943592] stage-2-init: + partNum='2  '

+ sfdisk -N2 --no-reread /dev/mmcblk0
+ echo ,+,
[    7.952690] stage-2-init: + sfdisk -N2 --no-reread /dev/mmcblk0
[    7.961696] stage-2-init: + echo ,+,
Disk /dev/mmcblk0: 29.72 GiB, 31[    8.414423] stage-2-init: Disk /dev/mmcblk0: 29.72 GiB, 31914983424 bytes, 62333952 sectors
914983424 bytes, 62333952 sector[    8.426412] stage-2-init: Units: sectors of 1 * 512 = 512 bytes
s
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/p[    8.437103] stage-2-init: Sector size (logical/physical): 512 bytes / 512 bytes
[    8.449146] stage-2-init: I/O size (minimum/optimal): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512[    8.458902] stage-2-init: Disklabel type: dos
 bytes / 512 bytes
Disklabel ty[    8.467187] stage-2-init: Disk identifier: 0x2178694e
pe: dos
Disk identifier: 0x2178[    8.474227] stage-2-init: Old situation:
694e

Old situation:

Device[    8.480878] stage-2-init: Device         Boot  Start     End Sectors   Size Id Type
         Boot  Start     End Sec[    8.492062] stage-2-init: /dev/mmcblk0p1       16384  147455  131072    64M  b W95 FAT32
tors   Size Id Type
/dev/mmcblk[    8.503879] stage-2-init: /dev/mmcblk0p2 *    147456 2003415 1855960 906.2M 83 Linux
0p1       16384  147455  131072 [    8.514069] stage-2-init: /dev/mmcblk0p2:
   64M  b W95 FAT32
/dev/mmcblk[    8.521369] stage-2-init: New situation:
0p2 *    147456 2003415 1855960 [    8.528324] stage-2-init: Disklabel type: dos
906.2M 83 Linux

/dev/mmcblk0p[    8.535613] stage-2-init: Disk identifier: 0x2178694e
2: 
New situation:
Disklabel t[    8.543731] stage-2-init: Device         Boot  Start      End  Sectors  Size Id Type
ype: dos
Disk identifier: 0x217[    8.554612] stage-2-init: /dev/mmcblk0p1       16384   147455   131072   64M  b W95 FAT32
8694e

Device         Boot  St[    8.565898] stage-2-init: /dev/mmcblk0p2 *    147456 62333951 62186496 29.7G 83 Linux
art      End  Sectors  Size Id T[    8.576823] stage-2-init: The partition table has been altered.
ype
/dev/mmcblk0p1       16384 [    8.585870] stage-2-init: Calling ioctl() to re-read partition table.
  147455   131072   64M  b W95 F[    8.595300] stage-2-init: Re-reading the partition table failed.: Device or resource busy
AT32
/dev/mmcblk0p2 *    147456[    8.607234] stage-2-init: The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).
 62333951 62186496 29.7G 83 Linu[    8.623406] stage-2-init: Syncing disks.
x

The partition table has bee[    8.630845] stage-2-init: + /nix/store/alj8qdbbzp12q50q50pqny3pyy2qhysc-parted-riscv64-unknown-linux-gnu-3.6/bin/partprobe
n altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).
Syncing disks.
+ /nix/store/alj8qdbbzp12q50q50pqny3pyy2qhysc-parted-riscv64-unknown-linux-gnu-3.6/bin/partprobe
+ /nix/store/5s7ivyzsnl90hr64zs6[    8.770906] stage-2-init: + /nix/store/5s7ivyzsnl90hr64zs60r803mvvf0vns-e2fsprogs-riscv64-unknown-linux-gnu-1.47.0-bin/bin/resize2fs /dev/disk/by-label/NIX
OS_SD
0r803mvvf0vns-e2fsprogs-riscv64-unknown-linux-gnu-1.47.0-bin/bin/resize2fs /dev/disk/by-label/NIXOS_SD
resize2fs 1.47.0 (5-Feb-2023)[    8.827902] stage-2-init: resize2fs 1.47.0 (5-Feb-2023)

[    8.841961] EXT4-fs (mmcblk0p2): resizing filesystem from 231995 to 7773312 blocks
[    9.378702] EXT4-fs (mmcblk0p2): resized filesystem to 7773312
Filesystem at /dev/disk/by-label[    9.529418] stage-2-init: Filesystem at /dev/disk/by-label/NIXOS_SD is mounted on /; on-line resizing required
/NIXOS_SD is mounted on /; on-line resizing required
old_desc_b[    9.545087] stage-2-init: old_desc_blocks = 1, new_desc_blocks = 4
locks = 1, new_desc_blocks = 4
[    9.555291] stage-2-init: The filesystem on /dev/disk/by-label/NIXOS_SD is now 7773312 (4k) blocks long.
The filesystem on /dev/disk/by-l[    9.568217] stage-2-init: + /nix/store/f68p1kpli7wx5i92shyz7ky24rawqjr2-nix-riscv64-unknown-linux-gnu-2.18.1/bin/nix-store --load-db
abel/NIXOS_SD is now 7773312 (4k) blocks long.

+ /nix/store/f68p1kpli7wx5i92shyz7ky24rawqjr2-nix-riscv64-unknown-linux-gnu-2.18.1/bin/nix-store --load-db
[   16.426511] random: crng init done
+ touch /etc/NIXOS[   17.405113] stage-2-init: + touch /etc/NIXOS

+ /nix/store/f68p1kpli7wx5i92shy[   17.418809] stage-2-init: + /nix/store/f68p1kpli7wx5i92shyz7ky24rawqjr2-nix-riscv64-unknown-linux-gnu-2.18.1/bin/nix-env -p /nix/var/nix/profiles/system --
set /run/current-system
z7ky24rawqjr2-nix-riscv64-unknown-linux-gnu-2.18.1/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
+ rm -f /nix-path-registration[   17.889252] stage-2-init: + rm -f /nix-path-registration

starting systemd...
[   18.263475] systemd[1]: System time before build time, advancing clock.
[   18.343763] systemd[1]: systemd 255.2 running in system mode (+PAM +AUDIT -SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +I
PTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK -XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified)
[   18.376730] systemd[1]: Detected architecture riscv64.

Welcome to NixOS 24.05 (Uakari)!

[   18.401924] systemd[1]: Hostname set to <nixos>.
[   18.412203] systemd[1]: Initializing machine ID from random generator.
[   18.503851] systemd[1]: bpf-lsm: BPF LSM hook not enabled in the kernel, BPF LSM not supported
[   20.225521] systemd[1]: Queued start job for default target Multi-User System.
[   20.252310] systemd[1]: init.scope: unit configures an IP firewall, but the local system does not support BPF/cgroup firewalling.
[   20.264498] systemd[1]: init.scope: (This warning is only shown for the first unit using IP firewalling.)
[   20.278778] systemd[1]: Created slice Slice /system/getty.
[  OK  ] Created slice Slice /system/getty.
[   20.300127] systemd[1]: Created slice Slice /system/modprobe.
[  OK  ] Created slice Slice /system/modprobe.
[   20.324172] systemd[1]: Created slice Slice /system/serial-getty.
[  OK  ] Created slice Slice /system/serial-getty.
[   20.348205] systemd[1]: Created slice Slice /system/systemd-zram-setup.
[  OK  ] Created slice Slice /system/systemd-zram-setup.
[   20.375877] systemd[1]: Created slice User and Session Slice.
[  OK  ] Created slice User and Session Slice.
[   20.399203] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[   20.427183] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
[   20.454818] systemd[1]: Expecting device /dev/ttyS0...
         Expecting device /dev/ttyS0...
[   20.474687] systemd[1]: Expecting device /dev/zram0...
         Expecting device /dev/zram0...
[   20.494701] systemd[1]: Reached target Local Encrypted Volumes.
[  OK  ] Reached target Local Encrypted Volumes.
[   20.514887] systemd[1]: Reached target Containers.
[  OK  ] Reached target Containers.
[   20.534897] systemd[1]: Reached target Path Units.
[  OK  ] Reached target Path Units.
[   20.554781] systemd[1]: Reached target Remote File Systems.
[  OK  ] Reached target Remote File Systems.
[   20.574763] systemd[1]: Reached target Slice Units.
[  OK  ] Reached target Slice Units.
[   20.614805] systemd[1]: Listening on Process Core Dump Socket.
[  OK  ] Listening on Process Core Dump Socket.
[   20.636047] systemd[1]: Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket (/dev/log).
[   20.660092] systemd[1]: Listening on Journal Socket.
[  OK  ] Listening on Journal Socket.
[   20.678906] systemd[1]: Userspace Out-Of-Memory (OOM) Killer Socket was skipped because of an unmet condition check (ConditionPathExists=/proc/pressure/memory).
[   20.695697] systemd[1]: Listening on udev Control Socket.
[  OK  ] Listening on udev Control Socket.
[   20.716050] systemd[1]: Listening on udev Kernel Socket.
[  OK  ] Listening on udev Kernel Socket.
[   20.735583] systemd[1]: Huge Pages File System was skipped because of an unmet condition check (ConditionPathExists=/sys/kernel/mm/hugepages).
[   20.756849] systemd[1]: Mounting POSIX Message Queue File System...
         Mounting POSIX Message Queue File System...
[   20.779388] systemd[1]: Kernel Debug File System was skipped because of an unmet condition check (ConditionPathExists=/sys/kernel/debug).
[   20.793126] systemd[1]: Create List of Static Device Nodes was skipped because of an unmet condition check (ConditionFileNotEmpty=/run/booted-system/kernel-modules/lib/modules/5.10.4/modu
les.devname).
[   20.816430] systemd[1]: Starting Load Kernel Module configfs...
         Starting Load Kernel Module configfs...
[   20.843265] systemd[1]: Starting Load Kernel Module drm...
         Starting Load Kernel Module drm...
[   20.867266] systemd[1]: Starting Load Kernel Module efi_pstore...
         Starting Load Kernel Module efi_pstore...
[   20.891157] systemd[1]: Starting Load Kernel Module fuse...
         Starting Load Kernel Module fuse...
[   20.914349] systemd[1]: Starting mount-pstore.service...
         Starting mount-pstore.service...
[   20.995515] systemd[1]: Starting Create SUID/SGID Wrappers...
         Starting Create SUID/SGID Wrappers...
[   21.066894] systemd[1]: File System Check on Root Device was skipped because of an unmet condition check (ConditionPathIsReadWrite=!/).
[   21.195775] systemd[1]: Starting Journal Service...
         Starting Journal Service...
[   21.303470] systemd[1]: Starting Load Kernel Modules...
         Starting Load Kernel Modules...
[   21.371847] systemd[1]: Starting Remount Root and Kernel File Systems...
         Starting Remount Root and Kernel File Systems...
[   21.426633] systemd[1]: Starting Create Static Device Nodes in /dev gracefully...
         Starting Create Static Device Nodes in /dev gracefully...
[   21.507466] systemd[1]: Starting Coldplug All udev Devices...
         Starting Coldplug All udev Devices...
[   21.670981] systemd[1]: Mounted POSIX Message Queue File System.
[  OK  ] Mounted POSIX Message Queue File System.
[   21.733092] systemd[1]: modprobe@configfs.service: Deactivated successfully.
[   21.800016] systemd[1]: Finished Load Kernel Module configfs.
[  OK  ] Finished Load Kernel Module configfs.
[   21.887423] systemd[1]: modprobe@drm.service: Deactivated successfully.
[   21.920998] systemd[1]: Finished Load Kernel Module drm.
[  OK  ] Finished Load Kernel Module drm.
[   21.949589] systemd[1]: modprobe@efi_pstore.service: Deactivated successfully.
[   21.983169] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   22.002724] systemd[1]: Finished Load Kernel Module efi_pstore.
[  OK  ] Finished Load Kernel Module efi_pstore.
[   22.092589] systemd[1]: modprobe@fuse.service: Deactivated successfully.
[   22.138322] systemd[1]: Finished Load Kernel Module fuse.
[  OK  ] Finished Load Kernel Module fuse.
[   22.193545] systemd[1]: mount-pstore.service: Skipped due to 'exec-condition'.
[   22.231804] systemd[1]: Condition check resulted in mount-pstore.service being skipped.
[   22.279004] systemd[1]: Finished Load Kernel Modules.
[  OK  ] Finished Load Kernel Modules.
[   22.316412] systemd[1]: Finished Remount Root and Kernel File Systems.
[  OK  ] Finished Remount Root and Kernel File Systems.
[   22.367489] systemd[1]: Finished Create Static Device Nodes in /dev gracefully.
[   22.380114] systemd-journald[311]: Collecting audit messages is disabled.
[  OK  ] Finished Create Static Device Nodes in /dev gracefully.
[   22.413293] systemd[1]: FUSE Control File System was skipped because of an unmet condition check (ConditionPathExists=/sys/fs/fuse/connections).
[   22.488991] systemd[1]: Mounting Kernel Configuration File System...
         Mounting Kernel Configuration File System...
[   22.534895] systemd[1]: Platform Persistent Storage Archival was skipped because of an unmet condition check (ConditionDirectoryNotEmpty=/sys/fs/pstore).
[   22.631495] systemd[1]: Starting Load/Save OS Random Seed...
         Starting Load/Save OS Random Seed...
[   22.699782] systemd[1]: Starting Apply Kernel Variables...
         Starting Apply Kernel Variables...
[   22.775494] systemd[1]: Starting Create Static Device Nodes in /dev...
         Starting Create Static Device Nodes in /dev...
[   22.898882] systemd[1]: Mounted Kernel Configuration File System.
[  OK  ] Mounted Kernel Configuration File System.
[   23.280245] systemd[1]: Finished Load/Save OS Random Seed.
[  OK  ] Finished Load/Save OS Random Seed.
[   23.342102] systemd[1]: Finished Apply Kernel Variables.
[  OK  ] Finished Apply Kernel Variables.
[   23.380436] systemd[1]: Finished Create Static Device Nodes in /dev.
[  OK  ] Finished Create Static Device Nodes in /dev.
[   23.423442] systemd[1]: Reached target Preparation for Local File Systems.
[  OK  ] Reached target Preparation for Local File Systems.
[   23.466846] systemd[1]: Reached target Local File Systems.
[  OK  ] Reached target Local File Systems.
[   23.515547] systemd[1]: Starting Rule-based Manager for Device Events and Files...
         Starting Rule-based Manager for Device Events and Files...
[   23.575365] systemd[1]: Started Journal Service.
[  OK  ] Started Journal Service.
         Starting Flush Journal to Persistent Storage...
[   23.960480] (md-udevd)[370]: systemd-udevd.service: ProtectHostname=yes is configured, but the kernel does not support UTS namespaces, ignoring namespace setup.
[  OK  ] Finished Create SUID/SGID Wrappers.
[   24.105450] systemd-journald[311]: Received client request to flush runtime journal.
[  OK  ] Finished Flush Journal to Persistent Storage.
         Starting Create Volatile Files and Directories...
[  OK  ] Finished Coldplug All udev Devices.
[  OK  ] Started Rule-based Manager for Device Events and Files.
[  OK  ] Found device /dev/zram0.
         Starting Create swap on /dev/zram0...
[  OK  ] Found device /dev/ttyS0.
[   25.566362] zram0: detected capacity change from 0 to 346030080
[  OK  ] Finished Create Volatile Files and Directories.
[  OK  ] Finished Create swap on /dev/zram0.
[  OK  ] Reached target Sound Card.
[  OK  ] Listening on Load/Save RF Kill Switch Status /dev/rfkill Watch.
[UNSUPP] Starting of Compressed Swap on /dev/zram0 unsupported.
[  OK  ] Reached target Swaps.
         Starting Rebuild Journal Catalog...
         Starting Network Time Synchronization...
         Starting Record System Boot/Shutdown in UTMP...
[  OK  ] Finished Record System Boot/Shutdown in UTMP.
[  OK  ] Finished Rebuild Journal Catalog.
         Starting Update is Completed...
[  OK  ] Finished Update is Completed.
[  OK  ] Started Network Time Synchronization.
[  OK  ] Reached target System Initialization.
[  OK  ] Started logrotate.timer.
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Reached target Timer Units.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Socket Units.
[  OK  ] Reached target Basic System.
         Starting Logrotate configuration check...
[  OK  ] Started Reset console on configuration changes.
         Starting resolvconf update...
         Starting User Login Management...
         Starting D-Bus System Message Bus...
[  OK  ] Finished Logrotate configuration check.
[  OK  ] Started D-Bus System Message Bus.
[  OK  ] Finished resolvconf update.
[  OK  ] Reached target Preparation for Network.
         Starting Networking Setup...
[  OK  ] Started User Login Management.
[  OK  ] Finished Networking Setup.
         Starting Extra networking commands....
[  OK  ] Finished Extra networking commands..
[  OK  ] Reached target Network.
[  OK  ] Reached target Network is Online.
         Starting Permit User Sessions...
[  OK  ] Finished Permit User Sessions.
[  OK  ] Started Serial Getty on ttyS0.
[  OK  ] Reached target Login Prompts.
[  OK  ] Reached target Multi-User System.

<<< Welcome to NixOS 24.05.20240215.69c9919 (riscv64) - ttyS0 >>>

Run 'nixos-help' for the NixOS manual.

nixos login: root (automatic login)

[0;root@nixos: ~root@nixos:~]# free -h
               total        used        free      shared  buff/cache   available
Mem:           165Mi        25Mi        54Mi       1.0Mi        85Mi       127Mi
Swap:             0B          0B          0B
mcdonc commented 8 months ago

I made stage 2 boot work automatically by adding

   populateRootCommands = ''
      cp ${config.system.build.toplevel}/init files/init
    '';

to the sdImage attrset.

This seems needless but it does work :)

mcdonc commented 8 months ago

FYI, Nick, I made a video pimping your work at https://www.youtube.com/watch?v=-ydXjEWUlGE