This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

sample net_sockets_can does not start correctly

Hi I try to build the sample 

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/zephyr/samples/net/sockets/can/README.html

but i get this this error.

*** Booting Zephyr OS build v2.6.99-ncs1-1 ***
Flash regions Domain Permissions
00 01 0x00000 0x10000 Secure rwxl
02 31 0x10000 0x100000 Non-Secure rwxl

Non-secure callable region 0 placed in flash region 1 with size 32.

SRAM region Domain Permissions
00 07 0x00000 0x10000 Secure rwxl
08 31 0x10000 0x40000 Non-Secure rwxl

Peripheral Domain Status
00 NRF_P0 Non-Secure OK
01 NRF_CLOCK Non-Secure OK
02 NRF_RTC0 Non-Secure OK
03 NRF_RTC1 Non-Secure OK
04 NRF_NVMC Non-Secure OK
05 NRF_UARTE1 Non-Secure OK
06 NRF_UARTE2 Secure SKIP
07 NRF_TWIM2 Non-Secure OK
08 NRF_SPIM3 Non-Secure OK
09 NRF_TIMER0 Non-Secure OK
10 NRF_TIMER1 Non-Secure OK
11 NRF_TIMER2 Non-Secure OK
12 NRF_SAADC Non-Secure OK
13 NRF_PWM0 Non-Secure OK
14 NRF_PWM1 Non-Secure OK
15 NRF_PWM2 Non-Secure OK
16 NRF_PWM3 Non-Secure OK
17 NRF_WDT Non-Secure OK
18 NRF_IPC Non-Secure OK
19 NRF_VMC Non-Secure OK
20 NRF_FPU Non-Secure OK
21 NRF_EGU1 Non-Secure OK
22 NRF_EGU2 Non-Secure OK
23 NRF_DPPIC Non-Secure OK
24 NRF_REGULATORS Non-Secure OK
25 NRF_PDM Non-Secure OK
26 NRF_I2S Non-Secure OK
27 NRF_GPIOTE1 Non-Secure OK

SPM: NS image at 0x10000
SPM: NS MSP at 0x200182b8
SPM: NS reset vector at 0x17071
SPM: prepare to jump to Non-Secure image.


[00:00:00.201,782] <dbg> mcp2515_can.socket_can_init: Init socket CAN device 0x2 a680 (SOCKET_CAN_1) for dev 0x2a6b0 (CAN_1)
[00:00:00.217,376] <dbg> net_core.net_init: (main): Priority 90
[00:00:00.225,982] <dbg> net_core.l3_init: (main): Network L3 init done
[00:00:00.235,290] <dbg> mcp2515_can.socket_can_iface_init: Init CAN interface 0 x200149f8 dev 0x2a680
uart:~$ *** Booting Zephyr OS build v2.6.99-ncs1-1 ***
[00:00:00.252,014] <inf> net_socket_can_sample: sleeping for 2 seconds
[00:00:02.261,352] <err> net_socket_can_sample: Cannot create 1st CAN socket (-106)
[00:00:02.271,972] <err> net_socket_can_sample: Cannot start CAN application (-106)
uart:~$

  • Hi Tomas

    The CAN library doesn't work unless you have a board that supports it. 

    The library uses the MCP2515 CAN driver, which is not available on the nRF9160DK. 

    The Requirements section in the sample readme lists the supported boards. 

    Best regards
    Torbjørn

  • Hi and thank you for the answer. 
    I have added a MCP2515 can module to my board.

    My installed shield

    In the text bellow i belive the four first line  the candrive are started. (CAN_1)

    what could be the reason for the errors on the two last lines ?

      

  • Hi 

    I assume it is this line that triggers the error.

    Error -106 corresponds to the EAFNOSUPPORT error (addr family not supported), which I assume is returned by this code snippet.
    Oddly the code there should not return an error if the family is set to AF_CAN. 
    Have you made any changes to the example?
    Best regards
    Torbjørn
  • I had an error during compiling and get this advice from your collige.

    thats the only modification.

  • Hi 

    I discussed the case with Øivind, which helped you out in the other case, and he pointed out that by default the example might use a different socket implementation than the one the CAN sample expects. The nRF9160 device is normally used for IP communication over LTE, and if the nrf91_socket implementation is used then it makes sense that it would fail when trying to communicate over the CAN bus. 

    In order to test this it should be possible to run the sample with logging enabled for the network drivers, by uncommenting the following lines from the prj.conf file:

    #CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=y
    #CONFIG_NET_CORE_LOG_LEVEL_DBG=y
    #CONFIG_NET_CONN_LOG_LEVEL_DBG=y

    Could you try to make this change, run the sample, and let me know what log output you get?

    Best regards
    Torbjørn

Related