# Crossbuilding Arm



## Phishfry (Sep 16, 2016)

I am getting ready to dive into the world of crossbuilding ARM on a AMD64 box.
https://wiki.freebsd.org/FreeBSD/arm/crossbuild
This wiki is very helpful but I want to confirm that the following directories files are buildable:
usr/src/sys/arm/conf
This folder contains kernconf files to build ARM platforms. Correct?
Granted not all features will work but generally anything in this folder should boot?

I see Tegra TK1 and Odroid C1 on my list of platforms I want to run FreeBSD on with kernconf files.

Should I try and manually get this going and then try and use crochet later by building a board file or should I concentrate on manually building with native tools?

I really appreciate the wiki showing a sample directory location for projects. I am still fuzzy on what should go where.


----------



## Phishfry (Sep 16, 2016)

Here are my steps---For the NVidia Tegra TK1 -1GB disk image.

This is a work in progress for now. Please don't use yet.

```
mkdir /project && mkdir /project/tk1
cd /project/tk1
svn co https://svn.freebsd.org/base/releng/11.0 /project/tk1/src
setenv BASEDIR /project/tk1
setenv MAKEOBJDIRPREFIX /project/tk1/obj
setenv TARGET_ARCH armv6
setenv TARGET arm
truncate -s 1024M tk1.img
mdconfig -f tk1.img -u0
newfs /dev/md0
mount /dev/md0 /mnt
make buildworld TARGET_ARCH=armv6 -DWITH_FDT
make buildkernel TARGET_ARCH=armv6 KERNCONF=TEGRA124
make installworld TARGET_ARCH=armv6 DESTDIR=/mnt
make distribution TARGET_ARCH=armv6 DESTDIR=/mnt
make installkernel TARGET_ARCH=armv6 KERNCONF=TEGRA124 DESTDIR=/mnt
##Need to fetch and copy uboot I think##
#fetch https://people.freebsd.org/~gonzo/arm/jetson-tk1/u-boot-dtb-tegra.bin
#cp -iw /u-boot-dtb-tegra.bin /mnt
umount /mnt
mdconfig -d -u0
##Here are commands to test build by output to da0
#sysctl kern.geom.debugflags=16
#dd if=tk1.img of=/dev/da0 bs=4096k
##Here are commands to write a disk image
#Next up build disk FAT32 and UFS image partitions.
#gpart create -s MBR "$mdfile"
#gpart add -s 32m -t '!12' "$mdfile"
#gpart set -a active -i 1 "$mdfile"
#newfs_msdos -L boot -F 16 /dev/"$mdfile"s1
#mount -t msdosfs /dev/"$mdfile"s1 /mnt
#cp -iv /u-boot-dtb-tegra.bin /mnt/
#umount /mnt
#gpart add -t freebsd "$mdfile"
#gpart create -s BSD "$mdfile"s2
#gpart add -t freebsd-ufs "$mdfile"s2
#newfs -U -j /dev/"$mdfile"s2a
#mount /dev/"$mdfile"s2a /mnt
#make KERNCONF=TEGRA124 DESTDIR=/mnt installkernel
#make DESTDIR=/mnt DB_FROM_SRC=1 installworld distribution
#umount /mnt
#mdconfig -d -u "$mdfile"
```

Gonzo's TK1 files
https://people.freebsd.org/~gonzo/arm/jetson-tk1/

Using this for disk image-partition bits:
http://ogris.de/howtos/freebsd-raspberry.html 

My reading sources:
https://kernelnomicon.org/?p=628
https://wiki.freebsd.org/EmbeddedHandbook
https://wiki.freebsd.org/A_Brief_Guide_To_Cross_Compiling_FreeBSD
http://blog.khubla.com/freebsd/cross-compiling-freebsd-arm-on-amd-64
https://wiki.freebsd.org/FlattenedDeviceTree#Flattened_Device_Tree


----------

