Page 1 of 1

Can Protocol (small issue)

Posted: 2026-01-29 18:13
by Stavros
Hi.
I have the luckfox lyra plus, and currenlty I am trying to work on an data intensive can application.
Going to the official documentation, I learned that in order to enable can I had to include the following snippet

Code: Select all

&can0 {
        assigned-clocks = <&cru CLK_CAN0>;
        assigned-clock-rates = <200000000>;
        pinctrl-names = "default";
        pinctrl-0 = <&rm_io30_can0_tx &rm_io31_can0_rx>;
        status = "okay";

};
in the device tree file kernel-6.1/arch/arm/boot/dts/rk3506g-luckfox-lyra-plus.dts
After rebuilding the kernel and the firmware without any issues and then flashing the board (SPI-NAND buildroot), this had as a result the following:

Code: Select all

root@luckfox:~# dmesg | grep -i can
[    1.502078] CAN device driver interface
[    1.503355] rk3576_canfd ff320000.can: Failed to request rxchan
[    1.503929] rk3576_canfd ff320000.can: CAN info: use_dma = 0, rx_max_data = 18, fifo_depth = 14
[    1.619928] can: controller area network core
[    1.620076] NET: Registered PF_CAN protocol family
[    1.620113] can: raw protocol
[    1.620140] can: broadcast manager protocol
Can was enabled but the rx side of the protocol was now Programmable IO (simply polling style) , this I suspect will limit the throughput.
After some thinking and slowly trying to understand .dts .dtsi notations (and learning that can0 is served by dmac0) I made this attempt:

Code: Select all

&can0 {
    assigned-clocks = <&cru CLK_CAN0>;
    assigned-clock-rates = <200000000>;
    pinctrl-names = "default";
    pinctrl-0 = <&rm_io30_can0_tx &rm_io31_can0_rx>;
    dmas = <&dmac0 20 1 0 0 0>; # channel request , direction[device --> mem] 
    dma-names = "rx";
    status = "okay";
};
But without any luck.
Has anybody faced this ?

Re: Can Protocol (small issue)

Posted: 2026-01-30 2:30
by Crocodile
Hello, "rk3576_canfd ff320000.can: Failed to request rxchan" merely indicates that DMA is not being used for receiving. I'm not quite clear on what "Programmable IO (simply polling style)" refers to? RMIO mounts the pins to the CAN controller for receiving using interrupts rather than polling. Maybe this Programmable IO does not refer to RMIO.
The correct configuration of DMA in the device tree should be

Code: Select all

dmas = <&dmac0 0  0xff2880a8 0x000c0000 0x0 0x0>;
dma-names = "rx";
For details, please refer to https://opensource.rock-chips.com/image ... 250811.pdf. Finally, enter the system to view the logs.

Code: Select all

root@luckfox:~# dmesg | grep can
[    1.512608] rk3576_canfd ff320000.can: CAN info: use_dma = 1, rx_max_data = 18, fifo_depth = 14
[    1.636404] can: Controller Area Network core
[    1.636638] can: Raw protocol
[    1.636668] can: Broadcast Manager protocol
[    1.636701] can: Netlink gateway - max_hops=1
[    2.387587] ubi0: Scanning is finished 

Re: Can Protocol (small issue)

Posted: 2026-02-01 1:57
by Stavros
Thank you for your reply.
After changing the .dts file the way you specified everything worked nicely!

Code: Select all

root@luckfox:~# dmesg | grep -i can
[    1.500689] CAN device driver interface
[    1.502588] rk3576_canfd ff320000.can: CAN info: use_dma = 1, rx_max_data = 18, fifo_depth = 14
[    1.619824] can: controller area network core
[    1.619986] NET: Registered PF_CAN protocol family
[    1.620024] can: raw protocol
[    1.620050] can: broadcast manager protocol
[    1.620078] can: netlink gateway - max_hops=1
Thank you!