No support for SPI on Rock PI S that is running dietpi version 9.4.2?

Creating a bug report/issue

I see that dietpiEnv.txt has the following lines
overlay_path=rockchip
overlay_prefix=rk3308

I also see that there is no spi related dtb file with rk3308 prefix in /boot/dtb/rockchip/overlay. Does it mean there is no support for SPI? Please let me know. Thank you!

I have searched the existing open and closed issues

Required Information

  • DietPi version | cat /boot/dietpi/.version
    G_DIETPI_VERSION_CORE=9
    G_DIETPI_VERSION_SUB=4
    G_DIETPI_VERSION_RC=2
    G_GITBRANCH=ā€˜master’
    G_GITOWNER=ā€˜MichaIng’
    G_LIVE_PATCH_STATUS[0]=ā€˜not applicable’

  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN
    bookworm

  • Kernel version | uname --all
    Linux DietPi 6.6.16-current-rockchip64 #1 SMP PREEMPT Fri Feb 23 08:25:28 UTC 2024 aarch64 GNU/Linux

  • Architecture | dpkg --print-architecture
    arm64

  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)
    ROCK Pi S (aarch64)

  • Power supply used | (EG: 5V 1A RAVpower)
    5V 1A

  • SD card used | (EG: SanDisk ultra)
    32 GB SanDisk ultra

Additional Information (if applicable)

  • Software title | (EG: Nextcloud)
  • Was the software title installed freshly or updated/migrated?
  • Can this issue be replicated on a fresh installation of DietPi?
    ← If you sent a ā€œdietpi-bugreportā€, please paste the ID here →
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

  1. …
  2. …

Expected behaviour

  • …

Actual behaviour

  • …

Extra details

  • …
1 Like

These overlays are not part of mainline kernel and I think you would need to add them by yourself.
You can find the overlays here:
https://github.com/radxa/kernel/tree/stable-4.4-rockpis/arch/arm64/boot/dts/rockchip/overlay

But I have no idea how good this will work when you are on kernel 6.6.

ok, thank you! I read that page. In fact, the same contents are available in /boot/dtb-6.6.16-current-rockchip64/rockchip/overlay/README.rockchip-overlays

I am sorry I am unable to find anything to help me enable SPI.

I did a find for all the overlay files that has the prefix rk3308 as follows:

root@DietPi:/boot# find . -iname "rk3308*"

I see only the following overlays are available. I don’t see any spi related overlay file unless spi interface is included in one of these files.

./dtb-6.6.16-current-rockchip64/rockchip/rk3308-roc-cc.dtb
./dtb-6.6.16-current-rockchip64/rockchip/rk3308-rock-s0.dtb
./dtb-6.6.16-current-rockchip64/rockchip/rk3308-rock-pi-s.dtb
./dtb-6.6.16-current-rockchip64/rockchip/overlay/rk3308-sdio@10mhz.dtbo
./dtb-6.6.16-current-rockchip64/rockchip/overlay/rk3308-emmc.dtbo
./dtb-6.6.16-current-rockchip64/rockchip/overlay/rk3308-s0-ext-antenna.dtbo
./dtb-6.6.16-current-rockchip64/rockchip/overlay/rk3308-bs.dtbo
./dtb-6.6.16-current-rockchip64/rockchip/overlay/rk3308-sdio@4mhz.dtbo
./dtb-6.6.16-current-rockchip64/rockchip/overlay/rk3308-bs@1.3ghz.dtbo
./dtb-6.6.16-current-rockchip64/rockchip/rk3308-evb.dtb

I wanted to check whether spidev kernel module is available and I ran the following find command:

find /lib/modules -name "*spi*"

I see a bunch of spi related modules and the following module:
/lib/modules/6.6.16-current-rockchip64/kernel/drivers/spi/spidev.ko

So I added spidev to /etc/modules and I see it gets loaded when I reboot the device. However, I don’t see any /dev/spi* device.

Please let me know what is missing. Thank you!

This if for the Pine64 RockPro64 I guess, and not suited for your Rock Pi S.#

Can you try the rk3308-spi-spidev.dts from https://github.com/radxa/kernel/tree/stable-4.4-rockpis/arch/arm64/boot/dts/rockchip/overlay

Thank you!
I have to ask a stupid question: I see only the device tree source (dts) files in that git repo and not the binary overlay files (dtbo) files. Is there a dtc available to do this compilation? Please let me know. Thank you!

You can compile the dtbo from the dts with the help of device-tree-compiler:
https://stackoverflow.com/questions/21670967/how-to-compile-dts-linux-device-tree-source-files-to-dtb

dtc -I dts -O dtb -o rk3308-spi-spidev.dtbo /path/to/rk3308-spi-spidev.dts

I suppose you are suggesting that I cross compile these dts files on a different machine as DietPi does not seem to include any dtc.

Hm on my RPi it’s available from repo :thinking:

root@RPi4:~# apt-cache search device-tree-compiler
device-tree-compiler - Device Tree Compiler for Flat Device Trees

ah ok. I searched for dtc. my bad.

I downloaded seven dts files kernel/arch/arm64/boot/dts/rockchip/overlay at stable-4.4-rockpis Ā· radxa/kernel Ā· GitHub. I created (with chatgpt’s help) a Makefile (included it below hoping it could be of use to others) to convert these dts files into dtb files and I placed the dtb files in /boot/dtb-6.6.16-current-rockchip64/rockchip.

I have added spidev to /etc/modules and I also noticed the following options are enabled in /boot/config-6.6.16-current-rockchip64:

  • CONFIG_PWM=y
  • CONFIG_PWM_ROCKCHIP=y
  • CONFIG_SPI_SPIDEV=m

Even after all that the following three device files are still missing:

  • /dev/spidev2.0
  • /sys/class/pwm/pwmchip1
  • /sys/class/pwm/pwmchip1

Please advise what can I do further to enable SPI and PWM.

DTS_FILES := rk3308-uart0.dts rk3308-spi-spidev.dts rk3308-uart3.dts \
	     rk3308-pwm1.dts rk3308-pwm2.dts rk3308-pwm3.dts rk3308-i2c1.dts


DTBO_FILES := $(DTS_FILES:.dts=.dtbo)


UNAME_R := $(shell uname -r)
DTB_DIR := dtb-$(UNAME_R)
TARGET_DIR := /boot/$(DTB_DIR)/rockchip/

all: $(DTBO_FILES)

default: all

%.preprocessed: %.dts
	cpp -nostdinc -I /usr/src/linux-headers/include -undef -x assembler-with-cpp $< -o $@

%.dtbo: %.preprocessed
	dtc -@ -I dts -O dtb -o $@ $<

tree:
	dtc -I fs -O dts -o /tmp/livedt.dts /proc/device-tree

deploy: $(DTBO_FILES)
	@echo "Deploying to $(TARGET_DIR)"
	mkdir -p $(TARGET_DIR)
	cp $(DTBO_FILES) $(TARGET_DIR)

clean:
	rm -f *.preprocessed *.dtbo

.PHONY: all default tree deploy clean

This topic was automatically closed 178 days after the last reply. New replies are no longer allowed.