Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: bmarkus on September 20, 2012, 07:42:55 AM

Title: Running piCore in QEMU
Post by: bmarkus 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 (http://lassauge.free.fr/qemu/)

Next download the piCore-5.3-QEMU.zip (http://tinycorelinux.net/5.x/armv6/releases/5.3/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
Title: Re: Running piCore in QEMU
Post by: vinnie 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
Title: Re: Running piCore in QEMU
Post by: vinnie 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?
Title: Re: Running piCore in QEMU
Post by: bmarkus 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 :)


Title: Re: Running piCore in QEMU
Post by: vinnie 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?
Title: Re: Running piCore in QEMU
Post by: bmarkus 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.

Title: Re: Running piCore in QEMU
Post by: roberts 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.
Title: Re: Running piCore in QEMU
Post by: bmarkus 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 :)

Title: Re: Running piCore in QEMU
Post by: hiro 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.
Title: Re: Running piCore in QEMU
Post by: bmarkus 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.
Title: Re: Running piCore in QEMU
Post by: Franxoois 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.
Title: Re: Running piCore in QEMU
Post by: bmarkus 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?
Title: Re: Running piCore in QEMU
Post by: Franxoois 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
Title: Re: Running piCore in QEMU
Post by: bmarkus on November 18, 2013, 01:49:41 AM
What is the piCore version displayed with the

Code: [Select]
version
command?
Title: Re: Running piCore in QEMU
Post by: Franxoois on November 18, 2013, 05:18:21 AM
In qemu : 4.7.5
on the raspi : 4.7.7
Title: Re: Running piCore in QEMU
Post by: Franxoois on November 21, 2013, 03:58:43 AM
I tried to run qemu with the piCore from qemu to test but it doesn't run. That's not so easy. Is there's a tuto to know how to remaster the piCore.gz, to make it run in qemu/raspberry ?
 
Title: Re: Running piCore in QEMU
Post by: bmarkus on November 21, 2013, 08:28:55 AM
I tried to run qemu with the piCore from qemu to test but it doesn't run. That's not so easy. Is there's a tuto to know how to remaster the piCore.gz, to make it run in qemu/raspberry ?

It is not clear what is your goal. Do you want to run piCore in QEMU or want to run QEMU on the Raspberrey?
Title: Re: Running piCore in QEMU
Post by: Franxoois on November 26, 2013, 12:56:02 PM
Sorry for my english.

For the moment I created an .img file I could run and configure in qemu, then copy on a SD card to boot a raspberry.

I run the .img file with qemu thanks to your script and your special piCore.gz created for qemu. When I copy the .img to a sd card, the Raspberry boot with onother the piCore.gz present in the first partition of the .img

If I would like to modify the core linux system, I presume I have to modify the piCore.gz. I don't even know if this is the good way to reduce the time loading extention at boot time.

I may modify the piCore.gz file used by qemu, but if I want to see this modification on the raspberry, I have to modify the piCore.gz on the first partition of the .img. Maybe there is a way to do this modification only once, using the same piCor.gz for the two plateform, qemu and raspi. That's maybe means the piCore.gz present in the .img file for raspberry would contains unecessary kernel used only for qemu.
Title: Re: Running piCore in QEMU
Post by: MysticGriffin on June 16, 2016, 07:29:21 PM
Hi guys,

I know this thread hasn't been active in a while... but it seemed like the best place for me to post this question instead of starting a new topic. Hope that's okay. I'm kind of a forum noob ;)

I have been playing around with TinyCore only a little, with the intent of ultimately running it on ARM architecture. Recently I've been looking at using Raspberry PI, and so have shifted to piCore (I'm excited for the debian packages!). I've successfully managed to get piCore running to the command line but...

The first thing I noticed is that it is really slow to do stuff. There is a very noticeable lag even when just using ls to display the contents of a directory.

Second it's not detecting any hard disks. I've set up a qcow2, it didn't work, so I tried a raw image. It didn't work either. This was created with "qemu-img create -f qcow2 tcdisk.qcow2 128M"
When running picore I've been using "qemu-system-arm -kernel piCore-140513-QEMU -cpu arm1176 -m 256 -M versatilepb -serial stdio -initrd piCore-140519-QEMU.gz -hda tcdisk.img -hdb tcswap.img -append "root=/dev/ram0 elevator=deadline quiet rootwait nortc"

I'm not sure what I've done wrong. Help?
Title: Re: Running piCore in QEMU
Post by: bmarkus on June 16, 2016, 10:28:34 PM

Second it's not detecting any hard disks.


What do you mean not detected? Not seen by the kernel or by piCore? Can yo access the virtual drive with fdisk?

If it is detected by the kernel, is it formatted to ext4?
Title: Re: Running piCore in QEMU
Post by: MysticGriffin on June 17, 2016, 03:32:00 AM

Second it's not detecting any hard disks.


What do you mean not detected? Not seen by the kernel or by piCore? Can yo access the virtual drive with fdisk?

If it is detected by the kernel, is it formatted to ext4?
Sorry for not giving that info. It cannot be seen by fdisk, and it does not show up in the dev or mnt directory. Mnt has sr0, and dev has ram, which I assume correlate. If there's any other way to look for it I don't know it.

I'm using qemu from Windows 10 64bit. Qemu is the latest build (qemu-w64-setup-20160523.exe)

The drives currently have no formatting. They are raw images made with qemu-img. I need piCore to be able to find them so I can set them up with fdisk.
Title: Re: Running piCore in QEMU
Post by: curaga on June 17, 2016, 09:11:06 AM
The Pi has no SATA, how would it attach hard drives? I think that's a qemu/versatile-specific option that wouldn't be found on a normal Pi kernel config.
Title: Re: Running piCore in QEMU
Post by: MysticGriffin on June 17, 2016, 09:30:23 AM
The Pi has no SATA, how would it attach hard drives? I think that's a qemu/versatile-specific option that wouldn't be found on a normal Pi kernel config.
That does seem to be a fair point. I never thought of that. But it is in bmarkus' tutorial. And of course the typical installation would have the OS running from an SD card so the idea is similar to a hard disk. I'll play around with that idea when I get back home.

Sent from my LG-D852 using Tapatalk

Title: Re: Running piCore in QEMU
Post by: bmarkus on June 17, 2016, 09:42:59 AM
Well, when it was written its was working as in the tutorial :)