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

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

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

Post by glenn20 » Wed Oct 20, 2021 1:42 am

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.

Post Reply