Build ARM on X86, no cross-compiler.

Post Reply
lazlo
Posts: 143
Joined: Sun Oct 01, 2017 11:32 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Build ARM on X86, no cross-compiler.

Unread post by lazlo » Sat Apr 06, 2019 5:28 am

Daniel Robbins, the creator of the Gentoo and Funtoo Linux distros, has announced a new package for building ARM binaries on AMD64 based systems without a cross-compiler.. It is a QEMU based version of chroot called Frankenchroot. It is very cool and will change the way you build for ARM systems. Check out the announcement here:

https://forums.funtoo.org/topic/1970-an ... root-tool/

EDIT: Fixed a typo and wanted to add the URL for the git repository.

https://code.funtoo.org/bitbucket/users ... oot/browse

User avatar
meveric
Posts: 9934
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, N2
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by meveric » Sat Apr 06, 2019 4:13 pm

I don't think that's anything new.
It's nice someone wrote a script for beginners to do all the mounting and calls for qemu you normally would have to do manually, but aside from that it's nothing new.

This is a guide from 2014 which does pretty much the same thing and I've seen older guides than this one.
https://olimex.wordpress.com/2014/07/21 ... m-scratch/

At the point where they use sudo chroot $targetdir you're pretty much at the same point at what they show in the video / guide of yours.
Except instead of creating a "new" image, they use a already pre-build one and don't need to add repositories, passwords and such since the image is already done.

Not sure which one you would trust more, but it's essentially the very same thing.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

lazlo
Posts: 143
Joined: Sun Oct 01, 2017 11:32 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by lazlo » Sat Apr 06, 2019 5:12 pm

You are right, it is not new technology. This is just the first time I have seen all of it automated into one package. If you are interested in the inspiration for the package you should check out the "Acknowledgements" section of the README.md on the git repository.

The main reason I am excited about it is because it will make installing and maintaining Funtoo Linux a lot easier on almost any ARM SBC. The secondary reason I am excited about it is because the the package is designed to be modular and allows patches to add support for even more CPU architectures in the future. Hopefully this package or something very similar will find it's way into the Debian ecosystem at some point.

User avatar
meveric
Posts: 9934
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, N2
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by meveric » Sat Apr 06, 2019 6:44 pm

lazlo wrote:
Sat Apr 06, 2019 5:12 pm
Hopefully this package or something very similar will find it's way into the Debian ecosystem at some point.
Don't think there will be much interest in it as you can simply use:

Code: Select all

sudo debootstrap --arch=armhf --foreign
and you already have all that you needed.
The --arch and --foreign tells the system it's a emulated system and you only need to place the qemu binary in the correct folder structure so chroot works fine. (In fact could be this works on it's own by now)
It works with all architectures already and can be used for multiple OSes such as Ubuntu and Debian in different flavors.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

lazlo
Posts: 143
Joined: Sun Oct 01, 2017 11:32 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by lazlo » Sun Apr 07, 2019 5:18 am

I didn't know you could use debootstrap to access an already installed system. I'll have to try that out. Thanks!

User avatar
meveric
Posts: 9934
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, N2
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by meveric » Sun Apr 07, 2019 6:18 am

I think if you already have a ready to use image, you only need to copy over the qemu-<arch>-static binary, the rest is done by the binfmt-support binary by the OS itself.
By now this entire process is rather uncomplicated.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

lazlo
Posts: 143
Joined: Sun Oct 01, 2017 11:32 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by lazlo » Sun Apr 07, 2019 1:47 pm

I just never even thought of trying to debootstrap into a system that was already installed and running. I didn't know you could use if more than installing a system. So you just mount the NFS share like in the video, copy the files you need and debootstrap takes care of the rest? No need to mount --rbind anything?

User avatar
meveric
Posts: 9934
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, N2
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by meveric » Sun Apr 07, 2019 5:47 pm

lazlo wrote:
Sun Apr 07, 2019 1:47 pm
I just never even thought of trying to debootstrap into a system that was already installed and running. I didn't know you could use if more than installing a system. So you just mount the NFS share like in the video, copy the files you need and debootstrap takes care of the rest? No need to mount --rbind anything?
As I said, by now you don't even need that anymore.
If you have working rootfs, just copy the qemu static lib and it should work right away:

Code: Select all

root@heimdall:#ODROIDs/Images/jessie# uname -a
Linux heimdall 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
root@heimdall:/#ODROIDs/Images/jessie# cp /usr/bin/qemu-arm-static ./usr/bin/
root@heimdall:#ODROIDs/Images/jessie# chroot .
root@heimdall:/# uname -a
Linux heimdall 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 armv7l GNU/Linux
90% of all tasks should work like this, if you really need /dev /proc and /sys you can mount them quickly it's not hard to do anyway.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

User avatar
mad_ady
Posts: 5676
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 18 times
Been thanked: 18 times
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by mad_ady » Mon Apr 08, 2019 3:26 am

Nifty trick, didn't know it either... :)

lazlo
Posts: 143
Joined: Sun Oct 01, 2017 11:32 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by lazlo » Mon Apr 08, 2019 7:12 am

meveric wrote:
Sun Apr 07, 2019 5:47 pm
90% of all tasks should work like this, if you really need /dev /proc and /sys you can mount them quickly it's not hard to do anyway.


That is cool. Thanks for sharing. I'll try it on my XU4 Later tonight. I am pretty sure that I'll need /proc /sys and /dev mounted since my interest in this is not working with images but with live, running systems.

User avatar
meveric
Posts: 9934
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, N2
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by meveric » Mon Apr 08, 2019 2:41 pm

lazlo wrote:
Mon Apr 08, 2019 7:12 am
That is cool. Thanks for sharing. I'll try it on my XU4 Later tonight. I am pretty sure that I'll need /proc /sys and /dev mounted since my interest in this is not working with images but with live, running systems.
As I said, that's not hard either, just add this before the chroot and you're good.

Code: Select all

root@heimdall:#ODROIDs/Images/jessie# uname -a
Linux heimdall 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
root@heimdall:/#ODROIDs/Images/jessie# cp /usr/bin/qemu-arm-static ./usr/bin/
mount --bind /dev ./dev
mount --bind /proc ./proc
mount --bind /sys ./sys
root@heimdall:#ODROIDs/Images/jessie# chroot .
root@heimdall:/# uname -a
Linux heimdall 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 armv7l GNU/Linux
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

escalade
Posts: 15
Joined: Thu Mar 14, 2019 8:34 pm
languages_spoken: english and norwegian
Has thanked: 0
Been thanked: 0
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by escalade » Wed Apr 10, 2019 5:10 am

meveric wrote:
Sun Apr 07, 2019 5:47 pm
As I said, by now you don't even need that anymore.
If you have working rootfs, just copy the qemu static lib and it should work right away:

Code: Select all

root@heimdall:#ODROIDs/Images/jessie# uname -a
Linux heimdall 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
root@heimdall:/#ODROIDs/Images/jessie# cp /usr/bin/qemu-arm-static ./usr/bin/
root@heimdall:#ODROIDs/Images/jessie# chroot .
root@heimdall:/# uname -a
Linux heimdall 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 armv7l GNU/Linux
90% of all tasks should work like this, if you really need /dev /proc and /sys you can mount them quickly it's not hard to do anyway.
This is definitely nothing new, running ARM binaries with qemu/binfmt has been possible for a very long time. I use it to run ARM docker containers like this:

Code: Select all

docker run -it --rm -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static raspbian/jessie bash
Useful for testing things, but why compile through an emulator when cross compiling is much faster :)

User avatar
meveric
Posts: 9934
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, N2
Has thanked: 1 time
Been thanked: 25 times
Contact:

Re: Build ARM on X86, no cross-compiler.

Unread post by meveric » Wed Apr 10, 2019 5:15 am

escalade wrote:
Wed Apr 10, 2019 5:10 am
This is definitely nothing new, running ARM binaries with qemu/binfmt has been possible for a very long time.
Exactly my point.
As I said above, it's nothing new.
And was meant as an explanation why the tool in the first post, is probably never converted to Debian/Ubuntu where it's simply not needed.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest