Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
Writing an image SD card
-
Hello,
I had tried to write an image into the SD card using the stb image library. Even though the image is written into the SD card the code after the stbi_write function is not executed and the nuttx Terminal shows these errors attached in the screenshot below. It would be great if someone can identify what is the error and how to rectify the same.nuttx Terminal Output:
Code:
Thank you in advance .
Reference for stb_image library: https://solarianprogrammer.com/2019/06/10/c-programming-reading-writing-images-stb_image-libraries/
-
Hi @sskcyber01
Try to increase the stack size of your application
- Run
make menuconfig
- Go to
Application Configuration -> Spresense SDK -> Examples
- Find your application and change the stack size from 2048 to 8192
- Select
<Save>
and <Exit> - Build your app again
Best Regards,
Kamil Tomaszewski - Run
-
Thank you for the response @kamiltomaszewski. The application worked successfully by changing the STACKSIZE within the Makefile. Is there any maximum STACKSIZE for running an application ?
Thanks in advance .
-
Hi @sskcyber01,
There is no maximum for
STACKSIZE
, but you have to fit into Spresense RAM.Best Regards,
Kamil Tomaszewski -
@KamilTomaszewski I tried changing the stack size value in makefile of my project yet I'm encountering same dump errors. Is the above way you mentioned the only way to change stack size?
-
The method I described is recommended. If you use my method instead of modifying the Makefile do you get this error?
Best Regards,
Kamil Tomaszewski -
@KamilTomaszewski i tried executing make menuconfig but I get this error "make: *** No rule to make target 'menuconfig'. Stop.". Do you know any means to rectify it?
-
Hi @Bhalaji-Kharthik When you try to run this command, are you under
spresense/sdk
? -
@KamilTomaszewski Now the command is running fine but I am not able to access projects outside spresense/sdk folder
-
@Bhalaji-Kharthik That's good. Do you mean you don't see configuration of your application which is outside the spresense directory in menuconfig?
-
This post is deleted! -
@KamilTomaszewski yes, I am only able to see applications within spresense/sdk folder
-
How did you configure your application before?
Could you please send me a link to the documentation you used to create your project?
Best Regards,
Kamil Tomaszewski -
@KamilTomaszewski I followed the steps to create a project from the below link.
-
@Bhalaji-Kharthik Ah, you are using the IDE. Then you need to change
STACKSIZE
inmyproject/myapps/Makefile
. Are you also trying to use std image library? -
@KamilTomaszewski Yes, i tried changing the stack size already in makefile but it doesn't seem to work. I am using stb image library. Are there any other reasons for getting stack dump errors?
-
@Bhalaji-Kharthik You can get a stack dump after Hard Fault or Assert.
I have just tried the stb library on the IDE and it works for me.
I added this line to the Makefile:
STACKSIZE = 8192
My code looks like this:
#include <nuttx/config.h> #include <stdio.h> #include <stdlib.h> #define STB_IMAGE_IMPLEMENTATION #include "stb_image/stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image/stb_image_write.h" int main(int argc, char *argv[]) { int width, height, channels; unsigned char *img = stbi_load("/mnt/sd0/test.jpg", &width, &height, &channels, 0); if(img == NULL) { printf("Error in loading the image\n"); exit(1); } printf("Loaded image with a width of %dpx, a height of %dpx and %d channels\n", width, height, channels); stbi_write_jpg("/mnt/sd0/test2.jpg", width, height, channels, img, 100); stbi_image_free(img); return 0; }
What is the size of the picture you are trying to read or write?