Busybox is a solution for embedded Linux designs that need a compact filesystem: the trick is compiling and linking many system utilities into a single binary that behaves differently based on the name it was used to execute it. A working Linux root filesystem then consists in a small directory tree (/bin
, /sbin
, /usr/bin
, …), a single executable binary in /bin/busybox
, and many symbolic links to the Busybox binary (/bin/ls
, /bin/sh
, /sbin/ifconfig
, …), and using a typical configuration it can be as small as 2MB (1MB if compressed).
Last time I compiled a Linux kernel and a minimal root filesystem containing just a “Hello World” program. Now we can build a reasonably working root filesystem and test it using QEMU. Note that, in order to follow this example, you need:
- The CodeSourcery Linux toolchain
- A Linux kernel image compiled for the Versatile platform, with EABI support (here is how I created mine)
- QEMU ARM emulator (the package to install is
qemu
on Debian orqemu-kvm-extras
on Ubuntu) - Developer’s libraries for ncurses (the package to install is
libncurses5-dev
) to compile the menu configuration
I downloaded version 1.16.0 of the Busybox source and extracted it. Inside the extracted directory I ran:
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- defconfig
A default configuration file is created. To change it to our needs:
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
I checked the option to compile Busybox as a static executable, so that we don’t have to copy the dynamic libraries inside the root filesystem. The setting can be found in “Busybox Settings --> Build Options
“. Then, the following command builds Busybox and creates a directory called _install
containing the root filesystem tree:
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install
We can now create a root filesystem image using the cpio
tool, and in order to compact the filesystem even more, we can run gzip
on it to create a compressed image:
$ cd _install $ find . | cpio -o --format=newc > ../rootfs.img $ cd .. $ gzip -c rootfs.img > rootfs.img.gz
In my case, the compressed image size is about 1MB. To test Busybox, we can emulate an ARM platform with QEMU using the following command, assuming we copy the Linux kernel zImage
in the current directory:
$ qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/bin/sh"
The Linux kernel will boot, and the shell /bin/sh
will be executed as specified by the boot parameter rdinit
, showing the common “#
” prompt. The shell can be used normally, for example you can run ls
to find the same directory structure of the Busybox _install
directory, but using commands like ps
and mount
we can see that not everything is in place: both programs complain abount the /proc
directory. We can create and populate the /proc
directory running these commands inside the QEMU emulated system prompt:
# mkdir /proc # mount -t proc none /proc
After that, the ps
and mount
programs work fine. We can also note that the /dev
directory is almost empty (the only exception being the console
device). To populate it we need to mount also the /sys
directory, so that we can use the mdev
tool; run inside QEMU:
# mkdir /sys # mount -t sysfs none /sys # mdev -s
The /sys
and /dev
directory are now populated. To execute these steps every time, we can use /sbin/init
functionality: this program is usually the first run by the Linux kernel, and its default behavior is to execute the initialization file with path /etc/init.d/rcS
. In the host computer this time, in the folder where we compiled Busybox, we create the missing directories:
$ cd _install $ mkdir proc sys dev etc etc/init.d $ cd ..
Now we create a new _install/etc/init.d/rcS
with the following content:
#!/bin/sh mount -t proc none /proc mount -t sysfs none /sys /sbin/mdev -s
Then set it as an executable file:
$ chmod +x _install/etc/init.d/rcS
We can then recreate an updated root filesystem compressed image as before, and run:
$ qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/sbin/init"
The Linux kernel will boot again, but this time it is asking to press Enter, and when we do the usual console prompt will appear. The system directories are fully populated, meaning that the script rcS
has been executed; other than that, /sbin/init
also spawns shell terminals using getty
.
In our example the Busybox filesystem is accessed using a ram disk, but it can also be read from a physical disk storage or loaded from the network using NFS protocol. Maybe another time I will describe in details how to run Busybox with NFS inside QEMU.
gilsken
2010/08/22
Hi,
I am working on a zImage that includes the initramfs. I’ve succeeded in extracting the rootfs and modifying the init.rc. But I dont know if it possible to reinject this new rootfs inside the same kernel and get a new zImage.
Do you think that is possible to do that ?
Thank.
Balau
2010/08/23
I don’t know if I understood correctly, but I think it can be done by recompiling the kernel while using CONFIG_INITRAMFS_SOURCE. This option should point to the extracted rootfs directory that you modified, then you “make” the kernel again and it will include the initramfs in the compressed kernel image (zImage). More information here. I don’t think it can be done without recompiling the kernel.
seubz
2010/11/04
Great tutorial !
I had issues with the execution of the rcS script as it was not executable. You might want to add the “chmod +x _install/etc/init.d/rcS” command in there.
Balau
2010/11/04
You’re right, thanks! I added the command to the post.
Adithya
2011/02/18
Hai
I m using ubuntu and when i type the command:
qemu-system-arm -M versatilepb -m 128M -nographic -kernel zImage -initrd rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh”
I get “Uncompressing Linux …. Booting Kernel” and it stops. But if i remove the filesystem, it boots normally and stops at finding the nfs:
qemu-system-arm -M versatilepb -m 128M -nographic -kernel zImage
I get some boot messages and it stops with:
Sending DHCP requests ., OK
IP-Config: Got DHCP answer from 10.0.2.2, my address is 10.0.2.15
IP-Config: Complete:
device=eth0, addr=10.0.2.15, mask=255.255.255.0, gw=10.0.2.2,
host=10.0.2.15, domain=, nis-domain=(none),
bootserver=10.0.2.2, rootserver=10.1.69.3, rootpath=
Looking up port of RPC 100003/2 on 10.1.69.3
rpcbind: server 10.1.69.3 not responding, timed out
Root-NFS: Unable to get nfsd port number from server, using default
Looking up port of RPC 100005/1 on 10.1.69.3
rpcbind: server 10.1.69.3 not responding, timed out
Root-NFS: Unable to get mountd port number from server, using default
Why are the boot meassages not being displayed when i try to mount a rootfs. Can u plz help me out !!!
Balau
2011/02/19
Hello,
it seems the messages are redirected to another console. Try to use “-append “root=/dev/ram rdinit=/bin/sh console=ttyAMA0” instead of your first command, or remove “-nographic” and see what happens in the window that opens.
In my case I don’t boot from NFS, if you check the “CONFIG_CMDLINE” inside your kernel “.config” file it probably contains the commands to boot from NFS, and maybe it contains an option to redirect the console to the serial port ttyAMA0.
sid
2011/03/10
very interesting articles .. I had these thoughts in my mind … to exploit qemu playing around with linux kernel … and your article helped me do so 🙂
Adithya
2011/03/22
Hi,
1) I am not able automate the procedure of populating the proc and sys folders. I dont think rcS is being executed during the bootup. Although I do get the empty directories for proc and sys.
2) Can we add “/var/log/messages” also ?
Thanks in Advance
Balau
2011/03/23
1) Are you sure you set the file as an executable before creating the root filesystem image? If you are, then you can add “echo” messages to rcS file to debug and see what points are executed. Do you see some error messages when the kernel launches init?
2) I think it should be easy to do because busybox also implements “syslogd”, it should be a matter of creating the directory “/var/log”, and launching the daemon “syslogd” from the rcS file, but I never tried it myself. Keep in mind that the root filesystem image in my blog post is a ram disk, so any changes to it will be lost when you close the emulator.
Adithya
2011/03/23
Hai Balau,
1) Yes i do get this error just before the /# prompt during boot.
“/bin/sh: can’t access tty; job control turned off”
2) I want to have the emulated system to have networking capabilities. But when i try to ping other systems in the network, it doesnt work. When i do “cat /proc/interrupts”, I find the no. interrupts corresponding to “eth0” is very low and constant (6,7 or 8). How can make sure that the emulated system has network capabilites ???
Thanks in Advance!!
Regards,
Adithya
Balau
2011/03/26
1) can you check that you don’t have a file such as
/etc/inittab
that overrides the default/sbin/init
behavior? Also, are you sure that/sbin/init
is the first executable that is run by the kernel? That “job control turned off” error appears to me when I am passing “rdinit=/bin/sh
” in the kernel parameters.2) I am not an expert at setting up networking with busybox. I tried executing “ifconfig eth0 10.0.2.15” and “route add default gw 10.0.2.1” and the guest QEMU network works, but DNS and external access don’t work. See also this post to set up some networking using kernel parameters.
Adithya
2011/04/15
In the above comment of yours:
“I think it should be easy to do because busybox also implements “syslogd”, it should be a matter
of creating the directory “/var/log” ”
1) How could you map syslogd to /var/log ?
2) How could you tell that syslogd was implemented by qemu ?
Thanking You
Regards,
B. Adithya
Balau
2011/04/17
The default behavior of syslogd should be to output messages to “/var/log/messages”. To change this behavior, call it with different available options.
It’s not QEMU that implements syslogd, it’s Busybox. The list of utilities implemented by Busybox is here; if it’s not compiled by default, it must be enabled with, for example “make menuconfig” before compiling Busybox.
bskumar7080
2011/07/07
HI balau,
I am very confused in using QEMU , Is it possible to boot kernel build with other configuration than versatile. How to create a initial ramdisk and root file system to boot in qemu. Can i known in detail about
append “root=/dev/ram rdinit=/sbin/init”
how to give root= when we build our own root file system
Balau
2011/07/10
Most of the information you need are written in the Linux kernel source. If you download it from kernel.org and then extract it, you can find that:
It is possible to build and boot Linux with other configurations, they are listed in “arch/arm/configs/”
More information on ramdisks and “init” is present in “Documentation/blockdev/ramdisk.txt”, “Documentation/initrd.txt” and “Documentation/init.txt”
Other details on kernel parameters are in “Documentation/kernel-parameters.txt”
Karthik
2011/08/04
Hi,
I would like to establish an ” ssh ” connection between busybox in qemu and the host(ubuntu 11.04).I tried the wget command to get the latest version of dropgear but cant install it.
Kindly help me ….
Rrgards Karthik
Balau
2011/08/04
I have yet to find a reliable and simple way to setup network with DNS on Busybox in QEMU.
Other than that, I never tried to use ssh. Busybox already provides telnet so you could try to run a simple telnetd on the host to troubleshoot networking.
I don’t know what you tried with DropBear, but I think the most straightforward way is to cross-compile it (on the host) into a static binary and put it in the root filesystem image together with busybox before creating the cpio archive.
Karthik
2011/08/05
Thanks…
I’ve successfully installed ubuntu-arm in qemu and by using ssh i was able to access the files in ma host pc.I was wondering if i could do the same in busybox….
Anyway i’ll try telnet…
Regards
Karthik
Somesh
2011/09/20
Excellent documentation and explanation of the steps. Could boot Linux (using steps from Balau’s other posts) along with the rootfs prepared from above procedure.
Wrote a character driver for PL011 uart while emulating on versatilepb and work with a sample application.
mike
2011/09/29
Hi ,
i am trying to build the initramfs into the kernel,so that i don’t need the initrd kernel parameter while booting.I read through the answer given by u also referred to the link http://processors.wiki.ti.com/index.php/Initrd and tried the following.
i) Compiled the the busybox and created the contents of the _install folder to be as the rootfs.cpio.gz. with the soft link called init to the /bin/busybox (as specified by the link )
ii) Created default config,and in menuconfig,in the CONFIG_INITRAMFS_SOURCE, gave the absolute path of the rootfs.cpio.gz.
iii) Bompiled the kernel
iv) Booted the kernel with the command.
qemu-system-arm -M versatilepb -m 128M -kernel zImage -append “console=ttyAMA0 ” -serial stdio
And i get the below as my output..
Uncompressing Linux… done, booting the kernel.
Linux version 3.0.0 (mike@mike-OptiPlex-380) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41) ) #5 Thu Sep 29 16:17:32 IST 2011
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile PB
Memory policy: ECC disabled, Data cache writeback
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956ms
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: console=ttyAMA0
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 125216k/125216k available, 5856k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 – 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 – 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 – 0xffe00000 ( 2 MB)
vmalloc : 0xc8800000 – 0xd8000000 ( 248 MB)
lowmem : 0xc0000000 – 0xc8000000 ( 128 MB)
modules : 0xbf000000 – 0xc0000000 ( 16 MB)
.init : 0xc0008000 – 0xc0134000 (1200 kB)
.text : 0xc0134000 – 0xc045d150 (3237 kB)
.data : 0xc045e000 – 0xc047a340 ( 113 kB)
.bss : 0xc047a364 – 0xc04941b0 ( 104 kB)
NR_IRQS:192
VIC @f1140000: id 0x00041190, vendor 0x41
Console: colour dummy device 80×30
Calibrating delay loop… 329.31 BogoMIPS (lpj=1646592)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a PL011 rev1
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a PL011 rev1
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a PL011 rev1
fpga:09: ttyAMA3 at MMIO 0x10009000 (irq = 38) is a PL011 rev1
bio: create slab at 0
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 244
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
clcd-pl11x dev:20: PL110 rev0 at 0x10120000
CLCD: unknown LCD panel ID 0x00001000, using VGA
clcd-pl11x dev:20: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80×60
brd: module loaded
physmap platform flash device: 04000000 at 34000000
physmap-flash physmap-flash.0: map_probe failed
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
eth0: SMC91C11xFD (rev 1) at c8800000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
mousedev: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
Warning: unable to open an initial console.
Freeing init memory: 1200K
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1
and it hangs with this
Any suggestions please
thanks
mike
Balau
2011/09/29
I think you should point CONFIG_INITRAMFS_SOURCE to the _install directory, not to the gz file.
Also, try to see if adding the “root=/dev/ram rdinit=/sbin/init” options change something (maybe use “/dev/ram0” if you created that device, I’m not sure about that).
Mark
2011/12/06
I’ve followed your tutorials from the bare metal hello world to this one, and they have been _so_ helpful. I’ve been struggling to find a good source of answers to all of the million things that seem to go wrong, and you have managed to answer almost all of the questions I had about cross compiling for arm and Linux. You are the man!
tanaka
2012/02/04
Balau,
I added the flash support to versatilepb board. The flash address is 0x34000000.
How can I create an booting image? I tried following, but it failed.
dd if=/dev/zero of=flash.img bs=256k count=256
dd if=u-boot.bin of=flash.img bs=256k conv=notrunc
dd if=uImage of=flash.img bs=256k seek=2 conv=notrunc
dd if=roofs.img.gz of=flash.img bs=256K seek=8 conv=notrunc
qemu-system-arm -M versatilepb -m 200 -nographic -pflash flash.img
After this command, there was an error:
qemu: fatal: Trying to execute code outside RAM or ROM at 0xffff0844
R00=fffcdf70 R01=ffff0000 R02=00000000 R03=00028250
R04=ffff0000 R05=fffcdf70 R06=ffff0000 R07=00000000
R08=008fff78 R09=fffe0000 R10=00028250 R11=00000000
R12=008ffff0 R13=fffcdf60 R14=ffff0844 R15=ffff0844
PSR=600001d3 -ZC- A svc32
Aborted
Look like the QEMU can not find my kernel. All the binary files are taken from this example, and it works with non-flash mode. But when putting them to image, it did not work. What I did incorrect here?
Thank you very much!
Balau
2012/02/04
I don’t know exactly what could be the problem. If you run QEMU adding the following options: “
-d in_asm,cpu -D qemu.log -singlestep
“, it will dump a log file (qemu.log) containing state of the CPU and the instructions during guest execution. Maybe it gives you some hints about where the code jumps to that wrong location.eng trojan
2012/02/10
I checked the option to compile Busybox as a static executable, so that we don’t have to copy the dynamic libraries inside the root filesystem. The setting can be found in “Busybox Settings –> Build Options“. Then, the following command builds Busybox and creates a directory called _install containing the root filesystem tree:
view source
print?
1 $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install
But i cannot found the _install directory
what is this error ?
and sorry for my bad english 🙂
Balau
2012/02/10
When you run “make … install” Busybox should create a new “_install” directory in the same directory where you run “make”, that contains the Busybox source code.
You can also find it in the configuration: “Busybox Settings -> Installation Options -> Busybox intallation prefix”
If it doesn’t create “_install”, it probably encountered an error in compilation, you should check the last error lines that “make” prints when you run it.
eng trojan
2012/02/10
it done good but i have rootfs.img.gz about 107 byte and rootfs.img about 512 byte and put them beside zimage and run the command
qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh”
and i found error in qemu
it give me a lot of texts at last of it
INFO: RCU DETECTED CPU 0 STALL (t=1000 Jifiles)
***********************************
finally i`m trying to build os for arm 2440 to make ip phone as graduation in my faculty and until now i did with your explains some good steps like zimage and i released 1.5 m and now this is the second step (busybox) but until now i do not make rfs
i need the right steps to make my aim please
and thanx alot for caring
and best wishes from me from Egypt and my friends 🙂
eng trojan
2012/02/11
i found my fault and the kernel and busybox work very good but now i want to display hello word when the system open so where can i put it ?
Balau
2012/02/11
When the kernel boots, the first program that is executed is Busybox’s “
/sbin/init
“, which executes “/etc/init.d/rcS
“.So you can put in “
_install/etc/init.d/rcS
” what you want, for example “echo hello world
” to display a message at boot.chandan
2012/02/19
I ran the following command:
qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh”
and I got the result:
VNC server running on `127.0.0.1:5900′
and terminal got hanged.
Balau
2012/02/19
I think QEMU has been compiled without SDL graphic libraries, so it can’t display the window and the fallback is to open a VNC connection that displays the same window.
If you got QEMU through your distribution, already compiled, it means there’s a bug in the package and you have to compile it yourself or wait for the fix.
If you compiled QEMU yourself, you need to re-compile it with SDL. It means you have to install the “libsdl…” package, which for example in Debian is called “libsdl1.2-dev”. When you install it you can compile QEMU with graphic support, so that when you run “./configure” in QEMU directory it should give you a line with “SDL support yes”.
halim
2012/03/18
hi balau
i need to make yaffs rootfs from busybox
i got with my kit mkyaffs2image-128M and i copied it to usr/bin
and i need the command to make this yaffs rootfs
Balau
2012/03/18
I never used yaffs, so I can’t help you. Maybe this link can give some pointers:
http://www.yaffs.net/howto-incorporate-yaffs-linux
If I understand correctly it seems that you have to create these “blocks”, add block numbers in their oob areas and put them together, maybe by concatenating them, in order to create a single binary image of the flash.
james lin
2012/03/24
Hi, Balau:
First, I want to thank you for such great detail tutorials and it’s free.
I follow your busybox tutorial using busybox-1.19.4 (because I ran into sysinfo redefinition problem on 1.16.0) and more recent sourcery eabi/gnueabi toolchains (2011.09).
Run the following command.
qemu-system-arm -M versatilepb -m 128M -nographic -kernel linux-2.6.33/arch/arm/boot/zImage -initrd rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh console=ttyAMA0”
I got the following mounting errors:
List of all partitions:
No filesystem could mount root, tried: ext2 cramfs minix vfat romfs
Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
[] (unwind_backtrace+0x0/0xcc) from [] (panic+0x3c/0x114)
[] (panic+0x3c/0x114) from [] (mount_block_root+0x1bc/0x1fc)
[] (mount_block_root+0x1bc/0x1fc) from [] (prepare_namespace+0x164/0x1b8)
[] (prepare_namespace+0x164/0x1b8) from [] (kernel_init+0xd8/0x104)
[] (kernel_init+0xd8/0x104) from [] (kernel_thread_exit+0x0/0x8)
INFO: RCU detected CPU 0 stall (t=1000 jiffies)
However, the following command is working for Hello World tutorial.
qemu-system-arm -M versatilepb -m 128M -kernel linux-2.6.33/arch/arm/boot/zImage -initrd rootfs.gz -append “root=/dev/ram rdinit=/test”
Also
file rootfs.img
rootfs.img: ASCII cpio archive (SVR4 with no CRC)
file rootfs.img.gz
rootfs.img.gz: gzip compressed data, was “rootfs.img”, from Unix, last modified: Sun Mar 25 05:21:18 2012
What can go wrong?
Thank you again.
James
Balau
2012/03/25
In my environment, if I give the wrong rootfs, I get the following errors in the messages:
…
Trying to unpack rootfs image as initramfs…
rootfs image is not initramfs (junk in compressed archive); looks like an initrd
…
RAMDISK: Couldn’t find valid RAM disk image starting at 0.
List of all partitions:
No filesystem could mount root, tried: ext2 cramfs minix vfat romfs
Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
[] (unwind_backtrace+0x0/0xd8) from [] (panic+0x40/0x118)
[] (panic+0x40/0x118) from [] (mount_block_root+0x1c8/0x208)
[] (mount_block_root+0x1c8/0x208) from [] (prepare_namespace+0x160/0x1b8)
[] (prepare_namespace+0x160/0x1b8) from [] (kernel_init+0xd8/0x10c)
[] (kernel_init+0xd8/0x10c) from [] (kernel_thread_exit+0x0/0x8)
Do you have the same messages aside from what you already reported? if so, somehow the rootfs archive is corrupted.
$ gunzip -c rootfs.img.gz |cpio -t
.
usr
usr/bin
usr/bin/last
…
sbin/poweroff
sbin/logread
sbin/fbsplash
3720 blocks
Also, if you go in “_install/bin/” from busybox source dir, check that the busybox binary has an ARM architecture and is statically linked. Mine is:
$ file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.18, BuildID[sha1]=0x0d1bdad0b9aaf8f2ab07d697ceee56a3a787e579, stripped
Geoffrey
2012/04/10
Hello Balau,
Thanks for the great how. I have followed the tutorial and its clear and well explained.
I am having a difficult in having the Busybox ramfs and Linux running in Qemu. The kernel boots upto the following line “VFP suppot v0.3: implemento 41 architecture 1 part 10 variant 9 rev 0” and remains stuck ther. The shell does not load.
When I run it on the Board the message on the serial port reads “/bin/sh can’t access tty: job control turned off” and remain stuck at the same point.
Thank you
Geoffrey
Balau
2012/04/10
It is maybe difficult to see that the shell is loaded because of the boot messages, but after hitting “Enter” three or four times I see the “#” prompt below the kernel messages. Check if it’s your case too.
The board message “/bin/sh can’t access tty…” is a good sign because it means the root filesystem has been created correctly and Linux is able to execute /bin/sh so busybox has been compiled correctly. The message is expected and harmless.
You can try to add “-serial stdio” to QEMU options and to append “console=ttyAMA0” to kernel parameters: it should give you the boot messages and the shell prompt on the terminal (emulated serial port) instead of inside the window. See if something changes in this way.
sudhesh
2012/04/11
Dear Balau,
I want to thank you for such nice tutorial.
I am facing some issue while bringing the qemu up with linux2.6.33 kernel + busybox1.16.0. Could you please guide me to resolve this issue?
qemu is coming up properly when i follow the same steps with linux2.6.28 kernel + busybox1.16.0
Successful log 😦 linux2.6.28 kernel + busybox1.16.0):
Uncompressing Linux……………………………………………………………………………. done, booting the kernel.
Linux version 2.6.28 (root@centlogic) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #3 Sun Apr 1 15:52:14 IST 2012
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile PB
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024
Kernel command line: root=/dev/ram rdinit=/sbin/init console=ttyAMA0
PID hash table entries: 1024 (order: 10, 4096 bytes)
Console: colour dummy device 80×30
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 256MB = 256MB total
Memory: 233088KB available (2484K code, 218K data, 104K init)
Calibrating delay loop… 186.36 BogoMIPS (lpj=931840)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 288 bytes
NET: Registered protocol family 16
NET: Registered protocol family 2
IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP reno registered
NET: Registered protocol family 1
checking if image is initramfs… it is
Freeing initrd memory: 23650K
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 502
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
sudhesh: amba_driver_register called
CLCD: unknown LCD panel ID 0x00001000, using VGA
CLCD: Versatile hardware, VGA display
Clock CLCDCLK: setting VCO reg params: S=1 R=99 V=98
Console: switching to colour frame buffer device 80×60
Serial: sudhesh: AMBA PL011 UART driver
sudhesh: amba_driver_register called
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
fpga:09: ttyAMA3 at MMIO 0x10009000 (irq = 38) is a AMBA/PL011
brd: module loaded
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
eth0: SMC91C11xFD (rev 1) at d08d6000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
sudhesh: amba_driver_register called
mice: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
Freeing init memory: 104K
input: AT Raw Set 2 keyboard as /class/input/input0
Please press Enter to activate this console. input: ImExPS/2 Generic Explorer Mouse as /class/input/input1
# ls
bin lib root sys
dev linuxrc rootfs.img.gz usr
etc proc sbin work
#
Failure log (linux2.6.33 kernel + busybox1.16.0):
Uncompressing Linux… done, booting the kernel.
Linux version 2.6.33 (root@pcb-sepuralab) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #2 Tue Apr 10 22:30:08 IST 2012
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile PB
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024
Kernel command line: root=/dev/ram rdinit=/sbin/init console=ttyAMA0
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 256MB = 256MB total
Memory: 232832KB available (2808K code, 229K data, 112K init, 0K highmem)
Hierarchical RCU implementation.
RCU-based detection of stalled CPUs is enabled.
NR_IRQS:192
VIC @f1140000: id 0x00041190, vendor 0x41
Console: colour dummy device 80×30
Calibrating delay loop… 181.86 BogoMIPS (lpj=909312)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
fpga:09: ttyAMA3 at MMIO 0x10009000 (irq = 38) is a AMBA/PL011
bio: create slab at 0
Advanced Linux Sound Architecture Driver Version 1.0.21.
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs…
Freeing initrd memory: 23648K
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 501
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
CLCD: unknown LCD panel ID 0x00001000, using VGA
CLCD: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80×60
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
brd: module loaded
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
eth0: SMC91C11xFD (rev 1) at d0800000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
mmc0: MMCI rev 0 cfg 00 at 0x0000000010005000 irq 22,33
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
Freeing init memory: 112K
Kernel panic – not syncing: Attempted to kill init!
Backtrace:
[] (dump_backtrace+0x0/0x110) from [] (dump_stack+0x18/0x1c)
r6:cf815c40 r5:00000004 r4:c02fdc44
[] (dump_stack+0x0/0x1c) from [] (panic+0x48/0x124)
[] (panic+0x0/0x124) from [] (do_exit+0x74/0x5d0)
r3:c02e9ac8 r2:cf821e30 r1:00000001 r0:c02bbad8
[] (do_exit+0x0/0x5d0) from [] (do_group_exit+0x94/0xc8)
r7:cf819e40
[] (do_group_exit+0x0/0xc8) from [] (get_signal_to_deliver+0x2fc/0x338)
r4:0830009f
[] (get_signal_to_deliver+0x0/0x338) from [] (do_signal+0x70/0x5ec)
[] (do_signal+0x0/0x5ec) from [] (do_notify_resume+0x20/0x54)
[] (do_notify_resume+0x0/0x54) from [] (work_pending+0x1c/0x20)
r4:bedafbf0
INFO: RCU detected CPU 0 stall (t=1000 jiffies)
Balau
2012/04/11
It seems that Linux is trying to execute the “init” program, but it fails. Are you sure that you configured the kernel with EABI support? The .config file should contain a line with “CONFIG_EABI=y”.
If this line is there, you should check in the toolchain documentation if it supports that version of Linux kernel.
Have you tried to execute “/bin/sh” instead of “/sbin/init”?
sudhesh
2012/04/11
Dear Balau,
Thank you for your reply and also thanks to “google search engine” to bring your website on top.
I have made the below changes in linux 2.6.33 kernel , now it works fine.
# make ARCH=arm menuconfig
a) Enable the lodable module support
[*] Enable lodable module support
b) If RAMdisk size might > 4MB, change CONFIG_BLK_DEV_RAM_SIZE to higher value.
Device Driver
Block devices
(4096) Default RAM disk size(kbytes)
Note:
Change the default size 4096 to higher value. I have increased to 409600.
c) Enable CONFIG_AEABI:
Kernel Features
[*] Use the ARM EABI to compile the kernel
Regards,
Sudhesh
Balau
2012/04/11
Glad to help.
Watch out with the CONFIG_BLK_DEV_RAM_SIZE, because the system must have enough memory for the kernel, the ramdisk and the userspace programs.
If you need a big filesystem, you have to use something else, such as NFS booting or an hard drive emulation.
Kaiwan
2012/04/20
Hi Balau,
Your blog is super! Thanks v much.
I have successfully tried out using QEMU for ARM emulation (with various kernels including the newer 3.2.x) using your posts as a base reference (and have in fact kind of automated the same via a shell script). The root fs type being used is ‘initrd’ again as per your inputs.
I wanted to try the same – emulating ARM 926 (or A9) using QEMU and a QEMU *disk image* (using the qemu-img utility to create a raw qemu disk which is then “formatted” as an ext3 image & populated using the loopback driver) instead of an initrd (volatile) image. This worked fine on QEMU emulating x86 target (on an Ubuntu x86 host). But when i try the same for an ARM target it fails when attempting to mount the root fs – the kernel panics. Any idea on what might be wrong? (I have used ARM-compiled binaries for the target). What would be the “right” kernel command line to provide in this case?
TIA!
kaiwan.
Balau
2012/04/20
I don’t know what could be the problem, but usually the kernel messages contains some errors that might point to the problem.
Be aware that when the kernel panics about not mounting the root fs it means it already passed the step where it tries to mount the ramdisk (the image you pass with -initrd).
victor
2012/06/02
Hello,
Many thanks for the tuto !!!
I’ve previously tried your other one “Compiling kernel for ARM emulator” and all went fine.
But now I have some troubles when I $ make install. The following error occurs :
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
I’ve replaced the CROSS_COMPILE variable with arm-linux-gnueabi-, since I have no arm-none-linux-gnueabi- is this correct ? Or am I missing something ?
Regards.
Balau
2012/06/02
Using
arm-linux-gnueabi-
toolchain should work anyway.I think
ld
should print more details about the error, such as “undefined reference” or something… Are you sure what you wrote is the only error that is printed?victor
2012/06/03
Well, after many tries I’ve finally a $ make install that works. I’ve installed the arm-none-linux-gnueabi package from Mentor website and did it as you described in your tuto. All went fine ! Thanks again for your magnificent blog. I’m starting using Linux and I’m interested in embedded systems (recently bought a devkit from elektor). Your blog is the best I’ve found on the web. Simple and clear ! Cheers…
Shantanu Sharma
2012/06/20
hiiii..
this is the error i m getting in my busybox 1.10.1 (stable)
networking/libiproute/lib.a(iptunnel.o): In function `print_tunnel’:
iptunnel.c:(.text.print_tunnel+0x1ec): undefined reference to `__cpu_to_be16′
iptunnel.c:(.text.print_tunnel+0x200): undefined reference to `__cpu_to_be16′
iptunnel.c:(.text.print_tunnel+0x238): undefined reference to `__cpu_to_be16′
iptunnel.c:(.text.print_tunnel+0x24c): undefined reference to `__cpu_to_be16′
iptunnel.c:(.text.print_tunnel+0x26c): undefined reference to `__cpu_to_be16′
networking/libiproute/lib.a(iptunnel.o):iptunnel.c:(.text.print_tunnel+0x290): more undefined references to `__cpu_to_be16′ follow
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
any suggestions
Shantanu Sharma
2012/06/20
hey.. it worked fine in busybox 1.16.0 .. thnx for this amazing..
sourav
2012/06/26
I have a doubt.what is the use of root=/dev/ram here when you are already using initrd to load the ramdisk.Besides is rdinit=/bin/sh trying to execute the shell binary from _install folder?
Balau
2012/06/26
You are right in pointing out “root” option is not actually useful since we use the ramdisk and never try to run a real root filesystem. I tried without the “
root=/dev/ram
” option and it works, too.“
rdinit=/bin/sh
” tries to run the shell from the ramdisk filesystem, which is mounted in “/”. If you created the ramdisk from the_install
folder as for the tutorial, then the “sh
” it executes is the same as the one in that folder.Manish
2012/08/23
Dear Mr Balau
Your blogs are really nice,
I am building the busybox 1.16.0 and 1.20.0, using Linux kernel 2.6.33, over Ubuntu 12.5
I am getting a error with respect to file types.h.
I am using EABI tool chain.
Please help to resolve this issue
Balau
2012/08/23
You are using the Sourcery ARM EABI toolchain? That toolchain is for bare metal programming, which means the program is intended to run without an Operating System.
What you need is a Linux toolchain, so that Busybox can use the Linux standard libraries and its headers.
Breno
2012/10/07
Hi, I’ d like to solve an issue during busybox make process. I’m levaving some of the last messages I got. Case you need more to figure out, send me. Is it missing any library to link?
Thank you in advance.
make[1]: *** [networking/tcpudp.o] Error 1
make: *** [networking] Error 2
Balau
2012/10/08
I don’t think it’s a linking problem because the error is on “tcpudp.o”, so it must be during compilation.
It could be a problem of incompatibility between the toolchain and the version of busybox you are using, you could try another toolchain and see if that solves your problem.
As usual it is useful to search for the specific error, but in your case you are looking at the wrong error lines. The “make” program launches the compiler, the compiler finds the error and exits, then the make program reports the error without the useful information.
Breno
2012/10/16
Hi Balau, thanks for your reply. I am using a 64bits platform. Is there any difference in all steps you mentioned here when using such machines?
I made all steps in a 32bits and everything works fine. But the letters are
lackluster, is it normal?
By the way, I wrote a simple Hello World and compiled with arm-…-gcc. The program run properly using qemu-arm -L…. But it doesn’t work running inside QEMU. Is there any specific command or option to be passed in QEMU environment.
Thanks again for all.
Balau
2012/10/17
Do you mean host or guest?
If host: not so different, you just need to have toolchain and QEMU compiled for 64bit host
If guest: there’s a world of difference. But ARMv8 is not here yet so I suppose you are talking about 64bit host.
Do you mean that the characters shown in the QEMU window can’t be seen very well?
You could try with “-nographic -serial stdio” QEMU options and append “console=/dev/ttyAMA0” to the kernel params. In this way the kernel messages and everything will be printed on the terminal instead of the QEMU window, so you can see them clearly.
I don’t know very well, but the character rendering in QEMU window could depend on many things: kernel driver for the emulated LCD, QEMU usage of the SDL libraries, your host graphic configuration, compiz, …
Try to compile with “-static” , I suspect the problem is that it doesn’t find the required shared libraries. Use “ldd” inside QEMU guest to find out the required libraries and then copy the libraries from the host toolchain folders into the guest filesystem. See this post in “Complete the filesystem” section to have an example.
Breno
2012/10/18
Hi Balau, thank you again. The options “-nographic -serial stdio” QEMU options and append “console=/dev/ttyAMA0″ didn’t work, but It’s not big deal. And you were right about -static option to be inserted.
My problem now in 64bits is at the step:
$ cd _install
$ find . | cpio -o –format=newc > ../rootfs.img
$ cd ..
$ gzip -c rootfs.img > rootfs.img.gz
at the end I got a huge compressed file that have problem to be loaded. It’s completely diferente when I execute it in 32b platform. In 32b platform, all steps you described works fine!
I’d like also to know what changes should I have to do to get QEMU for ARM microcontroler like cortex-M3 with no floating point support. Is there a defconfig for this?
Thank you!
Balau
2012/10/18
I really don’t know how to solve your 64bit situation. How huge are we talking about? You could:
Anyway there’s a bug somewhere in your environment and it’s not normal at all.
In order to simulate a Cortex-M3 with QEMU, you can see this example: Using CodeSourcery bare metal toolchain for Cortex-M3. QEMU is not able to emulate any architecture you want yet, only pre-defined machines. See this post to have an idea of what people are working on to make customization possible.
venkat
2012/10/21
I tried the above settings for my qemu setup. But I am not able to enter into qemu console Please help me.
Uncompressing Linux……………………………………………………………………………. done, booting the kernel.
pflash_write: Unimplemented flash cmd sequence (offset 0000000000000000, wcycle 0x0 cmd 0x0 value 0xf000f0)
pflash_write: Unimplemented flash cmd sequence (offset 0000000000000000, wcycle 0x0 cmd 0x0 value 0xf0)
Balau
2012/10/22
The error message is very strange, the kernel should not write in flash.
What QEMU version do you have?
What’s the command line you used to launch QEMU?
What is the version of the Linux kernel you are using?
Breno
2012/10/28
Hi Balau, for those ARM with DSP co-processor, is the use of this processor trahsparent for the user? I mean, if want to do some matrix calculation, do I have to force the use of DSP or it´s callled autmomatically.
Thanks,
Breno
Balau
2012/10/29
I think there’s no product yet that does it automatically.
There are ARM processors with NEON instruction set (DSP extension) where the toolchain makes the best effort in trying to use libraries that contain these extension.
But I think you are talking about chips that contain both an ARM processor and a full DSP co-processor. In that case the processor has a different instruction set and must be programmed and controlled by the ARM.
Breno
2012/10/29
Thatś rigth, in case I wanna do a FFT, it would be great to send some operations to DSP. I was thinking about ARM11, which is said to have DSP besides ARM processor. So, if I understood what you said, I have to explicit in my code the section that should be run in DSP core. It has to be necessarily in assembly? QUEMU are able to run those cases?
Thanks in advance!
Balau
2012/10/29
Wait, I try to rephrase it because you did not get it.
Case 1: there’s one core, that does “normal” execution and has an extension of the instruction set with DSP capabilities. It’s the case of ARM11, that has DSP-SIMD instructions, or modern NEON-enabled ARM Cortex processors. If the toolchain provides some API in C, it’s not necessary to go to assembly level to use the extensions.
Case 2: there are two cores, one that does “normal” execution, the other does “DSP”. It’s the case of Texas Instruments products such as this. The DSP has a completely different instruction set and toolchain. The way to execute programs depend on the product.
QEMU most likely supports the first case, if you launch it with “
qemu-system-arm -M ?
” or “qemu-system-arm -cpu ?
” you can discover what it can do. Otherwise you could ask QEMU user mailing lists.ML
2013/02/26
does not work for me I have the /sbin/init init on red color and qemu displays a black window
Balau
2013/02/27
The color doesn’t mean much, and before mounting the busybox filesystem the kernel displays many boot messages on screen, so the problem doesn’t seem to be busybox but the kernel compilation.
vamsi
2013/04/10
fatal error: byteswap.h: No such file or directory
i am getting this error while installing please help
Balau
2013/04/10
You are probably using a wrong toolchain: Busybox must be compiled with a Linux cross-toolchain (for example arm-linux-gnueabi) and not with a bare-metal cross-toolchain (for example arm-none-eabi).
arungopal
2013/06/15
Hi,
I saw u r tutorial it is excellent….i want to create zimage for raspberry pi with out using raspberry pi kernel..and how to create minimal root file system for the raspberry pi using busy box or buildroot..
Thanks&Regards,
K.Arungopal
Balau
2013/06/16
I am not familiar with Raspberry Pi. One problem seems that by reading in this forum that to access the documentation you need to ask Broadcom, they make you sign an NDA (non-disclosure agreement) and then they deliver the docs. Without the docs it’s hard to do what you want to do, and I think it involves some reverse engineering.
I think that when you download Raspberry Pi kernel they need to give you also the source code that generated the kernel (with probably some binary blobs of drivers). You could take that source together with the mainline kernel from where they started developing and see the differences. This would tell you what are the parts specific to Raspberry Pi.
These people here are working on adding to Linux the BCM2835 System on Chip that is the core of the board: https://patchwork.kernel.org/patch/1411871/
Also, one of the Buildroot developers said that they have a default configuration for it: http://stackoverflow.com/questions/14598457/building-a-minimal-linux-for-raspberry-pi
Hope this helps.
arungopal
2013/06/16
Hi Sir,
iam gone through the u r links….but iam did not fine NDA..Please Send link for getting docs about the raspberry pi for creation of root file system…….
Sir,
i have one dought..u r wrote rcs script file..it is similar for all creation of root file systems..actually iam creates zimage for raspberry pi..
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- defconfig
u r use this command instead of me iam use raspberry pi def config file…it is located in in kernel source code \arch/arm/configs/bcm2835_config file..iam cross compile the kernel with this config file…..i got the zimage but iam struct at rcs script file for raspberry pi…..
Thanks&Regards,
K.Arungopal
Balau
2013/06/16
I can’t help you more than the links that I already gave. As I said I am not familiar with Raspberry Pi.
Ronex
2013/08/08
busybox is not working for domain names, ping is working for IP addresses, But while using domain name it throws `bad address` error, I have added “nameserver 8.8.8.8” in /etc/resolv.conf still it’s not working .. Do I missing something there ? I would like to configure busybox for dns support, so that all nslookup, wget should work with domain names.
Balau
2013/08/08
This comment of mine is still true, I don’t know how to add DNS correctly. Googling seems to suggest adding “
--enable-static-nss
” to compilation and fiddling with the Makefile and it seems to be a problem related to thelibc
implementation that you are linking busybox with. But I really don’t know.Ronex
2013/08/16
Can you please suggest how can I build glibc with “–enable-static-nss” option, Generally I have used the one provided with the latest arm-none-linuxgnueabi- toolchain, Other thing is can we add the missing dns libraries inside created rootfs directory and deploy it ?
Balau
2013/08/16
I think that the option you mention must be used in busybox compilation, not for glibc.
Also I don’t think the DNS problem can be solved by adding other libraries because I understand that ultimately they use libc and the kernel API for networking.
Ronex
2013/08/26
After trying a lot to dns get worked with busybox, I didn’t succeed. Can anyone here please look into the issue and elaborate exact solution.
Balau
2013/08/26
I saw your question on StackOverflow.
I suggest asking a new question with the general problem you want to solve, which is adding DNS support to BusyBox on ARM (providing also some details of what you tried).
Otherwise you fall victim of the XY problem.
embedded developer
2013/12/10
I want to insert new module in busybox whcih I am writing for my understnding . When I am trying to do insmod “xxx.ko” it is shwoing as function not implemnted and can’t insert the module. can you pls tell me error I am doin.
We are disabling loadble Module support while compiling kernel for our convention as per your blog, is that reason it is not accepting the module.
Thank you
Regards
gsatish.net
Satish.G
Balau
2013/12/10
Exactly, you need to re-enable that option (CONFIG_MODULES=y) in order to load modules into the kernel.
embedded developer
2013/12/11
hi I am working with omap3630 platform for beagle board, can you please tell me the changes w.r.t boot args and commands, have to change to make qemu work with Beagle board.
Thank you
gsatish.net
Balau
2013/12/11
I never tried anything with the BeagleBoard, but official QEMU doesn’t seem to support them.
Linaro has its own version that should support the BeagleBoard: https://wiki.linaro.org/WorkingGroups/ToolChain/QEMU
There are the instructions to run their own Linux image here: https://wiki.linaro.org/Resources/HowTo/Qemu-beagleboard
Anil Kumar Prasad
2014/04/14
Hi,
i am trying to compile busy with arm-linux-gnueabihf-, which is by default compiles for hard float, but i have provide the -mfloat-abi=softfp, in the menuconfig of busy box under buid options…
but the make throws the following error..
arm-linux-gnueabihf/bin/ld: error: busybox_unstripped uses VFP register arguments, libbb/lib.a(xrealloc_vector.o) does not
am i doing anything wrong or missing something?
is it possible for to use arm-linux-gnueabihf- for softfp comiple.?
Thanks
Anil
Balau
2014/04/14
I’m not familiar with floating point implementations and compilation. From a quick search it seems you have to pass the right options both in compilation (
CONFIG_EXTRA_CFLAGS
) and in linking (CONFIG_EXTRA_LDFLAGS
). You can runarm-linux-gnueabihf-gcc -print-multi-lib
, choose a row and use all the options near the@
. For example for a toolchain I have installed:$ arm-none-eabi-gcc -print-multi-lib
.;
thumb;@mthumb
fpu;@mfloat-abi=hard
armv6-m;@mthumb@march=armv6s-m
armv7-m;@mthumb@march=armv7-m
armv7e-m;@mthumb@march=armv7e-m
armv7-ar/thumb;@mthumb@march=armv7
armv7e-m/softfp;@mthumb@march=armv7e-m@mfloat-abi=softfp@mfpu=fpv4-sp-d16
armv7e-m/fpu;@mthumb@march=armv7e-m@mfloat-abi=hard@mfpu=fpv4-sp-d16
armv7-ar/thumb/softfp;@mthumb@march=armv7@mfloat-abi=softfp@mfpu=vfpv3-d16
armv7-ar/thumb/fpu;@mthumb@march=armv7@mfloat-abi=hard@mfpu=vfpv3-d16
So I would compile and link with
-mthumb -march=armv7 -mfloat-abi=softfp -mfpu=vfpv3-d16
abhishek
2015/07/22
hey balau,
by using this procedure i have installed qemu. but i want to i2cdetect, i2cset, in2get etc on my qemu .. then how i can mount i2ctoot pkg with root file system of busybox for this functionality.
Balau
2015/07/22
I don’t know, probably by using buildroot instead. It seems from a quick look at source tree that they have i2c-tools in their packages. But I don’t have experience with buildroot. You probably need to emulate a full disk instead of a ramdisk like I did in this post, because I suppose buildroot creates filesystems that use more disk space.
marwa
2016/02/16
hey balau
I have followed the tutorial and its clear and well explained.
I am having a difficult , busybox does not run /etc/inittab/rcS even i wrote a msg “echo hello” inside this script but this msg didn’t appear also proc is not being mounted how can i fix this.
i want to add kernel module to the file system , should i put it in /lib ?
and finally i want to execute a file.c simple hello world , i add the executable to the file system but i can run it with qemu’s shell
Balau
2016/02/16
uname -r
hope this helps.
lara
2016/02/16
hello
i have a question , do you have any idea how to run xen on qemu ? if yes please tell me which steps should i follow
lara
2016/02/17
hello..
please have you any idea how can i run a xen hypervisor on qemu
if yes can you tell me which steps should i follow
i googling but i didn’t find something helpful ..i’ll appreciate your help
Balau
2016/02/17
I have no experience with xen, sorry
hamza
2016/02/29
hello
why when i run qemu with -M vexpress-a9 , it didn’t work “black window” eventhough i compile and configure the kernel with vexpress , and i used rootfs made with busybox
i want to work with vexpress because it supports cortex a9 and cortex a15 as cpu and versatilepb doesn’t support them it isn’t !!!, any suggestion?
Balau
2016/03/01
See this post and in particular this comment, it might be a matter of using a Device Tree Binary file to tell QEMU how to emulate and to pass to Linux to give it the details of the architecture.
hulia
2016/04/27
hello i am trying to run qemu using arch=powerpc and im using powerpc-linux-gnu tool chain
but i couldn’t compile the kernel in the end of compilation i got this error
powerpc-linux-gnu-ld: Unrecognized emulation mode: -T
supported emulations: elf32ppclinux elf32ppc elf32ppcsim elf64ppc elf32_spu
make[1]: *** [arch/powerpc/boot/zImage.pseries] Erreur 1
make: *** [zImage] Erreur 2
make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu pseries_defconfig
make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu
i though first that the problem was related to the compiler but when i compiled busybox i got no error
make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu
make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu _install
Can you please suggest how can I fix the error
Balau
2016/04/27
You could try running make with
V=1
option to print the actual commands that are being run. It seems the makefiles are calling the compiler or the linker with strange options:-T
is usually the option flag to pass the linker script, but here it seems to be the argument of a-m
ld option, see ld options page.Be aware that
ARCH=powerpc
must be uppercase,arch=powerpc
in lowercase will probably not work.Anyway I am not familiar with powerpc so I don’t think I can help you more than this.
aicha
2016/05/27
hey
I read your last comment, i know that u are not familiar with powerpc arch but i’m wondering if u probably saw this error before
I am trying to create a file system for powerpc 32bits using busybox, i downloaded the tool chain powerpc64-linux from https://www.kernel.org/pub/tools/crosstool/ (compatible with powerpc 64 bits and 32 bits, it’s indicated in the web site and i use it to compile a linux kernel for 32 bits and it works)
when i run make ARCH=powerpc CROSS_COMPILE=powerpc64-linux -install , i got this error
GEN include/usage_compressed.h
HOSTCC applets/applet_tables
applets/applet_tables.c: In function ‘main’:
applets/applet_tables.c:144:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(line_old, sizeof(line_old), fp);
^
GEN include/applet_tables.h
CC applets/applets.o
In file included from include/libbb.h:13:0,
from include/busybox.h:8,
from applets/applets.c:9:
include/platform.h:149:23: fatal error: byteswap.h: No such file or directory
compilation terminated.
make[1]: *** [applets/applets.o] Erreur 1
make: *** [applets_dir] Erreur 2
Balau
2016/05/28
In the notes of the page you linked, it says:
And Busybox is a userspace program. You need a different toolchain, but I don’t know which one. Many Linux distributions have cross toolchains that can be installed from package, for example Debian has
gcc-powerpc-linux-gnu
.aicha
2016/06/01
hey again
i have a question, is Qemu support the powerpc architecture?
coz i did every thing i compiled the kernel(linux-4.4.1) make ARCH=powerpc pseries_defconfig (I uncheck the 64bits option for this configuration coz i need to have powerpc 32bits ) then i compiled it make ARCH=powerpc CROSS_COMPILE powerpc64-linux-
i created the file system with (busybox-1.21.0) like u did for ARM i configured statically then make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu install , i created the directories(bin,sbin,proc,sys..) and rcS and inittab
after creating the rootfs i verified the executable format and i got file format elf32-big
architecture:UNKNOWN
i continued the work, i configured Qemu from source ./configure –target-list=ppc-softmmu –disable-vnc –enable-sdl –disable-kvm –enable-debug
make
i run Qemu
.
1/ i got a black screen with this sentence ” QEMU 2.4.0.1 monitor – type help for more information”
(QEMU)
if i run this command ./ppc-softmmu/qemu-system-ppc -M ppce500 -kernel ../linux-4.4.1/arch/powerpc/boot/zImage -initrd powerpc/busybox-1.21.0/rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh”
2/ or i got this error “rom: requested regions overlap (rom /home//powerpc/busybox-1.21.0/rootfs.img.gz. free=0x0000000001878dfc, addr=0x0000000001579000)
rom check and register reset failed ” if i run this command
./ppc-softmmu/qemu-system-ppc -M mac99 -kernel /home/powerpc/linux-4.4.1/arch/powerpc/boot/zImage -initrd /home/powerpc/busybox-1.21.0/rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh”
3/ or i got this error
qemu-system-ppc: Could not load PowerPC BIOS ‘ppc405_rom.bin’
when i run this command
./ppc-softmmu/qemu-system-ppc -M ref405ep -kernel /home/powerpc/linux-4.4.1/arch/powerpc/boot/zImage -initrd /home/powerpc/busybox-1.21.0/rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh”
and i have tried all machines available for powerpc in qemu but i got always one of those three result
please any suggestion can really help me i posted this question in qemu devel mail list but no one answer me
Balau
2016/06/03
Yes QEMU does support ppc. If I had these kind of errors I would conclude that it’s more likely that I’m doing something wrong, before having doubts about someone else’s software that is so widespread. These are the directions that I would take:
error 1: try to press shift-1 inside the QEMU monitor. See https://en.wikibooks.org/wiki/QEMU/Monitor .
error 2: try to avoid passing initrd and see if at least the kernel boots.
error 3: it’s probably releated to the fact that you compiled from source. You could try to find ppc405_rom.bin in source code, but I don’t know where you should put it.
Some suggestions that would make it more likely to work: Install QEMU from an already compiled package instead of compiling it yourself. Use an already prepared distribution (iso image?) instead of building kernel+rootfs yourself. See this page for pointers: https://gmplib.org/~tege/qemu.html
enthusiasticgeek
2016/07/12
I found building “buildroot” much simpler than “busybox”
wget https://buildroot.org/downloads/buildroot-2016.05.tar.gz
tar xvf buildroot-2016.05.tar.gz
cd buildroot-2016.05
then configure and make
make qemu_arm_vexpress_defconfig
make
cd output/images
The following files are created in this folder
zImage
vexpress-v2p-ca9.dtb
rootfs.ext2
To run in qemu
qemu-system-arm -M vexpress-a9 -smp 1 -m 256 -kernel zImage -dtb vexpress-v2p-ca9.dtb -drive file=rootfs.ext2,if=sd,format=raw -append “console=ttyAMA0,115200 root=/dev/mmcblk0” -serial stdio -net nic,model=lan9118 -net user
enthusiastic geek
2016/07/12
If one is using stock Linux kernel 4.6.3, like I am, there are few things to change –
Firstly of I am using vexpress-a9 board (This is because since 2015 Q3 the versatilepb was removed from uboot source code too) so I am gonna stick with the newer board and not use legacy board.
Secondly I compiled Linux kernel 4.6.3 with one major change
cd linux-4.6.3/
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make vexpress_defconfig
Now, use an editor to edit the config file
vim .config
Ensure the following line is set to y
CONFIG_DEVTMPFS_MOUNT=y
make all
This will generate the compressed kernel file
cp arch/arm/boot/zImage ..
cp arch/arm/dts/vexpress-v2p-ca9.dtb ..
Now generate busy box with the process listed above.
Lastly use,
qemu-system-arm -M vexpress-a9 -m 128M -kernel zImage -initrd rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh” -dtb vexpress-v2p-ca9.dtb
Venkat
2017/01/31
Dear balau,
I want to say thank you for this good tutorial.
I am facing some issue while bringing the qemu up with linux2.6.37.4 kernel + busybox1.26.2. Could you please guide me to resolve this issue?
$ qemu-system-arm -M versatilepb -m 128M -kernel ~/venkat/qemu/linux-2.6.37.4/arch/arm/boot/zImage -append “root=/dev/ram rdinit=/sbin/init console=ttyAMA0” -serial stdio
Uncompressing Linux… done, booting the kernel.
Linux version 2.6.37.4 (bv@mcs) (gcc version 4.5.1 (Sourcery G++ Lite 2010.09-50) ) #2 Tue Jan 31 15:43:59 IST 2017
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile PB
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: root=/dev/ram rdinit=/sbin/init console=ttyAMA0
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 111888k/111888k available, 19184k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 – 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 – 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 – 0xffe00000 ( 2 MB)
vmalloc : 0xc8800000 – 0xd8000000 ( 248 MB)
lowmem : 0xc0000000 – 0xc8000000 ( 128 MB)
modules : 0xbf000000 – 0xc0000000 ( 16 MB)
.init : 0xc0008000 – 0xc0e8b000 (14860 kB)
.text : 0xc0e8b000 – 0xc115ebdc (2895 kB)
.data : 0xc1160000 – 0xc117b2c0 ( 109 kB)
NR_IRQS:192
VIC @f1140000: id 0x00041190, vendor 0x41
Console: colour dummy device 80×30
Calibrating delay loop… 247.39 BogoMIPS (lpj=1236992)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
fpga:09: ttyAMA3 at MMIO 0x10009000 (irq = 38) is a AMBA/PL011
bio: create slab at 0
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 218
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
CLCD: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80×60
brd: module loaded
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre nico@fluxnic.net
eth0: SMC91C11xFD (rev 1) at c8800000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
mice: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
Warning: unable to open an initial console.
Freeing init memory: 14860K
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
request_module: runaway loop modprobe binfmt-464c
request_module: runaway loop modprobe binfmt-464c
request_module: runaway loop modprobe binfmt-464c
request_module: runaway loop modprobe binfmt-464c
request_module: runaway loop modprobe binfmt-464c
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1
After getting this log it got stuck.
please help me.
Regards,
Venkat