Used RCP.Call freeze the M4 core

hello
I try to have a simple example with RPC library. The goal is to passe the "boot button" state from m7 core to m4 core and the m4 core shall retrieved it and enable the LED
But when i call the function RPC.call on the M4, this core freeze. ( according the code, the led shall be blink but it's no the case).
To ensure it's this function who freeze the core, i have try to remove it and it's works ( LED blink)
Someone can help me to understand the problem?

set up:

  • arduino IDE 2.1.1
  • flash split "1MB M7 + 1MB M4"
  • lib: Arduino Mbed OS Giga board 4.0.4

M7 core:

/*Library use to start M4 core*/
#include <RPC.h>

const PinName eBOOTButtonPin = PC_13; // Pine mame where is the BOOT button on GIGA
int IntBOOTButtonState = 0;           // variable to store the boot button state
const int IntBluePin = LEDB; // Pin Number 88 for Arduino

void setup()
{

  pinMode(eBOOTButtonPin, INPUT);
  pinMode(IntBluePin, OUTPUT);

  /*blink to indicate boot is ok on M7*/

  digitalWrite(IntBluePin, LOW);
  delay(500);
  digitalWrite(IntBluePin, HIGH);
  delay(500);
  digitalWrite(IntBluePin, LOW);
  delay(500);
  digitalWrite(IntBluePin, HIGH);

  RPC.begin(); // boot M4 core
  // Bind the button state  on the M7
  RPC.bind("IntGetBootButtonState", IntGetBootButtonState);
}

void loop()
{

  IntBOOTButtonState = digitalRead(eBOOTButtonPin);
  IntGetBootButtonState(); //call to ensure le read button work. (LED ON/OFF when button is/is not push)
  delay(500);
}

int IntGetBootButtonState()
{
  if (HIGH == IntBOOTButtonState)
  {
    digitalWrite(IntBluePin, LOW);
  }
  else
  {
    digitalWrite(IntBluePin, HIGH);
  }

  return (int)IntBOOTButtonState;
}

M4 core:


#include "RPC.h"

/* constants won't change. They're used here to set pin numbers: */
const int IntGreenPin = LEDG; // Pin Number 87 for Arduino
const int IntRedPin = LEDR;   // Pin Number 86 for Arduino
const int IntBluePin = LEDB;  // Pin Number 88 for Arduino

int IntBOOTButtonStateRetrieved = 0; // variable to store the boot button state

void setup()
{
    pinMode(IntGreenPin, OUTPUT);
    pinMode(IntRedPin, OUTPUT);
    /*blink to indicate boot is ok on M7*/

    digitalWrite(IntRedPin, LOW);
    delay(500);
    digitalWrite(IntRedPin, HIGH);
    delay(500);
    digitalWrite(IntRedPin, LOW);
    delay(500);
    digitalWrite(IntRedPin, HIGH);
    RPC.begin();
}

void loop()
{
    digitalWrite(IntRedPin, LOW);
    delay(1000);
    digitalWrite(IntRedPin, HIGH);
    delay(1000);
    digitalWrite(IntRedPin, LOW);
    delay(1000);
    digitalWrite(IntRedPin, HIGH); 



    auto result = RPC.call("IntGetBootButtonState",IntBOOTButtonStateRetrieved).as<int>();
    
    if (0 == result)
    {
        digitalWrite(IntGreenPin, LOW);
    }
    else
    {
        digitalWrite(IntGreenPin, HIGH);
    }
    delay(500);
}

Thanks for your support

I have currently the same Problem, any ideas?

Hello @fana45 @mikemm101,

I’ve tested your exact setup and code, and it works perfectly for me without any freezes. Here are a few suggestions that might help resolve your issue:

  1. Use the latest Arduino IDE (2.3.6) – I recommend updating to the newest version, as it includes bug fixes and improvements that could affect RPC functionality.
  2. Upload order matters – Make sure you first upload the code to the M4 core, then upload the M7 (Main Core) code afterward. This sequence is important for proper initialization.
  3. Check your error – Could you share the exact error message or behavior you’re experiencing? For me, the LED blinks correctly, and the button state is passed between cores without freezing.

boot0

If you’re still encountering issues, let me know more details and I’ll be happy to help further.

Wishing you a great day!

1 Like