14
Netra CP3010 Board Programming Guide
• January
2006
static int
uflash_uninit() {
if (ufd0)
close(ufd0);
cleanup:
if (buf0)
free(buf0);
}
static int
uflash_write() {
int i;
/* write some pattern to the buffers */
for (i = 0; i < ufif0.info.blk_size; i += sizeof(int))
*((int *) (buf0 + i)) = 0xDEADBEEF;
/* write block 0 of user flash */
if (pwrite(ufd0, buf0, ufif0.info.blk_size, 0) != ufif0.info.blk_size)
perror("uflash0:write");
return(0);
}
main() {
int ret;
module = argv[0];
ret = uflash_init();
if (!ret)
uflash_write();
uflash_uninit();
}
CODE
EXAMPLE
2-4
Write Action on Flash Device
(Continued)