FreeBSD 14.0 Compiling kernel for Raspberry Pi 4B

 FreeBSD 14.0 Compiling kernel for Raspberry Pi 4B

in 4 easy steps, updated December 13, 2022



  1. Start with a downloaded RPI image .img FreeBSD snapshot file you can write into a USB Flash drive.   decompress the file with  command:     xz  -dv freebsd_raspi.img
  2. Boot  the from USB Flash drive image built from a  Snapshot image  
  3. Use the running Snapshot image FreeBSD use "bsdinstall" to download and install FreeBSD, over the ethernet cable connected to your router, to the external usb Hard drive or SSD drive.
  4. Shutdown reboot,  remove the USB Flash drive stick from the RasPi4B, reboot from the external usb Hard drive or SSD drive.

freebsd.org/where 

https://download.freebsd.org/snapshots/arm64/aarch64/ISO-IMAGES/14.0/

Here is the September 9, 2022 FreeBSD 14.0 Snapshot image for RPI 3 or 4, right click on to "save as" a file on your local hard drive.  or use either of the commands: 

curl -O https://url_link   

wget -c https://url_link

https://download.freebsd.org/snapshots/arm64/aarch64/ISO-IMAGES/14.0/FreeBSD-14.0-CURRENT-arm64-aarch64-RPI-20220909-1494f4776af-257908.img.xz 

FreeBSD-14.0-CURRENT-arm64-aarch64-RPI-20221209-b1ef176eb528-259626.img.xz This is a December 9 2022 image

Write the uncompressed .img file into a USB flash drive.  

  1. Download file first , 
  2. then second uncompress the .xz file to an .img file,  
  3. third write into a USB Flash drive using a tool appropriate to your operating system.

xz -dv  FreeBSD-14.0-CURRENT-arm64-aarch64-RPI-20220902-e1963173708-257718.img.xz

 https://www.cyberciti.biz/faq/how-to-write-freebsd-image-to-usb-disk-for-installation-using-dd-command/   A great tutorial on the Data Duplicator (better known a Disk Destroyer) command.

Windows:

Balena Etcher  etcher.io

Rufus                 rufus.ie

Linux:   Use what Linux image you prefer.  Checkout puppylinux.com if you need a small linux

Where X is a,b,c, or d   sba  or sbb or sbc or sbd  Notice Capitol M in the "bs=1M" block size option

 dd if=FreeBSD-14.0-CURRENT-arm64-aarch64-RPI-20220902-e1963173708-257718.img of=/dev/sdX  bs=1M conv=sync status=progress 

*BSD:  Check out these two live images that run from a USB flash drive. Nomadbsd.org/download  Ghostbsd.org/download  Use these running live images as a tool to download the FreeBSD image file, uncompress the .img.xz file, and write the file to the USB flash drive stick

https://ghostbsd-documentation-portal.readthedocs.io/en/latest/user/installation-guide/getting-started.html 

Where X is 0, 1, 2, 3 da0 or da1 or da2 or da3 
gpart status 
gpart show -lp 
dd if=/path/to/GhostBSD-YY.MM.DD.iso of=/dev/daX bs=1m conv=sync status=progress
 

 
 raspberrypi.org  or raspberrypi.com for Raspberry Pi OS tools for Raspberry Pi 4B hardware.
you can find the rpi-imager tool here, and the Raspberry Pi OS, and many other helpful items.
 https://www.raspberrypi.com/documentation/computers/getting-started.html
https://github.com/raspberrypi/rpi-imager  Github for rpi-imager software

Download and install Raspberry Pi Imager to a computer with an SD card reader.
Put the SD card you'll use with your Raspberry Pi into the reader and run Raspberry Pi Imager. in a Terminal window.

https://www.tomshardware.com/how-to/boot-raspberry-pi-4-usb
https://www.youtube.com/watch?v=8tTFgrOCsig  Jeff Gerling
https://www.youtube.com/watch?v=eFsjjjrqytQ Pi3g 
https://www.youtube.com/watch?v=_5Drx8hNIr0  Side of Burritos Ras Pi 4 usb boot

Setup the Raspberry Pi to boot from a USB flash drive. Insert the made USB flash drive to boot the raspberry pi 4B hardware.  Run the raspi-conf program to update the hardware configuration to boot from USB Flash drive before Micro SD card.

Attach a USB SSD and run "bsdinstall"

Attach an external USB hard drive (or SSD) via a USB 3.0 cable (or USB 2.0 cable)

Run command line "bsdinstall"  and install FreeBSD 14.0 from over the ethernet internet to your blank SSD drive.  Afterwards, "shutdown -r now", remove the USB flash drive after shutdown and before reboot.  The system should boot from external USB hard drive (or SSD).  Congratulations you have a booting functioning  FreeBSD operating system installed to your hard disk or SSD.  Enjoy the fruits of your labor.

https://wiki.freebsd.org/BSDInstall 

https://docs.freebsd.org/en/books/handbook/bsdinstall/

 https://docs.freebsd.org/doc/9.0-RELEASE.org/doc/-RELEASE/usr/share/doc/freebsd/handbook/using-bsdinstall.html

Booting from external USB SSD

After booting up a Fresh FreeBSD kernel from the external USB SSD with a Ethernet cable connected from Gigabit RJ-45 Ethernet port to your router.  Check that you are connected to the internet.  First check that you can ping the router:   ping -c 3 192.168.1.1  or  ping -c 3 192.168.0.1

ping -c 3 8.8.4.4  IP number for Google DNS 

ping -c 3   he.net  IP Name for Hurricane Electric IP network provider.  Also Supports IP6 networking

ping -c 3  ghostbsd.org 

Verify the local time and that the nntp time daemon has updated the local time clock for FreeBSD.

The command:
           date 202206131627
     sets the date to “June 13, 2022, 4:27 PM”.

date

su root

password:

 Installing FreeBSD Source Code 14.0-CURRENT to /usr/src

Originally download original /usr/src code head

git -C /usr clone -o freebsd -b main --depth 1 https://git.freebsd.org/src.git src

https://old.reddit.com/r/freebsd/comments/keme3b/heads_up_freebsd_changing_from_subversion_to_git/ghxggjm/

One-off, 2021-03-02,  Use this line to update  freebsd code to current state

git -C /usr/src pull --ff-only --unshallow

https://lists.freebsd.org/pipermail/freebsd-current/2021-March/078985.html

Standard update to /usr/src  code to the latest

git -C /usr/src pull --ff-only

-- https://freebsdfoundation.org/updating-freebsd-from-git/

-- https://docs.freebsd.org/doc/13.0-RELEASE/usr/local/share/doc/freebsd/en/books/handbook/makeworld.html

 

https://gist.github.com/grahamperrin/e7a266154793d0e039f9a7d52396f8d7#one-off-2021-03-10

https://gist.github.com/grahamperrin/e7a266154793d0e039f9a7d52396f8d7

git -C /usr clone -o freebsd -b main https://git.freebsd.org/src.git src

After Git Clone Pull source Code; Update Patch Audio code; Compile kernel

"time" the process.  Take about 17,500 seconds ( or about 5 hours on Raspberry Pi 4B with 8 gigs ram and running at 1500Mhz CPU clock. with out a "-j4"; equivalent to "-j1" or use one CPU for jobs.  6600 seconds with "-j4")   The make installkernel  takes about 3 or 4 minutes.
Two Lines to make and install the patched version of the Kernel from a standard user account use "sudo".   See the Patching FreeBSD paragraph below.

whoami
   fred
cd /usr/src
su root
time make -j4 buildkernel KERNCONF=GENERIC-VCHIQ
time make -j4 installkernel KERNCONF=GENERIC-VCHIQ
reboot



Robonuggie Youtube Channel Videos about Installing FreeBSD 13

Here are some related videos about Installing and using Desktop Environments for FreeBSD 13.0 on Raspberry Pi 4 and 400 hardware.


www.youtube.com/c/robonuggie has some great videos about installing FreeBSD 13.0 on Raspberry Pi 4 and 400 hardware:    
https://www.youtube.com/watch?v=WuoMPP_178U Installing FreeBSD 13.0, A Viable alternative, Not Rasberry Pi O/S    
https://www.youtube.com/watch?v=m6kyOHsvrsg A week using FreeBSD 13.0 on Raspberry Pi 400 ,  


Patching FreeBSD source code tree with HDMI Audio vchiq patch

[PATCH] Experimental vchiq and bcm2835_audio support for arm64 and arm32

https://lists.freebsd.org/archives/freebsd-arm/2022-May/001342.html  Marcos improved Patchfile source
https://lists.freebsd.org/archives/freebsd-arm/2022-February/000949.html Marcos Patchfile source
Select the whole patch source code from above URL link,  copy, paste into a filename like "HDMI_VCHIQ_sound_patch.txt".  Then follow steps below to patch kernel source code as ROOT user in source code directory base  /usr/src
 
 
https://reviews.freebsd.org/D36431 <https://reviews.freebsd.org/D36431>

Does this match your usage work flow? I am asking you to verify the steps,
so that I or others can duplicate those steps and have a working kernel to install.
please modify, add, or update the steps below:

su root
cd /usr/src
patch -v <HDMI_VCHIQ_sound_patch.txt
time make -j4 buildkernel KERNCONF=GENERIC-VCHIQ
or  time make -j4 buildkernel  KERNCONF=GENERIC-VCHIQ -DNO_CLEAN

time make -j4 installkernel KERNCONF=GENERIC-VCHIQ
reboot FreeBSD operating system and use the newly compiled kernel
uname -aK    What is the presently running kernel version.
ls -l /boot/kernel      Look at the file sizes and file dates FYI

Now I expect that HDMI port #0 sound will work and output to my Television connected via HDMI cable to TV's HDMI input #2. So when my tv is displaying the Raspberry Pi 4B desktop screen. Opening FireFox version 104 browser to youtube.com will play some Video and AUDIO too.


Your thoughts are welcome in the comments below?
 

ps. I tested the above steps for rebuilding my FreeBSD 14.0-CURRENT kernel and installing FreeBSD 14.0-CURRENT GENERIC-VCHIQ kernel. It worked and I opened Firefox Browser and played Youtube videos.  This made the audio sound come out the mini-HDMI port and play on the Television speakers.  WOW!  Great advance.  Made the FreeBSD distro installation come alive on my Raspiberry Pi 4B.

 

 FreeBSD ARM Mailing list  archives   https://lists.freebsd.org/archives/freebsd-arm/

Marco's Reply with simple test outputs 

    stock config.txt and dtb-s. 
    
    dmesg should then show
    
    vchiq0: <BCM2835 VCHIQ> mem 0x7e00b840-0x7e00b87b irq 72 on simplebus0
    vchiq: local ver 8 (min 3), remote ver 8.
    pcm0: <VCHIQ audio> on vchiq0
    
    and 
      cat /dev/random > /dev/dsp
    should play static
    
    If nothing’s playing, flipping the sysctl dev.pcm.0.dest through
     - 0: both hdmi and headphones
     - 1: headphones
     - 2: hdmi
    usually brings the audio back to life.
    
    Best,
    Marco

     Freds Thanks to Marco

     
    https://download.freebsd.org/doc/en/books/arch-handbook/arch-handbook_en.pdf 
     
    Ports Manual Information for Handbook and wiki 
     
    https://wiki.freebsd.org/arm/U-Boot-ports 
     
     

    Comments

    Popular posts from this blog

    HDMI Audio sound patches into GhostBSD source code /usr/ghost14/ghostbsd-src SOLVED Jan20 2024

    How to install GhostBSD-Arm64 into a USB Flash Drive stick April 24, 2024 update edition.

    January 19, 2024 Howto Download a Raspberry Pi 4B bootable image from http://ghostbsdarm64.hopto.org/packages/