0

I'm trying to get my embedded system to run an initramfs. Right now 'init' in this initramfs does nothing but echo a message to test if it is being ran.

My init script:

#!/bin/sh
echo "HELLO INITRAMFS"

My initramfs cpio file contains busybox statically linked. 'init' is located at /init in the filesystem. I first create the cpio archive and then convert it for u-boot.

(find initramfs-test |cpio -o -H newc --quiet) > initramfs.cpio
mkimage -A arm -a 80008000 -e 80008000 -T ramdisk -C none -n uInitrd -d initramfs.cpio ./uInitrd

Placing this uInitrd file with my kernel in a fat partition on an SD card and booting to the u-boot prompt I load both files into memory, set my bootargs and boot.

RIM-U-Boot# fatload mmc 0 0x81000000 uImage
reading uImage
4024775 bytes read in 415 ms (9.2 MiB/s)
RIM-U-Boot# fatload mmc 0 0x85000000 uInitrd
reading uInitrd
1410112 bytes read in 148 ms (9.1 MiB/s)
RIM-U-Boot# setenv bootargs console=${console} root=/dev/ram0 rootfstype=ramfs initrd=0x85000000
RIM-U-Boot# bootm 0x81000000 0x85000000
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   Linux 4.1 + Devicetree
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4024711 Bytes = 3.8 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 85000000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    1410048 Bytes = 1.3 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 4.1.18-ts-armv7l-crown-1.0 (mjohn@vbox) (gcc version 4.8.3 (Timesys 20161024) ) #1 SMP Tue Nov 13 16:40:10 EST 2018
[    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] Machine model: Crown RIM
[    0.000000] cma: Reserved 16 MiB at 0x86800000
[    0.000000] Memory policy: Data cache writeback
[    0.000000] CPU: All CPU(s) started in SVC mode.
[    0.000000] AM335X ES2.1 (neon )
[    0.000000] PERCPU: Embedded 13 pages/cpu @c7c77000 s23296 r8192 d21760 u53248
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 31968
[    0.000000] Kernel command line: console=ttyO3,115200n8 root=/dev/ram0 rootfstype=ramfs initrd=0x85000000
[    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Memory: 91580K/129024K available (7192K kernel code, 871K rwdata, 2580K rodata, 464K init, 8225K bss, 21060K reserved, 16384K cma-reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xc8800000 - 0xff000000   ( 872 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc09935f0   (9774 kB)
[    0.000000]       .init : 0xc0994000 - 0xc0a08000   ( 464 kB)
[    0.000000]       .data : 0xc0a08000 - 0xc0ae1fd0   ( 872 kB)
[    0.000000]        .bss : 0xc0ae4000 - 0xc12ec688   (8226 kB)
[    0.000000] Running RCU self tests
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU lockdep checking is enabled.
[    0.000000]  Additional per-CPU info printed with stalls.
[    0.000000]  RCU restricting CPUs from NR_CPUS=2 to nr_cpu_ids=1.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] IRQ: Found an INTC at 0xfa200000 (revision 5.0) with 128 interrupts
[    0.000000] OMAP clockevent source: timer2 at 24000000 Hz
[    0.000021] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[    0.000052] clocksource timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000118] OMAP clocksource: timer1 at 24000000 Hz
[    0.001261] Console: colour dummy device 80x30
[    0.001339] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.001352] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.001363] ... MAX_LOCK_DEPTH:          48
[    0.001373] ... MAX_LOCKDEP_KEYS:        8191
[    0.001384] ... CLASSHASH_SIZE:          4096
[    0.001393] ... MAX_LOCKDEP_ENTRIES:     32768
[    0.001404] ... MAX_LOCKDEP_CHAINS:      65536
[    0.001414] ... CHAINHASH_SIZE:          32768
[    0.001424]  memory used by lock dependency info: 5167 kB
[    0.001435]  per task-struct memory footprint: 1152 bytes
[    0.001466] Calibrating delay loop... 718.02 BogoMIPS (lpj=3590144)
[    0.108307] pid_max: default: 32768 minimum: 301
[    0.108753] Security Framework initialized
[    0.109015] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.109041] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.113214] Initializing cgroup subsys blkio
[    0.113271] Initializing cgroup subsys memory
[    0.113392] Initializing cgroup subsys devices
[    0.113510] Initializing cgroup subsys freezer
[    0.113689] Initializing cgroup subsys perf_event
[    0.113771] CPU: Testing write buffer coherency: ok
[    0.115776] CPU0: thread -1, cpu 0, socket -1, mpidr 0
[    0.115920] Setting up static identity map for 0x80008280 - 0x800082f0
[    0.126396] Brought up 1 CPUs
[    0.126434] SMP: Total of 1 processors activated (718.02 BogoMIPS).
[    0.126448] CPU: All CPU(s) started in SVC mode.
[    0.131751] devtmpfs: initialized
[    0.178685] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[    0.251639] omap_hwmod: debugss: _wait_target_disable failed
[    0.308946] clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.312216] pinctrl core: initialized pinctrl subsystem
[    0.319501] NET: Registered protocol family 16
[    0.327296] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.330401] cpuidle: using governor ladder
[    0.330444] cpuidle: using governor menu
[    0.347621] OMAP GPIO hardware version 0.1
[    0.379407] omap-gpmc 50000000.gpmc: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_nandflash_pins, deferring probe
[    0.384981] No ATAGs?
[    0.385022] hw-breakpoint: debug architecture 0x4 unsupported.
[    0.385802] omap4_sram_init:Unable to allocate sram needed to handle errata I688
[    0.385826] omap4_sram_init:Unable to get sram pool needed to handle errata I688
[    0.446811] edma 49000000.edma: TI EDMA DMA engine driver
[    0.449438] reg-fixed-voltage fixedregulator@1: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_wl12xx_gpio, deferring probe
[    0.453649] SCSI subsystem initialized
[    0.455728] usbcore: registered new interface driver usbfs
[    0.455982] usbcore: registered new interface driver hub
[    0.456188] usbcore: registered new device driver usb
[    0.479540] tps65910 0-002d: No interrupt support, no core IRQ
[    0.614304] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 100 kHz
[    0.615013] pps_core: LinuxPPS API ver. 1 registered
[    0.615032] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.615109] PTP clock support registered
[    0.620004] Bluetooth: Core ver 2.20
[    0.620170] NET: Registered protocol family 31
[    0.620185] Bluetooth: HCI device and connection manager initialized
[    0.620332] Bluetooth: HCI socket layer initialized
[    0.620370] Bluetooth: L2CAP socket layer initialized
[    0.620592] Bluetooth: SCO socket layer initialized
[    0.624095] Switched to clocksource timer1
[    0.820693] NET: Registered protocol family 2
[    0.823356] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.823542] TCP bind hash table entries: 1024 (order: 3, 36864 bytes)
[    0.824172] TCP: Hash tables configured (established 1024 bind 1024)
[    0.824497] UDP hash table entries: 256 (order: 2, 20480 bytes)
[    0.824757] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[    0.825968] NET: Registered protocol family 1
[    0.828351] RPC: Registered named UNIX socket transport module.
[    0.828381] RPC: Registered udp transport module.
[    0.828394] RPC: Registered tcp transport module.
[    0.828407] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.831337] CPU PMU: Failed to parse /pmu/interrupt-affinity[0]
[    0.831463] hw perfevents: enabled with armv7_cortex_a8 PMU driver, 5 counters available
[    0.838002] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.838313] audit: initializing netlink subsys (disabled)
[    0.838639] audit: type=2000 audit(0.830:1): initialized
[    0.845262] VFS: Disk quotas dquot_6.6.0
[    0.845456] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.847891] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.849171] NFS: Registering the id_resolver key type
[    0.849744] Key type id_resolver registered
[    0.849764] Key type id_legacy registered
[    0.860204] io scheduler noop registered
[    0.860252] io scheduler deadline registered
[    0.860327] io scheduler cfq registered (default)
[    0.863209] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
[    0.867560] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.876098] omap_uart 44e09000.serial: no wakeirq for uart0
[    0.877001] 44e09000.serial: ttyO0 at MMIO 0x44e09000 (irq = 158, base_baud = 3000000) is a OMAP UART0
[    0.879864] omap_uart 48022000.serial: no wakeirq for uart1
[    0.880322] 48022000.serial: ttyO1 at MMIO 0x48022000 (irq = 159, base_baud = 3000000) is a OMAP UART1
[    0.882065] omap_uart 481a6000.serial: no wakeirq for uart3
[    0.882510] 481a6000.serial: ttyO3 at MMIO 0x481a6000 (irq = 160, base_baud = 3000000) is a OMAP UART3
[    1.699898] console [ttyO3] enabled
[    1.705757] omap_uart 481aa000.serial: no wakeirq for uart5
[    1.712068] 481aa000.serial: ttyO5 at MMIO 0x481aa000 (irq = 161, base_baud = 3000000) is a OMAP UART5
[    1.760738] brd: module loaded
[    1.785830] loop: module loaded
[    1.789963] (stk) :sysfs entries created
[    1.800178] mtdoops: mtd device (mtddev=name/number) must be supplied
[    1.874092] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
[    1.880499] davinci_mdio 4a101000.mdio: detected phy mask fffffff5
[    1.894287] libphy: 4a101000.mdio: probed
[    1.898524] davinci_mdio 4a101000.mdio: phy[1]: device 4a101000.mdio:01, driver unknown
[    1.906962] davinci_mdio 4a101000.mdio: phy[3]: device 4a101000.mdio:03, driver unknown
[    1.917029] cpsw 4a100000.ethernet: Detected MACID = d0:ff:50:ab:2d:b7
[    1.927796] PPP generic driver version 2.4.2
[    1.933714] PPP BSD Compression module registered
[    1.938845] PPP Deflate Compression module registered
[    1.945366] usbcore: registered new interface driver cdc_acm
[    1.951296] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[    1.959997] usbcore: registered new interface driver usb-storage
[    1.970707] 47401300.usb-phy supply vcc not found, using dummy regulator
[    1.983582] musb-hdrc musb-hdrc.0.auto: Failed to request rx1.
[    1.990461] musb-hdrc musb-hdrc.0.auto: musb_init_controller failed with status -517
[    2.000788] 47401b00.usb-phy supply vcc not found, using dummy regulator
[    2.012019] musb-hdrc musb-hdrc.1.auto: Failed to request rx1.
[    2.018436] musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -517
[    2.055667] mousedev: PS/2 mouse device common for all mice
[    2.062865] i2c /dev entries driver
[    2.072753] omap_wdt: OMAP Watchdog Timer Rev 0x01: initial timeout 60 sec
[    2.082969] omap_hsmmc 48060000.mmc: Got CD GPIO
[    2.089408] vmmc: supplied by vbat
[    2.139221] ledtrig-cpu: registered to indicate activity on CPUs
[    2.147462] oprofile: using arm/armv7
[    2.151464] Netfilter messages via NETLINK v0.30.
[    2.157069] nf_conntrack version 0.5.0 (1686 buckets, 6744 max)
[    2.164144] ctnetlink v0.93: registering with nfnetlink.
[    2.170652] ipip: IPv4 over IPv4 tunneling driver
[    2.179323] ip_tables: (C) 2000-2006 Netfilter Core Team
[    2.185436] arp_tables: (C) 2002 David S. Miller
[    2.190642] Initializing XFRM netlink socket
[    2.195447] NET: Registered protocol family 17
[    2.200200] NET: Registered protocol family 15
[    2.207048] Bluetooth: RFCOMM TTY layer initialized
[    2.212284] Bluetooth: RFCOMM socket layer initialized
[    2.217831] Bluetooth: RFCOMM ver 1.11
[    2.221818] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    2.227427] Bluetooth: BNEP filters: protocol multicast
[    2.232927] Bluetooth: BNEP socket layer initialized
[    2.238179] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    2.244432] Bluetooth: HIDP socket layer initialized
[    2.249798] BT WLAN Gpio value is :10
[    2.254432] WD Enable Gpio value is :114
[    2.258976] WD Tick Gpio value is :115
[    2.263340] BT_WLAN Gpio value is :10
[    2.267239] WL1271: BT/WLAN Enable
[    2.284032] Voltage translator init complete
[    2.302427] mmc0: host does not support reading read-only switch, assuming write-enable
[    2.310942] WD: Enable
[    2.313464] WD: TICK
[    2.317180] Key type dns_resolver registered
[    2.322818] omap_voltage_late_init: Voltage driver support not added
[    2.329621] sr_dev_init: No voltage domain specified for smartreflex0. Cannot initialize
[    2.338138] sr_dev_init: No voltage domain specified for smartreflex1. Cannot initialize
[    2.348688] ThumbEE CPU extension supported.
[    2.353214] Registering SWP/SWPB emulation handler
[    2.358356] SmartReflex Class3 initialized
[    2.364460] mmc0: new high speed SDHC card at address 0001
[    2.373404] mmcblk0: mmc0:0001 SD32G 29.3 GiB
[    2.384627]  mmcblk0: p1 p2
[    2.399807] omap-gpmc 50000000.gpmc: GPMC revision 6.0
[    2.405715] gpmc_mem_init: disabling cs 0 mapped at 0x0-0x1000000
[    2.416508] nand: device found, Manufacturer ID: 0x01, Chip ID: 0xf1
[    2.423165] nand: AMD/Spansion S34ML01G2
[    2.427383] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    2.435458] nand: using OMAP_ECC_BCH4_CODE_HW ECC scheme
[    2.441305] 8 ofpart partitions found on MTD device 8000000.nand
[    2.447640] Creating 8 MTD partitions on "8000000.nand":
[    2.453212] 0x000000000000-0x000000020000 : "SPL"
[    2.467798] 0x000000020000-0x000000040000 : "SPL.backup1"
[    2.478062] 0x000000040000-0x000000060000 : "SPL.backup2"
[    2.488203] 0x000000060000-0x000000080000 : "SPL.backup3"
[    2.498676] 0x000000080000-0x000000260000 : "U-Boot"
[    2.508970] 0x000000260000-0x000000280000 : "U-Boot Env"
[    2.518872] 0x000000280000-0x000000780000 : "Kernel"
[    2.531256] 0x000000780000-0x000008000000 : "File System"
[    2.610135] musb-hdrc musb-hdrc.0.auto: MUSB HDRC host driver
[    2.617210] musb-hdrc musb-hdrc.0.auto: new USB bus registered, assigned bus number 1
[    2.628376] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    2.635588] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.643149] usb usb1: Product: MUSB HDRC host driver
[    2.648380] usb usb1: Manufacturer: Linux 4.1.18-ts-armv7l-crown-1.0 musb-hcd
[    2.655881] usb usb1: SerialNumber: musb-hdrc.0.auto
[    2.667430] hub 1-0:1.0: USB hub found
[    2.672216] hub 1-0:1.0: 1 port detected
[    2.692454] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    2.698661] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 2
[    2.708020] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[    2.715198] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.722758] usb usb2: Product: MUSB HDRC host driver
[    2.727986] usb usb2: Manufacturer: Linux 4.1.18-ts-armv7l-crown-1.0 musb-hcd
[    2.735499] usb usb2: SerialNumber: musb-hdrc.1.auto
[    2.743553] hub 2-0:1.0: USB hub found
[    2.747851] hub 2-0:1.0: 1 port detected
[    2.877465] hctosys: unable to open rtc device (rtc0)
[    2.882786] sr_init: No PMIC hook to init smartreflex
[    2.888543] sr_init: platform driver register failed for SR
[    2.930249] VFS: Mounted root (ramfs filesystem) readonly on device 0:15.
[    2.937980] devtmpfs: error mounting -2
[    2.943047] Freeing unused kernel memory: 464K (c0994000 - c0a08000)
[    2.950460] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
[    2.964386] ---[ end Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
[   79.333959] random: nonblocking pool is initialized

As you can see the kernel can not find init in the initramfs. Any idea on why? Kernel is 4.1.18 and u-boot is 2013.09.

Thanks

Edit: Reply to jc__ questions:

1. No, no kernel switches in the device tree

2. I've tried setting initrd=/dev/ram0 and I get the same error. I've also tried specifying the init as init=/init and see the following error:

[    2.953050] Freeing unused kernel memory: 464K (c0994000 - c0a08000)
[    2.960261] Kernel panic - not syncing: Requested init /init failed (error -2).
[    2.968092] ---[ end Kernel panic - not syncing: Requested init /init failed (error -2).

3. I'm using a cpio file, so initramfs, but I'm trying to load it separately (not a part of the kernel image) and I'm not sure if an initramfs can work that way. Something I found made it sound like this is possible. My initramfs.cpio filesystem contains a /dev. These modules are currently built into the kernel.

4. I'm not including a initramfs in the kernel image, so it should only include the default.

CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=16384

5. I could include it in my kernel, but it would require addition work. The kernel is built by the Timesys Factory build system, and the initramfs.cpio is built later on.

Reply to sourcejedi

I tried changing it to this:

# setenv bootargs console=${console} root=/dev/ram0 init=/init

And get:

[    2.882766] sr_init: No PMIC hook to init smartreflex
[    2.888519] sr_init: platform driver register failed for SR
[    2.930847] omap_hsmmc 481d8000.mmc: card claims to support voltages below defined range
[    2.946830] List of all partitions:
[    2.950696] 0100           16384 ram0  (driver?)
[    2.955763] 0101           16384 ram1  (driver?)
[    2.960639] 0102           16384 ram2  (driver?)
[    2.965564] 0103           16384 ram3  (driver?)
[    2.970442] 0104           16384 ram4  (driver?)
[    2.975364] 0105           16384 ram5  (driver?)
[    2.980239] 0106           16384 ram6  (driver?)
[    2.985153] 0107           16384 ram7  (driver?)
[    2.990029] 0108           16384 ram8  (driver?)
[    2.994937] 0109           16384 ram9  (driver?)
[    2.999791] 010a           16384 ram10  (driver?)
[    3.004781] 010b           16384 ram11  (driver?)
[    3.009725] 010c           16384 ram12  (driver?)
[    3.014700] 010d           16384 ram13  (driver?)
[    3.019642] 010e           16384 ram14  (driver?)
[    3.024616] 010f           16384 ram15  (driver?)
[    3.029577] b300        30707712 mmcblk0  driver: mmcblk
[    3.035191]   b301            9216 mmcblk0p1 00011b5e-01
[    3.040769]   b302          440320 mmcblk0p2 00011b5e-02
[    3.046421] 1f00             128 mtdblock0  (driver?)
[    3.051727] 1f01             128 mtdblock1  (driver?)
[    3.057074] 1f02             128 mtdblock2  (driver?)
[    3.062380] 1f03             128 mtdblock3  (driver?)
[    3.067723] 1f04            1920 mtdblock4  (driver?)
[    3.073030] 1f05             128 mtdblock5  (driver?)
[    3.078369] 1f06            5120 mtdblock6  (driver?)
[    3.083676] 1f07          123392 mtdblock7  (driver?)
[    3.089006] No filesystem could mount root, tried:  ext3 ext2 ext4 cramfs squashfs vfat msdos
[    3.098220] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
[    3.107068] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

Same thing if I change it to:

# setenv bootargs console=${console} root=/dev/ram0 initrd=/dev/ram0 init=/init

Edit2:

Tried:

# setenv bootargs console=${console} root=/dev/ram0 initrd=0x85000000,2M

And see the same error except I now get

[    2.978095] RAMDISK: Couldn't find valid RAM disk image starting at 0.
[    2.992086] List of all partitions:
[    2.996226] 0100           16384 ram0  (driver?)
[    3.001097] 0101           16384 ram1  (driver?)
[    3.006041] 0102           16384 ram2  (driver?)
[    3.010895] 0103           16384 ram3  (driver?)

Seems like the kernel doesn't see the initramfs at /dev/ram0. Could this be wrong. When u-boot loads the uImage and uInitrd to memory how is /dev/ram0 tied to that address, 0x85000000?

Edit 3:

I've built my initramfs.cpio in my kernel and I'm able to see my echo message. So my initramfs is valid, just not sure what I have wrong while trying to load it externally.

  • 1
    IIRC, the kernel expects the init at /sbin/init unless overridden (just glanced at the source, it also looks for /etc/init or /bin/init by default if a custom location is not defined). Have you tried the kernel boot option init=/init? – GracefulRestart Nov 15 '18 at 19:15
  • 1
    @GracefulRestart I have tried setting init=/init and get the following: Requested init /init failed (error -2) – dangeroushobo Nov 15 '18 at 19:43
  • initrd=/dev/ram0 just looks wrong to me. looking at random searches, have you tried 1) omitting initrd= altogether, since you already specify it as an argument to bootm, or 2) (even more random and desperately) the format initrd=0x85000000,1M or similar? – sourcejedi Nov 15 '18 at 21:41
  • looks like initrd= might not work without the second figure! but, i don't think it would hurt either, if the second argument in bootm was working as it should do. – sourcejedi Nov 15 '18 at 21:50
  • If u use bootm inplace of fatload, does bootm pass the initrd address to the kernel? Then pass root=/dev/root or something close. Thinking out loud.. the initrd=address (with fatload) kernel knows the address now pass root=/dev/something so the kernel will look at the initrd address for a root location. – jc__ Nov 15 '18 at 22:14
0

A few items to look into:

1:

## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   Linux 4.1 + Devicetree

Does the device tree contain kernel switches that may conflict with setenv bootargs console=${console} root=/dev/ram0 rootfstype=ramfs initrd=0x85000000

2:

setenv bootargs console=${console} root=/dev/ram0 rootfstype=ramfs initrd=0x85000000

Does the kernel need the memory address of initrd=0x850000000 or just the dev/ram0 location.

3:

Are you using an initramfs or initrd? Are you compiling the kernel yourself? Does the kernel image already contain an initramfs?

Check these in kernel config:

CONFIG_BLK_DEV_INITRD

CONFIG_INITRAMFS_SOURC

[ 0.131751] devtmpfs: initialized

[ 2.937980] devtmpfs: error mounting -2

Almost looks like devtmpfs is being mounted twice. What mounted it the first time (built in initramfs)? Agree with @sourcejedi comment. No /dev because no rootfs.

Also the kernel is initializing the hardware. Bluetooth, USB, mmc, and more. Unless these modules are compiled into the kernel and not loaded modules they are being loaded from somewhere. (built in initramfs)?

4:

If you are using an initrd instead of initramfs, and the kernel image does not contain a built in initramfs...

I think the kernel config needs:

BLK_DEV_RAM

"If used, modern kernels use /dev/ram0 for an initrd."

./linux-4.x.x/Documentation/blockdev/ramdisk.txt

Would'nt that be initrd=/dev/ram0 and not initrd=0x85000000?

"The old initrd was always a separate file, while the initramfs archive is linked into the linux kernel image."

./linux-4.x.x/Documentation/filesystems/ramfs-rootfs-initramfs.txtramfs-rootfs-initramfs.txt

"The program run by the old initrd (which was called /initrd, not /init) did some setup and then returned to the kernel..."

./linux-4.x.x/Documentation/filesystems/ramfs-rootfs-initramfs.txtramfs-rootfs-initramfs.txt

Should init be /initrd in place of /init?

5:

If you do compile your own kernel, it saves a lot of work on your part to let the kernel make process combine the initramfs into the kernel image.

CONFIG_BLK_DEV_INITRD

CONFIG_INITRAMFS_SOURCE

  • re devtmpfs: nah, looks like it is initialized correctly but cannot mount because errno = 2 - ENOENT - file not found - i.e. no /dev directory because the initramfs was not loaded correctly – sourcejedi Nov 15 '18 at 20:04
  • agree CONFIG_BLK_DEV_INITRD=y is needed for initramfs, that looks critical – sourcejedi Nov 15 '18 at 21:10
  • I believe that CONFIG_BLK_DEV_INITRD=y is required if you want the rootfs (initramfs or initrd) to be part of the kernel image and linked into the kernel image (no need to tell the kernel where rootfs is), otherwise if rootfs is "built" separate then treated as any other block device you must pass the location of root. root=/dev/ram0 or root=/dev/sda1 and so on. Correct? – jc__ Nov 15 '18 at 21:23
  • If CONFIG_BLK_DEV_INITRD=n, then I think root=ram0 will always fail because ram0 will be empty :-P. BLK_DEV_INITRD=n will not build do_mounts_rd.c and hence kernel will not have rd_load_image() – sourcejedi Nov 15 '18 at 21:31
  • "will always fail because ram0 will be empty" Unless you load the cpio file with u-boot? – jc__ Nov 15 '18 at 21:36
0

You don't want rootfstype=ramfs. I am certain. Though AFAICT it is not the real problem.

Mounting ramfs ignores the block device (root=/dev/ram0 in this case). ramfs is not backed by any device file. It is initially empty.

Therefore if rootfstype=ramfs takes effect, it would just mount an empty fs. Hence there would be no init program to run. (It would also generate error 2 = ENOENT = "No such file or directory" when the kernel attempts to mount devtmpfs on /dev, the same as you see in your log).


You show that you are using a new-style initramfs, i.e. a cpio archive instead of a filesystem image. This is good. But then you should get a message like "Unpacking initramfs...", when the kernel detects the new-style format and unpacks it.

The original doc says initramfs should be a gzipped cpio. However i think the current code is also happy with uncompressed cpio.

As you said, you seem to have a problem the kernel does not recognize the initramfs.

At least, initrd_start appears to be 0 when entering populate_rootfs(). If it was non-zero, you would have seen at least one initrd- or initramfs- related message or error.

https://elixir.bootlin.com/linux/v4.1/source/init/initramfs.c#L608

OR, initramfs.c is not even being included in the kernel, because you have not enabled CONFIG_BLK_DEV_INITRD. This is what init/Makefile tells me.

initrd: https://www.kernel.org/doc/html/v4.18/admin-guide/initrd.html

initramfs: https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt

0
RIM-U-Boot# bootm 0x81000000 0x85000000
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   Linux 4.1 + Devicetree
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4024711 Bytes = 3.8 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 85000000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    1410048 Bytes = 1.3 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Something looks wrong here. The load address for the kernel should not overlap the load address for the initrd!

For comparison, see https://community.nxp.com/thread/305045#comment-322873

Recreate the uInitrd using a load address of 0x80408000.

I do not know your hardware. The allocations suggested here should not conflict with each other AFAICT, hopefully they don't conflict with anything else :-).

Do not use the kernel boot options rootfsype=ramfs or root=/dev/ram0. I don't think they should affect your problems whatever you set them to. But they're wrong, so let's do without the distraction. You don't need either of these to boot an initramfs. (My computer boots Linux using an initramfs and does not use either of these boot options!)

You should not need to use initrd=..., because you pass the address as the second option to bootm. (But given the above, the correct value would be initrd=0x80408000,2M, so don't pass any different address!).

0

I met the same situation. I finally realize that the key is the way you create initramfs is not wrong. You MUST cd to the initramfs folder and then create the cpio archive.

The best way to create initramfs.gz is to follow kernels document. there's a handy script in the doc.

  #!/bin/sh

  # Copyright 2006 Rob Landley <rob@landley.net> and TimeSys Corporation.
  # Licensed under GPL version 2

  if [ $# -ne 2 ]
  then
    echo "usage: mkinitramfs directory imagename.cpio.gz"
    exit 1
  fi

  if [ -d "$1" ]
  then
    echo "creating $2 from $1"
    (cd "$1"; find . | cpio -o -H newc | gzip) > "$2"
  else
    echo "First argument must be a directory"
    exit 1
  fi

You don't need root=/dev/ram0 initrd=0x85000000,2M in bootargs at all if you're using initramfs.

Some keys to use initramfs

  1. CONFIG_BLK_DEV_INITRD=y in your kernel config
  2. Use above script to create initramfs.gz
  3. Make sure you have /init executable in your initramfs. You can specify another init process via rdinit=/bin/sh in bootargs
  4. If you're using u-boot to load initramfs.gz, make sure you initramfs.gz is uImage format
  5. Pass the right address from u-boot cmd bootm <kernel addr> <initramfs/ramdisk addr> <dtb addr>
0

There are two "inits" involved when you use a initrd:

rdinit=/init and init=/sbin/init (default values)

The first (rdinit=) tells early userspace what to run after the kernel has unpacked and mounted the initrd. Default is /init.

WITHOUT initrd, the second (init=) tells the kernel which init to run (just like root= tells the kernel which device to mount as /)

WITH a initrd, init= is used by switchroot at the end of early userspace to not only mount the new, real root, but to also run the real /sbin/init - or whatever you want: init=/sbin/test_init

(/init does not have to lead to a switchroot though; you can stay in initrd forever...embedded style)

I fully agree with Charles, the only one to mention rdinit=:

Make sure you have /init executable in your initramfs. You can specify another init process via rdinit=/bin/sh in bootargs

rdinit=/init and init=/init must also be possible, they are different files: the first "/" means top of your initrd (your cpio), the second "/" means top of root= aka newroot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.