Change bootloader(optiboot) register from arduino uno code

Hi,

I'm actually trying to change the registers from the arduino uno to do something inside the bootloader.
I've read the atmega328p datasheet and saw that there were registers and I tried to modify it.
I've seen several tutorials that shows that you can modify for example the WDTCSR and set some flags inside the arduino code and it seems to work after I print the WDTCSR values.

// Enter Watchdog Configuration mode:
WDTCSR |= (1<<WDCE) | (1<<WDE); 

// Set Watchdog settings:
WDTCSR = (1<<WDIE) | (1<<WDE) |
(1<<WDP3) | (1<<WDP2) | (1<<WDP1) |
(1<<WDP0);
Serial.println(WDTCSR, BIN);

But when I tried to see if I get the same flag inside the bootloader code with :

uint8_t val;

val = WDTCSR;
if (val & _BV(WDP0))
{
// do something
}

But I can't see the flag set to 1.

So my question is if I do a reset with watchdog does it reset all the flags to 0 and inside the bootloader I can't see the flag that I have set ?

I've also tried another thing.
I saw that there were also a MCUSR register but when I tried to modify it, it is always set the 0 even if I change some flags to like that for example : MCUSR = 1 << 4.
But when I print this value in arduino code it shows 0.
So can we modify it from arduino code or the arduino changes it by itself. And should I never tried to modify those two registers by hand ?

If someone had the answer for those questions, it would help me a lot thanks !

The MCUSR bits 4-7 on 328P are unused and will be always read as 0. You can write to other bits but only 0.

Ok I understand thanks.