Great, thank you Paval. Here's what I did: in the memmap linker file I created a new section:
MEMORY
{
...
ramfunction (rwx) : ORIGIN = 0x20043000, LENGTH = 0x01000 /* 4K bytes for storing functions */
}
...
__ramfunction_start__ = ORIGIN(ramfunction);
__ramfunction_length__ = LENGTH(ramfunction);
__ramfunction_end__ = __ramfunction_start__ + __ramfunction_length__; /* 4KB */
The map file says all is well:
0x0000000020043000 __ramfunction_start__ = ORIGIN (ramfunction)
0x0000000000001000 __ramfunction_length__ = LENGTH (ramfunction)
0x0000000020044000 __ramfunction_end__ = (__ramfunction_start__ + __ramfunction_length__)
...
.ramfunction_sect
0x0000000020043000 0x1c
*(.ramfunction_sect)
.ramfunction_sect
0x0000000020043000 0x1c CMakeFiles/.../myfile.c.obj
0x0000000020043000 ramFunction
...
Created a simple function just to have a bit of body:
__attribute__((section(".ramfunction_sect"))) void ramFunction(void) {
uint32_t cnt = 0;
while(cnt < 50000) {
cnt++;
}
while (1) {
;;
}
}
And then I call it from (flash) code to that function:
LOG_INFO("Leaving flash area...");
LOG_INFO("++ramFunction: 0x%08x", &ramFunction);
func_ptr = ramFunction;
func_ptr();
// We should never get here...
That results in this output:
[ INFO] (managestoragespace.c)(handleRequest @258) : Leaving flash area...
[ INFO] (managestoragespace.c)(handleRequest @259) : ++ramFunction: 0x20043001
[ERROR] ( startup.c)( BusFault_Handler @105) : Busfault! f0002
The datasheet says I'm in SRAM4, and the function is not accessing anything outside that bank (at this point):

FYI: toolchain is gcc and cmake, I'm not using MCUXpresso. But if there would be some kind of example somewhere, encapsulated in a MCUXpresso project, that would be neat.
Thanks in advance!