# Possible to fork/build BSD from scratch?



## manueljenkin (Sep 26, 2020)

Hi Everyone, hope you're doing good.

I would like to know if it is possible to build a BSD (not necessarily just freebsd) image from scratch?

What I'm intending to build is something like this. http://wtfplay-project.org/ . It's a Linux distro with most services removed (even battery management and networking), focusing just on audio playback - so it has a specific part of ALSA, and few other USB device/hard drive support and built specifically for X86.

I wish to build something like that for ARM, being able to customize what I need and what I don't need, including compilers. Very minimal with support only for USB and one specific dma capable IO for input (I'm still on the fence about what to choose, maybe a gpio or a spi interconnect). I wish to do it in BSD instead of Linux. Would it be possible. I'll be writing drivers for USB Audio Class (Asynchronous isochronous, ie buffered async) and I might take a page or two from ALSA (haven't yet found where they implemented support in alsa). I wouldn't be coding any mixer, just a playback suite.

Is this possible in BSD, or would you recommend sticking to Linux instead.

Thanks and Regards,
Manuel Jenkin.


----------



## a6h (Sep 26, 2020)

release(7)


----------



## drhowarddrfine (Sep 26, 2020)

manueljenkin You need to know that Linux is a kernel that needs to pull in a mish-mash of other software to create a distro. FreeBSD is a complete operating system unto itself, cultivated by the same team of developers who work on the kernel.


----------



## ekvz (Sep 26, 2020)

Very much possible in my opinion. Probably even easier than with Linux. With FreeBSD you get an uniform build system for the whole base OS. The scope of which is already pretty narrow. Take a look at src.conf(5) to see the available switches concerning the build process. If you want to take your customization further you should familiarize yourself with FreeBSD's version of make(1) which is somewhat related to netbsd `make` and bmake(1) (http://www.crufty.net/help/sjg/bmake.html) i think. That might seem a little exotic at first when one is used to all things make being gmake(1) but it's actually pretty easy.


----------



## Mjölnir (Sep 26, 2020)

RTFM build(7), release(7), make.conf(5), src.conf(5), nanobsd(8), picobsd(8), `locate tinybsd`, Arch Handbook, ...  IMHO much cleaner than on Linux.  Plus you have a superior sound system

```
hw.snd.latency=0
dev.pcm.0.bitperfect=1
```
in sysctl.conf(5)


----------



## ekvz (Sep 26, 2020)

mjollnir said:


> nanobsd(8), picobsd(8), `locate tinybsd`



Good points. I had completely forgotten about nano-/pico-/tinybsd.


----------



## Mjölnir (Sep 26, 2020)

And should you run into issues with nanobsd(8), ping Phishfry


----------



## a6h (Sep 26, 2020)

I think it must be easier to build from FreeBSD than Linux. Systemd is a problem, from user/admin point of view it's easy to use, but good luck with set it up from ground up in a brand new Linux distro.
PS. Of course I'm not talking about specific forking models, which is going to form a homogeneous distro set (ubuntu, lubuntu, xubuntu, etc).


----------



## ekvz (Sep 26, 2020)

vigole said:


> I think it must be easier to build from FreeBSD than Linux



I guess it somewhat depends. If you go the extreme route and just do kernel + busybox/toybox there is little difference but in a general sense i agree on FreeBSD likely being quite a bit easier to trim down and not just because of those minimal build setups mjollnir mentioned.


----------



## takumi (Sep 30, 2020)

Looks old, but may be can help you:



			FreeBSD From Scratch


----------



## manueljenkin (Sep 30, 2020)

Thank you very much everyone. I am looking into each of these references. I am looking for the ability to have access and be able to add tweaks till the way instructions are laid out (A specific reason for that, which I can't share now). I was earlier looking at unikernels, but since BSD lets me swap kernels on the fly, I felt this would be a better way, and also pre existing drivers/support for JEDEC memory sticks. I will be building my sound system from scratch. Since I need to support USB audio class, I'll likely derive some concepts about implementing the protocol from Linux ALSA USB implementation or from ASIO drivers in windows. I finally got leads to where it is located.


----------



## Mjölnir (Sep 30, 2020)

The FreeBSD wiki is a valuable source of information, too.  As always, beware some entries may be outdated.


----------



## mark_j (Sep 30, 2020)

manueljenkin said:


> Hi Everyone, hope you're doing good.
> 
> I would like to know if it is possible to build a BSD (not necessarily just freebsd) image from scratch?
> 
> ...



Every FreeBSD release since its inception has been built from scratch. It is not Linux. It is a fully integrated OS. It comes with a kernel and a set of basic (and perhaps not so basic) utilities. It does not come with even a window manager. No, there's no X11 or Wayland. If you want it, you install it. FreeBSD gives you a base. You can use it as is or build on it, that's your choice. So, in this regard it perfectly suits your goal.

Compare this with Linux, where you get a kernel and nothing else. Someone else has to assemble the bits like `ls`, `cat`, `find`, `bash`, etc etc, yet they are provided by FreeBSD *ALWAYS*. Then they'll throw in X11, KDE, GUI Applications etc. That's not FreeBSD.

So grab yourself FreeBSD, install it on hardware or software (VM) and cross build an arm image. You can look at */usr/src/sys/arm64/conf/GENERIC* for all the current devices placed into the kernel build. Go and remove what you want, keeping in mind removing some will mean your system fails to boot, but that's for trial and error. Oh, and follow the manual and handbook as others have indicated.

Good luck.


----------



## grahamperrin@ (Dec 31, 2021)

Mjölnir said:


> … `locate tinybsd`, …



FYI

tinybsd: Remove


----------

