# Building a nanobsd for rpi



## Daniel Bielefeldt (Sep 1, 2016)

I've been trying to build a nanobsd image for an rpi-b using the standard scripts available under /usr/src/tools/tools/nanobsd/embedded.

My general problem is that there is no image available after the build process is finished. I'm not sure if I have to do some custom config in my configuration, before nanobsd.sh will create an image that's ready for use.

I've checked the build log for world and the kernel, and both are completed without any errors.

What am I missing ?


----------



## Phishfry (Sep 1, 2016)

With Arm using uBoot I wonder if nanobsd works. Rpi requires a separate partition to boot and different loader. I never heard anyone using nanobsd on the Arm platform. Maybe you could customize your build with Crochet. It is similar in function and built around Arm processes..
https://github.com/freebsd/crochet


----------



## Phishfry (Sep 2, 2016)

I see stuff here about nanobsd on RPi.
http://bsdimp.blogspot.com/2015/12/nanobsd-reved-up-for-embedded.html


----------



## Daniel Bielefeldt (Sep 2, 2016)

I have found this nanobsd configuration online, and I have managed to build an image. The only thing left, is to put the image onto a flash card, an see if the pi will boot.

For reference: http://www.ogris.de/nanobsd/nanobsd-rasp.conf

I don't know Crochet that well, but it seems that nanoBSD is better for embedded devices where you have to minimize your write operations to disk. I don't know if Crochet is capable of doing the same thing out of the box.


----------



## Daniel Bielefeldt (Sep 4, 2016)

I was not able to boot the image, because the script did not succeed with creating the dos partition needed by the pi for booting.

I have not used nanobsd before, so I'm not that familiar with the configuration. I've found out that the reason why the dos partition isn't created is, that the methods named "build_ubldr" and "install_uboot" is not processed, when the nanobsd script is running. I'm not sure why and how nanobsd should know that they should be processed.

Can somebody perhaps take a look at the configuration in my last post, where I referrer to ogris.de. Maybe the file syntax is deprecated and needs some adjustments to work with the current version of nanobsd.

Thanks in advance!


----------



## Phishfry (Sep 4, 2016)

Check out the last paragraph here:
https://wiki.freebsd.org/FreeBSDAvila
This is old and for another board but I would think you have to build 2 slices and make one active mbr.


----------



## Daniel Bielefeldt (Sep 4, 2016)

Phishfry said:


> Check out the last paragraph here:
> https://wiki.freebsd.org/FreeBSDAvila
> This is old and for another board but I would think you have to build 2 slices and make one active mbr.



But all the magic is already in the script. All I need nanobsd to, is to process the methods "build_ubldr" and "install_uboot"


----------



## rfolkerts (Nov 9, 2016)

I ran into the same Problem, for Raspberry Pi 2; in my case (FreeBSD 11-STABLE), Installation of sysutils/u-boot-rpi2 solved that Problem. When you are on rpi (1), there's also a u-boot-rpi Port in syutils.


----------



## Phishfry (Jul 25, 2017)

So I have nanobsd working well building both RPi2 and RPi3.
For RPi2:
`pkg install u-boot-rpi2 mtools`
Then:
`cd /usr/src/tools/tools/nanobsd/embedded`
Now run the script with the configuration file.
`../nanobsd.sh -c rpi2.cfg`

The resulting image will be located in /usr/embedded/images/


----------



## aragats (Jan 10, 2019)

Just built NanoBSD for BeagleBone Black with the default configuration. However, /usr/embedded/images/ is empty, instead there are two directories with files for the FAT and UFS partitions:
	
	



```
# ll /usr/embedded/beaglebone/_.w/
total 96
-rw-r--r--   2 root  wheel   951 Jan  9 16:58 .cshrc
-rw-r--r--   2 root  wheel   470 Jan  9 16:58 .profile
-r--r--r--   1 root  wheel  6177 Jan  9 16:58 COPYRIGHT
drwxr-xr-x   2 root  wheel    46 Jan  9 16:58 bin/
drwxr-xr-x   9 root  wheel    41 Jan  9 16:58 boot/
-rw-r--r--   1 root  wheel    12 Jan  9 16:58 boot.config
drwxr-xr-x   2 root  wheel     2 Jan  9 16:58 cfg/
drwxr-xr-x   4 root  wheel     4 Jan  9 16:58 conf/
drwxr-xr-x   2 root  wheel     2 Jan  9 16:57 dev/
drwxr-xr-x  26 root  wheel   104 Jan  9 16:58 etc/
-rw-r--r--   1 root  wheel     0 Jan  9 16:58 firstboot
drwxr-xr-x   4 root  wheel    60 Jan  9 16:57 lib/
drwxr-xr-x   3 root  wheel     4 Jan  9 16:57 libexec/
drwxr-xr-x   2 root  wheel     2 Jan  9 16:57 media/
drwxr-xr-x   2 root  wheel     2 Jan  9 16:57 mnt/
drwxr-xr-x   2 root  wheel     2 Jan  9 16:57 net/
drwxr-xr-x   5 root  wheel     5 Jan  9 16:58 pkg/
drwxr-xr-x   2 root  wheel     2 Jan  9 16:57 proc/
drwxr-xr-x   2 root  wheel   145 Jan  9 16:57 rescue/
drwxr-xr-x   2 root  wheel    12 Jan  9 16:58 root/
drwxr-xr-x   2 root  wheel   129 Jan  9 16:58 sbin/
lrwxr-xr-x   1 root  wheel     7 Jan  9 16:58 tmp@ -> var/tmp
drwxr-xr-x   9 root  wheel     9 Jan  9 16:58 usr/
drwxr-xr-x  24 root  wheel    24 Jan  9 16:57 var/
# ll /usr/embedded/beaglebone/_.fat/
total 1184
-rw-r--r--  1 root  wheel   76324 Jan  9 16:58 MLO
-rw-r--r--  1 root  wheel     573 Jan  9 16:58 README
-r--r--r--  1 root  wheel   49171 Jan  9 16:58 am335x-bone.dtb
-r--r--r--  1 root  wheel   53139 Jan  9 16:58 am335x-boneblack-wireless.dtb
-r--r--r--  1 root  wheel   51500 Jan  9 16:58 am335x-boneblack.dtb
-r--r--r--  1 root  wheel   50344 Jan  9 16:58 am335x-boneblue.dtb
-r--r--r--  1 root  wheel   51249 Jan  9 16:58 am335x-bonegreen-wireless.dtb
-r--r--r--  1 root  wheel   49490 Jan  9 16:58 am335x-bonegreen.dtb
-r--r--r--  1 root  wheel   47489 Jan  9 16:58 am335x-pocketbeagle.dtb
-rw-r--r--  1 root  wheel     199 Jan  9 16:58 boot.scr
-rw-r--r--  1 root  wheel      41 Jan  9 16:58 metadata
-rw-r--r--  1 root  wheel  420068 Jan  9 16:58 u-boot.img
-rw-r--r--  1 root  wheel       0 Jan  9 16:58 uEnv.txt
-r--r--r--  1 root  wheel  436856 Jan  9 16:58 ubldr
-r--r--r--  1 root  wheel  367800 Jan  9 16:58 ubldr.bin
-r--r--r--  1 root  wheel   45904 Jan  9 16:58 ufw.dtb
```


----------



## Spartrekus (Jan 11, 2019)

Daniel Bielefeldt said:


> I've been trying to build a nanobsd image for an rpi-b using the standard scripts available under /usr/src/tools/tools/nanobsd/embedded.


Can it be that the script is not there? any chances to get it ?

Is _pkg install u-boot-rpi2 mtools _necessary to get it?


----------



## aragats (Jan 11, 2019)

The script is on the upper level: /usr/src/tools/tools/nanobsd/
As Phishfry said above, you run it from the location you mentioned `../nanobsd.sh ...`.
When you run it, it tells what you need if missing. In particular, you definitely need u-boot-rpiXXX.


----------



## Spartrekus (Jan 11, 2019)

I used to unpack kernel.txz and base.txz to get a minimum installation of regular bsd.

I need some days to read and to understand the process of installation of nanobsd.


----------

