Skip to contentSkip to conversation

minimal linux distribution for qemu

Qemu-devel Herbei Dacian 5 participants 20 messages Aug 15, 2013 – Aug 20, 2013

lore
Share & tools
lore
#0 lore raw

hi,
please, can anyone recommend me a distribution that offers a barebone linux kernel. minimum that I need on that image are:
_ the kernel
_ the compiler and development infrastructure to build it
regards,
dacian

#1 lore raw

Hi,

Am 15.08.2013 10:57, schrieb Herbei Dacian:

Quoted 6 lines

please, can anyone recommend me a distribution that offers a barebone linux kernel.
minimum that I need on that image are:
_ the kernel
_ the compiler and development infrastructure to build it

Aboriginal Linux.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw
In reply to Herbei Dacian
Quoted 4 lines · Herbei Dacian

please, can anyone recommend me a distribution that offers a barebone linux kernel. minimum that I need on that image are:
_ the kernel
_ the compiler and development infrastructure to build it

If you want something small and customizable, try Tiny Core Linux:

http://www.tinycorelinux.net/

#5 lore raw

In the end I went for debian cause it is widely used.

So I'm using the following command to install linux:
qemu-system-arm -m 1024 -hda arm.img -cdrom debian-7.1.0-armel-CD-1.iso -boot d

And I get this error:
Kernel image must be specified

In the documentation is mentioned that i don't need a bzImage if the CD is bootable. any suggestions?

#6 lore raw
Quoted 6 lines · Herbei Dacian

In the end I went for debian cause it is widely used.

So I'm using the following command to install linux:
qemu-system-arm -m 1024 -hda arm.img -cdrom debian-7.1.0-armel-CD-1.iso -boot d

This command line is totally broken. You're running (by default) an emulation of the 'integratorcp' board (which is pretty much obsolete and a bad choice), and you're trying to pass it a CDROM image, when the board doesn't have a CDROM drive. You need to specify the right board to emulate (with '-M something' and also pass a kernel and an initrd to load (with -kernel and -initrd).

-- PMM

#7 lore raw

OK but which command should I use if that is broken and where I can find some documentation that is actually up to date?

________________________________
From: Peter Maydell <[email protected]>
To: Herbei Dacian <[email protected]>
Cc: QEmu Devel <[email protected]>
Sent: Thursday, 15 August 2013, 15:31
Subject: Re: [Qemu-devel] minimal linux distribution for qemu

Quoted 6 lines · Herbei Dacian

In the end I went for debian cause it is widely used.

So I'm using the following command to install linux:
qemu-system-arm -m 1024 -hda arm.img -cdrom debian-7.1.0-armel-CD-1.iso -boot d

This command line is totally broken. You're running (by default) an emulation of the 'integratorcp' board (which is pretty much obsolete and a bad choice), and you're trying to pass it a CDROM image, when the board doesn't have a CDROM drive. You need to specify the right board to emulate (with '-M something' and also pass a kernel and an initrd to load (with -kernel and -initrd).

-- PMM

#8 lore raw
Quoted 2 lines · Herbei Dacian

OK but which command should I use if that is broken and where I can find some documentation that is actually up to date?

You need to start by finding out which of the boards QEMU models your distribution actually supports, and the expected install method for them. ARM is *not* like x86 here -- all x86 systems are basically identical, but all ARM boards are different and you need the correct kernel for the board you're running, whether that board is real hardware or emulated.

-- PMM

#9 lore raw

yes but which binary do I use to call to run an emulated arm image?

is there an actual binary that can emulate an existing arm board, anyboard? qemu?
if not which is the emulator that works with arm?
If not where is the project that I can tweak to build such a binary.

I can search for the board that is not a problem and then I can tweak the project but I need to know where can I find this. I couldn't find any documentation in this direction.

________________________________
From: Peter Maydell <[email protected]>
To: Herbei Dacian <[email protected]>
Cc: QEmu Devel <[email protected]>
Sent: Thursday, 15 August 2013, 15:48
Subject: Re: [Qemu-devel] minimal linux distribution for qemu

Quoted 2 lines · Herbei Dacian

OK but which command should I use if that is broken and where I can find some documentation that is actually up to date?

You need to start by finding out which of the boards QEMU models your distribution actually supports, and the expected install method for them. ARM is *not* like x86 here -- all x86 systems are basically identical, but all ARM boards are different and you need the correct kernel for the board you're running, whether that board is real hardware or emulated.

-- PMM

#10 lore raw
Quoted 1 line · Herbei Dacian

yes but which binary do I use to call to run an emulated arm image?

qemu-system-arm.

Quoted 1 line

is there an actual binary that can emulate an existing arm board, anyboard?

"qemu-system-arm -M help" lists the boards we support.

http://www.aurel32.net/info/debian_arm_qemu.php is a good howto type document.

-- PMM

#11 lore raw

but you said that "qemu-system-arm" is not maintained and it doesn't work.

The link below contains only links to kernel images that don't work. Anyway I'll figure it somehow cause this doesn't help me.

________________________________
From: Peter Maydell <[email protected]>
To: Herbei Dacian <[email protected]>
Cc: QEmu Devel <[email protected]>
Sent: Thursday, 15 August 2013, 16:05
Subject: Re: [Qemu-devel] minimal linux distribution for qemu

Quoted 1 line · Herbei Dacian

yes but which binary do I use to call to run an emulated arm image?

qemu-system-arm.

Quoted 1 line

is there an actual binary that can emulate an existing arm board, anyboard?

"qemu-system-arm -M help" lists the boards we support.

http://www.aurel32.net/info/debian_arm_qemu.php is a good howto type document.

-- PMM

#12 lore raw
Quoted 1 line · Herbei Dacian

but you said that "qemu-system-arm" is not maintained and it doesn't work.

No, I said that the arguments you were giving it were requesting a model of an obsolete board, and you should ask it to emulate a different board.

-- PMM

#2 lore raw
In reply to Andreas Färber
Quoted 6 lines · Andreas Färber

Hi,

Am 15.08.2013 10:57, schrieb Herbei Dacian:

Quoted 2 lines

please, can anyone recommend me a distribution that offers a

barebone

Quoted 8 lines
Quoted 4 lines

linux kernel.
minimum that I need on that image are:
_ the kernel
_ the compiler and development infrastructure to build it

Aboriginal Linux.

Andreas

Aboriginal actually comes with qemu launch scripts for each target. ./run-emulator.sh is just the qemu command line, ./dev-environment.sh is a wrappe around that providing a better development enviornment (more memory and disk space). It's all described at http://landley.net/aboriginal/about.html

Try this:

wget http://landley.net/aboriginal/bin/system-image-armv5l.tar.bz2
tar xvjf system-image-armv5l.tar.bz2
cd system-image.armv5l
./run-emulator.sh

gcc /usr/src/thread-hello2.c -lpthread
./a.out
exit

Thanks,

Rob

#14 lore raw
In reply to Herbei Dacian
Quoted 7 lines · Herbei Dacian

yes but which binary do I use to call to run an emulated arm image?

is there an actual binary that can emulate an existing arm board, anyboard? qemu?
if not which is the emulator that works with arm?
If not where is the project that I can tweak to build such a binary.

The arm versatilepb emulation can accept a range of processors (I've tried armv4, armv4t, armv5, armv6, and armv7), provides a PCI bus with a virtual hard drive controller and network card, and can accept 256 megs of ram. (In theory it can accept more but I have to get the discontiguous memory stuff to work, haven't done that yet.)

That's the one I used in Aboriginal Linux arm images.

Rob

#3 lore raw
In reply to Rob Landley

Thanks Rob I think that should do it for me.

________________________________
From: Rob Landley <[email protected]>
To: Andreas Färber <[email protected]>
Cc: Herbei Dacian <[email protected]>; QEmu Devel <[email protected]>
Sent: Friday, 16 August 2013, 17:59
Subject: Re: [Qemu-devel] minimal linux distribution for qemu

Quoted 6 lines · Andreas Färber

Hi,

Am 15.08.2013 10:57, schrieb Herbei Dacian:

Quoted 2 lines

please, can anyone recommend me a distribution that offers a

barebone

Quoted 8 lines
Quoted 4 lines

linux kernel.
minimum that I need on that image are:
_ the kernel
_ the compiler and development infrastructure to build it

Aboriginal Linux.

Andreas

Aboriginal actually comes with qemu launch scripts for each target. ./run-emulator.sh is just the qemu command line, ./dev-environment.sh is a wrappe around that providing a better development enviornment (more memory and disk space). It's all described at
http://landley.net/aboriginal/about.html

Try this:

  wget http://landley.net/aboriginal/bin/system-image-armv5l.tar.bz2
  tar xvjf system-image-armv5l.tar.bz2
  cd system-image.armv5l
  ./run-emulator.sh

  gcc /usr/src/thread-hello2.c -lpthread
  ./a.out
  exit

Thanks,

Rob

#15 lore raw
In reply to Rob Landley

my system should run in far less memory. something like 2-4MB.
but first I need to have a system running so that I can monitor with qemu the addresses accessed for read execute and write by the code run by the emulator. if I reach that is a real big deal.
dacian

________________________________
From: Rob Landley <[email protected]>
To: Herbei Dacian <[email protected]>
Cc: Peter Maydell <[email protected]>; QEmu Devel <[email protected]>
Sent: Friday, 16 August 2013, 18:05
Subject: Re: [Qemu-devel] minimal linux distribution for qemu

Quoted 8 lines · Herbei Dacian

yes but which binary do I use to call to run an emulated arm image?

is there an actual binary that can emulate an existing arm board, anyboard?
qemu?
if not which is the emulator that works with arm?
If not where is the project that I can tweak to build such a binary.

The arm versatilepb emulation can accept a range of processors (I've tried armv4, armv4t, armv5, armv6, and armv7), provides a PCI bus with a virtual hard drive controller and network card, and can accept 256 megs of ram. (In theory it can accept more but I have to get the discontiguous memory stuff to work, haven't done that yet.)

That's the one I used in Aboriginal Linux arm images.

Rob

#13 lore raw
In reply to Herbei Dacian
Quoted 2 lines · Herbei Dacian

but you said that "qemu-system-arm" is not maintained and it doesn't work.

Who said that?

git log --pretty=format:"%h %ci %s" hw/arm

be2f78b 2013-08-05 11:46:58 -0500 pxa2xx: Avoid object_get_link_property() asser cfc6b24 2013-07-29 21:06:27 +0200 versatilepb: QOM cast cleanup for vpb_sic_stat 0ca8187 2013-07-29 21:06:27 +0200 strongarm: QOM cast cleanup for StrongARMSSPSt fff3af9 2013-07-29 21:06:27 +0200 strongarm: QOM cast cleanup for StrongARMUARTS

Something like 50 commits to hw/arm last month alone, and August was feature freeze for the 1.6.0 release. (If it _wasn't_ actively developed I wouldn't have had to work around a darn IRQ routing issue on the arm target in the last Aboriginal release...)

Rob

#16 lore raw
In reply to Herbei Dacian

Am 16.08.2013 18:17, schrieb Herbei Dacian:

Quoted 1 line

my system should run in far less memory. something like 2-4MB.

I thought either 16MB or 64MB RAM was a lower limit for uCLinux?

If you want to write your own custom firmware then you can go pretty low of course. For low-end ARM embedded development the two Stellaris machines (Cortex-M3) might be a good starting point in that case.

Andreas

P.S. Please avoid top-posting and HTML on this mailing list.

Quoted 35 lines

but first I need to have a system running so that I can monitor with qemu the addresses accessed for read execute and write by the code run by the emulator.
if I reach that is a real big deal.
dacian

------------------------------------------------------------------------
*From:* Rob Landley <[email protected]>
*To:* Herbei Dacian <[email protected]>
*Cc:* Peter Maydell <[email protected]>; QEmu Devel <[email protected]>
*Sent:* Friday, 16 August 2013, 18:05
*Subject:* Re: [Qemu-devel] minimal linux distribution for qemu

Quoted 8 lines · Herbei Dacian

yes but which binary do I use to call to run an emulated arm image?

is there an actual binary that can emulate an existing arm board, anyboard?
qemu?
if not which is the emulator that works with arm?
If not where is the project that I can tweak to build such a binary.

The arm versatilepb emulation can accept a range of processors (I've tried armv4, armv4t, armv5, armv6, and armv7), provides a PCI bus with a virtual hard drive controller and network card, and can accept 256 megs of ram. (In theory it can accept more but I have to get the discontiguous memory stuff to work, haven't done that yet.)

That's the one I used in Aboriginal Linux arm images.

Rob

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#17 lore raw
In reply to Herbei Dacian
Quoted 4 lines · Herbei Dacian

my system should run in far less memory. something like 2-4MB.
but first I need to have a system running so that I can monitor with qemu the addresses accessed for read execute and write by the code run by the emulator. if I reach that is a real big deal.
dacian

Linux 2.6 and later won't run in 2 megs at all. You can trim it down to 4 megs on a nommu system (the page tables take up too much ram otherwise), but won't be able to do much.

Really, things like kobjects in the modern kernel take up too much space. Getting anything to work in 4 megs requires diabling all the printk strings at compile time. (The last time I saw somebody do a 4 meg system was CELF in 2006. 32 bit x86.)

Look at the uClinux project. Or try to bolt your app onto uboot and run it on the bare metal.

Rob

#18 lore raw

good to know.
I was working back in 2005-2006 with a company that had a 4MB kernel.
At that time I was too inexperienced to work at that level but I thought now I could reproduce their work with some help. Anyhow for the moment I'll go for 256 MB of ram board just so that I don't worry too much about things that are not yet relevant for me. But thanks again for the warning.
But since you helped me soo much I have another question.
Is it fisible to change the emulator so that I may visualize the following aspects:
_ address of the currently executed instruction from the guest system
_ if this instruction is a form of jump like call return conditional jump.
_ the address or range of addresses read by this instruction
_ the address or range of addresses written by this instruction

I read some things about the emulator and if I understood it correctly the emulator breaks the instructions of the gurest platform in micro ops which are then executed on the host operation system. So I'm asking the question above in the idea that maybe there is also somekind of reordering of these micro instructions.
best regards,
dacian

________________________________
From: Rob Landley <[email protected]>
To: Herbei Dacian <[email protected]>
Cc: Peter Maydell <[email protected]>; QEmu Devel <[email protected]>
Sent: Sunday, 18 August 2013, 8:00
Subject: Re: [Qemu-devel] minimal linux distribution for qemu

Quoted 6 lines · Herbei Dacian

my system should run in far less memory. something like 2-4MB. but first I need to have a system running so that I can monitor with qemu the addresses accessed for read execute and write by the code run by the emulator.
if I reach that is a real big deal.
dacian

Linux 2.6 and later won't run in 2 megs at all. You can trim it down to 4 megs on a nommu system (the page tables take up too much ram otherwise), but won't be able to do much.

Really, things like kobjects in the modern kernel take up too much space. Getting anything to work in 4 megs requires diabling all the printk strings at compile time. (The last time I saw somebody do a 4 meg system was CELF in 2006. 32 bit x86.)

Look at the uClinux project. Or try to bolt your app onto uboot and run it on the bare metal.

Rob

#19 lore raw
Quoted 12 lines · Herbei Dacian

good to know.
I was working back in 2005-2006 with a company that had a 4MB kernel.
At that time I was too inexperienced to work at that level but I thought now I could reproduce their work with some help. Anyhow for the moment I'll go for 256 MB of ram board just so that I don't worry too much about things that are not yet relevant for me. But thanks again for the warning.
But since you helped me soo much I have another question.
Is it fisible to change the emulator so that I may visualize the following aspects:
_ address of the currently executed instruction from the guest system
_ if this instruction is a form of jump like call return conditional jump.
_ the address or range of addresses read by this instruction
_ the address or range of addresses written by this instruction

If you feed qemu the -s option it'll open a network port you can connect to to provide the gdbserver protocol (gdb's "target remote" command attaches to this). For system emulation it acts like a jtag attached to the emulated hardware, letting you see registers and such.

Quoted 3 lines

I read some things about the emulator and if I understood it correctly the emulator breaks the instructions of the gurest platform in micro ops which are then executed on the host operation system.

Not really, no.

QEMU translates large blocks of code (used to be pages, now it's variable sized chunks depending on where the return instruction is) and keeps the translated versions cached (sort of like a java JIT). The main QEMU loop then calls the translated functions which execute until they return or get interrupted by signals (simulating things like timer IRQ). This is why QEMU is so fast, the actual translation overhead is amortized by the resulting native code being run lots of times, a function or loop gets translated once and then runs as native code.

This means that "the address of the currently executing instruction" isn't really something qemu naturally tracks, because although there _is_ a copy of the untranslated code page, it's not what we're running. The gdbserver code tries to do so artifically, but it's slow and awkward and not always perfect.

Self-modifying code is actually a horrible thing to do to qemu, from a performance perspective. Every time the emulated code page is modified, the cached copy of the translated code is discarded and the entire page gets retranslated. This means that in Aboriginal Linux, the shell scripts ./configure runs sped up 20% when I replaced my dynamically linked busybox with a statically linked one, due to the extra translations caused by the relocation fixups.

Rob