You have a Fedora x86_64 system and you want to use it to build software for Fedora ARM target.
This is a simple case because host and target run the same distribution,
so you can use /
directory (system root) as a tool root for your target.
Also Fedora already has all necessary crosscompilers for ARM architecture.
First, you have to install qemu and cross-compiler for ARM.
sudo yum install qemu-user gcc-c++-arm-linux-gnu
Or if you have Fedora 22 or newer:
sudo dnf install qemu-user gcc-c++-arm-linux-gnu
This will install plain C compiler as well as binutils for ARM as dependencies.
Create a directory where your ldbox
target will reside:
mkdir -p ~/ldbox/fedora-armhfp
Initialise target:
cd ~/ldbox/targets/fedora-armhfp
lb-init -L --sysroot=/ -C --sysroot=/ -c /usr/bin/qemu-arm -m obs-rpm-build -n -N -t / -A armv7hl -M armv7hl -P /usr/arm-linux-gnu/sys-root/ -P /usr/bin/arm-linux-gnu- -P /usr/libexec/gcc/arm-linux-gnueabi/ fedora-armhfp /usr/bin/arm-linux-gnu-gcc
Then download
cpuinfo file
and place in into $HOME/.ldbox/fedora-armhfp/lb.config.d
directory:
curl -o $HOME/.ldbox/fedora-armhfp/lb.config.d/cpuinfo https://ldbox.org/howto/Fedora-ARM-on-Fedora-x86_64/attachment/1/cpuinfo
Download Fedora ARM minimal disk image.
For Fedora 21:
cd ~/Download
curl -L -O https://download.fedoraproject.org/pub/fedora/linux/releases/21/Images/armhfp/Fedora-Minimal-armhfp-21-5-sda.raw.xz
unxz Fedora-Minimal-armhfp-21-5-sda.raw.xz
For Fedora 22:
cd ~/Download
curl -L -O https://download.fedoraproject.org/pub/fedora/linux/releases/22/Images/armhfp/Fedora-Minimal-armhfp-22-3-sda.raw.xz
unxz Fedora-Minimal-armhfp-22-3-sda.raw.xz
Mount system partition from downloaded image. This is partition 3 on downloaded image.
For Fedora 21:
sudo kpartx -a ~/Download/Fedora-Minimal-armhfp-21-5-sda.raw
sudo mount -v -r -t ext4 /dev/mapper/loop0p3 /mnt
For Fedora 22:
sudo kpartx -a ~/Download/Fedora-Minimal-armhfp-22-3-sda.raw
sudo mount -v -r -t ext4 /dev/mapper/loop0p3 /mnt
Copy mounted filesystem contents into target directory.
sudo tar -C /mnt -cf - . | lb -t fedora-armhfp -m obs-rpm-install -R tar -C / -xvpf -
There should be error message that it can't write /etc/resolv.conf
file.
Ignore this error.
Unmount system partition and delete partition mappings for disk image.
sudo umount -v /mnt
sudo kpartx -d /dev/loop0
sudo losetup -d /dev/loop0
lb -t fedora-armhfp uname -m
lb -t fedora-armhfp rpm -q glibc
lb -t fedora-armhfp -m obs-rpm-install -R yum install gcc-c++ rpm-build
Or for Fedora 22 or newer:
lb -t fedora-armhfp -m obs-rpm-install -R dnf install gcc-c++ rpm-build
These two packages is enough to
pull gcc
, glibc-devel
, binutils
, patch
, file
and many other necessary packages as dependencies
ln -s . usr/arm-linux-gnueabi
ln -s armv7hl-redhat-linux-gnueabi usr/include/c++/5.1.1/arm-linux-gnueabi
ln -s armv7hl-redhat-linux-gnueabi usr/lib/gcc/arm-linux-gnueabi
lb -t fedora-armhfp -m obs-rpm-install -R yum upgrade
Or for Fedora 22 or newer:
lb -t fedora-armhfp -m obs-rpm-install -R dnf upgrade