Mbed OS Unstable on Arduino Giga

I am experiencing intermitted crashes with the installed Mbed OS on the arduino giga wifi r1. If I run a simple hello world program which prints hello world once per second using the simple serial.println function followed by a 1 second delay the board will crash every couple minutes randomly at different intervals (boot LED 4 quick red flashed and 4 slow red flashes). Any ideas? Is Mbed OS known to be stable yet on the Giga? Thanks :slight_smile:

1 Like

I received my Giga less than a week an ago, but so far, all of my tests have been stable. Most of the projects have involved both multiple leds and prints to the serial monitor, and I’ve run some of them unattended for hours with no problems. Single core, dual core, and data transfers, all while running multiple threads have also been stable.

Have you checked your cables and connections?

Your topic has been moved to the dedicated Giga R1 section of the forum.

i am also gettin mbedos crash when i upload onewire library

For me I get crashes with some examples mainly involving wifi or flash

I've been working toward fixing that issue as well, I've been compiling a huge list of issues I've been working on 12 hours a day for the past 2 weeks. The long and the short of the situation is I've been seeing some of the most poorly written code in my long productive career as a professional software engineer coming from the Arduino team based on their commit logs. I'm scared that they are moving all their boards to ARM when they cant follow the documentation correctly, especially when it comes to MBED OS and truly whenever they touch an STM32 built chip. The number of undocumented hacky solutions (and some crazy security vulnerabilities and glaringly obvious buffer overflows) they are using gives me very little confidence in any industrial or safety critical systems built on their code base. I'm building both individual fixes and a single library anyone can add to their project and it will override the broken or sketchy code in Arduinos implementation. I love open source software and as a community we will rebuild the software and we will all be better for it. If anyone would like a better set of documentation of advanced features for the giga then let me know and ill make it. Most importantly RPC needs to die, it took 3000 microseconds to send a large struct to the M4 from M7. I wrote an implementation using SDRAM4 user space that takes less than 1 microsecond to interrupt the other core, transfer the data, and call a function to either do something or return more data, and is fully synchronized and is able to interrupt the other core, and vice versa. The cores handshake at boot to make sure any data structures moving between cores in code are the same (takes about 20 microseconds) this is done by doing ARM assembly byte code analysis of the program memory, otherwise a nice simple error message is printed to serial if serial has been started by the user. Easy peasy lemon squeezy. Also I will be restoring full functionality back to the M4 core as right now it is very restricted in its serial operations and is very reliant on M7 under the hood. I've already gotten it so that M4 can boot and run by itself without M7, and also is able to shutdown any core, take a stack frame and dump to SDRAM in tens of microseconds. The now shutdown core pulls almost zero power as I park it in its deepest power state, and release all its memory to the other core, then at the leisure of the other core choose to boot it up any time and resume right where it left off immediately from SDRAM while the other core that initiated the reboot and resume is transferring its memory back into core SRAM all protected by the hardware memory management unit on the STM32 so no performance penalty and crazy fast performance without memory address collisions. This is how STM32 intended it to be used and would have been trivial for Arduino to add and encapsulate it away from the user. My library has single easy function calls, and almost 10,000 lines of C and ARM assembly code under the hood that makes it all possible, everything is handled transparently by me and MBED OS.

3 Likes

Where do I find this code? If it's on GitHub please could you provide a link. Thanks.

I wish I could post, but my code is now proprietary as its part of a closed source business project. But I can give you some very good hints.

start with something like this (and include SDRAM.h)

SDRAM.begin(SDRAM_START_ADDRESS_4 + SDRAM_ALLOCATION_PROTECTED_BUFFER_SIZE);
const uint32_t SDRAM_START_ADDRESS_4 = ((uint32_t)0x38000000);  //USING THE AHB SRAM4 DOMAIN SPACE
const uint32_t SDRAM_ALLOCATION_PROTECTED_BUFFER_SIZE = 10000;  //for my own use, malloc will allocate after the size of this variable, increase if we need more than 10KB for core to core variables

//Pointers to memory locations
byte *send_frame_ready_flag = (byte *)SDRAM_START_ADDRESS_4;
byte *return_frame_ready_flag = (byte *)SDRAM_START_ADDRESS_4 + sizeof(byte);
DATA_FRAME_SEND *data_frame_send_sdram = (DATA_FRAME_SEND *)SDRAM_START_ADDRESS_4 + (2 * sizeof(byte));
DATA_FRAME_RETURN *data_frame_return_sdram = (DATA_FRAME_RETURN *)SDRAM_START_ADDRESS_4 + (2 * sizeof(byte) + sizeof(DATA_FRAME_SEND));

then use it something like this (I assume you know how to pass pointers and data in C++)

ON M7:

void sendDataToM4() {
  if (*send_frame_ready_flag == 0) {
    DATA_FRAME_SEND dataForM4;
    //GERRIKOIO CAN ADD HIS OWN ADD DATA TO STRUCT CODE HERE 
    *data_frame_send_sdram = dataForM4;
    *send_frame_ready_flag = 1;
  }
}

void receiveDataFromM4() {
  if (*return_frame_ready_flag == 1) {  //1 indicates it can read
    DATA_FRAME_RETURN dataFromM4 = *data_frame_return_sdram;
    telemetry.printTelemetry(String(dataFromM4.debugStringData));
    *return_frame_ready_flag = 0;  //0 indicates data has been read
  }
}

ON M4

void receiveDataFromM7() {
  if (*send_frame_ready_flag == 1) {  //data is available from M7
    DATA_FRAME_SEND dataFromM7 = *data_frame_send_sdram;
    *send_frame_ready_flag = 0;  //set to zero to let M7 know data has been read
  }
}

void sendDataToM7(String debugStringData, bool blocking) {
  do {
    if (*return_frame_ready_flag == 0) { //if 0 can send data 
      DATA_FRAME_RETURN dataForM7;
      debugStringData.toCharArray(dataForM7.debugStringData, sizeof(dataForM7.debugStringData));
      *data_frame_return_sdram = dataForM7;
      *return_frame_ready_flag = 1; //1 lets m7 know it can read data 
      return; //break out of do->while loop
    } else if (blocking) {
      delayMicroseconds(5);  //hang out and try again, in a little bit
    }
  } while (blocking);
}

DATA_FRAME_SEND and DATA_FRAME_RETURN are structs which you can customize. The code above will pass data effortlessly between the cores in a few microseconds to read/write at each cores convenience. To call functions on the other core with data passing, write the assembly for whichever microcontroller you are using (in my case the STM32H747) to trigger on the IO event of toggling the flag I outlined above, read the data, and take a function name or pointer to call the function (if they share the same function definitions in its header files). Shouldn't be too hard. Let me know if you need more help. :slight_smile:

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.