What I'm trying to do is change the directBoot bit in bootflags from the main application, so i can dictate if I want the bootloader to skip directly to the main app in case of reset, or to actually stay in bootlaoder mode to perform an application update.
I'm using Kinetis Flash Bootloader with a few modifications that shouldn't interfere with this subject.
I followed every step described in "How to adapt KDS applications for KBOOT.pdf". Everything is working smoothly other than this.
To turn on directBoot from my application I'm trying something like this:
memcpy(flashTmpBuffer,0xA3D8,sizeof(uint8_t)*8); //0xA3D8 is the 8-byte aligned address that contains the bootflags
flashTmpBuffer = 0x01; //0xA3D8 + 6 = 0xA3DE, the location of bootflags
status = FLASH_Init(&s_flashDriver);
status = FLASH_Program(&s_flashDriver,0xA3D8,(uint32_t *) flashTmpBuffer,sizeof(uint8_t)*8);
This causes a "MGSTAT0 non-correctable error" in the function flash_command_sequence (I'm using SDK 2.0).
Do I need an extra step to disable flash security in this sector? If so, how?
Is it even possible to go this route to achieve what I'm trying?
Has anyone done something to the same effect, successfully?
Thank you all for your help