Page 1 of 1

How to determine if a memory address is in ROM or RAM?

Posted: Wed Oct 20, 2021 1:42 am
by glenn20
What is the best way to test if a memory address is in ROM or in RAM?

To fix a bug in the espnow module (https://github.com/micropython/micropython/pull/6515) my current hacky fix is:

Code: Select all

    if (p < MP_STATE_MEM(gc_pool_start) || MP_STATE_MEM(gc_pool_end) < p) {
    	// Copy message to a temp buffer on the stack 
    }
I wanted to check if this is the most portable, canonical and complete solution.

Why: Because esp_now_send() panics on esp8266 (not esp32) if a string that is interned in ROM is passed as the message.