FreeCalypso > hg > freecalypso-tools
diff loadtools/flutil.c @ 669:ba9523ca6ed8
fc-loadtool code: preparations for e-program-* addition
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 08 Mar 2020 01:32:08 +0000 |
parents | 0dd2c87c1b63 |
children | 135de08c5d74 |
line wrap: on
line diff
--- a/loadtools/flutil.c Sun Mar 08 00:29:11 2020 +0000 +++ b/loadtools/flutil.c Sun Mar 08 01:32:08 2020 +0000 @@ -10,28 +10,23 @@ extern struct flash_bank_info flash_bank_info[2]; -get_flash_sector_table(bank) +get_flash_sector_table(bi) + struct flash_bank_info *bi; { - struct flash_bank_info *bi; struct flash_geom *geom; struct flash_region_desc *reg; struct sector_info *sp; uint32_t offset; int nr, i; - bi = flash_bank_info + bank; if (bi->sectors) return(0); - i = flash_detect(bank, 0); - if (i < 0) - return(i); geom = bi->geom; sp = (struct sector_info *) malloc(sizeof(struct sector_info) * (geom->total_sectors + 1)); if (!sp) { fprintf(stderr, - "unable to malloc buffer for flash bank %d sector table\n", - bank); + "unable to malloc buffer for flash sector table\n"); return(-1); } bi->sectors = sp; @@ -73,9 +68,11 @@ fprintf(stderr, "error: too many arguments\n"); return(-1); } - if (get_flash_sector_table(bank) < 0) + if (flash_detect(bank, 0) < 0) return(-1); bi = flash_bank_info + bank; + if (get_flash_sector_table(bi) < 0) + return(-1); printf("%u sectors in flash bank %d:\n", bi->geom->total_sectors, bank); printf("Offset Size\n"); for (sp = bi->sectors; sp->size; sp++)