Thursday, January 24, 2008

Running ARM Debian in qemu

I wanted a whole running ARM Linux system, but considered my real ARM devices (for example FIC Neo 1973) too slow and limited for the most tasks I wanted to perform. So had an idea of fully emulated ARM system, running on qemu. Best option for the installable system seemed to be Debian since it had a prebuilt packages and quite easy install system. And of course, I like Debian.

Fortunately I found a good guide for my adventure: http://www.aurel32.net/info/debian_arm_qemu.php. First started by getting the latest qemu, and built it for my system. Fine, then installed it and everything seemed good. So continued with the next step: installing Debian to the qemu system. Installer started fine. The installation went fine. Then the first boot and the first problem. For some reason the boot process hanged every time when the system was checking the disc image. The check was forced in first place because the clock of the qemu system was reseted to zero on every boot (back to 1970's) and the system thought that we have been too long without performing the check. Just spent a day trying to solve the issue and googled for solution. The main problem seemed to be qemu but even the newest CVS version didn't help. Finally made a dirty but a working solution: changed disc image parameters with tune2fs so that the image won't be checked any more. Success.

Finally logged to the Debian system and was able to operate as in any other system. I was able to install new packages, build packages and perform other operations. Then I downloaded a third party ARM Linux application which just didn't work. I was unable to execute it. Then figured out something. The kernel which was provided by the tutorial didn't support EABI. I wanted EABI. So I thought that building a own kernel would be nice and easy. Thought wrong.

First I needed cross compiling toolchain for ARM EABI, it was fortunately found from http://www.codesourcery.com/gnu_toolchains/arm/download.html. Then I downloaded newest kernel, set up cross compiling and chosen the default versatile kernel configure. And changed it to support EABI. Then built it. Success. Try to boot - and fail. The default versatile configure was not the right one. Since the tutorial didn't bother to provide kernel configuration to build the kernel, I was forced to figure it out myself. Gone through hundreds of different configuration and finally found one which worked almost. It just didn't found my hard disk or the disk image where my Debian installation was. I thought I had everything: PCI (took also some time to figure out that I need support for it) and SCSI disc support, but something just was missing. Hit my head against the wall until figured it out: SCSI low level driver. I had to check it from qemu home page, selected it from the configure and built. Finally a success!

Now everything was working again on my qemu ARM system. The lesson learned: you should always know the platform for which you're building the kernel for. To know all the devices, chips and drivers possibly needed. And the kernel configuration seems to hide some options, making unable to select or even see them, if they depend on other configuration option. Next time I will double check all the device drivers that I really need and study the platform better. No guesses any more. Only cold facts.

1 comment:

Nero said...

thanks for the info, Roivas. I am at the start of such an adventure of building the kernel myself....
my initial attempt to get qemu-arm-versatile was made much comfortable by fedora-arm support (they provide pre-built kernel and toolchain binaries-- with EABI support, and a fedora 8/10 rootfs, i found this package immensely more usable than debian-sarge.. in case you wanna check it out, here's the link:
http://fedoraproject.org/wiki/Architectures/ARM