# NAFlashWrite fails with NAFLASH\_SECTOR\_IS\_RESERVED

**URL:** <https://forums.digi.com/t/naflashwrite-fails-with-naflash-sector-is-reserved/5248>\
**Category:** NET+OS\
**Created:** [February 14, 2011, 6:33pm UTC](https://forums.digi.com/t/naflashwrite-fails-with-naflash-sector-is-reserved/5248 "2011-02-14T18:33:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkasari](https://avatars.discourse-cdn.com/v4/letter/l/bc8723/32.png) [@lkasari](https://forums.digi.com/u/lkasari)\
**Post date:** [February 14, 2011, 6:33pm UTC](https://forums.digi.com/t/naflashwrite-fails-with-naflash-sector-is-reserved/5248/1 "2011-02-14T18:33:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lkasari](https://avatars.discourse-cdn.com/v4/letter/l/bc8723/32.png) [@lkasari](https://forums.digi.com/u/lkasari)\
**Post date:** [February 16, 2011, 1:22am UTC](https://forums.digi.com/t/naflashwrite-fails-with-naflash-sector-is-reserved/5248/2 "2011-02-16T01:22:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lkasari](https://avatars.discourse-cdn.com/v4/letter/l/bc8723/32.png) [@lkasari](https://forums.digi.com/u/lkasari)\
**Post date:** [February 17, 2011, 8:56pm UTC](https://forums.digi.com/t/naflashwrite-fails-with-naflash-sector-is-reserved/5248/3 "2011-02-17T20:56:53Z")

</div>

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 &gt; (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.
