Setting ID code to lock the flash

I've been looking at ways of locking the code flash in a renesas-based UNO R4. This was easy with old ATMEGA based boards... just use avrdude to set a lock bit here and there.

I can't for the life of me understand how to write to the OSIS register in the UNO R4(renesas mcu). I have dug about to understand that it's a 16 byte value that gets written at code upload. I found these:

/*
 ID Code
 Note: To permanently lock and disable the debug interface define the BSP_ID_CODE_PERMANENTLY_LOCKED in the compiler settings.
 WARNING: This will disable debug access to the part and cannot be reversed by a debug probe.
 */
#if defined(BSP_ID_CODE_PERMANENTLY_LOCKED)
            #define BSP_CFG_ID_CODE_LONG_1 (0x00000000)
            #define BSP_CFG_ID_CODE_LONG_2 (0x00000000)
            #define BSP_CFG_ID_CODE_LONG_3 (0x00000000)
            #define BSP_CFG_ID_CODE_LONG_4 (0x00000000)
            #else
/* ID CODE: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF */
#define BSP_CFG_ID_CODE_LONG_1 (0xFFFFFFFF)
#define BSP_CFG_ID_CODE_LONG_2 (0xFFFFFFFF)
#define BSP_CFG_ID_CODE_LONG_3 (0xFFF**00**FFF)
#define BSP_CFG_ID_CODE_LONG_4 (0xffFFFFFF)
#endif

This is from bsp_mcu_family_cfg.h. I have verified by printing those bytes to serial that indeed they change to what I define them.

I have flipped 1 byte on purpose from FF to 00 to see if that would set the ID code; but it does not. Renesas Flash Programmer still reads the code, data and config areas with no problem. I mean to lock read access to these areas. Erase commands should be left active.
Some more info I read, related to this: https://en-support.renesas.com/knowledgeBase/20980156

It would mean that just setting ID code to anything BUT FFs (and leaving bits 127 and 126 as 1) would require this ID code be entered when trying to debug or read the MCU. Thats what I want to achieve, but fail to see how.
What is to be done ?

I have edited that 32 string of hex characters in bsp_mcu_family_cfg.h. It doesnt work. The string does not appear at all in the compiled binary, so the MCU is never locked. I have contacted renesas about this already, but they point me back to using ther IDE (e2 studio) which I'd rather not.
There must be some extra configuration I must be defining somewhere to get the compiler to add that 16 byte ID code to be written. Here is where I am lost at the moment... merely defining the ID code(and it being different than all FFs) WILL NOT mean that it will get written to the target MCU.

Update: it seems that even defining BSP_ID_CODE_PERMANENTLY_LOCKED does not lock the device via ID code...any help from a FSP/BSP wizard here ?

#define BSP_ID_CODE_PERMANENTLY_LOCKED 1

void setup{}
void loop{}

This much should have been enough, but the resulting .hex does not contain instructions to set the ID code OSIS register

That is the catch, there is something else missing which should enable this writing to the OSIS register. In e2 studio this gets enabled if you turn on ID code protection but it was left out in the arduino core.

And why do you think that would be ? Not by accident I'm thinking.

And nobody has noticed until you noticed it?

or perhaps you a have a big chunk of knowledge about how these things work.

Will simply replace all instances of the word
BSP_ID_CODE_PERMANENTLY_LOCKED
with the number 1.

It matters not what this word says, for example if the line said

The pre compiler would replace the word
last-thanks_giving_we had_turkey
with a value of 1.

To stop people from bricking their boards. Tamper with that in the wrong way, all access to flash is disabled.

If BSP_ID_CODE_PERMANENTLY_LOCKED is defined then it might be used somewhere else in the .h files I haven't yet dug up; excepting in bsp_mcu_family_cfg.h where it seems to be used. Being all edgy does not help, you can't contribute please refrain.

It prevents the code flash from being read. You can always reset it using the Renesas tools. The board is not bricked.

I will, but please correct your attitude. I find it offensive.

I will turn off this thread and so I will not get any further notifications from it.
Goodbye.

Nothing of value was lost, don't worry you two.
For the record setting an ID code whose 128th bit is 0 will absolutely lock the MCU entirely and will become unreadable/unwriteable. Just wanted to point that out before I figure out a how-to on the matter.

Manipulating the .hex file before writing it is one way to enable this ID code lock. Cumbersome but it does work.