Last address of program in STM32 HAL?
Your compiler might define a name for the last address used by code and/or const data sections. I know in the one I use, it has definitions for the end of code, something like __text_end__ and const data __rodata_end__. I can extern these in my C code - something like extern uint32_t __rodata_end__; and then use these 'variables' in my code. Once the compiler &amp; linker finish doing their jobs, these values are then automatically substituted into my code where needed.  

I've tried out a simple project in STM32CubeIDE, and with all the default settings it looks like it provides a symbol called __fini_array_end at the last used location in Flash. So you'd probably declare it as extern uint32_t __fini_array_end; in your code and then use &amp;__fini_array_end to work out the start of the next page to use as simulated EEPROM.  

Depending on how your project's linker is configures, you might find a different arrangement of sections in flash. The default project which STM32CubeIDE created for me put __fini_array_end at the end. So you'll have to look at your map file to see what symbol is at the end for your project and use that instead. Somewhere down near the end of your .map file you'll see the addresses of the symbols change from the 0x080xxxxx range (Flash) to 0x2000xxxx (RAM). You might find some others like __init_array_end, __preinit_array_end, etc.

If you're looking through the .map file and see the .data, .bss and other sections in the 0x2000xxxx range then you've gone too far and need to scroll back up a little to get back to the end of the 0x080xxxxx range.