diff --git a/src/p7os/args.c b/src/p7os/args.c index 293beae..1a53066 100644 --- a/src/p7os/args.c +++ b/src/p7os/args.c @@ -70,6 +70,7 @@ static const char help_main1[] = " If this option isn't used, the program will look for a\n" " calculator connected using direct USB.\n" " --no-prepare Use the current environment, instead of uploading one.\n" +" --erase-flash Instead of 0xA0270000 the last erase addr is 0xA0400000.\n" " -u, --uexe Use a custom update program.\n" " If `--no-prepare` is not given, this option is " "required.\n" @@ -181,6 +182,7 @@ static const struct option longopts[] = { {"version", no_argument, NULL, 'v'}, {"com", required_argument, NULL, 'c'}, {"no-prepare", no_argument, NULL, 'n'}, + {"erase-flash", no_argument, NULL, 'e'}, {"uexe", required_argument, NULL, 'u'}, {"output", required_argument, NULL, 'o'}, {"log", required_argument, NULL, 'l'}, @@ -225,7 +227,7 @@ int parse_args(int ac, char **av, args_t *args) version = 1; break; - /* COM port, should prepare or not. */ + /* COM port, should prepare or not, should erase flash or not. */ case 'c': args->com = optarg; @@ -233,6 +235,9 @@ int parse_args(int ac, char **av, args_t *args) case 'n': args->noprepare = 1; break; + case 'e': + args->eraseflash = 1; + break; /* log level, Update.Exe, output path */ diff --git a/src/p7os/main.h b/src/p7os/main.h index c66e309..7000335 100644 --- a/src/p7os/main.h +++ b/src/p7os/main.h @@ -38,6 +38,7 @@ enum menu_e { typedef struct { enum menu_e menu; int noprepare; + int eraseflash; /* communication and tweaks */ const char *com; diff --git a/src/p7os/procs/fxremote_flash.c b/src/p7os/procs/fxremote_flash.c index fd703a3..2b19105 100644 --- a/src/p7os/procs/fxremote_flash.c +++ b/src/p7os/procs/fxremote_flash.c @@ -177,11 +177,11 @@ int fxremote_flash(args_t *args) * Maybe it just ANDs, or something...? Anyway, I'll do it as well. */ { - int num = 1, total = (top - 0xA0010000) / 0x10000; + int num = 1, total = ((args->eraseflash ? 0xA0280000 : top) - 0xA0010000) / 0x10000; osdisp_init(&osdisp_cookie, "Clearing the sectors.", "Cleared!"); osdisp(&osdisp_cookie, 1, 0); - for (addr = 0xA0010000; addr < top; addr += 0x10000) { + for (addr = 0xA0010000; addr < (args->eraseflash ? 0xA0280000 : top); addr += 0x10000) { casio_uint32_t localaddr; localaddr = casio_htobe32(addr);