/dev/spidev0,0 on the Rock64 - Does anyone know how to enable it?
How can a user enable /dev/spidev0,0 on Rock64?
I've seen this very topic discussed and most of the threads / replies are vague, outdated or not working.

I would appreciate a "put this into this file" or "run this command" pointer. 
Or an article I have not found(yet) - see the ones that didn't help (me) below.

Current os (uname -a) is Linux rock64 4.4.126-rockchip-ayufan-239 aarch64 GNU/Linux .

Question aims at making python demo code of Waveshare ePaper (like https://www.waveshare.com/wiki/E-Paper_Driver_HAT) work with Rock64 - no, not in hat mode, in cable mode. 

Already took different python lib (with RPi.GPIO-PineA64) into account as well as different Pinout.

Current Error is:
File "/root/code-red/python/epdif.py", line 43, in 
SPI = spidev.SpiDev(0, 0)
FileNotFoundError: [Errno 2] No such file or directory

This should go away with spidev0,0 present in /dev and then ... I'll fix the next problem. 

I think it might be just a command similar to "enable_dtoverlay i2c0 i2c@ff150000 okay"  but I have not figured out what the magic words are. Most people point to a few who might know, but ... no dice. 

Similar unanswered Questions are:
Not understood to the point that I can act on it:

Similar Questions with an answer that does not work (anymore) or are beyond my skills are:
Chat on Irc: Similar Questions are on GitHub and StackOverflow. Once one of them fruits in an answer, I'll mirror it here.

Thank you for any help in advance.

  • If you know a paid service I can ask, I would pay the help out of my own pocket and publish the steps here, since our project  LiquidInvestigations is free and open and I'd rather work on testing elastic search, UI things, ... (things that I'm better at) than hanging in the air because of a seemingly trivial (but only known to a few) piece of information. Narf. 
  • This is to make https://liquidinvestigations.github.io/ (which uses the rock64) more usable and safer by having a (cheap) display to show codes for the air-gapped rock64 even when it is turned off (hence the use of ePaper)
  • I can't switch the Linux Distro/Flavour right now, but if /dev/spidev0,0  only available by changing, then its better than scrapping the use of ePaper displays. 
  • And finally: If someone will tell me "it does not work", then I'll move in the next iteration to another board which can work with existing code. 

    [Edit: Removed some snarky remarks.]
It seems that there is no solution except using another distro and experimenting, which will surely create other problems for us around liquid investigations

And even then, I have no idea how it will work. Dammit, is it really so hard to get an 08/15 eInk display run on advanced arm64s except raspberry?

So if you come here with the same question about spidev on rock64 as I did, there is no solution until someone tells you specifically otherwise for rock64.
Don't search further, because I've asked here, on github, reddit, stack overflow, irc, ...  and after more than a month no helpful answers, just redirects and complaints about wrong phrasing for the question...

Yes, I know everyone works her for free and for their own purpose. So do I: Spent half a year lobbying to give this platform a chance for a project supposed to help investigative journalists around the globe which otherwise would just run on intel as everything else. 

Occam's razor tells me this is a chicken and egg problem: The hardware seems to be missing use cases which causes a lack of knowledge how to use the hardware. If you want to just run eInk displays or anything ales, go the way of the raspberry pi.So I have to wait till raspberry pi finally gets to 2 or 4 gb and usb 3 since that was that is the critical demand for li.
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).
    # cat >spi1.dts <<EOF

    / {
            compatible = "pine64,rock64";

            fragment@0 {
                    target-path = "/spi@ff190000";
                    __overlay__ {
                            spidev@1 {
    # 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*
  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.
    # 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: 348)
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 !
Smile  Kinda offline & at my parents this weekend, so I can't test. But I sent 2 beers via my mums paypal. She also says "Enjoy!".
I'm having trouble recreating your steps. 

# uname -a 
Linux rock64 4.4.132-1075-rockchip-ayufan-ga83beded8524 #1 SMP Thu Jul 26 08:22:22 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux

# cat >spi1.dts <<EOF
[did that, worked]

# dtc spi1.dts -o spi1.dtbo
spi1.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
spi1.dtbo: Warning (pci_device_reg): Failed prerequisite 'reg_format'
spi1.dtbo: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
spi1.dtbo: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
spi1.dtbo: Warning (avoid_default_addr_size): Relying on default #address-cells value for /fragment@0/__overlay__/spidev@1
spi1.dtbo: Warning (avoid_default_addr_size): Relying on default #size-cells value for /fragment@0/__overlay__/spidev@1
# mkdir /sys/kernel/config/device-tree/overlays/spi1
[okay, did that with sudo, wrong?]
# cat spi1.dtbo > /sys/kernel/config/device-tree/overlays/spi1/dtbo
/sys/kernel/config/device-tree/overlays/spi1/dtbo: Permission denied
# ls /dev/spidev*
not found

so ...
  • it does sadly not show /dev/spidev0,0 nor other 
  • If it would work, what would the difference to spidev0,0 vs spidev32766.1 be?
  • If you read my issue before, what else would I need to modify for the eInk display?
PS: I'm willing to send you/someone one (smaller) eInk display with a driver-board if you need it to understand/make it work. You can keep it then.
Weird. I repeated steps again (using the same kernel 4.4.132-1075-rockchip-ayufan-ga83beded8524) with success.
  • Do all under root ("sudo bash") (Permission denied!). '#' is root prompt, '$' is user prompt.
  • "dtc" warning are ok.
  • Yes, you must change device from /dev/spidev0,0 to spidev32766.1 in application. The numbering is platform dependent.

Every eink module have own demo. Let's choose 1.54" and demo.
Connect SPI device pinheader Pi-2 Bus:
  • VCC = pin 17 (3.3V)
  • GND = pin 20 (GND)
  • DIN <- pin 19 (GPIO3_A1 (SPI_TXD_M2))
  • CLK <- pin 24 (GPIO3_A0 (SPI_CLK_M2))
  • CS <- pin 26 GPIO2_B4 (SPI_CSN1_M0)
  • D/C <- pin 15 GPIO3_A4
  • RES <- pin 16 GPIO3_A5
  • BUSY -> pin 18 GPIO3_A6

And demo the demo (under root) but untested:
# ls /dev/spidev*

# ### retrieve original
# wget https://www.waveshare.com/w/upload/7/73/1.54inch_e-Paper_Module_code.7z
# apt install p7zip
# 7zr x 1.54inch_e-Paper_Module_code.7z raspberrypi/python/*
# ### use attached copy (modified but unable to check it)
# tar xf epaper_demo.tar
# ls *.py *.bmp
epd1in54.py  epdif.py  main.py monocolor.bmp
# ### compare changes
# for i in raspberrypi/python/*.py; do diff -u $i .; done

# ### install required libraries and fonts
# git clone https://github.com/Leapo/Rock64-R64.GPIO.git
# ln -s Rock64-R64.GPIO/R64 .
# apt install fonts-freefont-ttf
# apt install python-pil
# apt install python-pip python-setuptools python-dev
# pip install spidev

# ### try demo
# python main.py

Attached Files
.tar   epaper_demo.tar (Size: 20 KB / Downloads: 319)
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 !
It worked (getting spidev ...) ... but how ... well:
I noticed there are two bionic versions bionic-minimal-rock64-0.7.9-1067-arm64.img and bionic-minimal-rock64-0.7.9-1067-armhf.img. 

I just used the other one and got an even stranger error for using dtc.
So I looked up the solution for that (didn't want to flash the sd again ..., curious ...): https://github.com/beagleboard/bb.org-ov...overlay.sh
Ran the script. Worked.
Ran your commands. Worked.
And now ...
# udevadm info --query=all --name=spidev32766.1 
P: /devices/platform/ff190000.spi/spi_master/spi32766/spi32766.1/spidev/spidev32766.1
N: spidev32766.1
E: DEVNAME=/dev/spidev32766.1
E: DEVPATH=/devices/platform/ff190000.spi/spi_master/spi32766/spi32766.1/spidev/spidev32766.1
E: MAJOR=153

YESSS! Thank you. Thank you. Thank you.

Next step: Getting that display to run. Will write detailed setup/how-to when done.
Got that fixed by just redoing everything and then ... it just worked up till here. Now ...

Now this happens:
# pip install spidev

Collecting spidev
Downloading https://files.pythonhosted.org/packages/...3.2.tar.gz
Building wheels for collected packages: spidev
  Running setup.py bdist_wheel for spidev ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-61F19v/spidev/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmptbr3Elpip-wheel- --python-tag cp27:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help
  error: invalid command 'bdist_wheel'
  Failed building wheel for spidev
  Running setup.py clean for spidev
Failed to build spidev
Installing collected packages: spidev
  Running setup.py install for spidev ... done
Successfully installed spidev-3.2 


When I start main.py, it doesn't complain, but nothing shows on the display ...
(DM me, my offer still stands to send you an gratis ePaper Display + Beer)
(08-22-2018, 12:22 PM)Kappuchino Wrote: # pip install spidev
  error: invalid command 'bdist_wheel'
When I start main.py, it doesn't complain, but nothing shows on the display ...
First must be ensure that "spidev" is working.
# pip uninstall spidev
# apt install python-wheel
# pip install spidev
What version of "eink display" are you using ?
I will try to check/modify specific version of demo code.
(I am running image "bionic-lxde-rock64-0.7.9-1067-arm64.img")
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 !
(Sorry for the wait, took a break from computing and else)

So now everything is smooth until I start the modified script then ... nothing. 

Here is the "proof of wireing" - this time with a 4.2'' display, but others didn't work as well. 

Huh When I force-quit with ctrl-c, this is the output:

^C You must setup() the GPIO channel (BOARD 26) as an output first
^C You must setup() the GPIO channel (BOARD 15) as an output first
 ^C Traceback (most recent call last):
  File "main.py", line 84, in <module>
  File "main.py", line 80, in main
    epd.set_frame_memory(time_image.rotate(90), 80, 80)
  File "/home/rock64/spidev/epd1in54.py", line 205, in set_frame_memory
  File "/home/rock64/spidev/epd1in54.py", line 97, in send_data
    self.digital_write(self.dc_pin, GPIO.HIGH)
  File "/home/rock64/spidev/epd1in54.py", line 82, in digital_write
    epdif.epd_digital_write(pin, value)
  File "/home/rock64/spidev/epdif.py", line 41, in epd_digital_write
    GPIO.output(pin, value)
  File "/home/rock64/spidev/R64/_GPIO.py", line 184, in output
    for index in range(len(channel)):

So ... I will write down line by line what I did, again (see that on github today) but no dice so far.

[Image: preview]

Possibly Related Threads…
Thread Author Replies Views Last Post
  RXDP from Win10 to Armbian on Rock64 Transportsicherung 0 32 05-27-2023, 06:11 AM
Last Post: Transportsicherung
  slarm64 (unofficial slackware) Rock64 RK3328 (aarch64) mara 130 152,473 03-06-2023, 12:57 PM
Last Post: mara
  how to use spidev0.1? jclab-joseph 2 1,445 02-06-2023, 04:43 PM
Last Post: monte
  DietPi OS for ROCK64 MichaIng 41 23,286 12-07-2022, 08:22 PM
Last Post: luminosity7
  Using multiple UART's on Rock64. ramprasad 0 492 08-29-2022, 01:22 PM
Last Post: ramprasad
  Using multiple UART's on Rock64. sachineswar 0 486 08-29-2022, 12:31 PM
Last Post: sachineswar
  Rock64 v2 - did not work song / audio sqw200zu 1 708 07-29-2022, 12:08 PM
Last Post: sqw200zu
  Rock64 Rev3 doesn't boot and leds blinking fast dishins 6 6,132 06-30-2022, 06:28 PM
Last Post: rookie_267
  my rock64 can't boot rookie_267 0 651 06-27-2022, 06:52 PM
Last Post: rookie_267
  Armbian for Rock64 pineadmin 57 58,831 04-01-2022, 03:16 PM
Last Post: TRS-80

Forum Jump:

Users browsing this thread: 1 Guest(s)