2018-08-14 06:49:20 +00:00
# CROSS-COMPILING
Installing a distro for ARM. The distro is CRUX, the target is an Odroid C2.
## TOC
1. [CROSS COMPILATION TOOLS ](#cross-compilation-tools )
2. [PARTITIONING ](#partitioning )
3. [BOOTLOADER ](#bootloader )
2018-09-06 00:11:33 +00:00
3. [MOUNTING ](#mounting )
2018-08-14 06:49:20 +00:00
4. [BOOT PARTITION ](#boot-partition )
2018-09-05 23:34:44 +00:00
5. [COMPILING KERNEL ](#compiling-kernel )
6. [ROOT PARTITION ](#root-partition )
2018-08-14 06:49:20 +00:00
## CROSS COMPILATION TOOLS
2018-09-06 00:11:33 +00:00
Installing GCC cross compilation tools (for the X86 machine, not target ARM). Includes binutils.
2018-08-14 06:49:20 +00:00
* OPTION 1: from repository (Devuan example)
`sudo apt-get install gcc-arm-none-eabi`
* OPTION 2: proportioned by odroid
```
wget http://odroid.in/guides/ubuntu-lfs/arm-unknown-linux-gnueabi.tar.xz
tar -Jxf arm-unknown-linux-gnueabi.tar.xz
```
Name of "_CROSS_COMPILE_" variable will change depending on the choosen option. This guide assumes from repository and therefore will equal to "_CROSS\_COMPILE=arm-none-eabi-_"
## PARTITIONING
* clear the section for the bootloader
`dd if=/dev/zero of=/dev/mmcblk0 bs=1M count=8`
* enter fdisk
`fdisk /dev/mmcblk0`
* help
`m`
* create new MBR partition table
`o`
* create boot partition
`n`
2018-09-05 23:30:33 +00:00
* make primary partition
`p`
* choose partition number
`1`
2018-08-14 06:49:20 +00:00
* assign start of boot partition at the end of the bootloader space
`3073`
* assign end of boot partition
`+128M`
2018-09-05 23:30:33 +00:00
* change display units to cylinders
`u`
2018-08-14 06:49:20 +00:00
* create root partition
`n`
2018-09-05 23:30:33 +00:00
* make primary partition
`p`
* choose partition number
`2`
* assign start of boot partition at the end of the bootloader space (default cylinder)
`131`
* assign end of boot partition (default) by pressing ENTER
* change display units back to sectors
`u`
* show the partitions
`p`
* if you agree save and exit
`w`
* if you disagree delete a partition and start from that partition
`d`
* or exit without saving
`q`
2018-08-14 06:55:13 +00:00
* Make root filesystem
`mkfs.<ROOT_FILESYSTEM> /dev/mmcblk0p2`
* Make boot filesystem according to supported bootloader (only "_mkfs.vfat_")
`mkfs.<BOOTLOADER_FILESYSTEM> /dev/mmcblk0p1`
2018-08-14 06:49:20 +00:00
## BOOTLOADER
Minimum 3072 bytes free at the start of the drive and before the boot partition.
2018-08-14 06:55:13 +00:00
* VERSION 1: compile
2018-08-14 06:49:20 +00:00
```
git clone https://github.com/hardkernel/u-boot.git -b odroidc2-v2015.01
cd u-boot
make ARCH=arm64 CROSS_COMPILE=arm-none-eabi- odroidc2_defconfig
make -j4
cd boot
```
2018-08-14 06:55:13 +00:00
* VERSION 2: download and extract the binary
2018-08-14 06:49:20 +00:00
```
wget http://odroid.in/guides/ubuntu-lfs/boot.tar.gz # http://dn.odroid.com/S905/BootLoader/ODROID-C2/c2_boot_release_ubuntu.tar.gz
tar -zxvf boot.tar.xz
cd boot
```
2018-08-14 06:55:13 +00:00
* flash bootloader
2018-08-14 06:49:20 +00:00
```
chmod +x sd_fusing.sh
./sd_fusing.sh /dev/sdX
```
2018-08-14 06:55:13 +00:00
* notice the target is the device NOT any partition
* set resolution by editing file root/boot/boot.ini
* might want to comment-out the display-autodetect option
2018-08-14 06:49:20 +00:00
2018-09-06 00:11:33 +00:00
## MOUNTING
* mount root filesystem
2018-09-06 00:13:42 +00:00
`mount /dev/mmcblk0p2 /mnt`
* create boot directory
`mkdir /mnt/boot`
2018-09-06 00:11:33 +00:00
* mount boot filesystem
2018-09-06 00:13:42 +00:00
`mount /dev/mmcblk0p1 /mnt/boot`
2018-09-06 00:11:33 +00:00
2018-08-14 06:49:20 +00:00
## BOOT PARTITION
Must be FAT32 and 64 MB minimum.
2018-08-14 06:55:13 +00:00
* cloning kernel repo to destination "odroidc2-kernel-folder"
2018-08-14 06:49:20 +00:00
`git clone --depth 1 --single-branch https://github.com/hardkernel/linux.git --branch odroidc2-v3.16.y odroidc2-kernel-folder`
2018-08-14 06:55:13 +00:00
* enter destination folder
2018-08-14 06:49:20 +00:00
`cd odroidc2-kernel-folder`
2018-08-14 06:55:13 +00:00
* OPTION 1: making kernel config
2018-08-14 06:49:20 +00:00
`make ARCH=arm64 CROSS_COMPILE=arm-none-eabi- odroidc2_defconfig`
2018-08-14 06:55:13 +00:00
* OPTION 2: making kernel config
2018-08-14 06:49:20 +00:00
```
export ARCH=arm64
export CROSS_COMPILE=arm-none-eabi-
make odroidc2_defconfig
```
2018-08-14 06:55:13 +00:00
* Refine configuration
2018-08-14 06:49:20 +00:00
`make menuconfig`
2018-09-05 23:34:44 +00:00
## COMPILING KERNEL
2018-08-14 06:55:13 +00:00
* Compiling devicetree blobs to destination "INSTALL_DTBS_PATH=/mnt/boot/dtbs/meson64_odroidc2.dtb"
2018-08-14 06:49:20 +00:00
`make -j 4 ARCH=arm64 CROSS_COMPILE=arm-none-eabi- INSTALL_DTBS_PATH=/mnt/boot/dtbs/ dtbs`
2018-08-14 06:55:13 +00:00
* Compiling kernel to destination "INSTALL_PATH=/mnt/boot/Image"
2018-08-14 06:49:20 +00:00
`make -j 4 ARCH=arm64 CROSS_COMPILE=arm-none-eabi- INSTALL_PATH=/mnt/boot/ Image`
2018-08-14 06:55:13 +00:00
* Compiling the modules to destination "INSTALL_MOD_PATH=/mnt/"
2018-08-14 06:49:20 +00:00
`make -j 4 ARCH=arm64 CROSS_COMPILE=arm-none-eabi- INSTALL_MOD_PATH=/mnt/ modules_install`
2018-08-14 06:55:13 +00:00
* Compiling firmware to destination "INSTALL_FW_PATH=/mnt/lib/firmware/"
2018-08-14 06:49:20 +00:00
`make -j 4 ARCH=arm64 CROSS_COMPILE=arm-none-eabi- INSTALL_FW_PATH=/mnt/lib/firmware/ firmware_install`
2018-08-14 06:55:13 +00:00
* Compiling kernel C headers to destination "INSTALL_HDR_PATH=/mnt/usr/"
2018-08-14 06:49:20 +00:00
`make -j 4 ARCH=arm64 CROSS_COMPILE=arm-none-eabi- INSTALL_HDR_PATH=/mnt/usr/ headers_install`
## ROOT PARTITION
Can be the rest of the disk.
2018-08-14 06:55:13 +00:00
* Download CRUX image
2018-08-14 06:49:20 +00:00
`wget -c http://resources.crux-arm.nu/files/devel-test/3.3/crux-arm-rootfs-3.3-64b-RC2.tar.xz`