FreeCalypso > hg > freecalypso-tools
changeset 711:44cdfc4fed4c
fc-loadtool: flash prot-reg command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 05 Jun 2020 06:46:21 +0000 |
parents | c1f72d807250 |
children | a167d7b376b7 |
files | loadtools/flash.h loadtools/flashops.c loadtools/flmain.c loadtools/flmisc.c |
diffstat | 4 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/loadtools/flash.h Sat May 23 03:39:48 2020 +0000 +++ b/loadtools/flash.h Fri Jun 05 06:46:21 2020 +0000 @@ -58,6 +58,7 @@ int (*unlock_sector)(); int (*erase_sector)(); int (*prep_for_program)(); + int (*read_prot_reg)(); char *loadagent_setbase_cmd; char *loadagent_program_cmd; char *loadagent_binmode_cmd;
--- a/loadtools/flashops.c Sat May 23 03:39:48 2020 +0000 +++ b/loadtools/flashops.c Fri Jun 05 06:46:21 2020 +0000 @@ -90,6 +90,7 @@ .unlock_sector = amd_invalid, .erase_sector = amd_sector_erase, .prep_for_program = noop, + .read_prot_reg = amd_invalid, .loadagent_setbase_cmd = "AMFB", .loadagent_program_cmd = "AMFW", .loadagent_binmode_cmd = "AMFWB", @@ -262,6 +263,25 @@ return(0); } +intel_read_prot_reg(bi, data) + struct flash_bank_info *bi; + uint16_t *data; +{ + int stat, i; + + if (do_w16(bi->base_addr, 0x90)) { + fprintf(stderr, + "unexpected response to w16 for Read ID command\n"); + return(-1); + } + for (i = 0; i < 9; i++) { + stat = do_r16(bi->base_addr + 0x100 + i * 2, data + i); + if (stat) + return(stat); /* error msg already printed */ + } + return(0); +} + struct flash_cmdset flash_cmdset_intel = { .cmdset_name = "Intel", .reset_cmd = intel_reset_cmd, @@ -269,6 +289,7 @@ .unlock_sector = intel_sector_unlock, .erase_sector = intel_sector_erase, .prep_for_program = intel_clear_sr, + .read_prot_reg = intel_read_prot_reg, .loadagent_setbase_cmd = "INFB", .loadagent_program_cmd = "INFW", .loadagent_binmode_cmd = "INFWB", @@ -282,6 +303,7 @@ .unlock_sector = intel_sector_unlock, .erase_sector = intel_sector_erase, .prep_for_program = intel_w30_clear_sr, + .read_prot_reg = intel_read_prot_reg, .loadagent_setbase_cmd = "INFB", .loadagent_program_cmd = "INFW", .loadagent_binmode_cmd = "INFWB",
--- a/loadtools/flmain.c Sat May 23 03:39:48 2020 +0000 +++ b/loadtools/flmain.c Fri Jun 05 06:46:21 2020 +0000 @@ -98,6 +98,7 @@ extern int flashcmd_progbin_wrap(); extern int flashcmd_program_m0(); extern int flashcmd_program_srec(); +extern int flashcmd_protreg(); extern int flashcmd_quickprog(); extern int flashcmd_reset(); extern int flashcmd_sectors(); @@ -123,6 +124,7 @@ {"program-bin", flashcmd_progbin_wrap}, {"program-m0", flashcmd_program_m0}, {"program-srec", flashcmd_program_srec}, + {"prot-reg", flashcmd_protreg}, {"quickprog", flashcmd_quickprog}, {"reset", flashcmd_reset}, {"sectors", flashcmd_sectors},
--- a/loadtools/flmisc.c Sat May 23 03:39:48 2020 +0000 +++ b/loadtools/flmisc.c Fri Jun 05 06:46:21 2020 +0000 @@ -121,6 +121,31 @@ format); } +flashcmd_protreg(argc, argv, bank) + char **argv; +{ + struct flash_bank_info *bi; + uint16_t data[9]; + int rc; + + if (argc > 2) { + fprintf(stderr, "error: too many arguments\n"); + return(-1); + } + if (flash_detect(bank, 0) < 0) + return(-1); + bi = flash_bank_info + bank; + rc = bi->ops->read_prot_reg(bi, data); + if (rc) + return(rc); + printf("Lock word: %04X\n", data[0]); + printf("Factory words: %04X %04X %04X %04X\n", data[1], data[2], + data[3], data[4]); + printf("User words: %04X %04X %04X %04X\n", data[5], data[6], data[7], + data[8]); + return(0); +} + flashcmd_quickprog(argc, argv, bank) char **argv; {