/dev/spidev0,0 on the Rock64 - Does anyone know how to enable it?
#3
SPI with user programs (python) for Rock64:
  1. There is only one SPI on rk3328 device with possible 2 chipselects CSN0/CSN1.
  2. Rockchip chose "pin multiplex 2 for SPI" (check pins *_M2 and spi2_* + grf_con_spi_io_sel in TRM) as default. This is wrong choice because only one chipselect (CSN0) is available on pin (GPIO3_B0 (SPI_CSN0_M2)).
  3. Chipselect CSN0 is used in Rock64 to activate embedded SPI-NOR flash (GD25Q128) and therefore unavailable to user (I requested RFE to be optional). Internal BOOTROM can boot only from SPI-NOR/CSN0. SPI is already enabled "okay" in DTS but only with embedded SPI-NOR flash.
  4. Let's enable SPI for user (need set driver "rockchip,spidev") with non-wired CSN1 (dynamically without reboot on ayufan kernel with backported configfs).
    Code:
    # cat >spi1.dts <<EOF /dts-v1/; /plugin/; / { compatible = "pine64,rock64"; fragment@0 { target-path = "/spi@ff190000"; __overlay__ { spidev@1 { compatible="rockchip,spidev"; reg=<1>; spi-max-frequency=<10000000>; }; }; }; }; EOF # dtc spi1.dts -o spi1.dtbo # mkdir /sys/kernel/config/device-tree/overlays/spi1 # cat spi1.dtbo > /sys/kernel/config/device-tree/overlays/spi1/dtbo # ls /dev/spidev* /dev/spidev32766.1
  5. Connect SPI device:
    • pin 19 (GPIO3_A1 (SPI_TXD_M2)) -> device SI
    • pin 21 (GPIO3_A2 (SPI_RXD_M2)) <- device SO (not used in e-paper device)
    • pin 24 (GPIO3_A0 (SPI_CLK_M2)) -> device CLK (There is bug in v2.0 hardware that swapped pins 23/24!)
    • any other pin (for example 26) -> device CS
  6. Let's try SPI with python and AT45DB041D SPI-NOR flash Smile. Because CSN1 is unavailable program must simulate CSN1 before any access of SPI transfer functions.
    Code:
    # apt install python-pip python-setuptools python-dev # pip install spidev # git clone https://github.com/Leapo/Rock64-R64.GPIO.git # ln -s Rock64-R64.GPIO/R64 . # ./spi.py JEDEC: 1f 24 00 00 00 00 run with parameters 'sector' or 'erase' or 'compare file' or 'write file' # ./spi.py erase JEDEC: 1f 24 00 00 00 00 chip erase ... wait wait wait wait wait wait wait wait wait wait wait wait wait wait wait ... done # ./spi.py write file : 1f 24 00 00 00 00 write ... 00000000 size 100: d0 0d fe ed ... wait wait wait wait wait wait 00000100 size 100: 00 00 00 4c ... wait wait wait wait wait wait 00000200 size 100: 00 00 01 38 ... wait wait wait wait wait wait ... # ./spi.py compare file JEDEC: 1f 24 00 00 00 00 compare ...

Demo code is attached. Happy hacking and buy me a Beer.


Attached Files
.zip   spi_demo.zip (Size: 1.03 KB / Downloads: 759)
I left this community in Aug 2019 due to PINE64 refusal to produce/deliver ROCK64-1G version 3 after more than one year of changing statuses to "planning", "evaluating", "releasing", "availability", "estimated availability" and finally "no schedule" Angry. ROCK64 is dead platform without any advantage. Buy Raspberry PI 4 !
Away
  Reply


Messages In This Thread
RE: /dev/spidev0,0 on the Rock64 - Does anyone know how to enable it? - by mcerveny - 08-17-2018, 06:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  irradium (based on crux linux) Rock64 riscv64, aarch64 mara 14 21,878 09-27-2026, 11:55 AM
Last Post: mara
  rAudio for Rock64 V2/Pine A64+ shinzuka 14 5,366 07-31-2026, 03:20 AM
Last Post: shinzuka
  DietPi OS for ROCK64 MichaIng 43 99,000 07-22-2026, 01:47 PM
Last Post: MichaIng
  A/V output enable 8lall0 0 1,394 03-24-2026, 04:45 PM
Last Post: 8lall0
  Rock64 v3 Tx/RX and GPIO connections for 3dprinter MinimumJargon 2 2,205 01-28-2026, 04:04 AM
Last Post: alicesphere
  Rock64 - not booting after Armbian update helpmerock 7 7,789 01-24-2026, 04:44 PM
Last Post: ff255
  Xen hypervisor on Rock64 tumbleweed 6 13,799 11-03-2025, 09:25 AM
Last Post: darkfader
  can rock64 4gb ram run entirely on free software? heocb 1 4,099 01-07-2025, 05:47 AM
Last Post: KC9UDX
  Upgrading ancient Rock64 timxjr1300 1 4,297 11-26-2024, 09:47 AM
Last Post: dmitrymyadzelets
  arch rock64 does not boot nemnob 1 5,161 09-20-2024, 11:18 AM
Last Post: AwU2HBg

Forum Jump:


Users browsing this thread: 1 Guest(s)