NAFlashWrite fails with NAFLASH_SECTOR_IS_RESERVED

Hi,
I’m in the middle of migrating from Net+OS 7.3 to 7.5 and am now having a problem with writing data to flash using NAFlashWrite.

I still have my old build system running 7.3 on another computer, and I can see that I am calling NAFlashWrite with the same sector, offset, lenth, etc. in both systems, but the 7.5 system returns with NAFLASH_SECTOR_IS_RESERVED.

I figure it is just a configuration issue in the BSP, but I can’t find the difference. bsp_fs.h is the same in 7_3 and 7_5.

Any ideas? Thanks.

Digging into it a bit more, this looks like it has something to do with the new BACKUP_RECOVERY stuff in the customize.ldr linker script. It looks like the new Net+OS 7.5 reserves the upper part of Flash for a backup image.

But even if I set BACKUP_RECOVERY_MAX_SIZE_IN_FLASH to 0 in customize.ldr, which is allowed, I still get the error that the upper sector is reserved.

I can’t find anyway to turn this flash reservation off.

We use this upper sector of Flash as a place to save configuration information, but it now looks like NET+OS won’t give the application code access to Flash in that way.

Does anyone know how to turn off this new Flash reservation stuff so that I can modify the upper sector?

Thanks.

So I got help from Digi Support on this. Here is the answer I got that fixed my problem.


If you just modifying the default devBoardParamsType structure to save your own data, the easy answer is modify your code to use customizeReadDevBoardParams and customizeWriteDevBoardParams.

Otherwise, if you want to disable the FLASH protection, you need to modify naflash.c and comment out the code shown below
in NAFlashWriteUnsafe around line 3199.

    else if (NABspNvramDriver == BSP_NVRAM_LAST_2_FLASH_SECTORS)
    {
        if (sectorNumber > (totalsectors - 3))
        {
            ret = NAFLASH_SECTOR_IS_RESERVED;
            goto doneFlashWrite;
        }
    }

You also need to rebuild the flash library by doing a make in the src/flash directory from the command line (make PLATFORM=connectem) (to build the debug library you will need to call make a second time, adding the parameter DEBUG=on)


That fixed my problem and I can now write in the upper area of flash again.