Installing FreeBSD on eMMC of Beaglebone

I have a working copy of the current version of FreeBSD-12 on beaglebone. But this copy is on the SD card. The beagle bone has about 4GB of eMMC space and I want to transfer the image from the SD card to the eMMC. Does anyone know how to do this?
 
You could boot your Beaglebone from the SD card and then use dd(1) to burn the latest Beaglebone FreeBSD 12.0-CURRENT snapshot image to /dev/mmcsd1, by using pretty much the same command which you used for preparing your SD card.

If you want to clone the contents of the working SD card to the internal eMMC, then dd(1) is not that adequate, because most probably the size of the SD card is different from the internal eMMC and in addition dd'ing a live file system is not guaranteed to result in a healthy one on the clone. Therefore, in the case of transferring a live filesystem from the SD card to the internal eMMC, I suggest the following procedure:

1. Convert the Linux partition into a FreeBSD slice using gpart(8)
gpart show mmcsd1

This command will show you the current partitioning of the eMMC. My Beaglebone Black got already FreeBSD on the internal eMMC, and therefore the following output is different from the one which above command would output on your Beaglebone:
Code:
root@CyStat-BBB:~ # gpart show mmcsd1
=>     63  7552961  mmcsd1  MBR  (3.6G)
       63     8129          - free -  (4.0M)
     8192     8192       1  fat32  [active]  (4.0M)
    16384  7536640       2  freebsd  (3.6G)
Anyway, the structure should be similar, and you need to identify and delete the partition which contains the Linux OS, which is most probably the one having index 2 -- verify!!! -- the following assumes that it is really 2.

gpart delete -i 2 mmcsd1
gpart add -t freebsd mmcsd1
gpart create -s bsd mmcsd1s2
gpart add -t freebsd-ufs mmcsd1s2
gpart show mmcsd1s2
Code:
root@CyStat-BBB:~ # gpart show mmcsd1s2
=>      0  7536640  mmcsd1s2  BSD  (3.6G)
        0  7536640         1  freebsd-ufs  (3.6G)

2. Create the file system on the new FreeBSD slice
newfs -ntEU -L system /dev/mmcsd1s2a
tunefs -a enable /dev/mmcsd1s2a


3. clone(1) the whole FreeBSD 12 installation on the startup volume of your SD card to /dev/mmcsd1s2a
pkg install clone
mount -o noatime /dev/mmcsd1s2a /mnt
clone -c rwoff / /mnt

Now, don't forget to edit the fstab on the cloned volume:
nano /mnt/etc/fstab
Code:
/dev/ufs/system    /            ufs      rw,noatime            0  1
/dev/label/boot    /boot/msdos  msdosfs  rw,noatime            0  0
tmpfs              /tmp         tmpfs    rw,mode=1777,size=50m 0  0
umount /mnt


4. Replace the Linux U-Boot image by the FreeBSD one
mount_msdosfs -o noatime /dev/mmcsd1s1 /mnt
rm -r /mnt/*
cp -p /boot/msdos/* /mnt/
umount /mnt

glabel label boot /dev/mmcsd1s1
 
Last edited:
You could boot your Beaglebone from the SD card and then use dd(1) to burn the latest Beaglebone FreeBSD 12.0-CURRENT snapshot image to /dev/mmcsd1, by using pretty much the same command which you used for preparing your SD card.

If you want to clone the contents of the working SD card to the internal eMMC, then dd(1) is not that adequate, because most probably the size of the SD card is different from the internal eMMC and in addition dd'ing a live file system is not guaranteed to result in a healthy one on the clone. Therefore, I suggest the following procedure:

1. Convert the Linux partition into a FreeBSD slice using gpart(8)
gpart show mmcsd1

This command will show you the current partitioning of the eMMC. My Beaglebone Black got already FreeBSD on the internal eMMC, and therefore the following output is different from the one which above command would output on your Beaglebone:
Code:
root@CyStat-BBB:~ # gpart show mmcsd1
=>     63  7552961  mmcsd1  MBR  (3.6G)
       63     8129          - free -  (4.0M)
     8192     8192       1  fat32  [active]  (4.0M)
    16384  7536640       2  freebsd  (3.6G)
Anyway, the structure should be similar, and you need to identify and delete the partition which contains the Linux OS, which is most probably the one having index 2 -- verify!!! -- the following assumes that it is really 2.

gpart delete 2
gpart add -t freebsd mmcsd1
gpart create -s bsd mmcsd1s2
gpart add -t freebsd-ufs mmcsd1s2
gpart show mmcsd1s2
Code:
root@CyStat-BBB:~ # gpart show mmcsd1s2
=>      0  7536640  mmcsd1s2  BSD  (3.6G)
        0  7536640         1  freebsd-ufs  (3.6G)

2. Create the file system on the new FreeBSD slice
newfs -ntEU -L system /dev/mmcsd1s2a
tunefs -a enable /dev/mmcsd1s2a


3. clone(1) the whole FreeBSD 12 installation on the startup volume of your SD card to /dev/mmcsd1s2a
pkg install clone
mount -o noatime /dev/mmcsd1s2a /mnt
clone -c rwoff / /mnt

Now, don't forget to edit the fstab on the cloned volume:
nano /mnt/etc/fstab
Code:
/dev/ufs/system    /            ufs      rw,noatime            0  1
/dev/label/boot    /boot/msdos  msdosfs  rw,noatime            0  0
tmpfs              /tmp         tmpfs    rw,mode=1777,size=50m 0  0
umount /mnt


4. Replace the Linux U-Boot image by the FreeBSD one
mount_msdosfs -o noatime /dev/mmcsd1s1 /mnt
rm -r /mnt/*
cp -p /boot/msdos/* /mnt/
umount /mnt

glabel label boot /dev/mmcsd1s1


Thank you for the information. I was able to just copy the image to the /dev/mmcsd1 using the dd command.
 
I curious about your opinion.

I tried the various scripts above and it failed.
Unfortunately, I don't have a ttl cable, so I am booting "blind" without serial console.

On the converse I booted on the official FreeBSD 11.1 image.
This is BeagleBone revision B with 2GB emmc and 512k memory.
My SD card is 4GB.

First I made an SD card to boot into FreeBSD:
dd if=FreeBSD-11.1-RELEASE-arm-armv6-BEAGLEBONE.img of=/dev/mysd

Insert the SD into the Beaglebone and booted on the SD.
You need to click on the little button near USB connector.

For convenience, there are two users:
user: root password:root
user: freebdf password freebsd

When it was done, I connected on the router to fetch Beaglebone IP.
root cannot connect over SSH.

Transfered the installer on the Beagleboard:
scp FreeBSD-11.1-RELEASE-arm-armv6-BEAGLEBONE.img freebsd@mybeagleboneIP

Then I simply ssh freebsd@mybeagleboneIP
su to get root and ran:
dd if=FreeBSD-11.1-RELEASE-arm-armv6-BEAGLEBONE.img of=/dev/mmcsd1

Upon reboot the partitions grew to fit in the 2GB onboard emmc:
df -lh
Filesystem Size Used Avail Capacity Mounted on
/dev/ufs/rootfs 1.7G 906M 718M 56% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/msdosfs/MSDOSBOOT 2.0M 944K 1.1M 47% /boot/msdos
tmpfs 50M 4.0K 50M 0% /tmp


I am so happy to have a small appliance running FreeBSD.
What is wrong with this installation schema and what should I fix?

Kind regards
 
  • Thanks
Reactions: pez
worked perfectly for me as well, with my Beaglebone Black that has only been collecting dust since receiving it
 
Does anybody know why when I run FreeBSD 11.1 form eMMC I get 800 or so lines:
Card did not respond to voltage select!?
It looks to be u-boot output, and eventually FreeBSD boots and works properly. The same BBB boots fine from an SD card.

[EDIT] It's not u-boot, but ubldr.bin output. Those warnings start right after jumping to ubldr.bin address.
 
Although FreeBSD has switched to the main line u-boot, I guess, there still are some issues with their interaction.
As I mentioned before and checked again just a week ago, if I use u-boot not from a FreeBSD image, it resets the CPU when jumps to ubldr.bin.
So, one day I'd like to compare u-boot's configurations thoroughly: the source code is the same, but there are so many different variables to be set properly, it's not an hour or two of work. The latest u-boot is capable of loading DTB(O)s, however, I'm not sure whether FreeBSD's kernel can get any advantage out of this. That is really cool, I use it in Linux on BBB: I added a script to u-boot to sources a text file and conditionally load this or that DTB based on possible peripherals connected.
 
The latest u-boot is capable of loading DTB(O)s,
I think this is how I got ADC working with dtbo on FreeBSD 11.1. The newer uboot allows overlays.

By default the Ti ADC is enabled but no pins are assigned. So you need the overlay to define the pins.
I have used the /boot/msdos/config.txt facility used on RPi3 with -CURRENT.
First time I have used /boot/loader.conf to enable an overlay.
 
Last edited:
Does anybody know why when I run FreeBSD 11.1 form eMMC I get 800 or so lines:
Card did not respond to voltage select!?
It looks to be u-boot output, and eventually FreeBSD boots and works properly. The same BBB boots fine from an SD card.

[EDIT] It's not u-boot, but ubldr.bin output. Those warnings start right after jumping to ubldr.bin address.
Any ideas regarding that flood of messages?
I measured the clock frequency, it's 50MHz for both external uSD and eMMC. It doesn't look to be related to the hardware.
The message itself comes from the MMC driver of U-Boot (mmc.c). I guess, I can just suppress it in the code as a workaround. Those messages are annoying and significantly increase the boot time of NanoBSD.
 
Back
Top