52 Netra CP2500 Board Programming Guide • March 2007
printf("manfacturer id = 0x%p\n", ufif0.info.mfr_id);
printf("device id = 0x%p\n", ufif0.info.dev_id);
printf("number of blocks = 0x%p", ufif0.info.blk_num);
printf("block size = 0x%p" ufif0.info.blk_size);
}
}
static int
uflash_uninit() {
if (ufd0)
close(ufd0);
}
static int
uflash_blockerase() {
/* erase 2 blocks starting from block 1 of user flash */
uf0.blk_num = 1;
uf0.num_of_blks = 2;
if (ufd0 && ioctl(ufd0, UIOCEBLK, &ufif0) == -1 ) {
perror("ioctl(ufd0, UIOCEBLK): ");
return(-1);
}
printf("\nblockerase successful on %s\n", uflash0);
return(0);
}
main() {
int ret;
module = argv[0];
ret = uflash_init();
if (!ret)
uflash_blockerase();
uflash_uninit();
}
CODE EXAMPLE 3-5 Block Erase Action on User Flash Device (Continued)