WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Running piCore in QEMU  (Read 28024 times)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Running piCore in QEMU
« on: September 20, 2012, 07:42:55 AM »
Article is updated for piCore-5.3 release.

piCore can run in QEMU, you do not need a real hardver. This way you can get familiar with the system and see how it works. Even if you own a Raspberry Pi it can be easier to test programs or develop than on a real hardware.

Prerequisits

First you need qemu-system-arm version 1.1 or later release, olders doesn't work. On TC, install quemu-arm.tcz available in the repo. It is available in most LINUX distributions, probably in the qemu-extra package.

Windows version of QEM can be downloaded from from this site

Next download the piCore-5.3-QEMU.zip of piCore and extract it to the directory where qemu-system-arm is found. Please note, for QEMU a special version of piCore (both kernel and initrd) required, normal version doesn't work.

Running piCore

Run piCore-start.sh or piCore-start.bat depending on operating system. udevd messages during boot running on older versions of QEMU can be safely omitted.

Adding persistency

Now you must have piCore running in QEMU with networking. You can install package online with tce or tce-load but they are loaded to RAM in /tmp/tce directory. Lets add a virtual drive. Create a virtual disk image:

qemu-img create -f qcow2 tcdisk.qcow2 128M

It will create a 128Mbyte sized qcow2 type blank disk image. qcow2 is a special QEMU format; initial size is very small and automatically growing when necessary. Choose size fits to your requirements. Next, add

-hda tcdisk.qcow2

to the startup options. Start piCore, there will be a blank /dev/sda drive. Create a LINUX partition with fdisk and run rebuildfstab as root, than format with mkfs.ext4 Mount and create a tce directory in root. As you see nothing special, works exactly on the same way as x86 version with a new blank drive.

Add swap

Due to Raspberry Pi's low memory compressed RAM swap is disabled; it is worth to add a SWAP partition. You can have it on the same virtual disk as your persistent partition, but I advice to have a different raw type drive, created with

qemu-img create -f raw tcswap.img 256M

Add

-hdb tcswap.img

to qemu options. Drive will be seen as /dev/sdb in piCore. Create a swap partition with fdisk and prepare with mkswap. It will be recognized at next boot automatically. Use free to check. You can activate it after creation without reboot with the swapon command.

Note: remove noswap option in start.sh/start.bat when swap used.

Install GUI

To install basic GUI environment install TC.tcz extension. As a normal user (tc) execute

Code: [Select]
tce-load -iw TC
than type

Quote
startx
« Last Edit: May 19, 2014, 09:19:04 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: Running piCore in QEMU
« Reply #1 on: September 21, 2012, 02:58:39 PM »
really thanks markus, I wanted to ask but I felt embarrassed
as soon as I have some free time I try

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: Running piCore in QEMU
« Reply #2 on: September 24, 2012, 01:01:29 AM »
ok, it works well!
but how can I compile programs?
there are no compile.tcz, submitqc and others in the series?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Running piCore in QEMU
« Reply #3 on: September 24, 2012, 01:41:55 AM »
ok, it works well!
but how can I compile programs?
there are no compile.tcz, submitqc and others in the series?

As you see, at the moment I'm the only one creating extensions. My first goal was to make it usable somehow, having mc, remote access, etc. Second goal was to have Python available with Sqlite3. It is ready, extensions submitted. Third is to have my APRS gateway running including AX.25 stack.

At the same time I'm building generic extensions used by many others, like openssl, gnutls, etc. These are necessary to have a mail client like alpine and basic servers.

Next major goal is to have development toolchain available, but there are many missing extensions. Existing build scripts make it easier, however, even if there are buggy or obsolate scripts too.

To make extensions you do not need toolchain running on piCore. I'm building them on Raspberry. Result is binary compatible with piCore.

I have limited time to deal with it specially with extension I do not need to reach above goals. You are welcome to join :)


Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: Running piCore in QEMU
« Reply #4 on: September 24, 2012, 06:55:07 AM »
And then you use another distro for compilations? debian?
I do not possess raspberry, I wanted to try on qemu.
But to start compiling each component of the toolchain (compiletc.tcz) it is sufficient to have gcc.tcz?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Running piCore in QEMU
« Reply #5 on: September 24, 2012, 07:48:57 AM »
No, I'm not using Debian but Raspbian in QEMU on WINDOWS XP.

Toolchain, for sure not, normally you need not only gcc but other tool. It requires iteration in several steps to be move verything to target platform and finally recompile them there.

But there is a lazy but faster solution, move binaries from Raspbian to piCore and use them.

Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Running piCore in QEMU
« Reply #6 on: September 24, 2012, 07:50:15 AM »
Even with a Raspberry Pi compiles can be very slow. Example when I compiled the first kernel it took 10 hours.
So I setup a cross compiler on Tiny Core x86. I have used such cross compiler to build subsequent rpiCore kernels and the Qemu rpiCore kernel.  I suppose that you could use Raspbian on Qemu but I don't own machine powerful enough to run Qemu + full Raspbian + do compiles. I have posed in the allwinner thread on the setup and use of a cross-compiler.
10+ Years Contributing to Linux Open Source Projects.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Running piCore in QEMU
« Reply #7 on: September 24, 2012, 08:03:13 AM »
I don't like cross compilers except very early stage, but it's  a personal staff. QEMU eats up 100% of one CPU core on my desktop machine, compilation of a bigger pacakage, like Python takes 2 hours. But thats' fine, it runs in the background. Can't compare it with compiling on real hardware. Anyhow, I'm progressing :)

Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline hiro

  • Hero Member
  • *****
  • Posts: 1217
Re: Running piCore in QEMU
« Reply #8 on: October 25, 2012, 12:27:43 AM »
it's qemu-img create -f raw tcswap.img 256M
and qemu-img create -f qcow2 tcdisk.qcow2 128M

at least with qemu-arm from the repo.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Running piCore in QEMU
« Reply #9 on: October 25, 2012, 01:02:13 AM »
it's qemu-img create -f raw tcswap.img 256M
and qemu-img create -f qcow2 tcdisk.qcow2 128M

at least with qemu-arm from the repo.

Thanks, corrected in the article.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Franxoois

  • Newbie
  • *
  • Posts: 18
Re: Running piCore in QEMU
« Reply #10 on: November 15, 2013, 09:21:02 AM »
Hello,

I just try qemu and it's running very well.

I would like to know if there's a way to set up a system which run as well in qemy as on the raspberry ? I would like to create an .img file I can load with qemy, configure and then made a dd to a sd card and put in many real raspi.

Edit :
The solution was quite simple. I copied the piCore-20130627.img in myPiCore.img and use the command "qemu-img resize myPiCore.img +600M"
I had the "-hda myPiCore.img" at the end of the start.sh file. This way I can manage partition, tce and install dropbear ssh server. I just boot the raspi with dropbear allready installed.
« Last Edit: November 16, 2013, 03:03:53 AM by Franxoois »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Running piCore in QEMU
« Reply #11 on: November 17, 2013, 12:17:58 PM »
Hello,

I just try qemu and it's running very well.

I would like to know if there's a way to set up a system which run as well in qemy as on the raspberry ? I would

Thanks for the feedback. Which version of QEMU are you using and which host? Can you share the startup script ot batch file with us?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Franxoois

  • Newbie
  • *
  • Posts: 18
Re: Running piCore in QEMU
« Reply #12 on: November 18, 2013, 01:42:43 AM »
Hello,

I use ubuntu 13.10 with default qemu from the official's depo.

The script is basicly yours

Code: [Select]
#!/bin/sh

qemu-system-arm -kernel piCore-qemu-20130226/zImage -cpu arm1176 -m 512 -M versatilepb -no-reboot \
-serial stdio -initrd piCore-qemu-20130226/piCore.gz -append \
"root=/dev/ram0 elevator=deadline rootwait quiet nozswap nortc" \
-hda myPiCore.2.img \
-redir tcp:5022::22 \
-redir tcp:5080::80

The myPiCore.2.img is a copy of piCore, with the size extended by qemu-img.

I think you saw that my probleme is that the zImage and the piCore.gz I use with qemu differs from the one booting on the raspi. I only share the persistents partitions. I understand the kernel has to be different. I don't really know the differences between the piCore.gz I use and the piCore3611a.gz wich is in the first partition of myPiCore.2.img

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Running piCore in QEMU
« Reply #13 on: November 18, 2013, 01:49:41 AM »
What is the piCore version displayed with the

Code: [Select]
version
command?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Franxoois

  • Newbie
  • *
  • Posts: 18
Re: Running piCore in QEMU
« Reply #14 on: November 18, 2013, 05:18:21 AM »
In qemu : 4.7.5
on the raspi : 4.7.7