The Emdebian project works to bring Debian on embedded platforms, with repositories of custom distributions and toolchains to cross-compile software. I wanted to try their ARM toolchains, and coincidentally the Linux kernel 3.0 has been released in these days, so I tried to cross-compile it and emulate it on QEMU. These tests have been done on my Debian “wheezy” desktop.
In order to install software from Emdebian repository, their authentication key must be installed first. I ran as root:
# aptitude install emdebian-archive-keyring
To use the Emdebian repository with Debian “apt” package management, I added to “/etc/apt/sources.list” the following lines:
deb http://www.emdebian.org/debian/ testing main deb-src http://www.emdebian.org/debian/ testing main
Then I updated the repository information and installed all that was needed for my tests:
# aptitude update # aptitude install gcc-4.4-arm-linux-gnueabi libncurses5-dev qemu-system
I then downloaded the Linux kernel and extracted it. To keep things simple, I chose to compile the kernel for an architecture that has support both in the kernel and in QEMU, which is the ARM Versatile Platform Baseboard.
These are the commands that I ran (as regular user, not as root) to donwload and compile the kernel:
$ wget http://www.kernel.org/pub/linux/kernel/v3.0/testing/linux-3.0.tar.bz2 $ tar xjf linux-3.0.tar.bz2 $ cd linux-3.0 $ export ARCH=arm $ export CROSS_COMPILE=arm-linux-gnueabi- $ make versatile_defconfig
at this point I changed the configuration to enable EABI support, which is the new “Application Binary Interface” that is used by all modern ARM compilers.
$ make menuconfig (Kernel features -> enable EABI)
Then I compiled the kernel:
$ make ... Kernel: arch/arm/boot/zImage is ready ...
To test it, I used “qemu-system-arm”, which is a full system emulator for many platforms. To emulate the Linux boot on a VersatilePB machine, I ran the command:
$ qemu-system-arm -M versatilepb -kernel arch/arm/boot/zImage
The window that opens emulates the machine’s monitor. At the end of the boot phase, since there’s no root filesystem, an error message is displayed.
... Kernel panic - not syncing ...
Milind Lokde
2011/09/14
Thanx. I have read most of your blogs on qemu, arm, embedded. I have Imate PDAL smartphone running wm6.5 having armv5tej omap850 processor. I have tried installing android from wing-linux project or omap850. Unfortunately my phone is not yet supported in linux kernel. I now have haret bootloader which loads the precompiled kernel for omap850 from wing-linux project. The kernel boots and shows some message at odd position on screen but doesn’t load the android filesystem. Is the odd position of messages result of framebuffer issue? How do I rectify it?
I now want debian rootfs installed on it, using haret and linux kernel. My smartphone does not have keyboard, just touchscreen, D-pad and few necessary keys.
Does arm-debian have packages for smartphone – sms, call, contacts, etc?
Will using u-boot ruin my windows mobile bootloader?
Those are a lot of questions and a little more work for you. Whatever little information you provide will be helpful to me.
I am not a programmer and never yet tried porting anything myself. I have compiled kernel earlier using basic steps. I have qemu-arm and gnu-eabi-arm compiler from codeSourcery on Debian Sqeeze. Thanks again for your helpful blogs.
Balau
2011/09/15
I think the task you are trying to accomplish is not easy. I don’t have much experience on that and I will try to give you some ideas and pointers but nothing I am sure of.
The fact that the text does not display properly maybe is an issue, but maybe the behavior is fixed when Linux reaches the filesystem and the graphical libraries are loaded and run.
The fact that Linux does not load the filesystem maybe is because Haret is not giving Linux the correct parameters. A solution that might work would be to configure Linux (with “make menuconfig…” for example) with the correct parameters before compiling it.
I don’t know if Debian has the packages you need: it is not meant to be a smartphone operating system; I suppose there are libraries to manage SMS sending. Anyway if a package is present in Debian, it is very likely that it’s prepared also for ARM architecture.
U-Boot will probably override Haret, and I don’t know if U-Boot can boot Windows Mobile; if you don’t care about that, then you can overwrite Haret. I think one of the main problem is how to write U-Boot into your device’s memory, maybe a special procedure is needed.
Hope this helps.
milindlokde
2011/09/15
I have compiled my kernel for arm – omap1_defconfig using procedure you have mentioned in your earlier blog. Thanx.
BusyBox compiling is giving error missing menuconfig/xconfig. But I have compiled my arm kernel using xconfig (menuconfig gave ncurses missing error).
I am downloading debian sqeeze qcow image now as per your blog. Thanx again.
I will now have haret bootloader, linux kernel and filesystem.
It may not be so difficult as it seems, as a lot of things are in place and a lot of work has been done by android and debian community.
Only my PDAL board should be compatible with any one of omap1 models. If not, I would have to define my own board configuration under arch/arm/omap1 and it would be a lot of work and understanding.
Balau
2011/09/15
The menuconfig problems should disappear if you install the “libncurses5-dev” on your system (I’m assuming you are running Ubuntu or Debian distribution on the PC that you are using to compile Linux kernel and Busybox)
milindlokde
2011/09/18
Thanks. I got menuconfig working. BusyBox compiling worked, but it said I will have to set suid root. How?
The compiled arm kernel for omap1 gave following error on selecting ‘-M sx1-v1’ option to qemu:
>tried to create id “null” twice for “chardev”
>Can’t create serial device, empty char device
The compiled kernel gave following error on selecting ‘-M versatilepb’ option to qemu:
>qemu: hardware error: pl181_write: Bad offset 10
>CPU #0:
>R00=10005010 R01=40400c12 R02=10008000 R03=10004000
>R04=10008000 R05=00010000 R06=41069265 R07=00000183
>R08=00000100 R09=10000000 R10=20000000 R11=00000000
>R12=000100bc R13=0019dd1c R14=00010270 R15=00010224
>PSR=200001d3 –C- A svc32
>Aborted
What must be the reason?
I got debian for Arm working for versatilepb as per your instruction on https://balau82.wordpress.com/2010/10/17/trying-debian-for-arm-on-qemu/ . Thanks, I have made a lot more progress in these few days, than I did in the last one year.
Balau
2011/09/18
You can add the “setuid” flag on the busybox binary file by doing something like “chmod +s ./busybox” in the directory where busybox binary is.
I don’t know about that error in QEMU, try to add “-serial stdio” and if it does not work I think you could report a bug.
If you compiled the kernel for OMAP and tried to run it on VersatilePB, then it is normal that QEMU does not executes it correctly, because they are two different architectures with different memory maps.
lamia
2012/03/20
I have this error when i try to compile my kernel :
/bin/sh: arm-linux-gnueabi-gcc : commande introuvable
make[1]: *** [kernel/bounds.s] Erreur 127
make: *** [prepare0] Erreur 2
can you help me plz 😦
Balau
2012/03/20
It seems the toolchain has not been installed correctly… did you receive errors when you installed it?
lamia
2012/03/20
thank’s for your answer
i have no problem in installing the toolchain i followed this tutoriel https://balau82.wordpress.com/2011/07/24/compiling-linux-kernel-3-0-with-emdebian-arm-toolchain/comment-page-1/#comment-1404
but i still have the same problem
Balau
2012/03/20
Could you check the output of the following commands?
which arm-linux-gnueabi-gcc
ls -l /usr/bin/arm-linux-gnueabi-gcc
ls -l /etc/alternatives/arm-linux-gnueabi-gcc
ls -l /usr/bin/arm-linux-gnueabi-gcc-4.4
This is my output for reference:
francesco@debian-c2d:~$ which arm-linux-gnueabi-gcc
/usr/bin/arm-linux-gnueabi-gcc
francesco@debian-c2d:~$ ls -l /usr/bin/arm-linux-gnueabi-gcc
lrwxrwxrwx 1 root root 39 Jul 21 2011 /usr/bin/arm-linux-gnueabi-gcc -> /etc/alternatives/arm-linux-gnueabi-gcc
francesco@debian-c2d:~$ ls -l /etc/alternatives/arm-linux-gnueabi-gcc
lrwxrwxrwx 1 root root 34 Jul 21 2011 /etc/alternatives/arm-linux-gnueabi-gcc -> /usr/bin/arm-linux-gnueabi-gcc-4.4
francesco@debian-c2d:~$ ls -l /usr/bin/arm-linux-gnueabi-gcc-4.4
-rwxr-xr-x 1 root root 207692 Nov 25 2010 /usr/bin/arm-linux-gnueabi-gcc-4.4
lamia
2012/03/21
thank you 🙂
I found the error, I used the wrong path of ” arm-linux-gnueabi- “
Alto Stratus
2012/03/29
Hello! great tutorial! I don’t know why but when I follow these exact instructions, qemu starts and I get a black screen when I try a 2.6.33 kernel it works fine.
I’ve tried disabling the graphics with “-nographic” and adding console ttyAMA0 I see that it hangs at “Uncompressing Linux… done, booting the kernel.”
any ideas? thanks
Balau
2012/03/29
Some tips:
– if you try “-append earlyprintk” when launching QEMU, the kernel should give you some other information on the terminal.
– try different QEMU versions (older or newer), maybe they emulate hardware differently.
– use arm-specific gdb and QEMU options “-s -S” to debug step by step what’s happening.
Alto Stratus
2012/03/29
Thanks for your quick response Balau! I think yo’ure right, it has something to do with qemu, I’ve installed version 0.11.1
GCC 4.5.3
would be appreciated if you u could give me info on the versions u’re using
thanks again!
Balau
2012/03/29
Glad to help. I am using Debian testing (wheezy), so the QEMU version is very new, specifically the 1.0 (Debian 1.0+dfsg-3).
Alto Stratus
2012/03/29
That’s very helpful 🙂
seems like my qemu version is a bit old (0.11.1 from the gentoo repositories), I’ll upgrade
Thank you for the earlyprintk tip 😉