Mailing List Archive

Gentoo/arm64 quickstart
for people wanting to get their hands dirty

first you'll want to build stuff

- make sure you sync first; a lot of work is recent
emerge --sync
- make sure you have latest crossdev
emerge '>=crossdev-20140118'
- create your cross-compiler
crossdev arm64
- update the profile
ln -sfT /usr/portage/profiles/default/linux/arm64/13.0 \
/usr/aarch64-unknown-linux-gnu/etc/portage/make.profile
- adjust your USE flags in /usr/aarch64-unknown-linux-gnu/etc/portage/make.conf
suggest adding USE='-fortran -openmp -go -mudflap'
- cross-compile a bunch of packages
aarch64-unknown-linux-gnu-emerge @system
aarch64-unknown-linux-gnu-emerge <more stuff!>
- if you want python, use 2.7 for now as 3.3 does not cross-compile
- perl & pam do not cross-compile today, so don't bother
- binutils & gcc work fine, so you can easily create a self hosting system

tweak a few things in /usr/aarch64-unknown-linux-gnu/etc to get it booting

- hack /etc/inittab to enable an automatic root shell
sed -i -e '/^c[1-6]/s:^:#:' etc/inittab
echo 's0:12345:respawn:/bin/bash' >> etc/inittab
- disable some useless init scripts
cd etc/runlevels
rm */consolefont */hostname */hwclock */keymaps */modules \
*/swap */termencoding */mtab
- enable net.eth0/swclock
ln -s /etc/init.d/swclock sysinit/
ln -s /etc/init.d/net.eth0 boot/
- simplify mtab
cd etc/
ln -s /proc/mounts mtab

now you'll want to build a disk image using that sysroot

- create a sparse disk image
# It won't take up 20G, but may grow to fill that.
truncate -s 20G gentoo.img
- partition the disk image
# This will create two partitions automatically.
# A small vfat /boot and a large ext4 /.
printf '%s\n' n p 1 '' +50MB n p 2 '' '' t 1 b w | fdisk gentoo.img
- format the disk image
losetup -P /dev/loop5 gentoo.img
mkfs.vfat /dev/loop5p1
mkfs.ext4 /dev/loop5p2
- mount the disks
mkdir -p root
mount /dev/loop5p2 root
- copy the sysroot to the root partition
rsync -a /usr/aarch64-unknown-linux-gnu/ root/
- unmount the disks
umount root
losetup -d /dev/loop5
- repeat the mount/rsync/umount steps if you want to install more packages

now we'll need something to boot

- get linux-3.12.6 from kernel.org
tar xf linux-3.12.6.tar.xz
# Create a linux symlink to it.
ln -s linux-3.12 linux
- build the kernel (worry about customizing after you have a working system)
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- defconfig
# Enable CONFIG_DEVTMPFS_MOUNT to fix booting.
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- menuconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4
- build a boot image for the emulator
git clone git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/boot-
wrapper-aarch64.git
cd boot-wrapper-aarch64
for f in ../linux/arch/arm64/boot/dts/*.dts* ; do ln -s $f ; done
ln -s ../linux/arch/arm64/boot/Image
make \
CROSS_COMPILE=aarch64-unknown-linux-gnu- \
BOOTARGS='"root=/dev/vda2 consolelog=9 rw console=ttyAMA0"' \
FDT_SRC=foundation-v8.dts \
IMAGE=gentoo.axf

finally let's boot the fsckin thing

- install the armv8 foundation model
emerge armv8-fast-model
- run it (should be done in a GUI as it'll run an xterm of the console)
Foundation_v8 \
--image gentoo.axf \
--block-device gentoo.img \
--network=nat
- wait a little while because it's slow
- profit!

this default mode gives you a network connection where the emulator can
connect out, but you can't easily connect to it. the good news is that dhcpcd
"Just works" and you can get going.

if you do want to connect to the system, that's what --network=bridged mode is
for. the downside is you have to run it as root. then on your dev system:
ifconfig ARM0 10.1.1.1
and in the emulator:
ifconfig eth0 10.1.1.2
now you can ping/ssh to each other.
-mike
Re: Gentoo/arm64 quickstart [ In reply to ]
On Sat, Jan 18, 2014 at 05:00:43PM -0500, Mike Frysinger wrote:
> for people wanting to get their hands dirty
>
> first you'll want to build stuff
>
> - make sure you sync first; a lot of work is recent
> emerge --sync
> - make sure you have latest crossdev
> emerge '>=crossdev-20140118'
> - create your cross-compiler
> crossdev arm64
> - update the profile
> ln -sfT /usr/portage/profiles/default/linux/arm64/13.0 \
> /usr/aarch64-unknown-linux-gnu/etc/portage/make.profile
> - adjust your USE flags in /usr/aarch64-unknown-linux-gnu/etc/portage/make.conf
> suggest adding USE='-fortran -openmp -go -mudflap'
> - cross-compile a bunch of packages
> aarch64-unknown-linux-gnu-emerge @system
> aarch64-unknown-linux-gnu-emerge <more stuff!>
> - if you want python, use 2.7 for now as 3.3 does not cross-compile
> - perl & pam do not cross-compile today, so don't bother
> - binutils & gcc work fine, so you can easily create a self hosting system

building now. Why did you leave the tuple aarch64- ?

thx,

Jason.
Re: Gentoo/arm64 quickstart [ In reply to ]
On Saturday 18 January 2014 17:23:34 Jason Cooper wrote:
> Why did you leave the tuple aarch64- ?

it's the name binutils/gcc/glibc/etc... uses. don't get a choice there.
-mike
Re: Gentoo/arm64 quickstart [ In reply to ]
i've uploaded my binaries here:
http://dev.gentoo.org/~vapier/aarch64/
-mike