Implement p7os erase flash

This commit is contained in:
Lailouezzz 2020-01-05 18:23:09 +01:00
parent 737e63a312
commit 5e80fec3fe
Signed by: Lailouezzz
GPG Key ID: 03FCE8A99EF8482C
3 changed files with 9 additions and 3 deletions

View File

@ -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 <path> 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 */

View File

@ -38,6 +38,7 @@ enum menu_e {
typedef struct {
enum menu_e menu;
int noprepare;
int eraseflash;
/* communication and tweaks */
const char *com;

View File

@ -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);