1 |
for people wanting to get their hands dirty |
2 |
|
3 |
first you'll want to build stuff |
4 |
|
5 |
- make sure you sync first; a lot of work is recent |
6 |
emerge --sync |
7 |
- make sure you have latest crossdev |
8 |
emerge '>=crossdev-20140118' |
9 |
- create your cross-compiler |
10 |
crossdev arm64 |
11 |
- update the profile |
12 |
ln -sfT /usr/portage/profiles/default/linux/arm64/13.0 \ |
13 |
/usr/aarch64-unknown-linux-gnu/etc/portage/make.profile |
14 |
- adjust your USE flags in /usr/aarch64-unknown-linux-gnu/etc/portage/make.conf |
15 |
suggest adding USE='-fortran -openmp -go -mudflap' |
16 |
- cross-compile a bunch of packages |
17 |
aarch64-unknown-linux-gnu-emerge @system |
18 |
aarch64-unknown-linux-gnu-emerge <more stuff!> |
19 |
- if you want python, use 2.7 for now as 3.3 does not cross-compile |
20 |
- perl & pam do not cross-compile today, so don't bother |
21 |
- binutils & gcc work fine, so you can easily create a self hosting system |
22 |
|
23 |
tweak a few things in /usr/aarch64-unknown-linux-gnu/etc to get it booting |
24 |
|
25 |
- hack /etc/inittab to enable an automatic root shell |
26 |
sed -i -e '/^c[1-6]/s:^:#:' etc/inittab |
27 |
echo 's0:12345:respawn:/bin/bash' >> etc/inittab |
28 |
- disable some useless init scripts |
29 |
cd etc/runlevels |
30 |
rm */consolefont */hostname */hwclock */keymaps */modules \ |
31 |
*/swap */termencoding */mtab |
32 |
- enable net.eth0/swclock |
33 |
ln -s /etc/init.d/swclock sysinit/ |
34 |
ln -s /etc/init.d/net.eth0 boot/ |
35 |
- simplify mtab |
36 |
cd etc/ |
37 |
ln -s /proc/mounts mtab |
38 |
|
39 |
now you'll want to build a disk image using that sysroot |
40 |
|
41 |
- create a sparse disk image |
42 |
# It won't take up 20G, but may grow to fill that. |
43 |
truncate -s 20G gentoo.img |
44 |
- partition the disk image |
45 |
# This will create two partitions automatically. |
46 |
# A small vfat /boot and a large ext4 /. |
47 |
printf '%s\n' n p 1 '' +50MB n p 2 '' '' t 1 b w | fdisk gentoo.img |
48 |
- format the disk image |
49 |
losetup -P /dev/loop5 gentoo.img |
50 |
mkfs.vfat /dev/loop5p1 |
51 |
mkfs.ext4 /dev/loop5p2 |
52 |
- mount the disks |
53 |
mkdir -p root |
54 |
mount /dev/loop5p2 root |
55 |
- copy the sysroot to the root partition |
56 |
rsync -a /usr/aarch64-unknown-linux-gnu/ root/ |
57 |
- unmount the disks |
58 |
umount root |
59 |
losetup -d /dev/loop5 |
60 |
- repeat the mount/rsync/umount steps if you want to install more packages |
61 |
|
62 |
now we'll need something to boot |
63 |
|
64 |
- get linux-3.12.6 from kernel.org |
65 |
tar xf linux-3.12.6.tar.xz |
66 |
# Create a linux symlink to it. |
67 |
ln -s linux-3.12 linux |
68 |
- build the kernel (worry about customizing after you have a working system) |
69 |
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- defconfig |
70 |
# Enable CONFIG_DEVTMPFS_MOUNT to fix booting. |
71 |
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- menuconfig |
72 |
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 |
73 |
- build a boot image for the emulator |
74 |
git clone git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/boot- |
75 |
wrapper-aarch64.git |
76 |
cd boot-wrapper-aarch64 |
77 |
for f in ../linux/arch/arm64/boot/dts/*.dts* ; do ln -s $f ; done |
78 |
ln -s ../linux/arch/arm64/boot/Image |
79 |
make \ |
80 |
CROSS_COMPILE=aarch64-unknown-linux-gnu- \ |
81 |
BOOTARGS='"root=/dev/vda2 consolelog=9 rw console=ttyAMA0"' \ |
82 |
FDT_SRC=foundation-v8.dts \ |
83 |
IMAGE=gentoo.axf |
84 |
|
85 |
finally let's boot the fsckin thing |
86 |
|
87 |
- install the armv8 foundation model |
88 |
emerge armv8-fast-model |
89 |
- run it (should be done in a GUI as it'll run an xterm of the console) |
90 |
Foundation_v8 \ |
91 |
--image gentoo.axf \ |
92 |
--block-device gentoo.img \ |
93 |
--network=nat |
94 |
- wait a little while because it's slow |
95 |
- profit! |
96 |
|
97 |
this default mode gives you a network connection where the emulator can |
98 |
connect out, but you can't easily connect to it. the good news is that dhcpcd |
99 |
"Just works" and you can get going. |
100 |
|
101 |
if you do want to connect to the system, that's what --network=bridged mode is |
102 |
for. the downside is you have to run it as root. then on your dev system: |
103 |
ifconfig ARM0 10.1.1.1 |
104 |
and in the emulator: |
105 |
ifconfig eth0 10.1.1.2 |
106 |
now you can ping/ssh to each other. |
107 |
-mike |