nBuino RAM location

It seems to me, that Stack address is starting wrong at 0x10001FFF ( = 0x10002000 - 1 )

I think the Stack should start at 0x100017FF ( = 0x10008000 - 1 )

The area ( 0x10001800 to 0x10001FFF) overwrites the area (0x10000000 to 0x100007FF) and this is causing a conflict of memory if we use more than 2Kb.

Because Global and Heap are starting at 0x10000000 and Stack starts writing at 0x100007FF (if it starts at 0x10001FFF).

I’ve had a lot of memory problems creating my game for contest, so I had to optimize the code to use less memory, and only now I noticed that.

The code below I tested on mBuino Retro:

#include "mbed.h"

int main() {   
    char  RAM_stack[8];

    DigitalOut led1(P0_9);
    DigitalOut led2(P0_8);
    
    led1 = 0; led2 = 0;
    wait_ms( 1000 );  
      
    if( (int)RAM_stack > 0x10001800 ) led1 = 1; // RAM_stack is over 0x10001800
    wait_ms( 1000 );
    
    led1 = 0;                           // turn off led1
    wait_ms( 1000 );
    
    char *p = RAM_stack;
    p -= 0x1800;
    if( (int)p < 0x10000800 ) led1 = 1; // Confirm that p is below 0x10000800
    wait_ms( 1000 );
    
    *p = 0xA6;                          // Set value in p
    RAM_stack[0] = 0x59;                // Set value in Stack
    
    if( *p == 0x59 ) led2 = 1;          // Verify value in Stack - 0x1800

    while( 1 );
}

This was supposed to be fixed a long time ago.

@ Rogerup - If you are using an old copy of the library imported prior to the fix, the fix does not get updated. You will need to delete the library from your project and re import it. The problem should be solved if you re import the library.

Ah, ok. Thank you.

I simply downloaded the official_RETRO code 1 month ago and didn’t worry about update the mbed of it.

You should be able to right-click the library and choose “Update” to pull the latest in. I really wish it would do this automatically.

But not all updates are 100% backwards compatible. If things were automatically updated it could cause a program that built and ran perfectly to suddenly stop working without the user doing a thing. The compiler/IDE shouldn’t make any changes to your code that you haven’t told it to make.

Yes you can always manually force it to go back and use an old version but who’s going to think to try that if they didn’t even know that there had been an update because it was automatically applied?

The icon changes to indicate that there is an update and it takes two mouse clicks to update to the latest version, hardly an excessive burden on the user.