This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TCAN4550: TCAN4550

Part Number: TCAN4550

Tool/software:

Hi,

We are using TCAN4450 module is integrated in IMX8DXL processor. The TCAN module is successfully initialized but unable to send the data(TX) and RX is happenening is correctly.
When we are trying to send the message (TX) from the processor, observed TCAN panic.

Below is the dts configuration.

&lpspi3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpspi3>;
fsl,spi-num-chipselects = <1>;
spi-max-frequency = <6000000>;
cs-gpios = <&lsio_gpio0 16 GPIO_ACTIVE_HIGH>;
status = "okay";


tcan4x5x1: tcan4x5x@0 {
compatible = "ti,tcan4x5x";
reg = <0>;
pinctrl-names = "default";
#address-cells = <1>;
#size-cells = <1>;
spi-max-frequency = <4000000>;
bosch,mram-cfg = <0x0 3 2 28 10 0 20 12>; 
clocks = <&hclk>, <&cclk>;
clock-names = "hclk", "cclk";
interrupt-parent = <&lsio_gpio3>;
interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
data-ready-gpios = <&lsio_gpio3 18 GPIO_ACTIVE_HIGH>;
reset-gpios = <&exp2 11 GPIO_ACTIVE_HIGH>;
iw-tcan-prop;
wakeup-source;
status = "okay";

};
};

And below is the PANIC when trying to send the data

root@imx8dxl-iwg46s:~# insmod /run/media/mmcblk0p1/tcan4x5x.ko
[ 25.051965] inside probe-----------
[ 25.409155] tcan4x5x spi3.0: m_can device registered (irq=215, version=32)
[ 25.419456] tcan4x5x spi3.0 can3: TCAN4X5X successfully initialized.
root@imx8dxl-iwg46s:~#
root@imx8dxl-iwg46s:~# ip link set can3 up type can bitr[ 33.851928] can-3v3: disabling
[ 33.855019] vref_1v8: disabling
[ 33.858219] usb_otg1_vbus: disabling
ate 250000
[ 36.234793] IPv6: ADDRCONF(NETDEV_CHANGE): can3: link becomes ready
root@imx8dxl-iwg46s:~# cansend can3 123#aabbccddee
[ 42.931517] begining-----
[ 42.934202] handler begining---------------------
[ 42.938970] 11th bit identifier
[ 42.938977] else part of version----------------
[ 42.946910] BUG: scheduling while atomic: cansend/447/0x00000203
[ 42.952990] Modules linked in: tcan4x5x
[ 42.956893] CPU: 1 PID: 447 Comm: cansend Not tainted 5.15.52+gf266012f09d6 #129
[ 42.964318] Hardware name: iW-RainboW-G46M-i.MX8DXL OSM (DT)
[ 42.969983] Call trace:
[ 42.972429] dump_backtrace+0x0/0x1a0
[ 42.976116] show_stack+0x1c/0x70
[ 42.979451] dump_stack_lvl+0x68/0x84
[ 42.983124] dump_stack+0x1c/0x38
[ 42.986454] __schedule_bug+0x60/0x80
[ 42.990126] __schedule+0x658/0x710
[ 42.993627] schedule+0x74/0x110
[ 42.996869] schedule_timeout+0x80/0xf0
[ 43.000716] wait_for_completion_timeout+0x80/0x10c
[ 43.005607] fsl_lpspi_transfer_one+0x4c8/0x6e0
[ 43.010153] spi_transfer_one_message+0x174/0x1d0
[ 43.014868] __spi_pump_messages.constprop.0+0x264/0x50c
[ 43.020195] __spi_sync+0x18c/0x1c0
[ 43.023694] spi_write_then_read+0xf8/0x1e0
[ 43.027890] tcan4x5x_regmap_read+0x3c/0x64 [tcan4x5x]
[ 43.033051] _regmap_raw_read+0xd8/0x17c
[ 43.036986] _regmap_bus_read+0x48/0x80
[ 43.040835] _regmap_read+0x64/0xf0
[ 43.044338] regmap_read+0x50/0x80
[ 43.047752] tcan4x5x_read_reg+0x34/0x60 [tcan4x5x]
[ 43.052652] m_can_tx_handler+0x298/0x89c
[ 43.056672] m_can_start_xmit+0xac/0x14c
[ 43.060610] dev_hard_start_xmit+0xd8/0x160
[ 43.064803] sch_direct_xmit+0xe8/0x36c
[ 43.068652] __dev_queue_xmit+0x524/0xb6c
[ 43.072677] dev_queue_xmit+0x18/0x24
[ 43.076351] can_send+0xc0/0x260
[ 43.079592] raw_sendmsg+0x140/0x30c
[ 43.083180] sock_write_iter+0xa4/0x110
[ 43.087028] new_sync_write+0x174/0x184
[ 43.090877] vfs_write+0x230/0x29c
[ 43.094291] ksys_write+0xdc/0xf4
[ 43.097618] __arm64_sys_write+0x20/0x2c
[ 43.101554] invoke_syscall+0x48/0x114
[ 43.105313] el0_svc_common.constprop.0+0xd4/0xfc
[ 43.110033] do_el0_svc+0x2c/0x94
[ 43.113361] el0_svc+0x28/0x80
[ 43.116427] el0t_64_sync_handler+0xa8/0x130
[ 43.120707] el0t_64_sync+0x1a0/0x1a4
[ 43.124997] putidx 0000 0000 0000 0000 0000 0000 0000 0000
[ 43.132847] M_CAN_TXFQS0000 0000 0000 0000 0000 0000 0000 1100
[ 43.139491] M_CAN_FIFO_ID,------------0011 0010 0001 0101 0000 0011 0010 0000
[ 43.147313] After---- M_CAN_FIFO_ID,------------0011 0010 0001 0101 0000 0011 0010 0000
[ 43.155643] before fifo write----------------------------
[ 43.161333] after fifo write-----------------------------
[ 43.166784] inside for loop fifo write-------------------------
[ 43.172771] inside for loop fifo write-------------------------
[ 43.178959] beg of delay-------------------------------
[ 43.184270] end of delay--------------------------
[ 43.189777] not full------------
[ 43.193134] ------------[ cut here ]------------
[ 43.193139] WARNING: CPU: 0 PID: 447 at kernel/softirq.c:362 __local_bh_enable_ip+0xac/0xbc
[ 43.193164] Modules linked in:
[ 43.193168] tcan4x5x
[ 43.209194]
[ 43.209202] CPU: 0 PID: 447 Comm: cansend Tainted: G W 5.15.52+gf266012f09d6 #129
[ 43.209213] Hardware name: iW-RainboW-G46M-i.MX8DXL OSM (DT)
[ 43.209218] pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 43.209227] pc : __local_bh_enable_ip+0xac/0xbc
[ 43.209240] lr : __dev_queue_xmit+0x424/0xb6c
[ 43.209250] sp : ffff80000af5bb20
[ 43.209253] x29: ffff80000af5bb20 x28: ffff000005f38000 x27: 0000000000000000
[ 43.209268] x26: ffff000005c59028 x25: ffff000005b91000 x24: 0000000000000010
[ 43.209283] x23: ffff000005b91000 x22: ffff000005e99e00 x21: ffff000005b90400
[ 43.209300] x20: 0000000000000000 x19: ffff000005c59000 x18: 0000000000000003
[ 43.209314] x17: 0000000000001aeb x16: 0000000000000113 x15: 000000b4caf04ccf
[ 43.209329] x14: 0000000000000245 x13: 0000000000000000 x12: 0000000000000000
[ 43.209343] x11: 0000000000000002 x10: 0000000000000990 x9 : ffff80000af5b7a0
[ 43.209359] x8 : ffff000005f389f0 x7 : ffff000005b90540 x6 : ffff000005b90780
[ 43.209378] x5 : 000000000000000a x4 : 000000000000000a x3 : ffff000005b904d8
[ 43.209391] x2 : 0000000000000000 x1 : 0000000000000200 x0 : 00000000fffffffe
[ 43.209409] Call trace:
[ 43.209414] __local_bh_enable_ip+0xac/0xbc
[ 43.209425] __dev_queue_xmit+0x424/0xb6c
[ 43.209435] dev_queue_xmit+0x18/0x24
[ 43.209445] can_send+0xc0/0x260
[ 43.209456] raw_sendmsg+0x140/0x30c
[ 43.209465] sock_write_iter+0xa4/0x110
[ 43.209480] new_sync_write+0x174/0x184
[ 43.209494] vfs_write+0x230/0x29c
[ 43.209505] ksys_write+0xdc/0xf4
[ 43.209518] __arm64_sys_write+0x20/0x2c
[ 43.209529] invoke_syscall+0x48/0x114
[ 43.209540] el0_svc_common.constprop.0+0xd4/0xfc
[ 43.209554] do_el0_svc+0x2c/0x94
[ 43.209567] el0_svc+0x28/0x80
[ 43.209578] el0t_64_sync_handler+0xa8/0x130
[ 43.209586] el0t_64_sync+0x1a0/0x1a4
[ 43.209595] ---[ end trace 1101eba41d86a994 ]---
[ 43.209712] Unable to handle kernel paging request at virtual address 0000ffff84049df0
[ 43.209726] Mem abort info:
[ 43.209728] ESR = 0x82000007
[ 43.209731] EC = 0x20: IABT (lower EL), IL = 32 bits
[ 43.209737] SET = 0, FnV = 0
[ 43.209741] EA = 0, S1PTW = 0
[ 43.209744] FSC = 0x07: level 3 translation fault
[ 43.209749] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000094a20000
[ 43.209755] [0000ffff84049df0] pgd=0800000085ee3003, p4d=0800000085ee3003, pud=0800000085c1d003, pmd=0800000085c25003, pte=0000000000000000
[ 43.209776] Internal error: Oops: 82000007 [#1] PREEMPT SMP
[ 43.209782] Modules linked in: tcan4x5x
[ 43.209790] CPU: 0 PID: 447 Comm: cansend Tainted: G W 5.15.52+gf266012f09d6 #129
[ 43.209799] Hardware name: iW-RainboW-G46M-i.MX8DXL OSM (DT)
[ 43.209803] pstate: 20000000 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 43.209812] pc : 0000ffff84049df0
[ 43.209815] lr : 0000ffff83fd06d0
[ 43.209817] sp : 0000ffffd6ba8250
[ 43.209820] x29: 0000ffffd6ba8250 x28: 0000ffff8417c350 x27: 0000aaaad3e13b88
[ 43.209834] x26: 0000ffffd6ba82d0 x25: 0000000000000000 x24: 0000ffff8417aaf8
[ 43.209850] x23: 0000ffff8412c000 x22: 0000000000000004 x21: 0000ffff8412c748
[ 43.209864] x20: 0000aaaad3e14008 x19: 0000ffff8412c728 x18: fffffffffffff000
[ 43.209881] x17: 0000000000000000 x16: 0000000000000000 x15: 0000ffff84175da0
[ 43.209894] x14: 0000ffff8417c000 x13: 0000ffff8417bb60 x12: 0000ffff841740b0
[ 43.209909] x11: 0000ffffd6ba82c0 x10: 0000210000000000 x9 : 0000ffffd6ba82bf
[ 43.209924] x8 : 0000000000000020 x7 : 0000ffff8417c930 x6 : 0000ffff8417c350
[ 43.209939] x5 : 000000000000017f x4 : 0000ffff8417bab0 x3 : 0000000000000000
[ 43.209953] x2 : 0000ffff8412cb60 x1 : 0000000000000001 x0 : 0000aaaad3e14008
[ 43.546303] ---[ end trace 1101eba41d86a995 ]---
[ 43.546310] Kernel panic - not syncing: Oops: Fatal exception in interrupt
[ 43.546316] SMP: stopping secondary CPUs
[ 43.546324] Kernel Offset: disabled
[ 43.546327] CPU features: 0x00000001,20000846
[ 43.546333] Memory Limit: none
[ 43.572634] ---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]---

  • Hello Tanushree,

    If I understand you correctly, the TCAN4550 is getting initialized correctly and can receive CAN messages, but has an issue when trying to transmit a message.  Is that correct?

    I'm not sure about what "Kernel panic" is and my expertise is with the TCAN4550 device and not with Linux so I can help you with register configuration and hardware related questions.  

    However, my first thoughts are that you may have a memory allocation in the TCAN4550's MRAM that could be causing issues.  The TCAN4550 only has 2Kb of MRAM that you need to configure for your application.  All of the TX and RX buffers, SID and XID filters, and event FIFO messages must fit within the 2Kb limit. I don't know how many bytes of data you are configuring for your TX and RX buffers which will determine how much memory is needed for those elements.  But just based on the number of elements in your configuration, you are almost certainly exceeding the 2Kb limit. 

    bosch,mram-cfg = <0x0 3 2 28 10 0 20 12>; 

    Please review the m_can.yaml (Link) for a description of this MRAM configuration.

    Please note that there is no error checking on the memory allocation within MRAM.  Also note that the memory address wraps around automatically if you try to access a location beyond the max address.  Therefore, it is possible for you to overwrite memory cells within your configuration and you need to calculate and verify your memory allocation will not exceed the max limit in order to prevent and overwrite.

    The number of elements that MCAN can be configured to support exceeds the physical memory in the TCAN4550, so you will not be able to allocate the maximum number of elements for each type.  Please verify your MRAM memory allocation requirements and adjust the number of elements in your configuration if necessary.

    If you can read back the final register values from the device after initialization I can review them for possible errors at the device level if you feel your MRAM allocation is correct.

    Regards,

    Jonathan

  • Hello Jonathan,

    Yes, your understood correctly.

    With the same configuration and m_can file is working in the IMX6ULL. but in IMX8DXL it is not working. In m_can_xmit function queue work function is calling but we are removing the queue work function and we are directly calling the m_can_tx_handler function.

    Below is the m_can.c and tcan4x5x.c file. The same changes is working in the IMX6 processor. This changes is for CANFD optimization.

    0410.tcan4x5x.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    // SPDX-License-Identifier: GPL-2.0
    // SPI to CAN driver for the Texas Instruments TCAN4x5x
    // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
    #include <linux/regmap.h>
    #include <linux/spi/spi.h>
    #include <linux/regulator/consumer.h>
    #include <linux/gpio/consumer.h>
    #include "m_can.h"
    #define DEVICE_NAME "tcan4x5x"
    #define TCAN4X5X_EXT_CLK_DEF 40000000
    #define TCAN4X5X_DEV_ID0 0x00
    #define TCAN4X5X_DEV_ID1 0x04
    #define TCAN4X5X_REV 0x08
    #define TCAN4X5X_STATUS 0x0C
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    m_can.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    // SPDX-License-Identifier: GPL-2.0
    // CAN bus driver for Bosch M_CAN controller
    // Copyright (C) 2014 Freescale Semiconductor, Inc.
    // Dong Aisheng <b29396@freescale.com>
    // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
    /* Bosch M_CAN user manual can be obtained from:
    * http://www.bosch-semiconductors.de/media/pdf_1/ipmodules_1/m_can/
    * mcan_users_manual_v302.pdf
    */
    #include <linux/interrupt.h>
    #include <linux/io.h>
    #include <linux/kernel.h>
    #include <linux/module.h>
    #include <linux/netdevice.h>
    #include <linux/of.h>
    #include <linux/of_device.h>
    #include <linux/platform_device.h>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hello Tanushree,

    If the TCAN4550 is working with your code on the IMX6 processor, then it is likely not a TCAN4550 register configuration issue and instead related to some difference between the IMX6 and the IMX8DXL processors.  I don't have experience with either of these so I don't know how to help you with a processor issue.

    If there are any interrupt or status bits being set in the TCAN4550 registers that you can monitor during your issues, I could try to offer some insight at a functional level.  But I can only support you by working with the register values in the device to verify the configuration is correct and what any interrupt and status bits are indicating.

    Because I'm not a Linux expert, and I'm not familiar with either of these two processors, I won't be able to tell you why the code works on one processor and not the other.

    Regards,

    Jonathan