Post topics, source code that relate to the Arduino Platform

User avatar
By gmag11
#80567 Hello,

I'm developing a sensor platform using ESP-NOW protocol. I started using WiFiEspNow library but at some point I decided to use plain sdk functions.

Node and gateway code works fine, so I wanted to cleanup code before going on.

When I remove `#include <WiFiEspNow.h>` line I get random crashes both on gateway and sensor node. I've double and triple checked that there is no reference in my code to it, and looked inside library files for anything that can cause this problem. Sincerely I do not understand this issue. It is an X-File for me.

This is one of the crash dumps I get:

Code: Select allException (9):
epc1=0x40204128 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0020453a depc=0x00000000

ctx: sys
sp: 3fffed40 end: 3fffffb0 offset: 01a0

   :Error:9 -> LoadStoreAlignmentCause: Attempt to read/write memory with an unaligned address (for example, trying to read/write a 32-bit word at an address that is not a multiple of 4)
   0x40204128 ESP8266WiFiGenericClass
   : ?? ??:0
   : ?? ??:0
   : ?? ??:0
   : ?? ??:0
   :808 (discriminator 2):::0x40206654:Curve25519
   0x40204526 Curve25519
   0x402126b8 etharp_raw
   0x4020b078 __ssputs_r
   0x402071cd _printf_common
   0x40207588 _printf_i
   : ?? ??:0
   : ?? ??:0
   0x401064d4 millis
   0x402039a9 CryptModule
   0x402033a8 loop
   0x402059f4 HardwareSerial
   0x402056d9 esp_schedule

I am confused about LoadStoreAlignmentCause. All buffers are accessed as uint8_t pointers and managed with memcpy.

I have my code on Github In order to reproduce this problem only sensor code is needed. Just comment first line on `espnow_sensor.ino`. If that line is active it woks perfectly.

I'm using Visual Micro to compile this project, but Arduino IDE results the same behavior.

I have absolutely no clue about what can be the reason. Any advice will be helpful.

Thank you
User avatar
By theenggprojects
#80753 You have to include the library header line `#include <WiFiEspNow.h>` in order for your code to use these files. There's must be some function, your code is using from that library.

Sometimes, it happens that Library A is dependent on Library B so you are not directly using Library B in your code but in order for Library A to use it you have to include Library B. I hope you understood the concept. Arduino IDE is better option though.
User avatar
By gmag11
#81475 Finally, I found the problem.

It was related to a debug string whose length was not controlled. This caused accesses out of allocated memory.

Most probably, including that library made that writing into that address was not harmful because its functions were not used.

I've learnt something new :D