-
-
Notifications
You must be signed in to change notification settings - Fork 98
Description
I have 2 Arduino R4 WiFi with the following configuration:
Firmware version 0.6.0
Core version 1.5.1
ArduinoBLE library version 1.4.1
For these boards I'm working on a sketch which uses the build in LED matrix. In particular, I use renderBitmap(bitmap, rows, columns)
.
After my sketch grew to approx. 96000 bytes of program space I occasionally got errors as:
=================== Registers information ====================
R0 : 01d01501 R1 : 00000000 R2 : 00000001 R3 : 000012c0
R12: 00000001 LR : 000059f9 PC : 000012c0 PSR: 00000000
==============================================================
Usage fault is caused by attempts to switch to an invalid state (e.g., ARM)
Show more call stack info by run: addr2line -e "/home/runner/.cache/arduino/sketches/98C63A9984C497D380D738D44806C96E/Arduino.ino".elf -a -f 000012c0 000059f8 00005e44 00005096 00013700 0001373e 0000cc9a 000103a2 00010398
First I thought the hardware is faulty, but it happens on a second R4, too. Sometimes it helped to recompile from scratch, sometimes it happened only when compiled locally on Windows with the IDE, other times it was only the Linux-compiled version with CLI (Github actions on Ubuntu 24.04). A first workaround was to reduce the sketch size and the error wouldn't pop up again for some time. But as the sketch keeps growing this is no longer an option.
Running addr2line with the elf file tells me:
??
??:0
0x000059f8
_ZN16ArduinoLEDMatrix4nextEv
/home/runner/.arduino15/packages/arduino/hardware/renesas_uno/1.5.1/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h:202
0x00005e44
_ZN16ArduinoLEDMatrix9loadFrameEPKm
/home/runner/.arduino15/packages/arduino/hardware/renesas_uno/1.5.1/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h:212
0x00005096
loop
/home/runner/work/PresepeSmart/PresepeSmart/Arduino/Arduino.ino:114
0x00013700
_Z12arduino_mainv
/home/runner/.arduino15/packages/arduino/hardware/renesas_uno/1.5.1/cores/arduino/main.cpp:121 (discriminator 1)
0x0001373e
$t
/home/runner/.arduino15/packages/arduino/hardware/renesas_uno/1.5.1/cores/arduino/main.cpp:143
0x0000cc9a
main
/home/runner/.arduino15/packages/arduino/hardware/renesas_uno/1.5.1/variants/UNOWIFIR4/tmp_gen_c_files/main.c:7
0x000103a2
Reset_Handler
/home/pennam/Arduino/hardware/arduino-git/renesas/extras/e2studioProjects/Santiago/Debug/../ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c:69 (discriminator 1)
0x00010398
Reset_Handler
/home/pennam/Arduino/hardware/arduino-git/renesas/extras/e2studioProjects/Santiago/Debug/../ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c:62
Which points me here:
ArduinoCore-renesas/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h
Lines 199 to 202 in 989073d
if(_callBack != nullptr){ | |
_callBack(); | |
} | |
_sequenceDone = true; |
I noticed that _callback
and a few other variables are not initialized:
ArduinoCore-renesas/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h
Lines 334 to 344 in 989073d
private: | |
int _currentFrame = 0; | |
uint32_t _frameHolder[3]; | |
uint32_t* _frames; | |
uint32_t _framesCount; | |
uint32_t _interval = 0; | |
uint32_t _lastInterval = 0; | |
bool _loop = false; | |
FspTimer _ledTimer; | |
bool _sequenceDone = false; | |
voidFuncPtr _callBack; |
Initializing them effectively solved my issue. I plan to run some more tests and then send a PR.