Author Topic: Emulate (or cross compile) Raspberry Pi on Linux64 to save time and flash disk?  (Read 3263 times)

0 Members and 1 Guest are viewing this topic.

Offline cdevTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
Hello, I am running various versions of raspbian (2 wheezy and 1 jessie) on 3 Raspberry Pis and trying to learn new stuff with hardware.

However, building software on the Pi, especially the older hardware, is very slow, and as I invariably forget things and want to do it again its frustrating.

Is anybody here adept at cross-compiling for their Pi from Linux, (64 bit) or using armhf emulation on qemu or VirtualBox or KVM and building images that way?

who could maybe share their own experiences, the relative merits of each, etc.




« Last Edit: July 19, 2017, 04:32:14 pm by cdev »
"What the large print giveth, the small print taketh away."
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
building software on the Pi, especially the older hardware, is very slow, and as I invariably forget things and want to do it again its frustrating

Bah ... flash? Are you using an SD card as rootfs? Bad idea! You complaint that it's s slow because the storage device is slow, thus attaching an USB-hard drive will save you, since it's different orders of magnitude faster.

Oh, now you have to chroot, from the SD (from where PI bootstraps) into the "mounted" harddrive. Not a problem, you also need to "bound" dev-names.

PI, even the first model appeared on the market, is much more faster than older Unix machines whose user experiences has never gone in anything can be called "complain".
 

Offline elecman14

  • Supporter
  • ****
  • Posts: 169
  • Country: us
Did the qemu thing in the past. It was somewhat limited on emulation from what I remember. From what I remember it had limited screen resolution using cmd or a gui. This was a couple of years ago so things might have changed. You probably should read up on that before you end up spending the time to get it working.

Also I do not believe virtualbox has emulation support for ARM only x86. No idea on KVM since I have never used it.

Depending on what you want to do you should also look at network booting. It would save from having to flash multiple SD cards.
 

Offline cdevTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
What I do when I want to build software is I have a small external USB hard drive that is partitioned with a Linux filesystem which I use exclusively for builds on RPIs.  I create a directory for the software untar the archive and build it there under my regular username. The Pi boots normally using the SD card but I don't build software on the SD card because of the wear issue.

How long does it take? at least an hour for ntpd, several hours for the linux kernel.

 I build it on the external hard drive, which internally is a PATA drive mounted using a PATA adaptor. I could also use an external SATA drive. I am pretty sure the bottleneck is the RPI just not being that fast. Sure, its a lot faster than most machines decades or so ago. My desktop machine is not all that fast but it has six cores and the CPU speed is several times faster so its much faster.

When I mount the external partition its in the normal way, mount -t . I don't use a chroot.

I haven't thought of using a chroot. Under some conditions it would make sense definitely.
"What the large print giveth, the small print taketh away."
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6203
  • Country: ro
Some weeks ago I found this RPi emulator, but never had the time to test it: http://www.makeuseof.com/tag/emulate-raspberry-pi-pc/

Offline 3db

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: gb
There used to be a Virtualbox VM for that purpose in the early days of Raspberry PI.
 
The following users thanked this post: cdev

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4037
  • Country: nz
Hello, I am running various versions of raspbian (2 wheezy and 1 jessie) on 3 Raspberry Pis and trying to learn new stuff with hardware.

However, building software on the Pi, especially the older hardware, is very slow, and as I invariably forget things and want to do it again its frustrating.

Is anybody here adept at cross-compiling for their Pi from Linux, (64 bit) or using armhf emulation on qemu or VirtualBox or KVM and building images that way?

who could maybe share their own experiences, the relative merits of each, etc.

Yes, we do this all the time at work when we're building software for ARM devices. not only do x86 desktops or servers have more and faster cores than an ARM board like a Pi, but they can have dozens or hundreds of GB of RAM and big fast SSDs.

Generally the best way:

1) set up qemu-arm-static with binfmt_misc so that you can run arm linux elf binaries from the x86 command line the same as if they were x86 binaries.

2) get a root file system for armhf or armel or whatever you want. I prefer to expand it on the host file system but you can also put it on a disk image and mount that

3) copy qemu-arm-static to the same relative place in the ARM root filesystem as it is in the host file system e.g. /usr/bin/qemu-arm-static. If you don't use a disk image then you can hard link it instead of copying

4) use chroot to switch into the ARM root filesystem. You need to set up a few things for /proc and maybe /dev before doing the chroot. Any chroot tutorial will go through that.

On the fastest current x86 chips, qemu is a little bit slower than a core on a Pi 2 or Pi 3 (and quite a lot slower than an Odroid C2 or better XU4). But if you have a server with 36 cores and 128 GB of RAM then you're flying overall :-)
« Last Edit: July 20, 2017, 11:10:43 am by brucehoult »
 
The following users thanked this post: cdev

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4037
  • Country: nz
Some instructions that look like they should work here:

https://wiki.debian.org/RaspberryPi/qemu-user-static

That's using a disk image and mounting it. It's all much of a muchness really. If you use a disk image you've got to worry about mounting it, making sure it's big enough etc. Copying the files into your normal filesystem you don't have to worry about any of that and it might even be slightly faster.

 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us

Are you thinking of big picture?

From the PI being able to to
apt get update

would be an easy command on PI. You would need to setup your own software source. Have no idea how hard this is, but could pull from cross compiled output.

You might also want to look at ANSIBLE.
It's a way to build, update & check systems.
Not a bad way to automate things, just needs SSH access to the PI's.
You could go so far as to build the cross compile environment on your PC as part of process.
Think sky is limit for possible use.


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf