Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: Brycey92 on April 12, 2018, 01:44:27 AM
-
Hello, all! This is my first post on this board, so please excuse any poor formatting or rookie mistakes.
Anyway, I recently started a project using Tiny Core on a Pi Zero to try to interface with my car's CAN bus.
I've attempted to get this MCP2515+TJA1050 board (https://www.amazon.com/gp/product/B01HXI5LH8/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1) to work by altering the PCB and connecting it to the Pi as discussed here (https://www.raspberrypi.org/forums/viewtopic.php?t=141052).
I've set mounted home and tce directories in my cmdline.txt, since this Pi will not be able to connect to the internet to download extensions in its normal operation, and it will need to read many audio files which I would prefer were not copied to RAM on every boot.
Additionally, I have put these 2 lines at the bottom of my config.txt:
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi-bcm2835-overlay
and I changed
dtparam=i2c=on,spi=on,i2s=on
to dtparam=i2c=off,spi=on,i2s=off
elsewhere in the file to slightly speed up boot times.
To get the can0 interface recognized on spi0.0, I placed the following files from the source archive into /usr/local inside two .tcz extensions which I have load on boot:
/lib/modules/4.9.22-piCore/kernel/drivers/net/can/can-dev.ko
/lib/modules/4.9.22-piCore/kernel/drivers/net/can/spi/mcp251x.ko
/lib/modules/4.9.22-piCore/kernel/net/can/can-raw.ko
/lib/modules/4.9.22-piCore/kernel/net/can/can-gw.ko
/lib/modules/4.9.22-piCore/kernel/net/can/can-bcm.ko
/lib/modules/4.9.22-piCore/kernel/net/can/can.ko
I attempted to use code in a C++ program to listen for messages over can0 using the socketcan broadcast manager, but when that didn't work, I compiled can-utils and ran the following 2 commands:
tce-load -il iproute2
sudo ip link set can0 up type can bitrate 500000
I set up another of these MCP2515 boards with an Arduino Uno to create a testbench CAN bus. I then connected the 2 modules together and placed jumpers on the boards to enable the 120 ohm resistors between CAN high and low on each end of the bus, and put a sketch on the Arduino to send a CAN message every second. When I ran candump on the Pi and scoped each pin of the MCP boards, I discovered that there was normal activity on the Arduino's SPI connection to the MCP board, and the signal was present on both sides of the CAN bus at the boards, but on the Pi's SPI connection, only INT, CS, and VCC were high at 3.3v, while SCK, SI, SO, and of course GND were at 0v. At no point during sending or receiving with my program nor with candump, cangen, and cansend did any of these pins change.
At this point, I'm at a loss as to what to do next to diagnose this or get it working, so any help is appreciated! Thanks for reading!
-
Check config.txt and enable SPI DT overlay if necessary.
-
And you can maybe get something from another thread regarding CAN BUS.
http://forum.tinycorelinux.net/index.php/topic,18858.0.html
-
Check config.txt and enable SPI DT overlay if necessary.
Which SPI DT overlay should I enable, aside from the 2 overlays I already have enabled?
And you can maybe get something from another thread regarding CAN BUS.
http://forum.tinycorelinux.net/index.php/topic,18858.0.html
Thanks for the link, but I actually used that thread to get as far as I am. As there is no Tiny Core 9.x Arm 6 extension in the official repo, I don't know if the files listed in that thread and the others I found are all that would need to go into a CAN extension.
-
By the way, the following is the output of lsmod:
Module Size Used by Not tainted
can_bcm 14631 1
can 30005 1 can_bcm
i2c_dev 6802 0
snd_usb_audio 144481 1
snd_usbmidi_lib 22479 1 snd_usb_audio
snd_rawmidi 23989 1 snd_usbmidi_lib
snd_seq_device 5234 1 snd_rawmidi
snd_hwdep 6479 1 snd_usb_audio
snd_bcm2835 23079 0
snd_pcm 96791 3 snd_usb_audio,snd_bcm2835
mcp251x 10503 0
can_dev 13841 1 mcp251x
snd_timer 22721 1 snd_pcm
snd 69129 9 snd_usb_audio,snd_usbmidi_lib,snd_rawmidi,snd_seq_device,snd_hwdep,snd_bcm2835,snd_pcm,snd_timer
squashfs 33444 25
evdev 11764 0
rfkill 21444 0
bcm2835_gpiomem 3751 0
spi_bcm2835 7468 0
fixed 3029 0
uio_pdrv_genirq 3718 0
uio 10281 1 uio_pdrv_genirq
zram 20761 1
zsmalloc 17097 1 zram