EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Using writeIDBlock to update SysIDBlock

Started by Tom Collins December 8, 2005
I'm trying to use writeIDBlock from write_idblock.c 2.01 in TN229, and
it just isn't working as I'd expect. Perhaps someone here has some
experience that applies...

This is on an RCM2260, so it has two 256k flash chips. I'm using
uC/OS-II, and I'm just trying to set the serial number in the
SysIDBlock structure and then write it back out to flash. My call to
writeIDBlock finishes rather quickly, and I'm left with a blank
SysIDBlock. When I restart my program, I get the following error: "Run
Time Error : No valid MAC address for board."

Here's the code I'm using, including the OS_ENTER_CRITICAL and
OS_EXIT_CRITICAL that I use to disable uC/OS-II.

int writeIDBlock()
{
auto unsigned long physaddr;
auto int err;

OS_ENTER_CRITICAL();

#ifdef _FLASH_
physaddr = sectorToLong(_FlashInfo.numSectors) - sizeof(SysIDBlock);
#else
physaddr = ((sectorToLong(_FlashInfo.numSectors) - sizeof(SysIDBlock))
&
0x0003FFFFul) + 0x000C0000ul;
#endif
physaddr &= 0x000FFFFFul; // ensure physical address is within 1MB
range
_overwrite_block_flag = 1;
err = WriteFlash(physaddr, &SysIDBlock, sizeof(SysIDBlock));
_overwrite_block_flag = 0;

// Has a User Block, now check if mirrored . . .
if (SysIDBlock.tableVersion >= 3) {
// Mirrored ID/User Block version, might as well do it now!
physaddr -= MAX_USERBLOCK_SIZE / 2;
_overwrite_block_flag = 1;
SysIDBlock.marker[5] = '\x00';
err = WriteFlash(physaddr, &SysIDBlock, sizeof(SysIDBlock));
SysIDBlock.marker[5] = '\xAA';
_overwrite_block_flag = 0;
}

OS_EXIT_CRITICAL();

return err;
}

Tom Collins
Tom Logic LLC
PO Box 5717
Napa, CA 94581
(707) 265-6622
(707) 265-6646 fax
tom@tom@...


On Dec 8, 2005, at 5:14 PM, Tom Collins wrote:
> I'm trying to use writeIDBlock from write_idblock.c 2.01 in TN229, and
> it just isn't working as I'd expect. Perhaps someone here has some
> experience that applies...

Sometimes it's a good idea to step away from the problem for awhile. I
think I figured out my problem when I went to bed last night. I forgot
to update the CRC on the SysIDBlock before writing it.

If that's not it, I'll come back to the list, but I'm fairly confident
that that is the cause of my problems.

Tom Collins
Tom Logic LLC
PO Box 5717
Napa, CA 94581
(707) 265-6622
(707) 265-6646 fax
tom@tom@...



Tom,

I'm trying to do the same thing, and after running the WriteIDblock.c it indicates in the sdio that it wrote the ID block but gives me "error-3 when reading ID block". How do you update the CRC you speak of? I'm trying to set a Mac address in my custom Rabbit2000 board. Upon compiling the WriteIDblock.c I also get a warning for "reference to getCPUID has no valid prototype"

Thanks, --- In rabbit-semi@rabb..., Tom Collins <tom@t...> wrote:
>
> On Dec 8, 2005, at 5:14 PM, Tom Collins wrote:
> > I'm trying to use writeIDBlock from write_idblock.c 2.01 in TN229, and
> > it just isn't working as I'd expect. Perhaps someone here has some
> > experience that applies...
>
> Sometimes it's a good idea to step away from the problem for awhile. I
> think I figured out my problem when I went to bed last night. I forgot
> to update the CRC on the SysIDBlock before writing it.
>
> If that's not it, I'll come back to the list, but I'm fairly confident
> that that is the cause of my problems.
>
> Tom Collins
> Tom Logic LLC
> PO Box 5717
> Napa, CA 94581
> (707) 265-6622
> (707) 265-6646 fax
> tom@t...
>




Memfault Beyond the Launch