Power & Source of Big Ideas

Solving the problem with boards for Sunxi H3 and MCP2515

Moderators: chensy, FATechsupport

Starting from kernel version 5.5 to 5.11.2, when connecting the CAN module MCP2515 and when entering commands in the terminal
ip link set can0 up type can bitrate 500000
ifconfig can0 up

terminal freezes

The reason for this is the call to this subroutine
ret = mcp251x_hw_wake (spi);
in this driver code snippet

INIT_WORK(&priv->tx_work, mcp251x_tx_work_handler);
INIT_WORK(&priv->restart_work, mcp251x_restart_work_handler);

ret = mcp251x_hw_wake(spi);

if (ret)
goto out_free_wq;
ret = mcp251x_setup(net, spi);


return to call
ret = mcp251x_hw_reset (spi);
fixes this problem Linux 5.5 - 5.11.2 for sunxi H3 (example Nano Pi NEO,modul MCP2515 8mhz)

The assembled image with linux kernel 5.11.2 for NanoPI NEO with support for the MCP2515 CAN module is located here, as well as the driver file itself and the modified device tree, and settings for Buildroot and Linux there))

https://github.com/AlekseyMamontov/Linu ... l-Alsa-CAN
It seems that in my experiments I got lost in the wrong place)
I was led astray mainly by this information.

https://github.com/armbian/sunxi-DT-ove ... cp251x.dts



With the default driver and with the correct parameters, everything works and the terminal does not freeze, here are the correct DT settings as an example for Nano PI NEO



clocks {

can0_osc_fixed: can0_osc_fixed {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <8000000>;
};
}



pio: pinctrl@1c20800 {
/* compatible is in per SoC .dtsi file */
reg = <0x01c20800 0x400>;
interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&rtc 0>;
clock-names = "apb", "hosc", "losc";
gpio-controller;
#gpio-cells = <3>;
interrupt-controller;
#interrupt-cells = <3>;

.....

can0_pin_irq: can0_pin_irq {
pins = "PG8";
function = "irq";
bias-pull-up;
};

}



spi0: spi@1c68000 {
compatible = "allwinner,sun8i-h3-spi";
reg = <0x01c68000 0x1000>;
interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>;
clock-names = "ahb", "mod";
dmas = <&dma 23>, <&dma 23>;
dma-names = "rx", "tx";
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
resets = <&ccu RST_BUS_SPI0>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;



can0: can@0 {
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&can0_pin_irq>;
interrupt-parent = <&pio>;
interrupts = <6 8 IRQ_TYPE_LEVEL_LOW>; /* This is the correct meaning */
clocks = <&can0_osc_fixed>;
spi-max-frequency = <10000000>;
gpio-controller;
#gpio-cells = <2>;
status = "okay";
};

};



If someone was confused by my search for a solution to the problem, I am sorry.

If you set IRQ_TYPE_EDGE_FALLING, the terminal will hang.
This parameter leads to the terminal freezing when calling functions ret = mcp251x_hw_wake(spi);
, and in it functions disable_irq(spi->irq) to disable interrupts

static int mcp251x_hw_wake(struct spi_device *spi)
{
u8 value;
int ret;
/* Force wakeup interrupt to wake device, but don't execute IST */
disable_irq(spi->irq);

Who is online

In total there are 20 users online :: 0 registered, 0 hidden and 20 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 20 guests