RockPi S + CS42448 I2S/I2C DAC setup

Yep, device is there

#0: Loopback 1
#1: multi-ch-card

Playback seems ok, gives no errors at least

I would suggest to try adding the config rockchip,trcm-sync-tx-only;. IIUC it internally connects clock tx to clock rx and makes the two interfaces synchronously running. I remember I was hitting the same error when trying to find a working config, but do not remember exactly if it was this one. This config should already work in 6.1

That was the culprit indeed.
Spectrogram 96kHz:


192kHz:

Hm, that looks pretty clean. Please can you make the two spectrograms of e.g. 10 minutes too?

I wonder why my spectrogram at 192kHz is basically totally broken and I never get a clean 96kHz loopback either. Please can you post:

Your whole DTS tree:

dtc -I fs /sys/firmware/devicetree/base

Your clock tree while running playback and capture /sys/kernel/debug/clk/clk_summary

What cpu freq governor do you use?

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

What extra patches to the kernel have you applied?

How did you get your 6.1 kernel? Maybe there is some issue introduced between your 6.1 and my 6.6, maybe your 6.1 source has some extra patches required for RK3308.

Thanks a lot!!

192kHz:


clk_summary:
clk.zip (2.2 KB)

96kHz:


clk_summary:
clk96.zip (2.2 KB)

dts:
dts.zip (14.0 KB)

governor:

# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
cat: can't open '/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor': No such file or directory

How did you get your 6.1 kernel? Maybe there is some issue introduced between your 6.1 and my 6.6, maybe your 6.1 source has some extra patches required for RK3308.

I posted link above with the branch name. It’s radxa kernel. I did not apply any patches personally.

Thanks a lot. I will play with your configs/kernel etc. to try fixing my issues and let you know my results.

A few questions please, to check for possible HW differences.

Do you have RK3308B or the newer RK3308B-S (should be written on the SoC, IIUC). I have RK3308B.

How do you power your Pi-S?

You have a heatsink on your Pi-S SoC. Mine runs hardly warm even when stressing all cores to max. Does your SoC run hot without the heatsink?

Thanks a lot!

Hm, I built the 6.1 kernel using bsp stable, but IIUC that does not build https://github.com/radxa/kernel/tree/linux-6.1-stan-rkr1 , but mainline with some patches included in bsp

BSP_GIT="https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux.git"
BSP_TAG="v6.1.68"

I get even worse results than on 6.6.

The radxa kernel linux-6.1-stan-rkr1 is likely very different. Please how did you build your kernel, what .config did you use?

I am sorry for bothering you, but this situation bugs me too. Kind of looks like a mess in the radxa kernel projects.

Thanks a lot,

Pavel

I have RK3308B SoC, v1.3 board produced in 20190910. Powered up from an USB3 port at the moment. Heatsink is for ‘just in case’ reason, SoC does not become that hot in real.

I’m crosscompiling it with ‘gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu’ toolchain.
My defconfig:

CONFIG_DTC_SYMBOLS=y
CONFIG_WERROR=y
CONFIG_DEFAULT_HOSTNAME="localhost"
CONFIG_SYSVIPC=y
CONFIG_FHANDLE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_PREEMPT=y
CONFIG_LOG_BUF_SHIFT=18
CONFIG_CGROUPS=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_MEMCG=y
CONFIG_MEMCG_KMEM=y
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_CFS_BANDWIDTH=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_BLK_CGROUP=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_EMBEDDED=y
CONFIG_PROFILING=y
CONFIG_ARCH_ROCKCHIP=y
CONFIG_SCHED_MC=y
CONFIG_NR_CPUS=4
CONFIG_HZ_1000=y
CONFIG_COMPAT=y
CONFIG_PM_DEBUG=y
CONFIG_PM_ADVANCED_DEBUG=y
CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y
CONFIG_ENERGY_MODEL=y
CONFIG_CPU_IDLE=y
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPUFREQ_DT=y
CONFIG_ARM_ROCKCHIP_CPUFREQ=y
CONFIG_JUMP_LABEL=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_PARTITION_ADVANCED=y
CONFIG_DEFAULT_MMAP_MIN_ADDR=32768
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_NET_KEY=y
CONFIG_INET=y
CONFIG_SYN_COOKIES=y
CONFIG_BT=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_HIDP=y
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_H4=y
CONFIG_BT_RTL=y
CONFIG_RFKILL=y
CONFIG_RFKILL_RK=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_ROCKCHIP_SIP=y
CONFIG_NETDEVICES=y
CONFIG_STMMAC_ETH=y
CONFIG_REALTEK_PHY=y
CONFIG_WL_ROCKCHIP=y
CONFIG_WIFI_BUILD_MODULE=y
CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP=y
CONFIG_RTL8723DS=y
CONFIG_INPUT_EVDEV=y
CONFIG_KEYBOARD_ADC=y
CONFIG_KEYBOARD_GPIO=y
CONFIG_INPUT_MISC=y
CONFIG_INPUT_GPIO_ROTARY_ENCODER=y
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_8250_NR_UARTS=5
CONFIG_SERIAL_8250_RUNTIME_UARTS=5
CONFIG_SERIAL_8250_DW=y
CONFIG_HW_RANDOM=y
CONFIG_HW_RANDOM_ROCKCHIP=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_MUX=y
CONFIG_I2C_RK3X=y
CONFIG_SPI=y
CONFIG_SPI_ROCKCHIP=y
CONFIG_SPI_SPIDEV=y
CONFIG_GPIO_SYSFS=y
CONFIG_SYSCON_REBOOT_MODE=y
CONFIG_BATTERY_RK816=y
CONFIG_POWER_AVS=y
CONFIG_THERMAL=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR=y
CONFIG_THERMAL_GOV_USER_SPACE=y
CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y
CONFIG_CPU_THERMAL=y
CONFIG_DEVFREQ_THERMAL=y
CONFIG_ROCKCHIP_THERMAL=y
CONFIG_WATCHDOG=y
CONFIG_DW_WATCHDOG=y
CONFIG_MFD_RK808=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_REGULATOR_GPIO=y
CONFIG_REGULATOR_PWM=y
CONFIG_REGULATOR_RK808=y
CONFIG_DRM=y
CONFIG_DRM_IGNORE_IOTCL_PERMIT=y
CONFIG_DRM_ROCKCHIP=y
CONFIG_DRM_PANEL_SIMPLE=y
CONFIG_BACKLIGHT_PWM=y
CONFIG_SOUND=y
CONFIG_SND=y
CONFIG_SND_HRTIMER=y
CONFIG_SND_ALOOP=y
CONFIG_SND_SOC=y
CONFIG_SND_SOC_ROCKCHIP=y
CONFIG_SND_SOC_ROCKCHIP_I2S=y
CONFIG_SND_SOC_ROCKCHIP_I2S_TDM=y
CONFIG_SND_SOC_ROCKCHIP_MULTI_DAIS=y
CONFIG_SND_SOC_ROCKCHIP_PDM=y
CONFIG_SND_SOC_ROCKCHIP_SPDIF=y
CONFIG_SND_SOC_ROCKCHIP_SPDIFRX=y
CONFIG_SND_SOC_ROCKCHIP_VAD=y
CONFIG_SND_SOC_ROCKCHIP_MULTICODECS=y
CONFIG_SND_SOC_DUMMY_CODEC=y
CONFIG_SND_SOC_RK3308=y
CONFIG_SND_SOC_TAS571X=y
CONFIG_SND_SIMPLE_CARD=y
CONFIG_SND_SOC_CS42XX8_I2C=y
CONFIG_USB_DWC2=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DEBUG_FILES=y
CONFIG_USB_GADGET_VBUS_DRAW=500
CONFIG_USB_CONFIGFS=y
CONFIG_USB_CONFIGFS_UEVENT=y
CONFIG_USB_CONFIGFS_F_FS=y
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=32
CONFIG_MMC_DW=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_IS31FL32XX=y
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_TIMER=y
CONFIG_LEDS_TRIGGER_ONESHOT=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
CONFIG_LEDS_TRIGGER_MULTI_CTRL=y

CONFIG_I2C_GPIO=y
CONFIG_IR_GPIO_CIR=y
CONFIG_POWER_RESET_GPIO=y

CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_RK808=y
CONFIG_RTC_DRV_RK_TIMER=y
CONFIG_DMADEVICES=y
CONFIG_PL330_DMA=y
CONFIG_STAGING=y
CONFIG_COMMON_CLK_RK808=y
CONFIG_RPMSG_ROCKCHIP_SOFTIRQ=y
CONFIG_RPMSG_VIRTIO=y
CONFIG_CPU_RK3308=y
CONFIG_ROCKCHIP_AMP=y
CONFIG_ROCKCHIP_CPUINFO=y
CONFIG_ROCKCHIP_GRF=y
CONFIG_ROCKCHIP_IODOMAIN=y
CONFIG_ROCKCHIP_PM_DOMAINS=y
CONFIG_ROCKCHIP_PVTM=y
CONFIG_ROCKCHIP_SUSPEND_MODE=y
CONFIG_FIQ_DEBUGGER=y
CONFIG_FIQ_DEBUGGER_NO_SLEEP=y
CONFIG_FIQ_DEBUGGER_CONSOLE=y
CONFIG_FIQ_DEBUGGER_CONSOLE_DEFAULT_ENABLE=y
CONFIG_FIQ_DEBUGGER_TRUST_ZONE=y
CON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TPARAM_HARDLOCKUP_PANIC=y
CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
CONFIG_RCU_CPU_STALL_TIMEOUT=60

Thanks a lot, that’s the same as mine.

Thanks, I will test and report. Actually, how did you create your defconfig, did you write it manually or is it from somewhere? Thanks!

Default ‘rk3308_linux_defconfig’ tailored for my needs.

Thanks a lot. Now this is THE major difference - your kernel + defconfig have no issues even at 192kHz/8ch loopback:

There must be something seriously broken in the mainline for RK3308. I wonder what that kernel repo is - is it android 14 6.1 kernel + radxa patches?

I think mainline kernel was your troublemaker. With radxa kernel it works with 4.x and 6.x versions for me so I guess some radxa patches do the trick.

I assumed that radxa would put all the necessary patches into their bsp structure to make their mainline identical to this repo, but apparently there are some key differences.

But it’s ok, for the couple of modules I need to work on (mostly dwc2 and uac2 gadget function) the mainline code can be backported to this kernel, not many changes there since 6.1.

Anyway thank you very much, without your help I would never be able to move forward with this. It’s just a pitty nobody from Radxa stepped in, a simple recommendation to use their kernel repo instead of their bsp would have saved me many tens of hours…

Things are not so simple, as always. The radxa kernel is based on rockchip android kernel. E.g. Rockchip engineers make patches totally unrelated to rockchip HW which are never submitted upstream to the respective subsystems (such as changes to the USB gadget UAC2 function https://github.com/radxa/kernel/commit/01ccdd1489f1fd6006498aca34aad4dab5cac192 ).

So I end up with working I2S, but totally broken dwc2 USB gadget mode (which works perfectly in mainline). One must appreciate the RaspberryPi team which tracks mainline in their kernel very closely. This android kernel swamp is a nightmare…

Sorry for the offtopic, it’s just a frustratingly huge waste of time…

Actually the reason is missing CONFIG_ROCKCHIP_OPP=y in rk3308_linux_defconfig . As a result no operating points defined in rk3308.dtsi are used and all cores run at the initial 800MHz. After adding this config the cpufreq features start working and the SoC can be switched to any frequency, including the upstream-disabled 1.2 and 1.3GHz.

The actual frequency can be measured with the kernel perf tool

sudo ./perf stat sleep 1

 Performance counter stats for 'sleep 1':

              4.25 msec task-clock                       #    0.004 CPUs utilized          
                 3      context-switches                 #  706.242 /sec                   
                 0      cpu-migrations                   #    0.000 /sec                   
                54      page-faults                      #   12.712 K/sec                  
         5,437,117      cycles                           #    **1.280 GHz**                    
         1,385,027      instructions                     #    0.25  insn per cycle         
           245,433      branches                         #   57.778 M/sec                  
            27,744      branch-misses                    #   11.30% of all branches

Just FYI, found RK3308B-S based board - BPI-P2 PRO
It has better Wifi/BT chip onboard (BCM4345) b/g/n with 5Ghz support but board form factor is bigger though.

Thanks a lot for the link. To be honest - IMO this SoC’s audio features are very unique but standard boards offer only a sadly limited subset of all its capabilities. There are many SBCs with 8ch I/O I2S (starting at 10+ USD, up to RPi5 with its excellent software support and performance) . But this SoC allows up to 26 IO channels I2S at 384kHz/32bit (tested to be clean, with the android kernel of course :slight_smile: ) plus SPDIF IO plus 8ch ADC inputs with microphone preamps plus 8ch PDM inputs - all for 20USD incl. eMMC, while powered from the incoming USB port - that is VERY unique. I am looking at the Rock Pi S core board which offers almost all the important pins with very few external components required. For me it’s the only way of using this SoC to make it shine (in other words to make sense) compared to all the many other SoCs (most of which are more powerful and some of which offer incomparably better SW support).