writeUserBlock - Corrrupted values

I am using a BL2100 controller w/ (RCM2200) core. I am writing a block of data via WriteUserBlock. The data is:

sizeof(configtype) unsigned int 2920 (0x0B68) bytes

I am writing starting at address 0x0000;

Occasionally, on a power cycle; the values from ReadUserBlock are corrupted. This causes a system re-init, which is somewhat shocking to the customer.

As the user makes changes to the options, WriteUserBlock is used to update the configurations. This is running in a task in uC/OS-II. Is WriteUserBlock task safe or is it getting interrupted and corrupting the write process?

Results from userblock_info.c

Does not contain mirrored ID/User blocks. A power cycle
while the User block is being written can leave the User
block in an inconsistent state.

Combined ID and User blocks consume 0x00004000 (16384) bytes
at the top of the first flash.

Combined ID plus User blocks size: 0x00002000 (8192) bytes.

System ID block / area size: 0x00000084 (132) bytes.
User block size: 0x00001F7C (8060) bytes.
Available User block size: 0x00001C00 (7168) bytes.
Reserved User block size: 0x0000037C (892) bytes.

Make sure you only call WriteUserBlock() from one of your tasks. If you were to interrupt it with another call, it’s possible you could corrupt the userblock.

Also, consider updating your device to use mirrored user blocks. By doing so, the library either writes to user block A or B, ensuring that there’s always a valid block available if a write fails.

I believe you can update to mirrored user blocks using this program from Dynamic C 9:


Your report is a bit confusing though, since it claims both 16K for combined blocks and 8K, which would appear to represent mirrored 8KB user blocks.

What version of Dynamic C are you using? If it isn’t 9.62, can you try the userblock report program from that release?

I am using 9.62. I will download and try the mirrored blocks routine. I am calling WriteUserBlock() from a task. Thanks