Spresense Hard fault issue with Arduino
I am using Spresense board to test our NN model (converted the NN model to C-model and deployed in Spresense using Arduino). This C model is already verified in different SoC's.
Pseudo code of the sketch:
Initialize recorder (using Arduino Audio library). Start Recorder. Initialize our application.
Dynamic memory allocation required for application.
Read audio frame of 320 bytes. Check read size is 320 bytes. Do application process.
Just to isolate if at all there is a memory conflict, I used the cut down version of the code to do the testing now. The model uses only 150KB, still encountered the Hardfault exception. I could track down the code to a point which causing the hardfault, but the observation seems to be weird.
First observation is that the exception is caused by the exp() and powf() (lib in the math.h) used in a function and later commenting out these libs fixed the exception.
a. For the exp(), though the algo doesn’t execute the exp() in the code snippet but simply having it in the code causes the issue. Later removed the exp() as this is no more required in the specific code snippet fixed the issue.
b. For the powf(), replacing the same with its alternative code (it was power of 2, replaced with Multiplication) resolved the hardfault issue. But the same powf() in other previous functions did not cause any exception.
After fixing those mentioned above, the next function caused exception but there is not math.h lib used.
Please see the console dump when Hard fault occurs.
KamilTomaszewski DeveloperWorld last edited by
First of all, I would like to confirm whether a hard fault occurs during the execution of function
Secondly, if you want to analyze the hard fault log you got, you can try the instructions from: https://forum.developer.sony.com/topic/66/up_assert-assertion-failed-at-file-manager-audio_manager-cpp-line-649-task-init/8
Please try this and let me know what you got.