Topics

Canopen node nRF52832


Cristian Anceschi <cristian.anceschi@...>
 

Hi all

I'm quite new on Zephyr and on CAN BUS so my question might have an easy or obvious answer.

I'm on Ubuntu and I'm using an nRF52DK nRF52832 (PCA10040) wired to a custom board equipped with a MCP2515 and a MCP2551 devices.

Is the samples\subsys\canbus\canopen suitable for an hardware like the one I'm using?
If so, any hints on how make this sample working?

1)
I can compile it  from command line with
west build -b nrf52dk_nrf52832 samples\subsys\canbus\canopen -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf 

declaring in  subsys\canbus\canopen\CO_driver.c (even though I thought it wasn't really need to declare this here)
#define CONFIG_CAN_MAX_FILTER 13

and prj.mcp2515.conf as attachment

Executing the project, I get the attached log file with a series of error messages and this stucks me here for this moment. 

2)
Just to give some more info, I'd like to say that I did compile the samples/drivers/can from command line launching this

west build -b nrf52dk_nrf52832 samples/drivers/can/ -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf

and everything works as expected (tested using a CAN sniffer).
But it is not clear to me how to add in this project the CANOpen stack library.

Thanks in advance for the support 

Kind regards
Crisian



--
Ing Cristian Anceschi
Galileo Engineering s.r.l.
Via Cavallotti 16
IT - 42122 Reggio Emilia
Phone +39 0522 920496 / +39 0522 516244
Fax     +39 0522 920496 / +39 0522 516244

Privacy - Le informazioni contenute nel presente messaggio di posta elettronica ed in ogni allegato sono da ritenersi informazioni riservate. Chi ricevesse il presente messaggio senza esserne l'effettivo destinatario è rigorosamente tenuto a evitarne ogni divulgazione, diffusione o riproduzione, ai sensi del D.Lgs n.196/2003. Qualora abbiate ricevuto la presente comunicazione per errore siete pregati di distruggerla e di segnalarlo al mittente. Grazie. 

Privacy - The information contained in this e-mail message and any attached files are considered private information. If you have received this message without being the intended recipient, prevent any dissemination or reproduction. If you are not the addressee, please contact the sender and destroy all copies of the original message. Thanks.


Bolivar, Marti
 

Hi,

The MPU fault may be due to a missing CONFIG_MPU_ALLOW_FLASH_WRITE=y.

I don't know anything about CAN, though :).

Martí

"Cristian Anceschi via lists.zephyrproject.org"
<cristian.anceschi=galileo.engineering@lists.zephyrproject.org> writes:

Hi all

I'm quite new on Zephyr and on CAN BUS so my question might have an easy or
obvious answer.

I'm on Ubuntu and I'm using an nRF52DK nRF52832 (PCA10040) wired to a
custom board equipped with a MCP2515 and a MCP2551 devices.

Is the samples\subsys\canbus\canopen suitable for an hardware like the one
I'm using?
If so, any hints on how make this sample working?

1)
I can compile it from command line with
west build -b nrf52dk_nrf52832 samples\subsys\canbus\canopen
-DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf

declaring in subsys\canbus\canopen\CO_driver.c (even though I thought it
wasn't really need to declare this here)
#define CONFIG_CAN_MAX_FILTER 13

and prj.mcp2515.conf as attachment

Executing the project, I get the attached log file with a series of error
messages and this stucks me here for this moment.

2)
Just to give some more info, I'd like to say that I did compile the
samples/drivers/can from command line launching this

west build -b nrf52dk_nrf52832 samples/drivers/can/
-DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf

and everything works as expected (tested using a CAN sniffer).
But it is not clear to me how to add in this project the CANOpen stack
library.

Thanks in advance for the support

Kind regards
Crisian



--
Ing Cristian Anceschi
Galileo Engineering s.r.l.
Via Cavallotti 16
IT - 42122 Reggio Emilia
Phone +39 0522 920496 / +39 0522 516244
Fax +39 0522 920496 / +39 0522 516244

Privacy - Le informazioni contenute nel presente messaggio di posta
elettronica ed in ogni allegato sono da ritenersi informazioni riservate.
Chi ricevesse il presente messaggio senza esserne l'effettivo destinatario
è rigorosamente tenuto a evitarne ogni divulgazione, diffusione o
riproduzione, ai sensi del D.Lgs n.196/2003. Qualora abbiate ricevuto la
presente comunicazione per errore siete pregati di distruggerla e di
segnalarlo al mittente. Grazie.

Privacy - The information contained in this e-mail message and any attached
files are considered private information. If you have received this message
without being the intended recipient, prevent any dissemination or
reproduction. If you are not the addressee, please contact the sender and
destroy all copies of the original message. Thanks.





# Alternate conf file required for building the CAN sample for the
# MCP2515 stand alone CAN controller

CONFIG_GPIO=y

CONFIG_CAN=y
CONFIG_CAN_INIT_PRIORITY=80
CONFIG_CAN_MCP2515_MAX_FILTER=5

CONFIG_SHELL=y
CONFIG_CAN_SHELL=y
CONFIG_DEVICE_SHELL=y


CONFIG_LOG=y
CONFIG_PRINTK=y
CONFIG_CONSOLE=y
#CONFIG_LOG_PRINTK=y
CONFIG_RTT_CONSOLE=y
#CONFIG_HAS_SEGGER_RTT=y
CONFIG_USE_SEGGER_RTT=y

#

CONFIG_LOG=y
CONFIG_CANOPEN_LOG_LEVEL_DBG=y

CONFIG_CAN=y
CONFIG_CAN_INIT_PRIORITY=80
CONFIG_CAN_MCP2515=y
CONFIG_CAN_MAX_FILTER=13


CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y

CONFIG_CANOPEN=y
CONFIG_CANOPEN_SYNC_THREAD=y
CONFIG_CANOPEN_STORAGE=y
CONFIG_CANOPEN_LEDS=y

CONFIG_REBOOT=y
canstat=0
new mode value : 0
init mode 0
*** Booting Zephyr OS version 2.4.99 ***
[00:00:00.413,665] <inf> fs_nvs: 6 Sectors of 4096 bytes
[00:00:00.413,665] <inf> fs_nvs: alloc wra: 0, ff0
[00:00:00.413,665] <inf> fs_nvs: data wra: 0, 0
[00:00:00.413,726] <dbg> canopen_driver.CO_CANmodule_init: rxSize = 13, txSize = 9
canstat=0
new mode value : 0
[00:00:00.414,978] <err> canopen_driver: failed to attach CAN rx isr, no free filter
[00:00:00.415,039] <err> canopen_driver: failed to attach CAN rx isr, no free filter
[00:00:00.415,069] <err> canopen_driver: failed to attach CAN rx isr, no free filter
[00:00:00.415,130] <inf> app: CANopen stack initialized
[00:00:00.415,527] <err> os: ***** MPU FAULT *****
[00:00:00.415,527] <err> os: Data Access Violation
[00:00:00.415,527] <err> os: MMFAR Address: 0x7a000
[00:00:00.415,557] <err> os: r0/a1: 0x0007a000 r1/a2: 0x00000055 r2/a


Nick Ward
 

Hi Cristian,

I'm not sure if the MCP1525 is a good match for Canopen but you may need to increase this kconfig symbol CONFIG_CAN_MCP2515_INT_THREAD_STACK_SIZE

Nick


On Thu, 10 Dec 2020, 2:38 am Bolivar, Marti, <marti.bolivar@...> wrote:
Hi,

The MPU fault may be due to a missing CONFIG_MPU_ALLOW_FLASH_WRITE=y.

I don't know anything about CAN, though :).

Martí

"Cristian Anceschi via lists.zephyrproject.org"
<cristian.anceschi=galileo.engineering@...> writes:

> Hi all
>
> I'm quite new on Zephyr and on CAN BUS so my question might have an easy or
> obvious answer.
>
> I'm on Ubuntu and I'm using an nRF52DK nRF52832 (PCA10040) wired to a
> custom board equipped with a MCP2515 and a MCP2551 devices.
>
> Is the samples\subsys\canbus\canopen suitable for an hardware like the one
> I'm using?
> If so, any hints on how make this sample working?
>
> 1)
> I can compile it  from command line with
> west build -b nrf52dk_nrf52832 samples\subsys\canbus\canopen
> -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf
>
> declaring in  subsys\canbus\canopen\CO_driver.c (even though I thought it
> wasn't really need to declare this here)
> #define CONFIG_CAN_MAX_FILTER 13
>
> and prj.mcp2515.conf as attachment
>
> Executing the project, I get the attached log file with a series of error
> messages and this stucks me here for this moment.
>
> 2)
> Just to give some more info, I'd like to say that I did compile the
> samples/drivers/can from command line launching this
>
> west build -b nrf52dk_nrf52832 samples/drivers/can/
> -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf
>
> and everything works as expected (tested using a CAN sniffer).
> But it is not clear to me how to add in this project the CANOpen stack
> library.
>
> Thanks in advance for the support
>
> Kind regards
> Crisian
>
>
>
> --
> Ing Cristian Anceschi
> Galileo Engineering s.r.l.
> Via Cavallotti 16
> IT - 42122 Reggio Emilia
> Phone +39 0522 920496 / +39 0522 516244
> Fax     +39 0522 920496 / +39 0522 516244
>
> Privacy - Le informazioni contenute nel presente messaggio di posta
> elettronica ed in ogni allegato sono da ritenersi informazioni riservate.
> Chi ricevesse il presente messaggio senza esserne l'effettivo destinatario
> è rigorosamente tenuto a evitarne ogni divulgazione, diffusione o
> riproduzione, ai sensi del D.Lgs n.196/2003. Qualora abbiate ricevuto la
> presente comunicazione per errore siete pregati di distruggerla e di
> segnalarlo al mittente. Grazie.
>
> Privacy - The information contained in this e-mail message and any attached
> files are considered private information. If you have received this message
> without being the intended recipient, prevent any dissemination or
> reproduction. If you are not the addressee, please contact the sender and
> destroy all copies of the original message. Thanks.
>
>
>
>
>
> # Alternate conf file required for building the CAN sample for the
> # MCP2515 stand alone CAN controller
>
> CONFIG_GPIO=y
>
> CONFIG_CAN=y
> CONFIG_CAN_INIT_PRIORITY=80
> CONFIG_CAN_MCP2515_MAX_FILTER=5
>
> CONFIG_SHELL=y
> CONFIG_CAN_SHELL=y
> CONFIG_DEVICE_SHELL=y
>
>
> CONFIG_LOG=y
> CONFIG_PRINTK=y
> CONFIG_CONSOLE=y
> #CONFIG_LOG_PRINTK=y
> CONFIG_RTT_CONSOLE=y
> #CONFIG_HAS_SEGGER_RTT=y
> CONFIG_USE_SEGGER_RTT=y
>
> #
>
> CONFIG_LOG=y
> CONFIG_CANOPEN_LOG_LEVEL_DBG=y
>
> CONFIG_CAN=y
> CONFIG_CAN_INIT_PRIORITY=80
> CONFIG_CAN_MCP2515=y
> CONFIG_CAN_MAX_FILTER=13
>
>
> CONFIG_FLASH=y
> CONFIG_FLASH_MAP=y
> CONFIG_NVS=y
> CONFIG_SETTINGS=y
> CONFIG_SETTINGS_NVS=y
>
> CONFIG_CANOPEN=y
> CONFIG_CANOPEN_SYNC_THREAD=y
> CONFIG_CANOPEN_STORAGE=y
> CONFIG_CANOPEN_LEDS=y
>
> CONFIG_REBOOT=y
> canstat=0
> new mode value : 0
> init mode 0
> *** Booting Zephyr OS version 2.4.99  ***
> [00:00:00.413,665] <inf> fs_nvs: 6 Sectors of 4096 bytes
> [00:00:00.413,665] <inf> fs_nvs: alloc wra: 0, ff0
> [00:00:00.413,665] <inf> fs_nvs: data wra: 0, 0
> [00:00:00.413,726] <dbg> canopen_driver.CO_CANmodule_init: rxSize = 13, txSize = 9
> canstat=0
> new mode value : 0
> [00:00:00.414,978] <err> canopen_driver: failed to attach CAN rx isr, no free filter
> [00:00:00.415,039] <err> canopen_driver: failed to attach CAN rx isr, no free filter
> [00:00:00.415,069] <err> canopen_driver: failed to attach CAN rx isr, no free filter
> [00:00:00.415,130] <inf> app: CANopen stack initialized
> [00:00:00.415,527] <err> os: ***** MPU FAULT *****
> [00:00:00.415,527] <err> os:   Data Access Violation
> [00:00:00.415,527] <err> os:   MMFAR Address: 0x7a000
> [00:00:00.415,557] <err> os: r0/a1:  0x0007a000  r1/a2:  0x00000055  r2/a





Alexander Wachter
 

Hi Cristian,

Macros prefixed with CONFIG_ come from Kconfig.
Never try to set them in your application.
CONFIG_CAN_MAX_FILTER=13 goes to your mcp2515.conf
The CAN_MAX_FILTER is used in the MCP2515 driver,
and if you set it in some of your files, it won't end up in the driver.

As Marti already mentioned, you also need to allow MPU flash writes.

Cheers,

Alex

On 09.12.20 11:54, Cristian Anceschi wrote:
Hi all
I'm quite new on Zephyr and on CAN BUS so my question might have an easy or obvious answer.
I'm on Ubuntu and I'm using an nRF52DK nRF52832 (PCA10040) wired to a custom board equipped with a MCP2515 and a MCP2551 devices.
Is the samples\subsys\canbus\canopen suitable for an hardware like the one I'm using?
If so, any hints on how make this sample working?
1)
I can compile it  from command line with
west build -b nrf52dk_nrf52832 samples\subsys\canbus\canopen -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf
declaring in subsys\canbus\canopen\CO_driver.c (even though I thought it wasn't really need to declare this here)
#define CONFIG_CAN_MAX_FILTER 13
and prj.mcp2515.conf as attachment
Executing the project, I get the attached log file with a series of error messages and this stucks me here for this moment.
2)
Just to give some more info, I'd like to say that I did compile the samples/drivers/can from command line launching this
west build -b nrf52dk_nrf52832 samples/drivers/can/ -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf
and everything works as expected (tested using a CAN sniffer).
But it is not clear to me how to add in this project the CANOpen stack library.
Thanks in advance for the support
Kind regards
Crisian
--
Ing Cristian Anceschi
Galileo Engineering s.r.l.
Via Cavallotti 16
IT - 42122 Reggio Emilia
Phone +39 0522 920496 / +39 0522 516244
Fax     +39 0522 920496 / +39 0522 516244
Privacy - Le informazioni contenute nel presente messaggio di posta elettronica ed in ogni allegato sono da ritenersi informazioni riservate. Chi ricevesse il presente messaggio senza esserne l'effettivo destinatario è rigorosamente tenuto a evitarne ogni divulgazione, diffusione o riproduzione, ai sensi del D.Lgs n.196/2003. Qualora abbiate ricevuto la presente comunicazione per errore siete pregati di distruggerla e di segnalarlo al mittente. Grazie.
Privacy - The information contained in this e-mail message and any attached files are considered private information. If you have received this message without being the intended recipient, prevent any dissemination or reproduction. If you are not the addressee, please contact the sender and destroy all copies of the original message. Thanks.


"Karsten König <karsten.koenig.030@...>
 

Hi,

I am trying to remember why I added a separate CONFIG_CAN_MCP2515_MAX_FILTER next to the existing CONFIG_CAN_MAX_FILTER. I think there was a reason, but maybe I just misunderstood the kconfig system. Can you please open a github issue so we can discuss there?

I attached a small patch to drop CONFIG_CAN_MCP2515_MAX_FILTER in favor of CONFIG_CAN_MAX_FILTER, please apply that for further tests.
The rest of the comments in this email apply as well :-)


Cheers,
Karsten

On 12/9/20 9:12 PM, Nick Ward wrote:
Hi Cristian,
I'm not sure if the MCP1525 is a good match for Canopen but you may need to increase this kconfig symbol CONFIG_CAN_MCP2515_INT_THREAD_STACK_SIZE
Nick
On Thu, 10 Dec 2020, 2:38 am Bolivar, Marti, <marti.bolivar@nordicsemi.no <mailto:marti.bolivar@nordicsemi.no>> wrote:
Hi,
The MPU fault may be due to a missing CONFIG_MPU_ALLOW_FLASH_WRITE=y.
I don't know anything about CAN, though :).
Martí
"Cristian Anceschi via lists.zephyrproject.org
<http://lists.zephyrproject.org>"
<cristian.anceschi=galileo.engineering@lists.zephyrproject.org
<mailto:galileo.engineering@lists.zephyrproject.org>> writes:

> Hi all
>
> I'm quite new on Zephyr and on CAN BUS so my question might have
an easy or
> obvious answer.
>
> I'm on Ubuntu and I'm using an nRF52DK nRF52832 (PCA10040) wired to a
> custom board equipped with a MCP2515 and a MCP2551 devices.
>
> Is the samples\subsys\canbus\canopen suitable for an hardware
like the one
> I'm using?
> If so, any hints on how make this sample working?
>
> 1)
> I can compile it  from command line with
> west build -b nrf52dk_nrf52832 samples\subsys\canbus\canopen
> -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf
>
> declaring in  subsys\canbus\canopen\CO_driver.c (even though I
thought it
> wasn't really need to declare this here)
> #define CONFIG_CAN_MAX_FILTER 13
>
> and prj.mcp2515.conf as attachment
>
> Executing the project, I get the attached log file with a series
of error
> messages and this stucks me here for this moment.
>
> 2)
> Just to give some more info, I'd like to say that I did compile the
> samples/drivers/can from command line launching this
>
> west build -b nrf52dk_nrf52832 samples/drivers/can/
> -DSHIELD=dfrobot_can_bus_v2_0 -DCONF_FILE=prj.mcp2515.conf
>
> and everything works as expected (tested using a CAN sniffer).
> But it is not clear to me how to add in this project the CANOpen
stack
> library.
>
> Thanks in advance for the support
>
> Kind regards
> Crisian
>
>
>
> --
> Ing Cristian Anceschi
> Galileo Engineering s.r.l.
> Via Cavallotti 16
> IT - 42122 Reggio Emilia
> Phone +39 0522 920496 / +39 0522 516244
> Fax     +39 0522 920496 / +39 0522 516244
>
> Privacy - Le informazioni contenute nel presente messaggio di posta
> elettronica ed in ogni allegato sono da ritenersi informazioni
riservate.
> Chi ricevesse il presente messaggio senza esserne l'effettivo
destinatario
> è rigorosamente tenuto a evitarne ogni divulgazione, diffusione o
> riproduzione, ai sensi del D.Lgs n.196/2003. Qualora abbiate
ricevuto la
> presente comunicazione per errore siete pregati di distruggerla e di
> segnalarlo al mittente. Grazie.
>
> Privacy - The information contained in this e-mail message and
any attached
> files are considered private information. If you have received
this message
> without being the intended recipient, prevent any dissemination or
> reproduction. If you are not the addressee, please contact the
sender and
> destroy all copies of the original message. Thanks.
>
>
>
>
>
> # Alternate conf file required for building the CAN sample for the
> # MCP2515 stand alone CAN controller
>
> CONFIG_GPIO=y
>
> CONFIG_CAN=y
> CONFIG_CAN_INIT_PRIORITY=80
> CONFIG_CAN_MCP2515_MAX_FILTER=5
>
> CONFIG_SHELL=y
> CONFIG_CAN_SHELL=y
> CONFIG_DEVICE_SHELL=y
>
>
> CONFIG_LOG=y
> CONFIG_PRINTK=y
> CONFIG_CONSOLE=y
> #CONFIG_LOG_PRINTK=y
> CONFIG_RTT_CONSOLE=y
> #CONFIG_HAS_SEGGER_RTT=y
> CONFIG_USE_SEGGER_RTT=y
>
> #
>
> CONFIG_LOG=y
> CONFIG_CANOPEN_LOG_LEVEL_DBG=y
>
> CONFIG_CAN=y
> CONFIG_CAN_INIT_PRIORITY=80
> CONFIG_CAN_MCP2515=y
> CONFIG_CAN_MAX_FILTER=13
>
>
> CONFIG_FLASH=y
> CONFIG_FLASH_MAP=y
> CONFIG_NVS=y
> CONFIG_SETTINGS=y
> CONFIG_SETTINGS_NVS=y
>
> CONFIG_CANOPEN=y
> CONFIG_CANOPEN_SYNC_THREAD=y
> CONFIG_CANOPEN_STORAGE=y
> CONFIG_CANOPEN_LEDS=y
>
> CONFIG_REBOOT=y
> canstat=0
> new mode value : 0
> init mode 0
> *** Booting Zephyr OS version 2.4.99  ***
> [00:00:00.413,665] <inf> fs_nvs: 6 Sectors of 4096 bytes
> [00:00:00.413,665] <inf> fs_nvs: alloc wra: 0, ff0
> [00:00:00.413,665] <inf> fs_nvs: data wra: 0, 0
> [00:00:00.413,726] <dbg> canopen_driver.CO_CANmodule_init: rxSize
= 13, txSize = 9
> canstat=0
> new mode value : 0
> [00:00:00.414,978] <err> canopen_driver: failed to attach CAN rx
isr, no free filter
> [00:00:00.415,039] <err> canopen_driver: failed to attach CAN rx
isr, no free filter
> [00:00:00.415,069] <err> canopen_driver: failed to attach CAN rx
isr, no free filter
> [00:00:00.415,130] <inf> app: CANopen stack initialized
> [00:00:00.415,527] <err> os: ***** MPU FAULT *****
> [00:00:00.415,527] <err> os:   Data Access Violation
> [00:00:00.415,527] <err> os:   MMFAR Address: 0x7a000
> [00:00:00.415,557] <err> os: r0/a1:  0x0007a000  r1/a2:
0x00000055  r2/a