20071212

Building a bootable ARM SD

A few weeks ago, I wrote up how to make a bootable i386 image. People have been asking me to extend it for my ARM platform.

Here are the instructions for a hypothetical box that has a boot loader that can load an image from a FAT partition of a SD card, and FreeBSD runs off of a ufs partition on the SD card. This will be for a big endian ARM target, based on the AVILA kernel. I'm also assuming that this platform doesn't use FreeBSD's normal /boot/loader.
  1. setenv MAKEOBJDIRPREFIX /blah
  2. setenv TARGET arm
  3. setenv TARGET_ARCH arm
  4. setenv TARGET_CPU xscale
  5. make buildworld
  6. make buildkernel KERNCONF=AVILA
  7. fdisk -I da0
  8. fdisk -f disk-partitions da1
  9. newfs -t msdos /dev/da0s1
  10. bsdlabel -w da0s2 auto
  11. newfs /dev/da0s2a
  12. mount /dev/da0s2a /mnt
  13. make installworld DESTDIR=/mnt
  14. make installkernel DESTDIR=/mnt KERNCONF=AVILA INSTALL_NODEBUG=t
  15. make distrib-dirs DESTDIR=/mnt
  16. make distribution DESTDIR=/mnt
  17. echo /dev/da0s2a / ufs rw 1 1 > /mnt/etc/fstab
  18. echo ifconfig_DEFAULT=DHCP > /mnt/etc/rc.conf
  19. echo hostname=demo >> /mnt/etc/rc.conf
  20. cp /mnt/boot/kernel/kernel /tmp
  21. umount /mnt
  22. mount -t msdos /dev/da0s1 /mnt
  23. cp /tmp/kernel /mnt
  24. umount /mnt
In step 8, one needs to have a special file. Here's what I use, but one needs to automate it a little more. Here's a hand-tuned one that I used for a 1GB SD card I had laying around.

# partition table
g c940 h32 s63
p 1 6 63 201537
p 2 165 201600 1780128

Clearly, one needs to tune the above for their specific part. NanoBSD tries to automate this process, but that is beyond the scope of this posting.

Update: fixed step 17.

2 comments:

  1. Hi Warner,
    this article is a great help. I'm looking forward for the next one about NanoBSD and ARM.
    Greetings

    ReplyDelete
  2. Anonymous5:49 AM

    Hi, This is a great article to help newcomers like myself.
    I'm trying to run step 7 above but for a USB Key on a Sheevaplug - having done what i understand to be the equivalent of steps 1-6 using http://wiki.freebsd.org/FreeBSDMarvell

    But i get the following error:
    step7:
    # fdisk -I da0
    ******* Working on device da0 *******
    fdisk: /boot/mbr: No such file or directory

    is this the result of a difference in kernel compilation or can you offer any direction? (post to MilingList freebsd-arm
    is as yet unanswered)
    Thanks

    ReplyDelete