mciupak / nrf24

nrf24l01 linux device driver
GNU General Public License v3.0
23 stars 13 forks source link

Rasbian Setup #3

Closed killerkalamari closed 6 years ago

killerkalamari commented 6 years ago

I'm not seeing any /dev devices created on a Raspberry Pi 3. Here are my installation steps and system. Any tips?

git clone https://github.com/mciupak/nrf24.git
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential raspberrypi-kernel-headers
sudo reboot
ln -s /usr/src/linux-headers-$(uname -r)/ linux
cd nrf24
make
../linux/scripts/dtc/dtc -@ -I dts -O dtb -o nrf24-spi0.dtbo devicetree/nrf24-spi0-overlay.dts
cp nrf24-spi0.dtbo /boot/overlays
sed -i "s/dtparam=spi=on/#dtparam=spi=on/" /boot/config.txt
echo "dtparam=nrf24-spi0-overlay" >> /boot/config.txt
sudo reboot
sudo insmod nrf24/nrf24.ko

uname -a: Linux wgct 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

dmesg | tail: [ 1574.700708] nrf24: loading out-of-tree module taints kernel.

cat /proc/modules:

nrf24 27901 0 - Live 0x7f032000 (O)
ftdi_sio 32963 0 - Live 0x7f01e000
usbserial 29943 1 ftdi_sio, Live 0x7f00f000
spi_bcm2835 7596 0 - Live 0x7f00a000
i2c_bcm2835 7167 1 - Live 0x7f005000
i2c_dev 6913 2 - Live 0x7f000000
mciupak commented 6 years ago

Hi,

this is wrong: echo "dtparam=nrf24-spi0-overlay" >> /boot/config.txt

You have nrf24-spi0.dtbo so do the following: echo "dtparam=nrf24-spi0" >> /boot/config.txt

And do not comment out dtparam=spi=on. Leave it enabled.

Marcin

killerkalamari commented 6 years ago

Okay uncommented it and changed the dtparam as you indicated. Also moved out /boot/overlays/spi*.dtbo just in case. Same dmesg output (just the kernel taint line). No luck yet!

mciupak commented 6 years ago

Is your Log Level set to debug? What does cat /proc/sys/kernel/printk say?

killerkalamari commented 6 years ago

Not sure on the Log Level.

$ cat /proc/sys/kernel/printk
4   4   1   7

Update: I tried insmod again after running the following, but got no extra output in dmesg (or otherwise): echo 8 | sudo tee /proc/sys/kernel/printk

mciupak commented 6 years ago

Weird... Do you see any spidev in /dev or any nrf* folder in /proc/device-tree/soc/spi@7e204000/ ?

killerkalamari commented 6 years ago

Nope on /dev. Here's proc (grep -i nrf isn't finding anything):

/proc/device-tree/soc/spi@7e204000/:
total 0
-r--r--r-- 1 root root  4 Dec 20 14:00 #address-cells
-r--r--r-- 1 root root  8 Dec 20 14:00 clocks
-r--r--r-- 1 root root 17 Dec 20 14:00 compatible
-r--r--r-- 1 root root 24 Dec 20 14:00 cs-gpios
-r--r--r-- 1 root root  6 Dec 20 14:00 dma-names
-r--r--r-- 1 root root 16 Dec 20 14:00 dmas
-r--r--r-- 1 root root  8 Dec 20 14:00 interrupts
-r--r--r-- 1 root root  4 Dec 20 14:00 name
-r--r--r-- 1 root root  4 Dec 20 14:00 phandle
-r--r--r-- 1 root root  8 Dec 20 14:00 pinctrl-0
-r--r--r-- 1 root root  8 Dec 20 14:00 pinctrl-names
-r--r--r-- 1 root root  8 Dec 20 14:00 reg
-r--r--r-- 1 root root  4 Dec 20 14:00 #size-cells
drwxr-xr-x 2 root root  0 Dec 20 14:00 spidev@0/
drwxr-xr-x 2 root root  0 Dec 20 14:00 spidev@1/
-r--r--r-- 1 root root  5 Dec 20 14:00 status

/proc/device-tree/soc/spi@7e204000/spidev@0:
total 0
-r--r--r-- 1 root root 4 Dec 20 14:00 #address-cells
-r--r--r-- 1 root root 7 Dec 20 14:00 compatible
-r--r--r-- 1 root root 7 Dec 20 14:00 name
-r--r--r-- 1 root root 4 Dec 20 14:00 phandle
-r--r--r-- 1 root root 4 Dec 20 14:00 reg
-r--r--r-- 1 root root 4 Dec 20 14:00 #size-cells
-r--r--r-- 1 root root 4 Dec 20 14:00 spi-max-frequency

/proc/device-tree/soc/spi@7e204000/spidev@1:
total 0
-r--r--r-- 1 root root 4 Dec 20 14:00 #address-cells
-r--r--r-- 1 root root 7 Dec 20 14:00 compatible
-r--r--r-- 1 root root 7 Dec 20 14:00 name
-r--r--r-- 1 root root 4 Dec 20 14:00 phandle
-r--r--r-- 1 root root 4 Dec 20 14:00 reg
-r--r--r-- 1 root root 4 Dec 20 14:00 #size-cells
-r--r--r-- 1 root root 4 Dec 20 14:00 spi-max-frequency
mciupak commented 6 years ago

There is something wrong with Device Tree overlay. It is not loaded. If loaded there should be nrf0@0 folder in /proc/device-tree/soc/spi@7e204000/.

Paste /boot/config.txt please.

Are you sure that dtc compiled dts to dtbo?

I use quite new kernel (Linux pi 4.15.0-rc4-v7+ #4 SMP Wed Dec 20 11:20:28 -00 2017 armv7l GNU/Linux) but don't think it should be a problem...

killerkalamari commented 6 years ago

file /boot/overlays/nrf24-spi0.dtbo:

/boot/overlays/nrf24-spi0.dtbo: Device Tree Blob version 17, size=1487, boot CPU=0, string block size=215, DT structure block size=1216

/boot/config.txt:

# For more options and information see
# http://rpf.io/configtxtreadme
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=off
enable_uart=1
dtparam=i2c1_baudrate=400000
dtparam=nrf24-spi0
mciupak commented 6 years ago

Change dtparam=nrf24-spi0 to dtoverlay=nrf24-spi0 in /boot/config.txt

killerkalamari commented 6 years ago

That did the trick! Thanks a lot!

For posterity:

[   22.022768] nrf24: loading out-of-tree module taints kernel.
[   22.096026] nrf24 nrf0: nrf24_create_pipe: device created: major(244), minor(0)
[   22.187412] nrf24 nrf0: nrf24_create_pipe: device created: major(244), minor(1)
[   22.278623] nrf24 nrf0: nrf24_create_pipe: device created: major(244), minor(2)
[   22.369499] nrf24 nrf0: nrf24_create_pipe: device created: major(244), minor(3)
[   22.460449] nrf24 nrf0: nrf24_create_pipe: device created: major(244), minor(4)
[   22.551145] nrf24 nrf0: nrf24_create_pipe: device created: major(244), minor(5)
[   22.643850] nrf24 nrf0: nrf24_tx_thread: waiting for new messages
mciupak commented 6 years ago

No problem 😉

sergey-suloev commented 6 years ago

@mciupak a little bit off-topic, do you have a proven working arm64 mainline kernel config at hand ? Asking because I saw your message "I use quite new kernel"

mciupak commented 6 years ago

Have not tried this, but apparently for Upstream BCM2837 as far as I know defconfig should be fine. Have you tried this?

sergey-suloev commented 6 years ago

@mciupak I am sure it needs some tweaks.. I tried it, yes.. it might be fine but I see that it builds all possible platforms... There should be a lot useless stuff. One more question: how do you usually prepare rpi rootfs ? Do you use your own scripts or any open-source ?