FreeCalypso > hg > freecalypso-sw
changeset 410:81d387690063
Intel flash: clear SR before programming
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 17 Jun 2014 03:40:49 +0000 |
parents | 23ab8fe81764 |
children | d7f409493eb6 |
files | loadtools/flashops.c loadtools/flmisc.c loadtools/flprogbin.c loadtools/flprogsrec.c |
diffstat | 4 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/loadtools/flashops.c Tue Jun 17 03:18:02 2014 +0000 +++ b/loadtools/flashops.c Tue Jun 17 03:40:49 2014 +0000 @@ -193,12 +193,25 @@ return(0); } +intel_clear_sr(bi) + struct flash_bank_info *bi; +{ + printf("Clearing Intel flash SR\n"); + if (do_w16(bi->base_addr, 0x50)) { + fprintf(stderr, + "unexpected response to w16 for Clear SR command\n"); + return(-1); + } + return(0); +} + struct flash_cmdset flash_cmdset_intel = { .cmdset_name = "Intel", .reset_cmd = intel_reset_cmd, .status_cmd = intel_status_cmd, .unlock_sector = intel_sector_unlock, .erase_sector = intel_sector_erase, + .prep_for_program = intel_clear_sr, .loadagent_setbase_cmd = "INFB", .loadagent_program_cmd = "INFW", .needs_unlock = 1,
--- a/loadtools/flmisc.c Tue Jun 17 03:18:02 2014 +0000 +++ b/loadtools/flmisc.c Tue Jun 17 03:40:49 2014 +0000 @@ -187,13 +187,13 @@ char *targv[4], targ_base[10]; int stat; - if (flash_get_cfi(bank) < 0) - return(-1); if (argc != 4) { fprintf(stderr, "usage: %s %s hex-offset hex-data-string\n", argv[0], argv[1]); return(-1); } + if (flash_get_cfi(bank) < 0) + return(-1); bi = flash_bank_info + bank; sprintf(targ_base, "%lx", (u_long) bi->base_addr); targv[0] = bi->ops->loadagent_setbase_cmd;
--- a/loadtools/flprogbin.c Tue Jun 17 03:18:02 2014 +0000 +++ b/loadtools/flprogbin.c Tue Jun 17 03:40:49 2014 +0000 @@ -125,6 +125,10 @@ fclose(binf); return(cc); } + if (bi->ops->prep_for_program(bi) < 0) { + fclose(binf); + return(-1); + } fseek(binf, fileoff, SEEK_SET); targv[0] = bi->ops->loadagent_program_cmd; targv[1] = shortarg;
--- a/loadtools/flprogsrec.c Tue Jun 17 03:18:02 2014 +0000 +++ b/loadtools/flprogsrec.c Tue Jun 17 03:40:49 2014 +0000 @@ -48,6 +48,10 @@ fclose(srr.openfile); return(resp); } + if (bi->ops->prep_for_program(bi) < 0) { + fclose(srr.openfile); + return(-1); + } targv[0] = bi->ops->loadagent_program_cmd; targv[1] = shortarg; targv[2] = longarg;