[uClinux-dev] Start files from initramfs

Frank Mölendörp frank.moelendoerp at ewetel.net
Sat May 29 07:48:46 EDT 2010


Hi all,

i have read a lot about the kernel starting process and decide to put 
all the programs to the initramfs.
So I mount the romfs.img, which is created with
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnuebi-
and set this new path to CONFIG_INITRAMFS_SOURCE
and recompile the kernel with:
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnuebi-
So I get the image vmlinux.
I load this file to the flash and start the kernel and get the following 
output
(the bootloader will copy it to the memory position 0x10008000):
---------------------8<---------------------8<---------------------8<---------------------8<---------------------8<
Linux version 2.6.33-arm1rc2 (quotrader at ubuntu) (gcc version 4.4.1 
(Sourcery G++ Lite 2010q1-202) ) #35 Sat May 29 12:03:26 CEST 2010
CPU: ARMv7-M Processor [410fc240] revision 0 (ARMv?(11)M)
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: ARM MPS
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 1016
Kernel command line: root=/dev/ram0 init=/bin/sh console=ttyAMA3 mem=4M 
earlyprintk
bootconsole [earlycon0] enabled
PID hash table entries: 16 (order: -6, 64 bytes)
Dentry cache hash table entries: 1024 (order: 0, 4096 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 4MB = 4MB total
Memory: 2460k/2460k available, 1636k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0x00000000 - 0x00001000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0x00000000 - 0xffffffff   (4095 MB)
    lowmem  : 0x10000000 - 0x10400000   (   4 MB)
    modules : 0x10000000 - 0x10400000   (   4 MB)
      .init : 0x10008000 - 0x100ff000   ( 988 kB)
      .text : 0x100ff000 - 0x1017f000   ( 512 kB)
      .data : 0x10188000 - 0x10190920   (  35 kB)
Hierarchical RCU implementation.
NR_IRQS:32
Calibrating delay loop... 33.07 BogoMIPS (lpj=165376)
Mount-cache hash table entries: 512
Serial: AMBA PL011 UART driver
dev:uart0: ttyAMA0 at MMIO 0x40006000 (irq = 6) is a AMBA/PL011
dev:uart1: ttyAMA1 at MMIO 0x40007000 (irq = 7) is a AMBA/PL011
dev:uart2: ttyAMA2 at MMIO 0x40008000 (irq = 8) is a AMBA/PL011
fpga:uart3: ttyAMA3 at MMIO 0xdfff5000 (irq = 30) is a AMBA/PL011
console [ttyAMA3] enabled, bootconsole disabled
console [ttyAMA3] enabled, bootconsole disabled
Switching to clocksource timer3
ARMv7-M VFP Extension supported
Freeing init memory: 988K
Failed to execute /init
Failed to execute /bin/sh.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to 
kernel.
[<1010201d>] (unwind_backtrace+0x1/0x80) from [<1015a7f3>] (panic+0x33/0xc4)
[<1015a7f3>] (panic+0x33/0xc4) from [<100ff38d>] (init_post+0x8d/0xb4)
[<100ff38d>] (init_post+0x8d/0xb4) from [<100083c9>] (kernel_init+0x91/0xbc)
[<100083c9>] (kernel_init+0x91/0xbc) from [<100fff55>] 
(kernel_thread_exit+0x1/0x6)
--------------------->8--------------------->8--------------------->8--------------------->8--------------------->8

The line "Fail to execute /init" appears only when the file init is in 
the root of initramfs. So I can say, that
initramfs is really loaded and the files are available. I think that the 
"ÿ" is some output created by the script
/init. I set the flag, that this file is executable and tried different 
content of this file:
- Simply to test, an unmodifed version of: 
http://www.sourcemage.org/HowTo/Initramfs
- a absolute minimal content:
---------------------8<---------------------8<---------------------8<---------------------8<---------------------8<
#! /bin/sh
# sh is sash.
echo "Hello World"
/bin/sh
--------------------->8--------------------->8--------------------->8--------------------->8--------------------->8
- and other different minimal scripts

I used also a minimal configuration for the initramfs as described at 
linux-2.6.33/Documentation/ramfs-rootfs-initramfs.txt.
---------------------8<---------------------8<---------------------8<---------------------8<---------------------8<
  dir /dev 755 0 0
  nod /dev/console 644 0 0 c 5 1
  nod /dev/loop0 644 0 0 b 7 0
  dir /bin 755 1000 1000
  slink /bin/sh busybox 777 0 0
  file /bin/busybox initramfs/busybox 755 0 0
  dir /proc 755 0 0
  dir /sys 755 0 0
  dir /mnt 755 0 0
  file /init initramfs/init.sh 755 0 0
--------------------->8--------------------->8--------------------->8--------------------->8--------------------->8

The .config of the kernel contains the following settings:
---------------------8<---------------------8<---------------------8<---------------------8<---------------------8<
CONFIG_BLK_DEV_INITRD=y
CONFIG_BLK_DEV_RAM=y
CONFIG_INITRAMFS_SOURCE="../../romfs"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_INITRAMFS_COMPRESSION_NONE=y
--------------------->8--------------------->8--------------------->8--------------------->8--------------------->8

So I decided to analyze the executable files:
vmlinux is placed in 0x10000000 which is the right memory address 
(0x10000000 to 0x10040000 is sram)
The other programms are placed at 0x00000000. This area is flash and the 
kernel is not able to write to this region.
Maybe that this is the answer. But may also that it's relocating the 
programs.
However, I don't know to get the programs the right memory address.

I also tried different commandlines. But with out seeing any effect. 
root doesn't change anything. initrd sets the absolute
address of the romfs.img. But also when I don't give this parameter 
nothing will change. I tried also thinks like retain_initrd
and keepinitrd, also without any success.
When initrd is set to the right flash address, the following message 
appears:
---------------------8<---------------------8<---------------------8<---------------------8<---------------------8<
INITRD: 0x19200000+0x000eb000 extends beyond physical memory - disabling 
initrd
Kernel command line: root=/dev/rom0 initrd=0x19200000,940K 
init=/bin/init console=ttyAMA3 mem=4M earlyprintk
--------------------->8--------------------->8--------------------->8--------------------->8--------------------->8

I hope that someone could say that some of this right or wrong. It will 
really helps when someone could say:
Yes, this line is absolute ok or not. Or even, when someone has tip for 
me, to figure out what is wrong.

Thanks for every help!

Regards,

Frank



More information about the uClinux-dev mailing list