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

HDMI Audio sound patches into GhostBSD source code /usr/ghost14/ghostbsd-src   January 19, 2024  SOLVED Jan 20, 2024

Applied the three patches manually: D36431, D37878D37879   

D36431 date was September 2, 2022
D37879 date was December 26, 2022
D37878 date was December 26, 2022

fetch https://reviews.freebsd.org/D36431?download=true

wget -c https://reviews.freebsd.org/file/data/cc5gnx6lx7pcvduupcbj/PHID-FILE-ombv7ctfqm3de2dyqgeq/D36431.diff

fetch https://reviews.freebsd.org/D37878?download=true

wget -c https://reviews.freebsd.org/file/data/bicc7vdmyzwnylvq5soa/PHID-FILE-wc6uoit423pb3lpagwsq/D37878.diff

fetch https://reviews.freebsd.org/D37879?download=true

wget -c https://reviews.freebsd.org/file/data/ln65jga5vwpz4j2ijmnx/PHID-FILE-cnp5deghq74u3kcfwtxs/D37879.diff

Standard update to /usr/src  code to the latest

git -C /usr/src pull --ff-only
root@usr/src # git -C /usr/src pull --ff-only

Already up to date.

I add January 19 email from Yan-Hao Wang 

I tested and used D36431 patch.  D36431 is a separate code patch, so use all 3 patches. 
 
patch < D36431.diff   
patch < D37838.diff  
patch < D37839.diff  

Marcos 11-May-2022 email was the only patch I remember completing in September 5 , 2022 that I wrote about in my blog post.  Well, it was Marcos 11-May-2022 email with improved patch code from the FreeBSD arm -mailing list that I copied into HDMI_VCHIQ_sound_patch.txt file.  Today, I will use these

D36431, D37878 , D37879   diff patch files.


FreeBSD 14.0 Compiling kernel for Raspberry Pi 4B in 4 easy steps from year 2022.

su root
cd /usr/src
patch -v <HDMI_VCHIQ_sound_patch.txt
time make -j4 buildkernel KERNCONF=GENERIC-VCHIQ
https://lists.freebsd.org/archives/freebsd-arm/2022-May/001342.html
Marcos D. C. 11-May-2022 freebsd-arm mailing list post entry. was copied into file HDMI_VCHIQ_sound_patch.txt

I copied Marcos 11-May-2022 mail list diff into a file HDMI_VCHIQ_sound_patch.txt and used that patch file.  

I think it better to use those three patch diff files D36431, D37878, D37879 review.freebsd.org code.  D37878 was an improved finished patch.  I was compiling on a 64 bit system, and would only need a 64 bit patch code,  yet for complete of the code testing after patching with D37878 I would patch with  

D37879   the 32 bit code patch. vchiq: add compat_freebsd32 ioctls and respective datatypes,  so the code base being tested, includes both 32 bit paths and 64 bit paths.

I see your linear order procedure of using all 4 patch code reviews.    I would only use D37878 and D37879.  Next I will check dry run if patch D43399 has additional fixes to the broken printf format line statments.  D43399 was created by me because I could not compile the existing FreeBSD 14.0-STABLE (maybe it is FreeBSD 15.0-CURRENT )  /usr/src  source code base.  using the 3 lines to make build code:

D37878 code also creates the kernel configuration file  GENERIC-VCHIQ.conf
cd /usr/src
make -j4 buildworld -DNO_CLEAN # 16 plus hours to perform on Raspberry Pi 4B.
make -j4 buildkernel KERNCONF= GENERIC-VCHIQ # 5+ hours

That is my thoughts and procedures.  I will now test what I wrote above.  Through compiling and audio testing, I will find errors that I missed. This looked good did not see any errors.

PATCH Kernel example:


su -   # setup to be root user
cd /usr/ghost14 ;  mkdir  Patches
cd Patches
wget -c
https://reviews.freebsd.org/file/data/cc5gnx6lx7pcvduupcbj/PHID-FILE-ombv7ctfqm3de2dyqgeq/D36431.diff
wget -c
https://reviews.freebsd.org/file/data/bicc7vdmyzwnylvq5soa/PHID-FILE-wc6uoit423pb3lpagwsq/D37878.diff
wget -c
https://reviews.freebsd.org/file/data/ln65jga5vwpz4j2ijmnx/PHID-FILE-cnp5deghq74u3kcfwtxs/D37879.diff

cd /usr/ghost14/ghostbsd-src    # Now patch those files. for FreeBSD /usr/src


patch  <../Patches/D36431.diff
patch  <../Patches/D37878.diff
patch  <../Patches/D37879.diff

D37878 creates configuration file sys/arm64/conf/GENERIC-VCHIQ.  Now compile with this line.  make buildkernel KERNCONF=GENERIC-VCHIQ -DNO_CLEAN
whoami
su root
cd /usr/ghost14/ghostbsd-src
# previously completed patch -v <HDMI_VCHIQ_sound_patch.txt
time make -j4 buildkernel KERNCONF=GENERIC-VCHIQ -DNO_CLEAN

Compiling to see if errors show up.

MAKE buildKERNEL KERNCONF=GENERIC-VCHIQ

rk3399_pmucru.o rk3568_cru.o rk3568_pmucru.o uart_dev_cdnc.o zy7_gpio.o cdnc_i2c.o xlnx_dwc3.o zynqmp_firmware.o zynqmp_firmware_if.o zynqmp_clock.o zynqmp_clk_div.o zynqmp_clk_fixed.o zynqmp_clk_gate.o zynqmp_clk_mux.o zynqmp_clk_pll.o zynqmp_reset.o config.o env.o hints.o vnode_if.o force-dynamic-hack.pico vers.o; objcopy --wildcard --strip-symbol='$[adtx]*' kernel.full
ctfmerge -L VERSION -g -o kernel.full ...
text data bss dec hex filename
12815727 1372642 3235840 17424209 0x109df51 kernel.full
--- kernel.debug ---
--- kernel.bin ---
--- kernel.debug ---
objcopy --only-keep-debug kernel.full kernel.debug
--- kernel ---
objcopy --strip-debug --add-gnu-debuglink=kernel.debug kernel.full kernel
--- kernel.bin ---
created kernel.bin from kernel.full
3101.33 real 9150.40 user 880.64 sys
--------------------------------------------------------------
>>> Kernel build for GENERIC-VCHIQ completed on Sat Jan 20 11:05:12 UTC 2024
--------------------------------------------------------------
>>> Kernel(s) GENERIC-VCHIQ built in 3102 seconds, ncpu: 4, make -j4
--------------------------------------------------------------
3102.42 real 9152.45 user 884.01 sys
root@rpi-Ghost4B-test-Dec12-3-jan8:/usr/ghost14/ghostbsd-src #

No, No errors showed up. 3100 seconds is quicker than the usual 5000 seconds.   
Faster speed Must be that Ugreen Case with the NVMe P3 Crucial 500Gbyte drive.  
date
Sat Jan 20 11:20:34 UTC 2024


root@rpi-Ghost4B-test-Dec12-3-jan8:/usr/ghost14/ghostbsd-src # uname -aKmnopr

FreeBSD rpi-Ghost4B-test-Dec12-3-jan8 14.0-STABLE FreeBSD 14.0-STABLE #0 stable/14-n230715-6870ce788fe-dirty: Sat Oct 28 19:43:29 PDT 2023     root@fredselfbuilt_rpi4b:/usr/obj/usr/ghost14/ghostbsd-src/arm64.aarch64/sys/GENERIC-VCHIQ arm64 aarch64 1400500
 

root@rpi-Ghost4B-test-Dec12-3-jan8:/usr/ghost14/ghostbsd-src # ghostbsd-version -fkov
14.0-STABLE
1400500


MAKE installKERNEL example:


make installkernel KERNCONF=GENERIC-VCHIQ

If a custom kernel was built, KERNCONF must also be set to use the new custom kernel:

# cd /usr/src
# make installkernel KERNCONF=GENERIC-VCHIQ
# shutdown -r now
# cd /usr/src
# make installworld
# shutdown -r now

===> xl (install)
install -T release -o root -g wheel -m 444   if_xl.ko /boot/kernel/
install -T dbg -o root -g wheel -m 444   if_xl.ko.debug /usr/lib/debug/boot/kernel/
===> xz (install)
install -T release -o root -g wheel -m 444   xz.ko /boot/kernel/
install -T dbg -o root -g wheel -m 444   xz.ko.debug /usr/lib/debug/boot/kernel/
===> zfs (install)
install -T release -o root -g wheel -m 444   zfs.ko /boot/kernel/
install -T dbg -o root -g wheel -m 444   zfs.ko.debug /usr/lib/debug/boot/kernel/
===> zlib (install)
install -T release -o root -g wheel -m 444   zlib.ko /boot/kernel/
install -T dbg -o root -g wheel -m 444   zlib.ko.debug /usr/lib/debug/boot/kernel/
kldxref /boot/kernel
--------------------------------------------------------------
>>> Installing kernel GENERIC-VCHIQ completed on Sat Jan 20 11:40:22 UTC 2024
--------------------------------------------------------------
root@rpi-Ghost4B-test-Dec12-3-jan8:/usr/ghost14/ghostbsd-src # 


root@rpi-Ghost4B-test-Dec12-3-jan8:~ # pwd
/root
root@rpi-Ghost4B-test-Dec12-3-jan8:~ # mpg123 *.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
    version 1.32.3; written and copyright by Michael Hipp and others
    free software (LGPL) without any warranty but with best wishes


Terminal control enabled, press 'h' for listing of keys and functions.

Playing MPEG stream 1 of 1: Free_Test_Data_100KB_MP3.mp3 ...

MPEG 1.0 L III vbr 44100 j-s

[0:03] Decoding of Free_Test_Data_100KB_MP3.mp3 finished.
root@rpi-Ghost4B-test-Dec12-3-jan8:~ # dmesg | grep -in pcm
64:pcm0: <VCHIQ audio> on vchiq0
root@rpi-Ghost4B-test-Dec12-3-jan8:~ # dmesg | grep -in vchiq
8:    root@rpi-Ghost4B-test-Dec12-3-jan8:/usr/obj/usr/ghost14/ghostbsd-src/arm64.aarch64/sys/GENERIC-VCHIQ arm64
62:vchiq0: <BCM2835 VCHIQ> mem 0x7e00b840-0x7e00b87b irq 72 on simplebus0
63:vchiq: local ver 8 (min 3), remote ver 8.
64:pcm0: <VCHIQ audio> on vchiq0
root@rpi-Ghost4B-test-Dec12-3-jan8:~ #
ITS ALIVE and WELL and SOUNDS GREAT!! Marcos Devesas Campos for the WIN!

root@rpi-Ghost4B-test-Dec12-3-jan8:~ # dmesg | grep -in pcm
64:pcm0: <VCHIQ audio> on vchiq0
root@rpi-Ghost4B-test-Dec12-3-jan8:~ # dmesg | grep -in vchiq
8:    root@rpi-Ghost4B-test-Dec12-3-jan8:/usr/obj/usr/ghost14/ghostbsd-src/arm64.aarch64/sys/GENERIC-VCHIQ arm64
62:vchiq0: <BCM2835 VCHIQ> mem 0x7e00b840-0x7e00b87b irq 72 on simplebus0
63:vchiq: local ver 8 (min 3), remote ver 8.
64:pcm0: <VCHIQ audio> on vchiq0

root@rpi-Ghost4B-test-Dec12-3-jan8:~ # sysctl hw.snd.default_unit
hw.snd.default_unit: 0
root@rpi-Ghost4B-test-Dec12-3-jan8:~ # 

root@rpi-Ghost4B-test-Dec12-3-jan8:~ # sysctl dev.pcm
dev.pcm.0.trace: 0
dev.pcm.0.starved: 10
dev.pcm.0.freebuffer: 40000
dev.pcm.0.underruns: 2
dev.pcm.0.retrieved: 775696
dev.pcm.0.submitted: 812000
dev.pcm.0.callbacks: 824
dev.pcm.0.dest: 0
dev.pcm.0.mode: 3
dev.pcm.0.bitperfect: 0
dev.pcm.0.buffersize: 0
dev.pcm.0.play.vchanformat: s16le:2.0
dev.pcm.0.play.vchanrate: 48000
dev.pcm.0.play.vchanmode: fixed
dev.pcm.0.play.vchans: 1
dev.pcm.0.%parent: vchiq0
dev.pcm.0.%pnpinfo:
dev.pcm.0.%location:
dev.pcm.0.%driver: pcm
dev.pcm.0.%desc: VCHIQ audio
dev.pcm.%parent:


root@rpi-Ghost4B-test-Dec12-3-jan8:~ #

root@rpi-Ghost4B-test-Dec12-3-jan8:~ # cat /dev/sndstat
Installed devices:
pcm0: <VCHIQ audio> (play) default
No devices installed from userspace.

root@rpi-Ghost4B-test-Dec12-3-jan8:~ # freebsd-version -kru
14.0-STABLE
14.0-STABLE
14.0-STABLE

root@rpi-Ghost4B-test-Dec12-3-jan8:~ # ghostbsd-version -fkov
14.0-STABLE
1400501

root@rpi-Ghost4B-test-Dec12-3-jan8:~ # uname -aKmnopr
FreeBSD rpi-Ghost4B-test-Dec12-3-jan8 14.0-STABLE FreeBSD 14.0-STABLE #0 stable/14-n230719-b026f834365-dirty: Sat Jan 20 11:04:28 UTC 2024     root@rpi-Ghost4B-test-Dec12-3-jan8:/usr/obj/usr/ghost14/ghostbsd-src/arm64.aarch64/sys/GENERIC-VCHIQ arm64 aarch64 1400501


So sound is working for me, with just 3 patches and leaving OUT (NOT APPLIED) D4399 patch, Yan-Hao Wang.
~~~~~~~~~~~~~~~~~~~~~
Here is Yan-Hao Wang, sharing his methodology of patching FreeBSD source code.
https://reviews.freebsd.org/F75131370  
  1. Applied the three patches manually: D37878D37879   D36431. Then applied D43399 using the following commands:
$ patch <D36431.patch
$ patch <D37878.patch
$ patch <D37879.patch
$ git restore --source HEAD^  # Restore the files D43399 will use
$ patch <D43399.patch

Leave OUT do NOT USE D43399.patch anyone. Just use those 3 patch files.
https://reviews.freebsd.org/F75131370#30  
Fred Finster notes about using 3 VCHIQ patch files

As a commentary,
I am typing this on a Raspberry Pi 4B with 8 gigs running GhostBSD-Arm64 operating system:
Using ethernet cable from the RJ 45
connector to the 1 Gigabit Router.  A Ugreen Case USB 3.0 to NVMe M.2 stick in a 
aluminum case with a heat transfer pad sitting inside on top of the NVMe stick to transfer 
heat to the aluminum case, and a rubber bumper on the outside of the Ugreen Case for keeping
the case from sliding on the desktop or floor.  I have a 500GByte NVMe Crucial Memory stick 
inside.  For comfort I have the K400 Logitech wireless Keyboard with the trackpad. 
The logitech USB wireless dongle allows me to sit back from the 42" TV and not have 
wires to trip over.   So this is a great experience I have using a wonderful little 
compact computer in the Raspberry Pi 4B connected with a micro HDMI connector 
to Full size HDMI connector cable, connected to the older 2010 Samsung TV.  Yes, I did
move the easy recliner rocker closer to the TV and change K400 Logitech Keyboard 
for a standard USB wired Keyboard and a wired mouse.   But here today 40 years later 
(from 1982-1984), after building a little 6809 SBC computer by solder chips and 
parts to a designed 6809 PCB with 64K DRAM.    Also used the 8 bit Radio Shack Color Computer 
(TRS CoCo 6809 ) with 16K memory dram expanded to 64K dram and had a single or 
dual 5 1/4 floppy disk drives.

Now to have QUAD 64bit ARMv8a A72 Arm cpus, 8Gbytes dram, Still TV connected though ( ha ha)
yet the this LCD tv at 42" inch is larger than the 20" NTSB cathode ray tube back then in
the 80's,  500Gbytes with a transfer speed of 1050Mbyte per second.  
Cheap at about $150-$200  In conclusion, Smart phones, tablets allow you to consume 
information and media today.  So to create knowledge information, you need a 
keyboard and mouse, a small computer, storage space, a display device like a Television 
or monitor screen with Stereo speakers.  Having a cheap, small computer device connected 
to the TV is good for the third world users to connect to the internet and create 
knowledge information with keyboard and mouse.  Yes, one can perform tasks with a 
smart phone, yet to edit video and enter data into a spreadsheet, you need a mouse 
and keyboard.  I am excited to build, test, and right now use this Raspberry Pi 4B to 
create this document sitting in my easy recliner chair, with usb keyboard in my lap, and 
red laser optical usb mouse on my knee.  The computer is connected to the Large TV 
(I can see the screen! Ctrl-Shift-+ plus key sequence expands the text size for my
older eyes.) near by.  Cable from the router to the computer.   I can relax and type. 
The low power computer can be left on to run a compile session overnight.  I can view
youtube videos on the TV screen and when the sound works actually hear the audio from
videos.  Having a computer with mouse and keyboard, allows you type, click and select which
video to watch. 

Packages to Install after getting sound to work.

pkg search browser
pkg install falkon   or falcon-QT
pkg install abiword dia 
pkg install telegram-desktop-qt6

So yes this is quote "The good life" and I wish to share with
others like the TNB "The Next Billion" people to be connected to the internet.
2018  https://blog.google/technology/next-billion-users/next-billion-users-are-future-internet/
2020  https://www.visualcapitalist.com/the-next-billion-internet-users-worldwide/
Medium.com Article  https://medium.com/@gianninoto/connecting-the-next-billion-218a29e81d63


Ugreen Case and Crucial NVMe stick

Ugreen Case information below:

https://www.ugreen.com/products/ugreen-m-2-nvme-sata-ssd-enclosure-reader
https://www.ugreen.com/products/ugreen-m-2-nvme-sata-ssd-enclosure-reader?variant=39915665129534


XDA Developers UGreen NVMe M.2 Case review:
https://www.xda-developers.com/ugreen-m2-nvme-sata-ssd-enclosure-review/



AMAZON UGreen Store :
https://www.amazon.com/stores/UGREEN/page/0F31675B-CB83-4FA9-8BE4-A1BC3A4763C2?ref_=ast_bln
https://www.amazon.com/s?k=external+enclosure+nvme&language=en_US&adgrpid=1233652392855144&hvadid=77103442835054&hvbmt=bp&hvdev=c&hvlocphy=109834&hvnetw=s&hvqmt=p&hvtargid=kwd-77103547587714%3Aloc-190&hydadcr=24228_13648035&tag=txtstdbgdt-20&ref=pd_sl_98ql93hu08_p

Crucial Memory Sticks at Crucial.com
blob:https://www.amazon.com/2967b80b-0731-4f36-80e1-792d8d16710f
https://www.crucial.com/products/ssd/nvme-ssds
https://www.crucial.com/ssd/p3/CT500P3SSD8  This is the p3 CT500 I purchased
Crucial Memory NVMe sticks on Amazon:
https://www.amazon.com/Crucial-500GB-NAND-NVMe-2400MB/dp/B086BGWNY8
https://www.amazon.com/Crucial-500GB-PCIe-NAND-3500MB/dp/B0B25LQQPC/ref=ci_mcx_psdc_1292116011_t1_B086BGWNY8
https://www.amazon.com/Crucial-Plus-500GB-PCIe-6600MB/dp/B098W1NDV2







Comments

  1. So future readers, What are your experiences with using GhostBSD-Arm64 on a USB Flash Drive?
    Here are other Blog Posts and websites to read about installing an Arm64 image file for Raspberry Pi 4B, 400, 3B into a USB Flash Drive using dd write or Balena Etcher https://etcher.io
    https://ghostbsd-arm64.blogspot.com/2024/01/january-19-2024-howto-download.html
    https://ghostbsd-arm64.blogspot.com/2023/12/how-to-install-ghostbsd-arm64-into-usb.html
    http://ghostbsdarm64.hopto.org/packages/ Arm64 image files and shell scripts
    http://ghostbsdarm64.hopto.org/packages/Images/ configuration file samples /boot/loader.conf /etc/rc.conf
    https://www.bsdnow.tv/545 Thank you crew at BSDnow.tv for publishing my work and blogpost in Number #545 podcast
    https://youtube.com/watch?v=uJtLJGujjhM&si=SIsug3tpGvz_maJO My Video showing process to go from nothing to a USB Flash drive booting the Raspberry Pi 4B. Next install ZFS file system to a Ugreen Case and NVMe M.2 stick or to a USB to SATA cable connected to a 2.5" inch SATA SSD drive.
    https://youtube.com/watch?v=FqPuSd1DnZc&si=mMcISKIB_KGsqkPQ View parts needed for a minimum booting Raspberry Pi 4B, using SSH to connect via ethernet Cable for interaction with GhostBSD-Arm64 booting from a USB flash drive stick. HDMI Audio works out your TV Monitor stereo speakers, or a USB headphones, or a 3.5mm analog audio jack.
    https://Ghostbsd.org/download website for downloading x86_64 Live Media boot image written to a USB Flash Drive stick. Can use https://Ventoy.net to boot many different .ISO and .IMG boot files from a single USB flash drive stick
    https://t.me/ghostbsd_dev/24054 GhostBSD Development Arm64 Development channel
    https://t.me/+ST6N61pnu3Di8zgk Arm Open-Source Telegram Channel to share many Arm Open-Source ideas and tips and tools.

    Enjoy, have fun using GhostBSD-Arm64 on your Raspberry Pi 4B,400,3B hardware. Report back problems, tips, and solutions right here on comments. Thank you Fred L. Finster https://x.com/@finster_fred https://x.com/@l_finster34982 X twitter channel

    ReplyDelete

Post a Comment

Popular posts from this blog

FreeBSD 14.0 Compiling kernel for Raspberry Pi 4B

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