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.
How to set player_main as the SDK Application entry point?
-
I am using Spresense SDK and would like to start the audio player example on power up without using nsh. However when I configure player_main as the SDK Application entry point, I got the following run time error:
Starting AudioPlayer example
Error: mpshm_remap() failure. -2
Error: init_libraries() failurePlease help.
Thanks,
Qiang
-
Hi @QiangLi
If you want to use some other function as an entry point, you must initialize the Spresense board in it.
To do this, add it to the beginning of your main function (audio_player_main):
boardctl(BOARDIOC_INIT, 0);
The second thing you need to do is wait for the SD card to initialize.
You can do this using this loop:
/* In case that SD card isn't inserted, it times out at max 2 sec */ for (retry = 0; retry < 20; retry++) { if (stat("/mnt/sd0/", &buf) == 0) { break; } /* 100 ms */ usleep(100 * 1000); } if (retry >= 20) { printf("Error: SD card isn't inserted.\n"); return 1; }
When you add these two things to the beginning of your main function (audio_player_main), everything should work now.
BR,
Kamil Tomaszewski -
@KamilTomaszewski said in How to set player_main as the SDK Application entry point?:
/* In case that SD card isn't inserted, it times out at max 2 sec /
for (retry = 0; retry < 20; retry++)
{
if (stat("/mnt/sd0/", &buf) == 0)
{
break;
}
/ 100 ms */
usleep(100 * 1000);
}if (retry >= 20)
{
printf("Error: SD card isn't inserted.\n");
return 1;
}@KamilTomaszewski Thank you very much. It works now. By the way, where in the doc that talks about this usage?
-
Hello @QiangLi
This code was created based on the code from the Spresense Arduino Library (https://github.com/sonydevworld/spresense-arduino-compatible/blob/3ac9fd04398832052c9ef45d9738979877708384/Arduino15/packages/SPRESENSE/hardware/spresense/1.0.0/libraries/SDHCI/src/SDHCI.cpp#L66-L75).
This is not in the documentation. If you use your function as an entry point, you must wait for the SD card mount if you want to use it.
Here you can find information about Spresense board initialization process: https://developer.sony.com/develop/spresense/docs/sdk_developer_guide_en.html#_board_initialization_process
BR,
Kamil Tomaszewski -
@KamilTomaszewski Thank you for this wealth of info.