Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

SPI inside Docker Container #24

Closed
ThomasSchemmer opened this issue Jun 1, 2016 · 4 comments
Closed

SPI inside Docker Container #24

ThomasSchemmer opened this issue Jun 1, 2016 · 4 comments

Comments

@ThomasSchemmer
Copy link

ThomasSchemmer commented Jun 1, 2016

Hello,
first of , thanks for making my life easier. Now I'm afraid I'll have to make yours a tad harder. :(
I'm currently trying to enable SPI on my Raspberry Pi 2 B inside a Docker container.(edit: using HypriotOS 0.8)
In the end, I want to be able to communicate with a nrf24l01 wireless module via the RF24 lib.

For the image creation im following the tutorial here and adapted the run command to the following
docker run --cap-add ALL -v /lib/modules:/lib/modules -v /sys:/sys --device /dev/ttyAMA0:/dev/ttyAMA0 --device /dev/mem:/dev/mem --privileged -ti tschemmer/sensor bash
as Jerome states that it should enable modprobe within a container. I even added the --cap-add ALL for good measure ;)

The container starts up fine, sudo modprobe spi-bcm2835 works without error and lsmod returns the appropriate values:

root@24a1bfc0fab5:~/docker/test# lsmod
Module                  Size  Used by
...
uio                     8480  1 uio_pdrv_genirq
i2c_dev                 6372  0
spi_bcm2835             7412  0
snd_bcm2835            20243  0
snd_pcm                76775  1 snd_bcm2835
...

But when I checked the /dev directory, the spidev0.0 isnt there. So i tried to do it in the OS directly, outside of any container, according to Issue 13. Even added spi-bcm2835 to /etc/modules and restarted.
The spi is still not in the /dev directory, so trying the loopback test does not work for me.
Now my question is: what do I have to do to get that /dev/spidev0.0 up and running? I feel like im missing something :/ On raspbian i would be able to use raspi-config, is there somehting similar here?
Thanks for your help
Thomas

@DieterReuter
Copy link
Collaborator

To enable SPI, you also need to add “dtparam=spi=on” to your /boot/config.txt and reboot. I've successfully used SPI within a container on the HypriotOS 0.7 release (but not tested it on 0.8 yet).

@ThomasSchemmer
Copy link
Author

Thank you, that worked perfectly 👍 might i ask where you found the reference?

@DieterReuter
Copy link
Collaborator

DieterReuter commented Jun 1, 2016

Just googled for raspberrypi spi enable and the first hit http://raspi.tv/how-to-enable-spi-on-the-raspberry-pi had all the details. Then double-checked what raspi-config does internally to confirm the solution.

@ThomasSchemmer
Copy link
Author

Darn, i found the link before, just didnt completely read it. Thx again, closing the issue now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants