Wednesday, May 11, 2022

STM32F7, LWIP, FreeRTOS Error stopping on configASSERT( pxQueue->uxItemSize == 0 );

There is an unclear bug spotted recently in STM32F7 with FreeRTOS v2 and LWIP (ver. 2.1) library.

After a moment of using ethernet socket data stream soft hangs at this line: 

configASSERT( pxQueue->uxItemSize == 0 );

It seems related to semaphore/mutex internal code issue. Could not find chance to dig too deep into it, but this post gave me a good hint:

https://forums.freertos.org/t/xsemaphoretake-function-looping-at-configassert-pxqueue-uxitemsize-0/8116 

I made the similar approach and made semaphore statically defined:

osSemaphoreId Netif_LinkSemaphore = NULL;

in the same lwip.c file.

So far it seemed to help with above problem.

Regarding other different issues with STM32 ethernet communication there is a nice compilation which might help us all:

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32




Thursday, March 10, 2022

Useful links for CANopen in embedded platforms

    Here are useful links to resources and information on CANopen embedded programming in general but especially on STM32 microcontrollers.

CANopen Node project   https://github.com/canopennode

CANopen Node code issues https://github.com/CANopenNode/CANopenNode/issues

CANopen stack on embedded devices https://github.com/embedded-office/canopen-stack

CANopen Node supported devices https://github.com/CANopenNode/CANopenNode/blob/master/doc/deviceSupport.md

CANopen Node on Linux https://github.com/CANopenNode/CANopenLinux

CANopen Node example code https://github.com/CANopenNode/CANopenNode/blob/v1.0/example/main.c

CANopen Node Tutorial and testing https://github.com/CANopenNode/CANopenDemo

CANopen Node port on STM32 https://github.com/w1ne/CANOpenNode-CubeMX-HAL

CANopen Node on STM32 https://github.com/CANopenNode/CanOpenSTM32

CANopen application layer poster https://www.can-cia.org/fileadmin/resources/documents/brochures/co_poster.pdf

CANopen for Python https://github.com/christiansandberg/canopen

CANopen NOde Object Distionary editor https://github.com/CANopenNode/CANopenEditor

CANopen quick reference sheet https://www.kollmorgen.com/sites/default/files/public_downloads/S300_S600_S700_CAN%20Protocol%20Quick%20Reference.pdf

CANopen for Python documentation https://canopen.readthedocs.io/en/latest/index.html

CANopen node documentation https://canopennode.github.io/CANopenSocket/index.html

CANopen node discussion on SourceForge (abandoned) https://sourceforge.net/p/canopennode/discussion/

CANopen PDO example https://github.com/CANopenNode/CANopenDemo/blob/master/tutorial/PDO.md

CANopen on Wikipedia https://en.wikipedia.org/wiki/CANopen

CANopen hands-on tutorial slides https://os.mbed.com/media/uploads/sam_grove/canopenhothandouts.pdf

CANopen Nanotec online manual https://en.nanotec.com/products/manual/PD4E_CANopen_EN/bus%2Fcan%2Fcan_stack.html

CANopen Node random project Microchip source code http://www.laukutikls.lv/sites/laukutikls.lv/files/raksti/20_pielikums_ronin.pdf

The Basic of CANopen white paper https://www.ni.com/en-us/innovations/white-papers/13/the-basics-of-canopen.html

CAN bit time calculator http://www.bittiming.can-wiki.info/

CANopen basic explanation on CANFestival basis (RUS) http://we.easyelectronics.ru/STM32/can-canopen-canfestival-stm32-chast-pervaya.html

CANopen practical explanation (RUS) https://i-flashdrive.ru/raznoe/canopen-protokol-obzor-protokola-canopen-arm.html#PDO

CANopen explanation (RUS) https://www.rlocman.ru/review/article.html?di=147763

CANopen explanation (RUS) https://www.rlocman.ru/review/article.html?di=147764

Wednesday, January 12, 2022

Arduino Nano and MCP2515 bringup problem

    When using examples from internet like this popular for example: https://github.com/autowp/arduino-mcp2515 make sure you check your MCP2515 adapter board's hardware. Author of library assumes that MCP2515 are connected with 16MHz clock, and example script CAN_read initialize connection with 16 MHz crystal. In case when your board comes with different crystal remember to change code accordingly.

In my case it was needed

mcp2515.setBitrate(CAN_125KBPS, MCP_8MHZ);

 instead of just:

mcp2515.setBitrate(CAN_125KBPS);

My noname adapter coming from depths of Asia looks similar to this:

For connection to Arduino Nano you can follow this guide: