FreeBSD
Description
FreeBSD is an operating system for a variety of platforms which focuses on features, speed, and stability. It is derived from BSD, the version of UNIX® developed at the University of California, Berkeley. It is developed and maintained by a large community.
Prepare your uSD card
Configure partitions of uSD card
Adjust the card to the Clearfog boot from SD requirements – let’s assume the card is present in the FreeBSD host system as /dev/mmcsd0:
# dd if=/dev/zero of=/dev/mmcsd0
# gpart create -s MBR mmcsd0
# gpart add -t \!12 -b 4096 -s 32m mmcsd0
# gpart set -a active -i 1 mmcsd0
# gpart add -t \!12 -s 32m mmcsd0
# gpart set -a active -i 2 mmcsd0
# gpart add -t freebsd -s 2048m mmcsd0
# gpart create -s BSD mmcsd0s3
# gpart add -t freebsd-ufs -a 2m mmcsd0s3
# newfs_msdos /dev/mmcsd0s2
# newfs /dev/mmcsd0s3a
Mount uSD card
# mkdir /mnt/boot /mnt/rootfs
# mount -t msdosfs /dev/mmcsd0s2 /mnt/boot
# mount /dev/mmcsd0s3a /mnt/rootfs
Install FreeBSD on uSD card
This part must be done on the FreeBSD host (via virtual machine or natively). It’s impossible to build it directly on other OS.
Download sources
$ pkg install git
$ git clone https://github.com/freebsd/freebsd.git
$ cd freebsd
Export variables for cross-compilation
Some variables (shareown, makeobjdirprefix, etc) should be adjusted to your needs.
User in SHAREOWN variable must exist.
Build and install kernel
Use -j option to set cores/threads. In my case 4 threads.
Build and install world
At this point you have compiled and installed FreeBSD with the kernel at /mnt/rootfs/boot/kernel/ and dtb’s in /mnt/rootfs/boot/dtb/ directories of the mounted storage.
Copy loader to boot partition
Configure fstab
Environment variables for loader + tuning the kernel
In file /boot/loader.conf you can set kernel variables, which are passed further by loader.
Execute lines below to turn on L1 cache prefetch in FreeBSD kernel.
Later once the kernel is running on the target machine, above variables values can be verified, using sysctls.
Unmount uSD card
Following part of tutorial will cover all things necessary to build u-boot
U-Boot
Remember switch to linux machine.
Get toolchain and set env variables for cross compilation
Download and build u-boot
Assuming, that the uSD card is present in the system as /dev/mmcblk0:
Plug SD card to board and turn the Clearfog on.
U-boot configuration
Open board serial console, reset SoC and wait for:
Hit any key to stop autoboot:
Stop In U-Boot by pressing any key. Then set proper booting command in bootcmd variable:
Now you could restart board and wait for system:
After less then minute you could login to FreeBSD:
Finalizing
Set root password
After login to FreeBSD (root with no password) you can set password by typing:
Then you have to type new password 2 times.
Create ordinary user
To create new user use:
It works in interactive mode, so it will ask you few questions and suggest default values
Grow rootfs partition
If size of your SD card is larger than size of partition you have created you can type following command:
It will resize rootfs to maximum size.
Official SolidRun Images
The latest images can be found here:
http://images.solid-run.com/A38X/FreeBSD
Known Issues
Switching between Clearfog Base and Clearfog Pro need some software changes (Uboot etc.)
External Links
FreeBSD
Related pages
SolidRun Ltd.