Normally I netboot all my ARM devices but in case of Jetson TK1 I thought it would be nice to go and try to make it “real computer” – running by itself, may be use it for some port builds. I added Samsung EVO to it but the plan was to use SSD for builds/source code, and to use either external SD card or eMMC as a root device. TK1 survived buildworld/buildkernel (I had to add swap though, clang is a memory monster) so it was time to populate root device and eMMC was picked as a target. There were some ms-basic-data partitions on eMMC but I didn’t think much of it and happily typed dd if=/dev/zero of=/dev/mmcsd0 bs=128m. Well… Big mistake. Among those partitions was u-boot. And probably earlier stage boot loader as well. So I had to install ubuntu on one of unused machines and re-flash TK1. Luckily no permanent damage was done to the device. After this accident I added a little bit of planning into the process. Here is short summary:
Default eMMC partition looks like this:
Tegra124 (Jetson TK1) # mmc part
Partition Map for MMC device 0 -- Partition Type: EFI
Part Start LBA End LBA Name
1 0x00017000 0x01c16fff "APP"
2 0x01c17000 0x01c18fff "DTB"
3 0x01c19000 0x01c38fff "EFI"
4 0x01c39000 0x01c3afff "USP"
5 0x01c3b000 0x01c3cfff "TP1"
6 0x01c3d000 0x01c3efff "TP2"
7 0x01c3f000 0x01c40fff "TP3"
8 0x01c41000 0x01c41fff "WB0"
9 0x01c42000 0x01d58fff "UDA"
We need two things to make TK1 bootable: place ubldr on flash so u-boot can load it and create rootfs. The latter one is simple: APP partition is the one to be user as root. For the former either of TPx partitions can be used, TP stands for “Temporary Placeholder” and can be used for app-specific tasks. All three TPx are just 4Mb but ubldr is small enough to fit just fine. So let’s place ubldr to TP1:
# newfs_msdos /dev/gpt/TP1
# mount_msdosfs /dev/gpt/TP1 /mnt
# cp ubldr.tk1 /mnt/
# umount /mnt
Then populate rootfs:
# newfs /dev/gpt/APP
# mount /dev/gpt/APP /mnt
Then build/install stuff: … buildworld, buildkernel. installworld, distribution and installkernel with DESTDIR=/mnt …
Create /etc/fstab so kernel would pick up correct rootfs location. I also use nullfs to mount /tmp to the directory on SSD drive, and added swap file on SSD.
/dev/gpt/APP / ufs rw,noatime 0 0
/dev/ada0 /src ufs rw,noatime 0 0
md99 none swap sw,file=/src/swap,late 0 0
/src/tmp /tmp nullfs rw 0 0
# umount /mnt
Reboot to u-boot and set up boot command:
Tegra124 (Jetson TK1) # setenv bootcmd 'fatload mmc 0:5 $loadaddr ubldr.tk1; bootelf'
Tegra124 (Jetson TK1) # saveenv
Saving Environment to MMC...
Writing to MMC(0)... done
Tegra124 (Jetson TK1) # boot
That’s it. Also if I need to revert back to netbooting TK1 I can just set loaderdev to “net” in u-boot:
Tegra124 (Jetson TK1) # setenv loaderdev net; boot