[SOLVED] MCP2515 CAN BUS Ubuntu 18.04 intel CPU

BenSpex
BenSpex New Member Posts: 8
edited July 2019 in UP Squared Linux

Hi,

I have purchased the wave share can hat https://www.waveshare.com/w/upload/2/29/RS485-CAN-HAT-user-manuakl-en.pdf
It works well on my Raspberry PI, but I really need to get it working on the Up Squared und Ubuntu as well.

Steps I have taken:
Enable SPI this worked and I can control an E-Paper display through SPI
I took the kernel code from @nukular thanks for this.
You can find the kernel here https://forum.up-community.org/discussion/96/canbus-hat-support
And tried it to get it working.
I tried busnum 0, 1 and 2. Only with bus number 2 the kernel loads. Otherwise I get no such device.
Interrupt is on PIN 22 or 402 (Linux) I even tried every available pin, same result as below
Tried different settings on the SPI max Hz and went really low, to ensure that this was not the problem either.

The kernel module loads but gives the following output no matter what I try (except for changing the bus number, then it does not load at all):
running dmesg | grep mcp give me
> mcp2515_init: init mcp2515_init: irq for pin 402 is 130 mcp251x spi2.0: Cannot initialize MCP2515. Wrong wiring? mcp251x spi2.0: Probe failed, err=19 mcp2515_init: device created!

Does any one has any idea on where to look?

Thanks

Comments

  • BenSpex
    BenSpex New Member Posts: 8

    So if anyone else hast the problem I have found the solution:
    From @WereCatf :smile:
    https://forum.up-community.org/discussion/2415/cant-get-fbtft-device-working-ubilinux

    That's because you have used the spi-enable.zip from the Wiki -- it reserves those chip-select pins and that's why they can't be used by device-drivers. You have to delete the file /lib/firmware/acpi-upgrades/spidev1.0.aml if you want to use cs0, or /lib/firmware/acpi-upgrades/spidev1.1.aml if you want to use cs1, and run:
    sudo update-initramfs -u -k all
    This updates the initramfs, removing the claim on the SPI-bus, so you have to reboot afterwards.

  • ccalde
    ccalde New Member Posts: 348 ✭✭✭

    Hi @BenSpex ,

    Thank you very much for your contribution!
    The solution there looks fine!

  • PimpMyPizza
    PimpMyPizza New Member Posts: 1

    Hi everyone!

    Thanks @BenSpex for the infos. Unfortunately, this solution does not work with my UpBoard and MCP2515. I have a custom Hat with two CAN plugs that has following infos:

    For CAN 0:

    • Interrupt on Pin 22 (Linux GPIO 25 / UP GPIO 20)
    • CS 0 (Linux GPIO 8 / UP GPIO 21)

    For CAN 1

    • Interrupt on Pin 12 (Linux GPIO 18 / UP GPIO 17)
    • CS 1 (Linux GPIO 7 / UP GPIO 22)

    The Pins are active low
    Like BenSpex, I can only get a master if I use busum 2 (There is only one Bus and busnum 0 and busnum 1 does not work - do someone knows why busnum=2 and not 0 or 1?)

    When I use chip_select=0 and pin gpio_int=25 (or 22, or 20), I get:

    [ 774.714025] mcp2515_can_0: loading out-of-tree module taints kernel.
    [ 774.714203] mcp2515_can_0: module verification failed: signature and/or required key missing - tainting kernel
    [ 774.716826] mcp2515_init: init
    [ 774.716998] mcp2515_init: irq for pin 25 is 157
    [ 774.717069] pxa2xx-spi 8086228E:01: chipselect 0 already in use
    [ 774.717374] mcp2515_init: FAILED to create slave.

    When I use chip_select=1 and pin gpio_int=18 (or 12, or 17), I get:

    [ 885.431777] mcp2515_init: init
    [ 885.433589] mcp2515_init: irq for pin 18 is 158
    [ 885.433893] mcp2515_init: device created!
    [ 885.475287] CAN device driver interface
    [ 885.499562] mcp251x spi2.1: Cannot initialize MCP2515. Wrong wiring?
    [ 885.499767] mcp251x spi2.1: Probe failed, err=19

    I deleted /lib/firmware/acpi-upgrades/spidev1.0.aml and /lib/firmware/acpi-upgrades/spidev1.1.aml , runned sudo update-initramfs -u -k all and sudo reboot now, but nothing changed :( I tryied to dive in the kernel code but I'm not sure to understand everything (I'm new to this whole kernel thing). Does anyone know where the errors could come from or how I could proceed to solve this problem?

  • ccalde
    ccalde New Member Posts: 348 ✭✭✭

    Hi @PimpMyPizza ,

    That discussion was closed and solved for UPSquared boards in Linux distros.

    You must open a new discussion or search into the UP board sections for Linux:
    https://forum.up-community.org/categories/upb-lin-40pins

Privacy Policy