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.
Unsolved Is it possible to communicate between the subcores only?
-
I am trying to send a random data from subcore 2 to subcore 1. Main core is only booting up the cores. But I receive a core dump when I tried doing this.
Below is the code:#include <MP.h>
#if (!SUBCORE)
void setup() {
// put your setup code here, to run once:Serial.begin(115200);
/* Boot SubCores */
for (int subid = 1; subid <= 2; subid++) {
int ret = MP.begin(subid);
if (ret < 0) {
MPLog("MP.begin(%d) error = %d\n", subid, ret);
}
}
}void loop() {
}#endif
#if (SUBCORE == 2)
void setup() {
// put your setup code here, to run once:
MP.begin();
}void loop() {
// put your main code here, to run repeatedly:
uint8_t sub2ID = 200;
int ret;
uint32_t msgdata;msgdata = random(32767);
ret = MP.Send(sub2ID,msgdata,1);
if (ret < 0) {
MPLog("MP.Send error = %d\n", ret);
}MP.RecvTimeout(MP_RECV_BLOCKING);
delay(1000);
}#endif
#if (SUBCORE == 1)
void setup() {
// put your setup code here, to run once:
int ret = 0;ret = MP.begin();
if (ret < 0) {
MPLog("MP.begin error = %d\n",ret);
}
}void loop() {
// put your main code here, to run repeatedly:
int ret;
int8_t msgid;
uint32_t msgdata;ret = MP.Recv(&msgid, &msgdata,2);
if(ret < 0){
printf("MP.Receive error = %d\n", ret);
}MPLog("Received data : %lx\n", msgdata);
}
#endifAny help would be greatly appreciated.
Thanks in advance.
Navaneeth -
Hey, @NavaneethRao-2
Yes, it is possible to communicate between the subcores.
- Have you tried one of the arduino MP examples? Did they work for you?
- Have you tried reducing the memory allocated for the main core so you have more space in the subcores?
- Have you tried to but a little bit of a delay in the main core loop (like 1s)?
-
@CamilaSouza Yes I have tried the examples. Everything have worked fine. Since I am sending a very small data I didn't change the memory layout of the cores.
I tried to do a bit different than the examples. Just trying to send some random data from subcore 2 to subcore 1 while main core boots up the subcores.
I have few questions.
- I have an MP.Send in the subcore 2 code. Should I add delay there?
- Also MP.ReceiveTimeout() API is called in maincore loop. Should it be present in subcore 2?
Is there a go to guide or a troubleshooting info for working with multicores?
BR
Navaneeth S Rao -
@NavaneethRao-2
I received core dumps when I tried to send (repeated?) data to a core that was not listening. Can you double check if you have the core always listening especially when you use threads/tasks in what you tried.However I stoped using ASMP recently, so sorry I have no solution.
-
Hi, @NavaneethRao-2
Sorry for the delayed response.
I don't know if you're still interested in this topic, but I took a look at your code and found a fix.I simply replaced your message id it for 10 instead of 200 and the code worked.
Maybe it was too big before.BEFORE:
uint8_t sub2ID = 200;
AFTER:
uint8_t sub2ID = 10;
-
@CamilaSouza Thank you for your prompt response. Yeah, it worked.