I have built the busybox minimal file system which works fine if I mount the rootfs from the SD card. But, if i convert the file system into initramfs and load it in the ram, it is not able to run the sbin/init successfully even though the same file system when ran from SD card runs the init successfully.
Any help will be highly appreciated.
This is my uboot uEnv.bin file content:
serial=ttyO0,115200n8
loadaddr=0x82000000
fdtaddr=0x88000000
fsloadaddr=0x88080000
ipaddr=192.168.7.2
serverip=192.168.7.1
loadImages=load mmc 0:2 ${loadaddr} /boot/uImage; load mmc 0:2 ${fdtaddr} /boot/am335x-boneblack.dtb; load mmc 0:2 ${fsloadaddr} /boot/initramfs_new
bootarguments=setenv bootargs console=${serial} rootwait rootfstype=ramfs root=/dev/ram0 rw initrd=${fsloadaddr}
bootcmd=echo "*** ....JATW InitRamFS_NEW Example.... ***"; setenv autoload no; run loadImages; run bootarguments; bootm ${loadaddr} ${fsloadaddr} ${fdtaddr}
Here is the entire log of my boot sequence.
U-Boot SPL 2024.04-rc2-00030-ge4013bcb10 (Feb 20 2024 - 12:33:27 +0500)
Trying to boot from MMC1
U-Boot 2024.04-rc2-00030-ge4013bcb10 (Feb 20 2024 - 12:33:27 +0500)
CPU : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black
DRAM: 512 MiB
Core: 160 devices, 18 uclasses, devicetree: separate
WDT: Started wdt@44e35000 with servicing every 1000ms (60s timeout)
NAND: 0 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... OK
<ethaddr> not set. Validating first E-fuse MAC
Net: eth2: ethernet@4a100000using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
, eth3: usb_ether
Hit any key to stop autoboot: 0
*** ....JATW InitRamFS_NEW Example.... ***
5206440 bytes read in 336 ms (14.8 MiB/s)
70112 bytes read in 9 ms (7.4 MiB/s)
31619543 bytes read in 2040 ms (14.8 MiB/s)
## Booting kernel from Legacy Image at 82000000 ...
Image Name: Linux-6.8.0-rc5
Created: 2024-02-19 13:55:57 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 5206376 Bytes = 5 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 88080000 ...
Image Name: JATW_RamFs
Created: 2024-02-29 12:54:30 UTC
Image Type: ARM Linux RAMDisk Image (uncompressed)
Data Size: 31619479 Bytes = 30.2 MiB
Load Address: 80800000
Entry Point: 80800000
Verifying Checksum ... OK
## Flattened Device Tree blob at 88000000
Booting using the fdt blob at 0x88000000
Working FDT set to 88000000
Loading Kernel Image to 80008000
Loading Ramdisk to 9b100000, end 9cf27997 ... OK
Loading Device Tree to 9b0eb000, end 9b0ff1df ... OK
Working FDT set to 9b0eb000
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 6.8.0-rc5 (junaid@Ubuntu) (arm-linux-gnueabihf-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1 SMP Mon Feb 19 18:55:33 PKT 2024
[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: TI AM335x BeagleBone Black
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] cma: Reserved 16 MiB at 0x9e800000 on node -1
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x0000000080000000-0x000000009fdfffff]
[ 0.000000] HighMem empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000080000000-0x000000009fdfffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x000000009fdfffff]
[ 0.000000] CPU: All CPU(s) started in SVC mode.
[ 0.000000] AM335X ES2.1 (sgx neon)
[ 0.000000] percpu: Embedded 16 pages/cpu s35924 r8192 d21420 u65536
[ 0.000000] Kernel command line: console=ttyO0,115200n8 rootwait rootfstype=ramfs root=/dev/ram0 rw initrd=0x88080000
[ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 129412
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 452816K/522240K available (11264K kernel code, 1109K rwdata, 2584K rodata, 1024K init, 290K bss, 53040K reserved, 16384K cma-reserved, 0K highmem)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, 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=2 to nr_cpu_ids=1.
[ 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: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] IRQ: Found an INTC at 0x(ptrval) (revision 5.0) with 128 interrupts
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] TI gptimer clocksource: always-on /ocp/interconnect@44c00000/segment@200000/target-module@31000
[ 0.000002] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[ 0.000026] clocksource: dmtimer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.000495] TI gptimer clockevent: 24000000 Hz at /ocp/interconnect@48000000/segment@0/target-module@40000
[ 0.001932] Console: colour dummy device 80x30
[ 0.001979] WARNING: Your 'console=ttyO0' has been replaced by 'ttyS0'
[ 0.001986] This ensures that you still see kernel messages. Please
[ 0.001991] update your kernel commandline.
[ 0.002030] Calibrating delay loop... 996.14 BogoMIPS (lpj=4980736)
[ 0.090539] CPU: Testing write buffer coherency: ok
[ 0.090639] CPU0: Spectre v2: using BPIALL workaround
[ 0.090651] pid_max: default: 32768 minimum: 301
[ 0.090771] LSM: initializing lsm=capability,integrity
[ 0.090948] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.090967] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.092455] CPU0: thread -1, cpu 0, socket -1, mpidr 0
[ 0.094090] Setting up static identity map for 0x80100000 - 0x80100078
[ 0.094379] rcu: Hierarchical SRCU implementation.
[ 0.094391] rcu: Max phase no-delay instances is 1000.
[ 0.095110] smp: Bringing up secondary CPUs ...
[ 0.095154] smp: Brought up 1 node, 1 CPU
[ 0.095168] SMP: Total of 1 processors activated (996.14 BogoMIPS).
[ 0.095180] CPU: All CPU(s) started in SVC mode.
[ 0.096020] devtmpfs: initialized
[ 0.110287] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[ 0.110813] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.110849] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[ 0.112164] pinctrl core: initialized pinctrl subsystem
[ 0.114662] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.117362] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.117940] audit: initializing netlink subsys (disabled)
[ 0.119473] thermal_sys: Registered thermal governor 'fair_share'
[ 0.119494] thermal_sys: Registered thermal governor 'step_wise'
[ 0.119500] thermal_sys: Registered thermal governor 'user_space'
[ 0.119629] audit: type=2000 audit(0.110:1): state=initialized audit_enabled=0 res=1
[ 0.119704] cpuidle: using governor menu
[ 0.135469] No ATAGs?
[ 0.135494] hw-breakpoint: debug architecture 0x4 unsupported.
[ 0.138274] kprobes: kprobe jump-optimization is enabled. All kprobes are optimized if possible.
[ 0.154122] iommu: Default domain type: Translated
[ 0.154141] iommu: DMA domain TLB invalidation policy: strict mode
[ 0.161603] SCSI subsystem initialized
[ 0.162360] pps_core: LinuxPPS API ver. 1 registered
[ 0.162372] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[ 0.162394] PTP clock support registered
[ 0.171052] vgaarb: loaded
[ 0.171362] clocksource: Switched to clocksource dmtimer
[ 0.171969] VFS: Disk quotas dquot_6.6.0
[ 0.172028] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[ 0.194868] NET: Registered PF_INET protocol family
[ 0.195208] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.196476] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.196512] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.196529] TCP established hash table entries: 4096 (order: 2, 16384 bytes, linear)
[ 0.196571] TCP bind hash table entries: 4096 (order: 4, 65536 bytes, linear)
[ 0.196669] TCP: Hash tables configured (established 4096 bind 4096)
[ 0.196789] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.196817] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.196984] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.202524] RPC: Registered named UNIX socket transport module.
[ 0.202548] RPC: Registered udp transport module.
[ 0.202553] RPC: Registered tcp transport module.
[ 0.202559] RPC: Registered tcp-with-tls transport module.
[ 0.202564] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.202588] PCI: CLS 0 bytes, default 64
[ 0.204114] Initialise system trusted keyrings
[ 0.205022] Trying to unpack rootfs image as initramfs...
[ 0.221973] workingset: timestamp_bits=14 max_order=17 bucket_order=3
[ 0.232045] NFS: Registering the id_resolver key type
[ 0.232147] Key type id_resolver registered
[ 0.232155] Key type id_legacy registered
[ 0.232214] jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
[ 0.232667] Key type asymmetric registered
[ 0.232683] Asymmetric key parser 'x509' registered
[ 0.232754] io scheduler mq-deadline registered
[ 0.232765] io scheduler kyber registered
[ 0.232833] io scheduler bfq registered
[ 0.251973] Serial: 8250/16550 driver, 6 ports, IRQ sharing enabled
[ 0.358314] brd: module loaded
[ 0.398802] loop: module loaded
[ 0.399761] mtdoops: mtd device (mtddev=name/number) must be supplied
[ 0.402541] i2c_dev: i2c /dev entries driver
[ 0.403412] cpuidle: enable-method property 'ti,am3352' found operations
[ 0.403841] sdhci: Secure Digital Host Controller Interface driver
[ 0.403850] sdhci: Copyright(c) Pierre Ossman
[ 0.404020] sdhci-pltfm: SDHCI platform and OF driver helper
[ 0.411648] ledtrig-cpu: registered to indicate activity on CPUs
[ 0.412578] Initializing XFRM netlink socket
[ 0.412736] NET: Registered PF_INET6 protocol family
[ 0.436493] Segment Routing with IPv6
[ 0.436574] In-situ OAM (IOAM) with IPv6
[ 0.436686] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 0.437655] NET: Registered PF_PACKET protocol family
[ 0.437682] NET: Registered PF_KEY protocol family
[ 0.437838] Key type dns_resolver registered
[ 0.438053] ThumbEE CPU extension supported.
[ 0.438075] Registering SWP/SWPB emulation handler
[ 0.438528] omap_voltage_late_init: Voltage driver support not added
[ 0.438881] SmartReflex Class3 initialized
[ 0.471896] Loading compiled-in X.509 certificates
[ 0.546319] platform 44e10800.pinmux: Fixed dependency cycle(s) with /ocp/interconnect@44c00000/segment@200000/target-module@10000/scm@0/pinmux@800/clkout2-pins
[ 0.546833] pinctrl-single 44e10800.pinmux: 142 pins, size 568
[ 0.551318] ti-sysc: probe of 44e31000.target-module failed with error -16
[ 0.604038] ti-sysc: probe of 48040000.target-module failed with error -16
[ 0.652857] OMAP GPIO hardware version 0.1
[ 0.704278] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz
[ 0.761577] sdhci-omap 481d8000.mmc: supply pbias not found, using dummy regulator
[ 0.773110] sdhci-omap 481d8000.mmc: supply vqmmc not found, using dummy regulator
[ 0.841933] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6, bus freq 1000000
[ 3.373361] Freeing initrd memory: 30880K
[ 3.393759] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver SMSC LAN8710/LAN8720
[ 3.394219] cpsw-switch 4a100000.switch: initialized cpsw ale version 1.4
[ 3.394239] cpsw-switch 4a100000.switch: ALE Table size 1024
[ 3.394522] cpsw-switch 4a100000.switch: cpts: overflow check period 500 (jiffies)
[ 3.394545] cpsw-switch 4a100000.switch: CPTS: ref_clk_freq:250000000 calc_mult:2147483648 calc_shift:29 error:0 nsec/sec
[ 3.394641] cpsw-switch 4a100000.switch: Detected MACID = 80:30:dc:73:a1:00
[ 3.396346] cpsw-switch 4a100000.switch: initialized (regs 0x4a100000, pool size 256) hw_ver:0019010C 1.12 (0)
[ 3.406904] debugfs: Directory '49000000.dma' with parent 'dmaengine' already present!
[ 3.406946] edma 49000000.dma: TI EDMA DMA engine driver
[ 3.426930] hw perfevents: enabled with armv7_cortex_a8 PMU driver, 5 counters available
[ 3.434125] l3-aon-clkctrl:0000:0: failed to disable
[ 3.437415] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 34, base_baud = 3000000) is a 8250
[ 3.437498] printk: legacy console [ttyS0] enabled
[ 4.412267] tps65217-pmic: Failed to locate of_node [id: -1]
[ 4.418320] tps65217-bl: Failed to locate of_node [id: -1]
[ 4.429143] tps65217 0-0024: TPS65217 ID 0xe version 1.2
[ 4.435429] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[ 4.443163] omap_gpio 44e07000.gpio: Could not set line 6 debounce to 200000 microseconds (-22)
[ 4.452029] sdhci-omap 48060000.mmc: Got CD GPIO
[ 4.456993] sdhci-omap 48060000.mmc: supply pbias not found, using dummy regulator
[ 4.467246] sdhci-omap 48060000.mmc: supply vqmmc not found, using dummy regulator
[ 4.475644] sdhci-omap 481d8000.mmc: supply pbias not found, using dummy regulator
[ 4.484081] sdhci-omap 481d8000.mmc: supply vqmmc not found, using dummy regulator
[ 4.498287] clk: Disabling unused clocks
[ 4.530796] mmc1: SDHCI controller on 481d8000.mmc [481d8000.mmc] using External DMA
[ 4.539222] mmc0: SDHCI controller on 48060000.mmc [48060000.mmc] using External DMA
[ 4.548216] VFS: Mounted root (ramfs filesystem) on device 0:16.
[ 4.554655] devtmpfs: error mounting -2
[ 4.560215] Freeing unused kernel image (initmem) memory: 1024K
[ 4.581934] Run /sbin/init as init process
[ 4.586151] Run /etc/init as init process
[ 4.590290] Run /bin/init as init process
[ 4.594458] Run /bin/sh as init process
[ 4.598359] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[ 4.612603] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
2
Answers
You should not be passing
initrd=...
for two reasons. First, as seen in your boot log:So saying it starts at where you loaded it is wrong, it’s not there anymore.
Second, you’re overriding the information that U-Boot is populating in the device tree that says where we relocated the initrd to (and size).
A second, thorough review of your boot log indicates that the unpacking for your initramfs appears to have completed (after all). The following two kernel message would bookend the unpacking operation:
These messages are output from do_populate_rootfs() and free_initrd_mem() in init/initramfs.c.
To replicate some of what you did, I used the fool-proof method of building a compressed initramfs archive with a U-Boot header using Buildroot.
This boot is similar to yours, but with some exceptions:
Buildroot specifies null values for the
Load Address
andEntry Point
of the cpio archive. But U-Boot seems to ignore these values (which are outside the actual RAM address space), and (automatically) relocates this archive (and the DT blob) to high memory, just below the U-Boot executable.I booted with a minimal kernel command line. There is no
root=
parameter because the initramfs is integral to the kernel; it does not have to be specified.Once the initramfs is properly populated, it has precedence over any alternate specification. There is no
rootfstype=
parameter because the initramfs is integral to the kernel; it does not have to be specified. There is noinitrd=
parameter because the initramfs is not (nor uses) a ramdisk.An older, stable kernel version was used, rather than a release candidate version.
This boot does find an executable /init file, as evidenced by the message, and does complete the boot to the login prompt. Whereas your boot does not, as evidenced by the kernel attempting to mount a device for the rootfs and a futile search for an init file/program. The kernel panic you see is irrelevant, and simply the culmination of a futile search that was instigated when the /init was not found in the initramfs.
That’s a vague description.
Based on my experiment and comparison, the cpio archive that you made is suspect.
Suggest you inspect your cpio archive per Documentation/filesystems/ramfs-rootfs-initramfs.rst:
Try re-building the archive using the script provided in that kernel document:
Extract the archive produced by the above script, and compare it to your problematic archive.
Also refer to Documentation/driver-api/early-userspace/buffer-format.rst and
Documentation/driver-api/early-userspace/early_userspace_support.rst.
Addendum
Is this your problem?
The initramfs, per Documentation/filesystems/ramfs-rootfs-initramfs.rst, must contain an /init program (in the root directory).
When that check fails, "the kernel will fall through to the older code to locate and mount a root partition, then exec some variant of /sbin/init".
That seems to describe your failed boot.