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.
Limitations on ASMP?
-
I would like to get more insight on why exactly several libraries cannot be used on Sub cores.
According to this page https://developer.sony.com/develop/spresense/docs/arduino_developer_guide_en.html#_mp_supportlib the following libraries are all not available.- Audio
- Camera
- DNNRT
- GNSS
- LowPower
- LTE
- Sensing
- Storage (EEPROM, eMMC, File, Flash, SDHCI)
That is all core features of Spresense.
In my concrete case, I wanted to use Hardware Serial2. It seems to fail. I did not look into the details yet, but it worked on the Main Core.
Hardware Serial is not in the list. I thought it should work. It is also visible in the config.h of the sub core as CONFIG_CXD56_UART2 1
I have an assumption that the libraries do not work because
- The required features are not compiled into the Arduino SDK for subcores. See https://github.com/sonydevworld/spresense-arduino-compatible/blob/master/tools/configs/spresense_sub.conf
- The features do not support concurrency.
- For Audio it is using ASMP and maybe the core to communicate with is hard coded in the DSP binaries.
If I would compile e.g. the LTE into the subcore SDK and remove it from the main core. Would it work?
-
Update
Serial2 works with SubCores.
My issue was that I set the time after starting the sub core. Unfortunately the library in use on the sub core uses millis() to determine the timeout for polling. -> immediate timeout ...RTC.begin(); RtcTime compiledDateTime(__DATE__, __TIME__); RTC.setTime(compiledDateTime);
Anyway, I would be still interested if e.g. LTE could be enabled on the sub core somehow. I mean the ArduinoHttpClient in the LTE https sample is using delay() blocking effectively blocking all threads (as it is not sleep() or yield()).
-
Hey, @jens6151-0-1-1
So I have received some insights on why these libraries cannot be used on the subcores.
https://developer.sony.com/develop/spresense/docs/arduino_developer_guide_en.html#_tutorial_memory_config
As we can see in section 1.4 of the Arduino Development Guide, the subcores use virtual addresses instead of physical ones.
This is a problem for libraries that use DMA (e.g. LTE, Camera, SD controller), because DMA expects physical addresses.
You could translate the virtual address to the physical address before communicating with the DMA, but our libraries are not currently supporting this.
So to actually be able to use LTE for example in the subcore, you would have to implement this modification and then create a customized Arduino package.(https://developer.sony.com/develop/spresense/docs/arduino_set_up_en.html#_how_to_create_spresense_arduino_customized_package)With the GNSS and the Flash, the issue is that the application processor does not access them directly. You can see the block diagram for the CXD5602 here https://developer.sony.com/develop/spresense/docs/sdk_developer_guide_en.html
The M0+ and the GNSS processor can only communicate with the supervisor core.The audio library depend on files that are stores either in the flash or in an SD card, which can only be accessed through the supervisor core.
DNNRT and Sensing both use ASMP to do multicore communication and in order to make it simpler to the user, they are expected to have the main core as a supervisor core for the communication.
Low power makes modifications that affect all the cores, so it is also better for it to have the main core as supervisor.
I hope this explanation could make things more clear.
-
Thanks for the detailed answers. Very helpful. I definitely want to try to move some parts to the sub cores.
For now I have to write together what I have and submit something to the contest on hackster.io. Time left is very short. Hope I can make it. (If not it will use it for https://elchika.com/promotion/spresense2022/)
-
@jens6151-0-1-1
Good luck!