How to run FreeBSD on new boards built on Rockchip 35XX..

Im trying to add sound to rk356x boards. the existing dma driver did not worked and i fixed it

I'm interested for sure. Can you explain what should I do to fix it ? Until now I have postponed the problem while I'm working on the rewriting of the panfrost driver for FreeBSD 15 on the radxa zero,but I saw that the sound part didn't want to compile succesfully so,I have disabled all the options related to sound and midi :

Code:
nooptions SND_PCM
nooptions SND_DEV
nooptions SND_HDA
nooptions SND_MIDI
nooptions SND_SEQ
nooptions SND_TIMER
nodevice sound
nodevice snd
nodevice midi
nodevice pcm
nodevice hdac
nodevice hda

But I never thought that it didn't work on 14.x because I never tested sound.
 
...
....
He said, "Let there be sound"
There was sound

I have it working both PIO and DMA. I went PIO out of more pl330 dma frustration but in the end it works with DMA too.
I have no idea how pl330 worked with this code in older rk socs but it seems borderline impossible to me. maybe the wiring was somehow different or the targeted peripherals were more friendly.
Ill post the patches here in the following days (the code needs some minor cleaning)
 
Code:
pl3300: <ARM PrimeCell DMA Controller (PL330)> mem 0xfe530000-0xfe533fff irq 49,50 on ofwbus0
pl3300: We have apb_pclk clock
pl3300: Mode: NON Secure, Channels :8, Peripherals: 32, n_evts: 16, peri_reg: ffffffff evts_reg: 0000ffff quirks: 00000002
pl3301: <ARM PrimeCell DMA Controller (PL330)> mem 0xfe550000-0xfe553fff irq 51,52 on ofwbus0
pl3301: We have apb_pclk clock
pl3301: Mode: NON Secure, Channels :8, Peripherals: 32, n_evts: 16, peri_reg: ffffffff evts_reg: 0000ffff quirks: 00000002
rk_i2s_tdm0: <Rockchip I2S/TDM Controller> mem 0xfe400000-0xfe400fff irq 43 on ofwbus0
rk_i2s_tdm0: Rockchip I2S/TDM controller initialized
rk_i2s_tdm0: Playback: yes, Capture: no
rk_i2s_tdm1: <Rockchip I2S/TDM Controller> mem 0xfe410000-0xfe410fff irq 44 on ofwbus0
rk_i2s_tdm1: Rockchip I2S/TDM controller initialized
rk_i2s_tdm1: Playback: yes, Capture: yes
rk817c0: <RockChip RK817 Audio Codec> at addr 0x40 irq 81 on iicbus0
rk817c0: Enabling audio route MIC
rk817c0: Disabling audio route SPK
rk817c0: Enabling audio route HP
 
here it is.
tested on orange pi 3b / rk3566
the rk817_codec is somehow hackish because its in the same chip as the pmic so it has the same i2c address
one solution would have been to shove the code in the pmic driver but it looked ugly to me
so if you add option RK817_CODEC to the kernel then rk817 pmic driver will create a iic bus child device for the codec
there is still a problem that they have the same phandle (no separate dts entries) and if both the pmic and the codec want to
OF_device_register_xref crap will happen.
fortunately as of now the pmic does not xref itself. audio dai code needs xref for simple-audio-card,codec
 

Attachments

I plan to configure the audio on my radxa zero 3W following this tutorial :


They say :

Note: currently the HDMI audio is not working out-of-box on our official image. You will need to manually install this package to have it working. We will add it to our official image in a later time once we know the package won't negatively affect existing users.

So. Do I need to use your patches if I want to hear sounds using HDMI ?
 
Hello to everyone.

I ported the panfrost driver on FreeBSD 15.0 for my radxa zero 3W board. I mean,I've been able to fix all the errors I found and I compiled correctly the kernel and the modules. Unfortunately,when I tried to boot it,this is what happened :


Screenshot_2025-11-02_16-25-00.jpg


It is stuck there. My sensation is the problem can be fixed easily. But I need to understand why. What could be the reason,what to try and so on.

Anyway,I want to share the source code of the kernel ,the compiled kernel and the modules,if someone wants to study the code and try on his board :


This is the full log that I've got from the serial connection :

Code:
marietto# minicom -D /dev/ttyU0 -b 115200

Welcome to minicom 2.10

OPTIONS: I18n
Compiled on Apr  4 2025, 15:33:54.
Port /dev/ttyU0, 14:55:08 [U]

Press CTRL-A Z for help on special keys                    
                                                           
DDR Version V1.11 20211103                                 
ln                                                         
ddrconfig:7                                                
LP4 MR14:0x4d
LPDDR4, 324MHz
BW=32 Col=10 Bk=8 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=4096MB

change to: 324MHz
PHY drv:clk:38,ca:38,DQ:30,odt:0
vrefinner:41%, vrefout:41%
dram drv:40,odt:0
clk skew:0x58

change to: 528MHz
PHY drv:clk:38,ca:38,DQ:30,odt:0                                                              
vrefinner:41%, vrefout:41%                                                                    
dram drv:40,odt:0                                                                             
clk skew:0x73                                                                                 
                                                                                              
change to: 780MHz                                                                             
PHY drv:clk:38,ca:38,DQ:30,odt:0                                                              
vrefinner:41%, vrefout:41%                                                                    
dram drv:40,odt:0                                                                             
clk skew:0x58                                                                                 
                                                                                              
change to: 1560MHz(final freq)                                                                
PHY drv:clk:38,ca:38,DQ:30,odt:60                                                             
vrefinner:16%, vrefout:29%                                                                    
dram drv:40,odt:80                                                                            
clk skew:0xa                                                                                  
out                                                                                           
U-Boot SPL board init                                                                         
U-Boot SPL 2017.09-gaaca6ffec1-211203 #zzz (Dec 03 2021 - 18:42:16)                           
unknown raw ID phN                                                                            
unrecognized JEDEC id bytes: 00, 00, 00                                                       
Trying to boot from MMC2                                                                      
No misc partition                                                                             
Trying fit image at 0x5000 sector                                                             
## Verified-boot: 0                                                                           
## Checking atf-1 0x00040000 ... sha256(fe4f274c06...) + OK                                   
## Checking uboot 0x00a00000 ... OK                                                           
## Checking fdt 0x00b00000 ... sha256(1804d514f1...) + OK                                     
## Checking atf-2 0x00068000 ... sha256(8d44036095...) + OK                                   
## Checking atf-3 0xfdcd0000 ... sha256(e410275b51...) + OK                                   
## Checking atf-4 0xfdcc9000 ... sha256(990c53fc01...) + OK                                   
## Checking atf-5 0x00066000 ... sha256(315a4195a9...) + OK                                   
## Checking optee 0x08400000 ... sha256(08e1fd41e1...) + OK                                   
Jumping to U-Boot(0x00a00000) via ARM Trusted Firmware(0x00040000)                            
Total: 319.354 ms                                                                             
                                                                                              
INFO:    Preloader serial: 2                                                                  
NOTICE:  BL31: v2.3():v2.3-181-gc9a647cae:cl                                                 
NOTICE:  BL31: Built : 10:55:41, Oct 18 2021                                                  
INFO:    GICv3 without legacy support detected.                                               
INFO:    ARM GICv3 driver initialized in EL3                                                  
INFO:    pmu v1 is valid                                                                      
INFO:    dfs DDR fsp_param[0].freq_mhz= 1560MHz                                               
INFO:    dfs DDR fsp_param[1].freq_mhz= 324MHz                                                
INFO:    dfs DDR fsp_param[2].freq_mhz= 528MHz                                                
INFO:    dfs DDR fsp_param[3].freq_mhz= 780MHz                                                
INFO:    Using opteed sec cpu_context!                                                        
INFO:    boot cpu mask: 0                                                                     
INFO:    BL31: Initializing runtime services                                                  
INFO:    BL31: Initializing BL32                                                              
I/TC:                                                                                         
I/TC: OP-TEE version: 3.13.0-595-gf5add58be #hisping.lin (gcc version 10.2.1 20201103 (GNU Toolchai4
I/TC: Primary CPU initializing                                                                
I/TC: Primary CPU switching to normal world boot                                              
INFO:    BL31: Preparing for EL3 exit to normal world                                         
INFO:    Entry point address = 0xa00000                                                       
INFO:    SPSR = 0x3c9                                                                         
UEFI firmware (version EDK2-DEV built at 01:23:28 on May 24 2025)                             

3h

Consoles: EFI console
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p3:
FreeBSD/arm64 EFI loader, Revision 3.0

   Command line arguments: loader.efi
   Image base: 0xec0ae000
   EFI version: 2.70
   EFI Firmware: EDK2 (rev 1.00)
   Console: efi (0x1000)
   Load Path: \EFI\BOOT\BOOTAA64.EFI
   Load Device: MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(3,GPT,07D4C210-2E74-1
1F0-832C-F1B721F986A1,0x20000,0x10000)
   BootCurrent: 0002
   BootOrder: 0000 0001 0002[*]
   BootInfo Path: MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)
Ignoring Boot0002: Only one DP found
Trying ESP: MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(3,GPT,07D4C210-2E74-11F0-
832C-F1B721F986A1,0x20000,0x10000)
Setting currdev to disk0p3:
Trying: MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(1,GPT,07D35DA3-2E74-11F0-832C
-F1B721F986A1,0x40,0x4FC0)
Setting currdev to disk0p1:
Trying: MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(2,GPT,07D3AC23-2E74-11F0-832C              
-F1B721F986A1,0x5000,0x2800)                                                                  
Setting currdev to disk0p2:                                                                   
Trying: MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(4,GPT,07D6525C-2E74-11F0-832C              
-F1B721F986A1,0x30000,0xEDFAFD8)                                                              
Setting currdev to disk0p4:                                                                   
Loading /boot/defaults/loader.conf                                                            
/boot/kernel/kernel text=0x318 text=0xa5a548 text=0x28e030 data=0x1614d0 data=0x              
0+0x2c1000 0x8+0x15c0f0+0x8+0x18894d\                                                         
/etc/hostid size=0x25                                                                         
/boot/entropy size=0x1000                                                                     
/boot/kernel/if_bridge.ko text=0x3dde text=0x7de8 data=0x1038+0x8 0x8+0x1ec0+0x8              
+0x1847                                                                                       
loading required module 'bridgestp'                                                           
/boot/kernel/bridgestp.ko text=0x1463 text=0x4e44 data=0x320+0x28 0x8+0xbd0+0x8+              
0x6c0                                                                                         
/boot/dtb/rockchip/a.si.drm.dtb size=0x1a867                                                  
/boot/kernel/if_rtwn_usb.ko text=0xcc80 text=0x7880 data=0x1e40+0x37 0x8+0x4140+              
0x8+0x2a16                                                                                    
loading required module 'rtwn'                                                                
/boot/kernel/rtwn.ko text=0x6b90 text=0x1a820 data=0x6e8 0x8+0x3390+0x8+0x1ad6                
loading required module 'wlan'                                                                
/boot/kernel/wlan.ko text=0x1af18 text=0x4bce0 data=0x8c68+0x318 0x8+0x92d0+0x8+              
0x79fb                                                                                        
/boot/kernel/wlan_wep.ko text=0x1130 text=0xca0 data=0x310+0x4 0x8+0x888+0x8+0x4              
a1                                                                                            
/boot/kernel/wlan_ccmp.ko text=0x3788 text=0x25c0 data=0x388+0x4 0x8+0xb28+0x8+0              
x5dd                                                                                          
/boot/kernel/wlan_tkip.ko text=0x1488 text=0x1818 data=0x320+0x4 0x8+0x930+0x8+0              
x525                                                                                          
/boot/modules/ums.ko text=0x26c3 text=0x252c data=0x7a0+0x4 0x8+0x1110+0x8+0xbce              
                                                                                              
loading required module 'kernel'                                                              
module 'kernel' exists but with wrong version                                                 
?c                                                                                            
Hit [Enter] to boot immediately, or any other key for command prompt.                         
Booting [/boot/kernel/kernel]...                                                              
Using DTB from loaded file '/boot/dtb/rockchip/a.si.drm.dtb'.                                 
EFI framebuffer information:                                                                  
addr, size     0xec190000, 0x7e9000                                                           
dimensions     1920 x 1080                                                                    
stride         1920                                                                           
masks          0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
 
when it hangs try to connect at 1500000 baud. maybe you'll see more on the serial.
otherwise it may be collision between uefi and kernel code. it also happens or used to on some x86 systems.
 
Back
Top