How to use QEMU for learning ARM Linux kernel development? - linux

I want to learn it like developing some device driver etc and use QEMU for this because i have no hardware board for ARM like beagle board. What you guys suggest? Can i use Qemu simulator to learn Linux kernel on ARM targets? or any other option i should try ?

It depends on what you want to learn: hardware or software. If you really want to experiment with the different GPIO output to implement things like servo motor control, LED light blinking and display, a cheap board (eg, Raspberry Pi, about USD25) is much preferred.
But if you want to learn software in general, qemu is definitely much faster, and it lets you see the internal of what is happening. Experimenting with hardware will require oscilloscope etc. But experiment with software will depends on the error output of what others has implemented in their software.
As for drivers development, first version should be rapidly developed on QEMU. But testing which naturally involved hardware, should be done on the hardware.
Bottomline is: x86 is so much faster, that cross-crompilation is always done on x86 before it gets booted on the ARM board. Compiling on the board is too time consuming, and sometimes it may involved considerable amount of storage space for development libraries and source codes.

I used Qemu a while back to develop device drivers for an embedded programming class. It worked quite well. At the time we were learning device driver programming and then transitioning to Gumstix boards. I don't remember exactly what core we were using, but Qemu worked well.
I haven't done any ARM development, so I don't know if it is the best choice for learning ARM. But if you are new to drivers, it is probably a good place to start.

QEMU + Buildroot is great combination for ARM kernel development
Here is my setup that supports (mostly) both x86 and ARM: https://github.com/cirosantilli/linux-kernel-module-cheat
The kernel, toolchain, userland and QEMU are amazingly portable, that going from x86 to ARM is almost trivial.
Actually, you will seldom touch arch specifics, so you might as well start with x86.
I haven't played with ARM devices yet, only x86, but I bet it will be equally easy (i.e. not trivial due to lack of tutorials, but doable).

Related

What is SoC (system on chip)? Does Renesas V850 have a system on it?

I have experience writing a C program and burning the program into a chip using an IDE provided by the chip manufacturer.
I also heard that there is a concept called SoC, which means an operating system, like Linux, is running on a chip. In this case, I can run my program on the chip just like on a Linux PC.
I don't really know the differences between these two kinds of chips. Are they the same? Can I install Linux on every chip?
And I have to use a chip called Renesas V850 in my work. Which kind of chip is this V850?
SoC is just a marketing term for 'more than a processor on a chip'. It doesn't mean Linux or operating system.
Years ago, each part of a system was on its own chip: processor, serial port, memory, ADC, DAC, etc. You had a PCB and a schematic that tied them all together.
Over time, more and more got integrated into the processor, particularly for application-specific processors and microcontrollers. Today, pretty much only big iron processors like Intel and AMD flagship processors are stand-alone, and even then there's some x86 chip produced that are 'SoC's (like the AMD Geode line, if that's still around). Everything else has USB ports, serial ports, ADCs, DACs, even wireless radios integrated into the same die.
As for 'what is a Renasas v850?' You'd do better to google that and read the product documentation. It isn't an ARM or MIPs core, and it doesn't appear to support the mainline Linux kernel, only μClinux.
The Renesas V850 Wikipedia page states that the Linux kernel support for v850 has been absent since version 2.6.27 (which released in 2008).
Typically, you need to know what group your chip belongs to and to read more about it on Renesas website. They provide all the documentation you may need. There is also a section for application notes and sample code that may also help.

Benefits of UNIX or UNIX variant on microcontroller?

This may be a foolish question but I've been searching around for some time and don't see a clear answer. I've seen several microcontrollers advertised as running Unix-like software (Linux, Ubuntu) for example, the BeagleBone Black and Arduino Yun. Can someone please explain to me the benefit of this? So far I've used a couple of microcontrollers like the Arduino Uno/Duo, Freescale FRDM and STM32 Discovery which either didn't have this feature or I was not aware of it. I'm starting to see it more and more on newer microcontrollers so I'd like to know what it brings to the table.
Full disclosure: I've had minimal exposure to UNIX and its variants so far so please talk slowly and use small words =)
Hope to hear from you,
Yusif Nurizade
You get complex drivers already included Linux for free (USB, internet protocols, storage media and file systems).
You can use lots of free software for the things not included in the kernel.
It is simpler to develop software on a full OS (easier to debug, look what is going on, change the configuration, etc etc).
The drawback is that the real-time capabilities are generally worse than for some small RTOS, and it needs more resources (a couple of megabytes memory).
In the heart of all Android and iphone is a Embedded Linux System. Without getting too deep
Linux + Java = Android
BSD Unix variant + C/C++/Object C = iOS
Now if you get deeper the above two statement can be argued for accuracy
All Android devices run on ARM based microprocessors. Beaglebone is one such open source hardware platform with can run Android as well as Embedded Linux distribution and even a Ubuntu.
Now (IMHO) Ubuntu is primarily for desktop and server application. Many of the popular computer server farms uses Ubuntu.
Now STM32 is a ARM based CORTEX-M micro control. Once again (IMHO) is mostly used for bare metal embedded applications. I have hard that FreeRTOS can be ported to TM4C123 ARM Cortex-M TM4C123.
Now the advantages of using Linux base micro controller architecture are
OS is free for the most part
Larger community of users
The industry is moving towards open source
Lot of free resources get up to speed
Disadvantage are
Learning curve is pretty steep
Expect to stumble and fall a few time
Below to two good resources to learn Beaglebone open source development
Beaglebone
Introduction to Beaglebone development by Derek Molloy of Dublin City University
HTH and good luck

Linux kernel internals using ARM architecture as reference

Most of the linux kernel architecture books were written taking x86 architecture as reference (LKD by robert love or ULKI by bovett). Does there exist any book which explain linux kernel internals taking ARM architecture as reference.
Some basic questions are missing to really recommend you something and point you to useful resources:
what low level routines do you mean?
what are you going to do with that information?
The linux kernel is running on ARM already and most of the low level stuff is solved there and you shouldn't touch that unless you really know what you're doing. The linux kernel provides some generic low-level interfaces that its drivers stay portable without plattform specific snippets. Unless your intention is to add another ARM processor that is not supported yet you shouldn't need to dig around there.
If you want to add drivers or use components look into this device tree howto.
One major difference to X86 is the device tree/ open firmware stuff because System on Chip devices have often the same hardware mapped to different memory.
If you are looking for embedded kernel development you might also look into elinux.
Further reading is also provided in the linux-kernel tag wiki of stackoverflow.

Linux network driver port to ARM

I have a Linux network driver that was originally written for 2.4 kernel. It works perfect.
I want to port it to kernel 2.6.31 and then to ARM Linux with same kernel i.e. 2.6.31. I have actually done some minor changes to the driver so that it is able to compile under kernel 2.6.31 and it also loads and unloads without crashing. It also cross compiles for the ARM Linux. But I am unable to test it on ARM so far.
How do I check that the driver is fully compatible with the target kernel, and what considerations shall be made to make it compatible with ARM.
The driver is a virtual network device driver.
Thanks in advance.
Maybe you could use Qemu ( http://wiki.qemu.org/Main_Page) to emulate an ARM platform to be able to test your driver.
You cannot check the driver like that - you have to consider the API changes within 2.6.x series kernel. The changes are quite significant and the overall of the API's from the 2.4 series which is not currently in use.
I would suggest you to go here to the Amazon book store for this book in particular. The book is called 'Essential Linux Device Drivers', by Sreekrishnan Venkateswaran. A very well detailed explanation that will be your guidance in ensuring it works properly.
Since you mentioned the device driver is a network, presumably char device (You're not accessing it in blocks), well, the good news is that the 2.6.x series kernel APIs for the character devices are significantly easier and more centralized to focus on - in fact a lot of the framework is already in place in which the author of said book explains very clearly.
By the way, the book focusses on the latter 2.6.x series after 2.6.19, so this will help you clue in on what needs to be done to ensure your driver works.
You did not specify the ARM chipset you're targetting?
As for testing... well.. perhaps the best way to do this, this is dependant on how you answer the above question to you regarding ARM chipset - if its ARMv6, then perhaps, a cheap android handset that you can easily unlock and root, and pop the kernel in there and see what happens - sorry for sounding contrived but that's the best thing I can think of and that's what pops into my head, to enable you to test it out for ease of testing :)
PS: A lot of cheap ARMv6 handsets would have kernel 2.6.32 running Froyo if that's of any help!

Paravirtualizing linux on an ARM platform

I want to learn how to port linux to an ARM platform, and I am wondering if you guys have any tips or resources on how to do that? Everything from writing the boot file to setting up the interrupt vector, writing the linker script and having the executable system running.
I was thinking of buying a developer board to learn this, maybe Beagle board as it uses an ARM cortex processor and has a big user community. Is this a good idea? I am not very familiar with linux or porting operating systems in general, so any tips on how to get started would be nice!
What I want to do in the end is to virtualize all the linux kernels privileged operations to run in a hypervisor. Currently I have a hypervisor that is run beneath freeRTOS. All freeRTOS privileged operations (very few operations) have been changed to trap into the hypervisor by generating a SWI interrupt which leads to the hypervisor. What I want to do is too extend it to Linux instead which is more complex and alot bigger.
Best regards
Mr Gigu
You might want to check out the way it's done in L4Linux.
I would say start here...
http://elinux.org/BeagleBoard
From what I have seen, the Beagle Board seems to be one of the most widely supported boards 'community-wise' at this level.
As far as your questions goes, I am not totally sure what it is. If you are diving into all this embedded OS and linux stuff and want to have fun, that board is the probably way to go if you have some background with embedded development (which it seems you do). As far as professional development, not so sure...

Resources