Regarding HARD FAULT traps. Does the STM32 (or cortex cpus in general) have any kind of memory region that is read-only, and does not issue a hard fault when written to ?
The intend is to detect whether an array (size 256 bytes) is present in RAM at a location pointed to, and does not trap a HARDFAULT when the pointer written to it. A subsequent read from the same location should produce a value different from the value written. E.g. the complement or a value from a constant table. So a sequence such as :
typedef char barray[256];
char *ptr = /* a pointer from an array of pointers to barrays */ ;
*ptr = 0x55;
printf (*ptr == 0x55 ? "That RAM !" : "That's NOT RAM");
result in the result being printed without causing a HARD FAULT;
Further the HARDFAULT mechanism should not be disabled, so that it will still trap a HARDFAULT for other unwritable memory regions. If have considered the bitbanded memory space for this.