cancel
Showing results for 
Search instead for 
Did you mean: 

Not compiling SUBG2 generated project and not sure if working after fixing it

lauris
Associate III

Hello,

I want to try out 6LowPan on S2LP and found that in SUBG2 module I can do that on Contiki. Everything is being built on `NUCLEO-H753ZI` + `NUCLEO-S2868A2`. But after trying to generate code I found few issues in order to make it compile. Maybe it is some misconfiguration, some bugs or mixture of both. But basically issues I found with their fixes I have applied are as follows:

  1. even before `SUBG2` project was missing `NUCLEO...` defines in `stm32h7xx_nucleo_conf.h` and what is frustrating is that there is no user code place so what I have added is being removed after each code generation. Solution following lines added to `stm32h7xx_nucleo_conf.h`:
#define USE_NUCLEO_144
#define USE_NUCLEO_H753ZI​
  • COM (Serial interface) initialization is generated with single argument, while Function requires 2. Solution was add `COM_InitTypeDef` variable and pass it too in `contiki-platform.c`.
-  BSP_COM_Init(COM1);
+  COM_InitTypeDef comInit = {.BaudRate = 115200,
+				.WordLength = UART_WORDLENGTH_8B,
+				.Parity = UART_PARITY_NONE,
+				.StopBits = UART_STOPBITS_1,
+				.HwFlowCtl = UART_HWCONTROL_NONE};
+  BSP_COM_Init(COM1, &comInit);​
  • `SUBG2` timer callback conflicting with system timer callback. Solution was comment out Contiki timer callback function in `subg2_contiki_it.c`:
//#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
//void SUBG2_RTIMER_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
//#else
//void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
//#endif /*USE_HAL_TIM_REGISTER_CALLBACKS*/
//{
//  if(htim->Instance == SUBG2_RTIMER_INSTANCE)
//  {
//    __HAL_TIM_CLEAR_FLAG(&contiki_rtimer, TIM_FLAG_UPDATE);
//  }
//}​

and add Contiki timer clearing in system timer callback:

 /* Private includes ----------------------------------------------------------*/
 /* USER CODE BEGIN Includes */
+#include "subg2_bsp_ip_conf.h"
 
 /* USER CODE END Includes */


...

 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
 {
   /* USER CODE BEGIN Callback 0 */
 
   /* USER CODE END Callback 0 */
   if (htim->Instance == TIM13) {
     HAL_IncTick();
   }
   /* USER CODE BEGIN Callback 1 */
+  if(htim->Instance == SUBG2_RTIMER_INSTANCE)
+  {
+    __HAL_TIM_CLEAR_FLAG(&contiki_rtimer, TIM_FLAG_UPDATE);
+  }
   /* USER CODE END Callback 1 */
 }
  • [UDP client app only] `HAL_TIM_PERIOD_ELAPSED_CB_ID` is undefined and seems to be defined only with `USE_HAL_TIM_REGISTER_CALLBACKS` defined, but no idea how to define it from project side. As of solution just that part was commented out assuming `HAL_TIM_PeriodElapsedCallback()` will be called. Changes to `stm32h7xx_hal_timebase_tim.c`:
 /* Private function prototypes -----------------------------------------------*/
- void TimeBase_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
 /* Private functions ---------------------------------------------------------*/

...

   if(HAL_TIM_Base_Init(&htim13) == HAL_OK)
   {
     /* Start the TIM time Base generation in interrupt mode */
     return HAL_TIM_Base_Start_IT(&htim13);
   }
-  HAL_TIM_RegisterCallback(&htim13, HAL_TIM_PERIOD_ELAPSED_CB_ID, TimeBase_TIM_PeriodElapsedCallback);
 
   /* Return function status */
   return HAL_ERROR;

...

- /**
-  * @brief  Period elapsed callback in non blocking mode
-  * @note   This function is called  when TIM6 interrupt took place, inside
-  * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
-  * a global variable "uwTick" used as application time base.
-  * @PAram  htim TIM handle
-  * @retval None
-  */
-
-void TimeBase_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
-{
-  /* Prevent unused argument(s) compilation warning */
-  UNUSED(htim);
-
-  HAL_IncTick();
-}​

And after all these changes I have `UDP server` and `UDP Client` apps running side by side. But not working/communicating. Or I do not know how to test them. Since I assume they should see each other and client would broadcast some message and server receive and echo it back, and I would see that in their log. But no what I see on server side is:

[INFO: S2LP_platform] Starting Contiki-NG
[INFO: S2LP_platform] - Routing: RPL Lite
[INFO: S2LP_platform] - Net: sicslowpan
[INFO: S2LP_platform] - MAC: CSMA
[INFO: S2LP_platform] - 802.15.4 PANID: 0xabcd
[INFO: S2LP_platform] - 802.15.4 Default channel: 0
[INFO: S2LP_platform] Node ID: 32050
[INFO: S2LP_platform] Link-layer address: 0e51.3332.6f33.7d32
[INFO: RPL       ] initializing
[INFO: S2LP_platform] Tentative link-local IPv6 address: fe80::c51:3332:6f33:7d32
[INFO: S2LP_platform] ST S2LP Platform
Platform and Contiki-NG parameters:
"Board: stm32h7xx_nucleo":	"Board: stm32h7xx_nucleo"
"Expansion Board: S2868A2":	"Expansion Board: S2868A2"

RSSI_RX_THRESHOLD:	-118.0
RSSI_TX_THRESHOLD:	-90.0
RADIO_HW_CSMA:	1
POWER_DBM:	12.0
CHANNEL_SPACE:	100e3
FREQ_DEVIATION:	20e3
BANDWIDTH:	100.0e3
MODULATION_SELECT:	MOD_2FSK
DATARATE:	38400
IEEE802154_CONF_PANID:	abcd
BASE_FREQUENCY:	868.0e6
CHANNEL_NUMBER:	0
MAX_PACKET_LEN:	128

UIP_CONF_BUFFER_SIZE:	1280
UIP_CONF_ROUTER:	1
UIP_CONF_IPV6_RPL:	1
RPL_DEFAULT_LEAF_ONLY:	0
QUEUEBUF_CONF_NUM:	8
UIP_ND6_REACHABLE_TIME:	60000
UIP_TCP_MSS:	1220
UIP_RECEIVE_WINDOW:	1220
UIP_CONF_TCP:	0
UIP_MAX_ROUTES:	0
NBR_TABLE_CONF_MAX_NEIGHBORS:	16
UIP_CONF_ND6_SEND_RA:	0
UIP_CONF_ND6_SEND_NA:	1
UIP_CONF_ND6_SEND_NS:	0
IP64 is disabled.
DTLS is disabled.
RADIO_LOW_POWER:	0
RADIO_SNIFF_MODE:	0
RADIO_LONG_PREAMBLE:	0

[INFO: S2LP_platform] Contiki-NG and Sub-GHz Radio correctly configured... Starting all processes
[INFO: RPL       ] IPv6 addresses:
[INFO: RPL       ] -- fd00::c51:3332:6f33:7d32
[INFO: RPL       ] -- fe80::c51:3332:6f33:7d32
[INFO: RPL       ] reset DIO timer (Init root)
[INFO: RPL       ] created DAG with instance ID 0, DAG ID fd00::c51:3332:6f33:7d32, rank 128
[INFO: RPL       ] created a new RPL DAG
[INFO: RPL       ] sending a multicast-DIO with rank 128 to ff02::1a
[INFO: CSMA      ] sending to 0000.0000.0000.0000, len 80, seqno 70, queue length 1, free packets 7
[DBG : CSMA      ] scheduling transmission in 24 ticks, NB=0, BE=3
[INFO: CSMA      ] preparing packet for 0000.0000.0000.0000, seqno 70, tx 0, queue 1

And on client is:

[INFO: S2LP_platform] Starting Contiki-NG
[INFO: S2LP_platform] - Routing: RPL Lite
[INFO: S2LP_platform] - Net: sicslowpan
[INFO: S2LP_platform] - MAC: CSMA
[INFO: S2LP_platform] - 802.15.4 PANID: 0xabcd
[INFO: S2LP_platform] - 802.15.4 Default channel: 0
[INFO: S2LP_platform] Node ID: 23602
[INFO: S2LP_platform] Link-layer address: 0e51.3332.6133.5c32
[INFO: RPL       ] initializing
[INFO: S2LP_platform] Tentative link-local IPv6 address: fe80::c51:3332:6133:5c32
[INFO: S2LP_platform] ST S2LP Platform
Platform and Contiki-NG parameters:
"Board: stm32h7xx_nucleo":	"Board: stm32h7xx_nucleo"
"Expansion Board: S2868A2":	"Expansion Board: S2868A2"

RSSI_RX_THRESHOLD:	-118.0
RSSI_TX_THRESHOLD:	-90.0
RADIO_HW_CSMA:	1
POWER_DBM:	12.0
CHANNEL_SPACE:	100e3
FREQ_DEVIATION:	20e3
BANDWIDTH:	100.0e3
MODULATION_SELECT:	MOD_2FSK
DATARATE:	38400
IEEE802154_CONF_PANID:	abcd
BASE_FREQUENCY:	868.0e6
CHANNEL_NUMBER:	0
MAX_PACKET_LEN:	128

UIP_CONF_BUFFER_SIZE:	1280
UIP_CONF_ROUTER:	1
UIP_CONF_IPV6_RPL:	1
RPL_DEFAULT_LEAF_ONLY:	0
QUEUEBUF_CONF_NUM:	8
UIP_ND6_REACHABLE_TIME:	60000
UIP_TCP_MSS:	1220
UIP_RECEIVE_WINDOW:	1220
UIP_CONF_TCP:	0
UIP_MAX_ROUTES:	0
NBR_TABLE_CONF_MAX_NEIGHBORS:	16
UIP_CONF_ND6_SEND_RA:	0
UIP_CONF_ND6_SEND_NA:	1
UIP_CONF_ND6_SEND_NS:	0
IP64 is disabled.
DTLS is disabled.
RADIO_LOW_POWER:	0
RADIO_SNIFF_MODE:	0
RADIO_LONG_PREAMBLE:	0

[INFO: S2LP_platform] Contiki-NG and Sub-GHz Radio correctly configured... Starting all processes
[INFO: App       ] Not reachable yet
[INFO: App       ] Not reachable yet
[INFO: App       ] Not reachable yet
[INFO: App       ] Not reachable yet
[INFO: RPL       ] sending a DIS to ff02::1a
[INFO: CSMA      ] sending to 0000.0000.0000.0000, len 10, seqno 152, queue length 1, free packets 7
[DBG : CSMA      ] scheduling transmission in 29 ticks, NB=0, BE=3
[INFO: CSMA      ] preparing packet for 0000.0000.0000.0000, seqno 152, tx 0, queue 1

 

Bother devices are started/restarted same time and next to each other.

So all that boils down to 3 main questions:

  1. Are there some faults in configuration in order to avoid these code changes to make code compile? If not probably is some sort of a bug in `STM32CCubeIDE`.
  2. Can my fixes be responsible for examples not working as I expect. I would expect some kind of ping/pong scenario where `UDP client` broadcast `ping` and `UDP server` after receiving it sends back `pong`.
  3. My assumption of example is wrong and should be changed somehow (code added, other app compiled, or other) in order to make some data being transmitted over `6lowpan`?

Project `*.ioc` file of `UDP client` is attached if it would be of any help.

Thank you in advance for any help.

 

@SUBG2 @6lowpan @S2LP @Contiki

0 REPLIES 0