# Instructions for building FreeBSD 12.0 for RPi 3



## balanga (Jul 24, 2019)

Where do I find instructions for building FreeBSD 12.0 for RPi3?

I'm assuming it goes along the lines of something like this:-


```
make -j 8 buildworld TARGET_ARCH=arm -DWITH_FDT
make -j 8 buildkernel TARGET_ARCH=arm KERNCONF=??????
make installworld TARGET_ARCH=arm DESTDIR=/xxx
make distribution TARGET_ARCH=arm DESTDIR=/xxx
make installkernel TARGET_ARCH=arm KERNCONF=?????? DESTDIR=/xxx
```


----------



## SirDice (Jul 24, 2019)

arm/Raspberry Pi - FreeBSD Wiki


----------



## mark_j (Jul 25, 2019)

I used crochet for RPI2B: https://github.com/freebsd/crochet


----------



## acheron (Jul 25, 2019)

```
make TARGET_ARCH=aarch64 buildworld
make TARGET_ARCH=aarch64 KERNCONF=GENERIC-NODEBUG buildkernel
```
If you want to produce image you can use:

```
cd /usr/src/release
sh release.sh -c arm64/RPI3.conf
```
or "poudriere image"


----------



## balanga (Jul 25, 2019)

mark_j said:


> I used crochet for RPI2B: https://github.com/freebsd/crochet



See Thread 70545/#post-425077


----------



## balanga (Jul 25, 2019)

SirDice said:


> arm/Raspberry Pi - FreeBSD Wiki



Not as helpful as it could be...

There is this for RPi2:-


			arm/Raspberry Pi 2 image - FreeBSD Wiki
		

which suggests using Crotchet, which by some accounts is dead. 
Not much info (if any) on building for RPi3...


----------



## mark_j (Jul 25, 2019)

balanga said:


> See Thread 70545/#post-425077


It may be dead, but I use it, though not in the last year. Your choice what to use, but you can build rpi3 with crochet.
Actually in the next few weeks I might use it to try on the pi4 (whenever it arrives) and it will undoubtedly fail big time, but, hey I like to experiment.


----------



## balanga (Jul 27, 2019)

Many thanks, that seemed simple enough. It ran for about for about 1.5hrs before:-

```
/usr/include/machine/atomic.h:246:39: note: passing argument to parameter 'p' here
atomic_fetchadd_long(volatile u_long *p, u_long v)
                                      ^
2 warnings generated.
===> usr.bin/yacc (obj,all,install)
===> kerberos5/tools/make-roken (obj,all,install)
===> kerberos5/lib/libroken (obj,all,install)
===> kerberos5/lib/libvers (obj,all,install)
===> kerberos5/tools/asn1_compile (obj,all,install)
yacc: 4 shift/reduce conflicts.
===> kerberos5/tools/slc (obj,all,install)
===> usr.bin/compile_et (obj,all,install)
===> usr.bin/clang/clang-tblgen (obj,all,install)
===> usr.bin/clang/llvm-tblgen (obj,all,install)
c++: error: unable to execute command: Killed
c++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
c++: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
c++: note: diagnostic msg:.
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
c++: note: diagnostic msg: /tmp/AsmMatcherEmitter-9d371e.cpp
c++: note: diagnostic msg: /tmp/AsmMatcherEmitter-9d371e.sh
c++: note: diagnostic msg:.

********************
--- AsmMatcherEmitter.o ---
*** [AsmMatcherEmitter.o] Error code 254

make[3]: stopped in /scratch/usr/src/usr.bin/clang/llvm-tblgen
1 error

make[3]: stopped in /scratch/usr/src/usr.bin/clang/llvm-tblgen
--- _bootstrap-tools-usr.bin/clang/llvm-tblgen ---
*** [_bootstrap-tools-usr.bin/clang/llvm-tblgen] Error code 2

make[2]: stopped in /scratch/usr/src
A failure has been detected in another branch of the parallel make

make[3]: stopped in /scratch/usr/src/usr.bin/clang/clang-tblgen
--- _bootstrap-tools-usr.bin/clang/clang-tblgen ---
*** [_bootstrap-tools-usr.bin/clang/clang-tblgen] Error code 2

make[2]: stopped in /scratch/usr/src
2 errors

make[2]: stopped in /scratch/usr/src
--- _bootstrap-tools ---
*** [_bootstrap-tools] Error code 2

make[1]: stopped in /scratch/usr/src
1 error

make[1]: stopped in /scratch/usr/src
--- buildworld ---
*** [buildworld] Error code 2

make: stopped in /scratch/usr/src
1 error

make: stopped in /scratch/usr/src
umount: /scratch/dev: statfs: No such file or directory
umount: /scratch/dev: unknown file system

Command exit status: 1
```

Is there something obvious that I've done, or failed to do?

The msg above - *Target: x86_64-unknown-freebsd12.0* seems odd.

`uname -a` :-





> FreeBSD Z83 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  amd64


Do I need to set up the environment before running `sh release.sh -c arm64/RPI3.conf`?


----------



## acheron (Jul 28, 2019)

c++: error: unable to execute command: Killed
Make sure you have enough ram / swap.


----------



## balanga (Jul 29, 2019)

Not sure if this has worked:-

```
--------------------------------------------------------------
>>> stage 3.1: building everything
--------------------------------------------------------------
ld: warning: lld uses blx instruction, no object with architecture supporting feature detected
linking kernel.full
ctfmerge -L VERSION -g -o kernel.full ...
     text      data       bss        dec         hex   filename
  9687973   1644952   8694372   20027297   0x13197a1   kernel.full
--------------------------------------------------------------
>>> Kernel build for GENERIC completed on Mon Jul 29 03:53:40 UTC 2019
--------------------------------------------------------------
m>>> Kernel(s)  GENERIC built in 1145 seconds, ncpu: 4, make -j2
--------------------------------------------------------------
md0 created
md0s1 added
active set on md0s1
/dev/md0s1: 102264 sectors in 12783 FAT16 clusters (4096 bytes/cluster)
BytesPerSec=512 SecPerClust=8 ResSectors=1 FATs=2 RootDirEnts=512 Media=0xf0 FATsecs=50 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=102400
md0s2 added
md0s2 created
md0s2a added
Reduced frags per cylinder group from 160280 to 159320 to enlarge last cyl group
/dev/md0s2a: 2509.0MB (5138432 sectors) block size 32768, fragment size 4096
<------>using 5 cylinder groups of 622.34MB, 19915 blks, 79744 inodes.
<------>with soft updates
super-block backups (for fsck_ffs -b #) at:
 192, 1274752, 2549312, 3823872, 5098432
Bad system call (core dumped)
umount: unmount of /scratch/dev failed: Device busy

Command exit status: 1
```

`gpart show`:-

```
=>     63  5242817  md0  MBR  (2.5G)
       63     1985       - free -  (993K)
     2048   102400    1  fat32lba  [active]  (50M)
   104448  5138432    2  freebsd  (2.5G)

=>      0  5138432  md0s2  BSD  (2.5G)
        0  5138432      1  freebsd-ufs  (2.5G)
```

both partitions are empty.

How to tell how far things have got? The process took almost five hours so I suspect it got a long way.


----------



## acheron (Jul 30, 2019)

Bad system call (core dumped)
What is the version of your host system?


----------

