Running ARM applications on x86 (Running Raspberry pi applications on PC)

ARM on 86
3 minutes read

I hope you have some hands on experience on linux and have some knowledge of the processor architectures. If not let me explain you in layman terms.

There are so many computers out there and they all run on different processors with different architectures. For example our normal windows PC has a x86 architecture of processors, most of the Single Board Computer (eg:- Raspberry Pi) run on ARM architecture. With different architectures of processors their applications also differ and hence if an application is running on and ARM processor it will not run on x86 processor architectures (excluding java applications which are platform independent).

In this blog i will explain you how to run ARM application on and x86 machine using virtualisation and emulation. This means that we are going to make an ARM architecture machine inside a x86 machine using QEMU software to run our ARM based application on and x86 machine, for example running Raspberry Pi application on your linux PC.

Now the question is why we want to do such things when there have plethora of application already running on x86 machines ? There may be many use cases such as

  • For testing application on your machine before installing it on the original hardware.
  • For running specific application which are only available for different architecture, if you physically do not have the hardware.
  • For my purpose, i wanted to cross compile the application on PC as considering the weak hardware present on Raspberry Pi it was taking centuries to compile. Therefore i wanted to compile on PC and then would take the Debian package onto my original machine and just install it over there. This would save a lot of time and debugging will also become very easy.

I think i have discussed enough about the topic, now let us jump in for the creation of cross platform architecture on out PC (or on our x86 machine).

Multi platform virtualisation using chroot, QEMU, debootstrap

Install Required Packages

To accomplish the above task we need install the following packages.

Note :- We have logged in as a root user. To do that type “su”, press enter and enter the root password.

Get Root Access
apt-get install binfmt-support qemu qemu-user-static debootstrap
Installing QEMU

Make Directory for ARM OS installation

We have to make a directory where the guest OS for ARM architecture needs to be installed by debootstrap.

mkdir arm_dir
Making directory for Virtual ARM OS installation

Install guest OS

Install the guest OS by deebootstrap. By default, debootstrap creates a very minimal system.

qemu-debootstrap --arch armel stretch arm_dir
Creating debootstrap

Copy emulation file

Now we have to copy the QEMU emulation file onto our guest OS from the host OS to start the virtualisation of the ARM machine onto our x86 machine.

cp /usr/bin/qemu-arm-static arm_dir/usr/bin
Copy QEMU emulation file

Starting the virtual environment

Now environment is ready to be used. Start the environment by using the chroot command. This will take you into a sandbox and give you the root access in the virtual environment for ARM machine. This is really beneficial as any changes made in this environment will not affect the host system in any way, therefor this is also the best environment for testing purposes.

chroot arm_dir
Executing the chroot environment

Reference – Official Debian Documentation

Hope you have enjoyed learning something new in the linux world. I to love to learn and share new thing with you all. Therefore please like, share and subscribe to our youtube channel and for continuous learning you can bookmark our blog URL. This will give us motivation to bring more such learning to you all 🙂 .

8 Replies to “Running ARM applications on x86 (Running Raspberry pi applications on PC)”

  1. Finally someone that knows what they’re talking about.

  2. Great blog here! Also your site a lot up fast! What host are you using? Can I am getting your affiliate hyperlink in your host? I want my site loaded up as quickly as yours lol

    1. You can have a google search for many hosting companies. I made this blog to the minimal that is the reason i think it is loading up quickly. If you really want i can share my referral for my hosting 🙂

  3. Hey superb blog! Does running a blog such as this take a lot of work? I’ve very little expertise in coding but I was hoping to start my own blog in the near future. Anyhow, should you have any ideas or tips for new blog owners please share. I understand this is off subject however I simply wanted to ask. Thanks a lot!

    1. Thank you so much, Yes we have to put in some effort in writing the blogs. I am also not regular for my blogs 🙁

  4. Peculiar article, just what I was looking for.

  5. What’s up to all, how is all, I think every one is getting more from this web page, and your views are fastidious in support of new users.

  6. When someone writes an post he/she retains the thought of a user in his/her brain that how a user can be aware of it.
    So that’s why this piece of writing is perfect. Thanks!

Leave a Reply