In order to make the kernel do something, we can create a simple “Hello-World” user-space program. Which, instead of compiling sequentially, will use a parallelism of 2 to create the objects and the final images. For example if we are using arm-linux-gnueabi-gcc, we need to set CROSS_COMPILE to arm-linux-gnueabi. For CROSS_COMPILE we need to provide the prefix of the toolchain, which is the name of the compiler program minus the gcc at the end. The valid values for ARCH are basically the subdirectories of the “arch” directory. There are two environmental variable for this: ARCH and CROSS_COMPILE. We are going to compile for ARM architecture by using a cross-toolchain, so we need to tell it somehow to the Linux build system. This will create a new subdirectory called linux-3.2 containing the full source of the Linux kernel. One way to do it is by running in the same directory: tar xjf linux-3.2.tar.bz2 The official site for mainline Linux kernel is at The kernel version that I will use is the 3.2, be aware that if you want to use a different version you may have different results, even though most of the functionality used here is simple enough that it should not change between versions.ĭownload linux-3.2.tar.bz2 from the FTP site, or simply run from the command line: wget Emulate kernel boot and ramdisk execution. ![]() The last command opens a QEMU window, that shows a black background and many boot messages, and towards the end the “Hello World!” string is displayed. The kernel compilation (the “ make all” command) could take some minutes or hours depending on your host machine power. Qemu-system-arm -M vexpress-a9 -kernel linux-3.2/arch/arm/boot/zImage -initrd initramfs -serial stdio -append "console=tty1" Then in the same directory execute the following commands in order: wget Īrm-linux-gnueabi-gcc -static init.c -o initĮcho init|cpio -o -format=newc > initramfs The short storyĬreate a clean directory, then create a file called “ init.c“, which contains the following simple C code: #include You must install the correct package depending on your distribution sometimes distributions split the QEMU programs into different packages, for example Ubuntu packs it into the “ qemu-extras” package. In my case I use Emdebian toochain, which has the “ arm-linux-gnueabi-” prefix.įinally the emulator that I use is QEMU, in particular the program to emulate ARM hardware is “ qemu-system-arm“. Sourcery Codebench (was CodeSourcery) available for free only under registration,Ĭross-compilers offer a set of programs, mainly GCC and binutils, that start with a prefix indicating the architecture, the operating system of the libraries and the binary interface of the compiled programs.Linaro if you run a newish version of Ubuntu you can install it directly with “ sudo apt-get install gcc-arm-linux-gnueabi“,.Emdebian here some instructions on how to install,.Depending on your distribution and what works for your setup, you can choose from different toolchains: A cross-compiler produces binaries for a different architecture (in our case ARMv7). ![]() The difference between a traditional compiler and a cross-compiler is that the traditional compiler runs on an architecture (for example x86_64) and produces binaries for the same architecture. To compile the kernel for ARM architecture, a cross-compiler must be installed. To manage the kernel compilation, GNU make should be installed (it is usually in build-essential package) In order to follow the same steps that I did, you need some tools.įirst of all, anything I do is performed on a Linux machine, specifically a Debian testing distribution, in a bash shell. Moreover, this hardware platform runs on the Cortex-A9 core, which is an ARM CPU that is included in many smartphones today. I chose to emulate the Versatile Express product because it’s well supported both by the mainline Linux kernel and by mainline QEMU. To simplify things, the boot will not include a complete filesystem but uses a minimal ramdisk to show the kernel executing just one program. I am going to show how to compile the kernel and emulate the boot. While most of these products are quite expensive (think about smartphones, development kits or evaluation boards) it’s possible to explore the world of Linux on ARM freely, thanks to software emulators like QEMU. This tutorial is an updated version of this old post, with newer software and less obsolete emulated hardware.Įvery year the market produces tons of new products that run on ARM cores, and are able to run operating systems such as Linux.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |