Skip to content

Commit 1c05c7a

Browse files
committed
Refactor to latest requirements
1 parent 7f7e868 commit 1c05c7a

File tree

2 files changed

+7
-45
lines changed

2 files changed

+7
-45
lines changed

mdloader_common.c

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ char verbose;
3333
char testmode;
3434
char first_device;
3535
int restart_after_program;
36-
int force_smarteeprom_config;
36+
int ignore_smarteeprom_config;
3737
int hex_cols;
3838
int hex_colw;
3939

@@ -487,19 +487,9 @@ uint8_t configure_smarteeprom(void)
487487
return 1;
488488
}
489489

490-
uint8_t should_reconfigure;
491-
if(force_smarteeprom_config == FORCE_NONE)
490+
if(ignore_smarteeprom_config)
492491
{
493-
should_reconfigure = prompt_yes_no("SmartEEPROM: Your settings do not match the recommended values. Update setting?");
494-
}
495-
else
496-
{
497-
should_reconfigure = (force_smarteeprom_config == FORCE_YES);
498-
}
499-
500-
if(!should_reconfigure)
501-
{
502-
printf("SmartEEPROM: Skipped!\n");
492+
printf("SmartEEPROM: Your settings do not match the recommended values. Skipped!");
503493
return 1;
504494
}
505495

@@ -531,21 +521,6 @@ void strupper(char *str)
531521
}
532522
}
533523

534-
//Prompt for Yy/Nn with message
535-
uint8_t prompt_yes_no(const char* msg)
536-
{
537-
printf(msg);
538-
printf(" (y/n):\n");
539-
540-
char c;
541-
do {
542-
scanf(" %c", &c);
543-
c = toupper(c);
544-
} while(c != 'N' && c != 'Y');
545-
546-
return c == 'Y';
547-
}
548-
549524
//Return file size of given file
550525
int filesize(char *fname)
551526
{
@@ -637,7 +612,7 @@ void display_help(void)
637612
printf(" -s --size size Read firmware size of <size>\n");
638613
printf(" -D --download file Write firmware from <file> into device\n");
639614
printf(" -t --test Test mode (download/upload writes disabled, upload outputs data to stdout, restart disabled)\n");
640-
printf(" --forceeep answer Automatic answer to Smart EEPROM re-configuration prompt <y/n>\n");
615+
printf(" --ignore-eep Ignore differences in SmartEEPROM configuration\n");
641616
printf(" --cols count Hex listing column count <count> [%i]\n", COLS);
642617
printf(" --colw width Hex listing column width <width> [%i]\n", COLW);
643618
printf(" --restart Restart device after successful programming\n");
@@ -646,12 +621,12 @@ void display_help(void)
646621

647622
#define SW_COLS 1000
648623
#define SW_COLW 1001
649-
#define SW_FORCEEEP 1002
650624

651625
//Program command line options
652626
struct option long_options[] = {
653627
//Flags
654-
{ "restart", no_argument, &restart_after_program, 1 },
628+
{ "restart", no_argument, &restart_after_program, 1 },
629+
{ "ignore-eep", no_argument, &ignore_smarteeprom_config, 1 },
655630
//Other
656631
{ "verbose", no_argument, 0, 'v' },
657632
{ "help", no_argument, 0, 'h' },
@@ -666,7 +641,6 @@ struct option long_options[] = {
666641
{ "test", no_argument, 0, 't' },
667642
{ "cols", required_argument, 0, SW_COLS },
668643
{ "colw", required_argument, 0, SW_COLW },
669-
{ "forceeep", required_argument, 0, SW_FORCEEEP },
670644
{ 0, 0, 0, 0 }
671645
};
672646

@@ -676,7 +650,7 @@ int main(int argc, char *argv[])
676650
testmode = 0;
677651
first_device = 0;
678652
restart_after_program = 0;
679-
force_smarteeprom_config = FORCE_NONE;
653+
ignore_smarteeprom_config = 0;
680654
hex_cols = COLS;
681655
hex_colw = COLW;
682656

@@ -797,11 +771,6 @@ int main(int argc, char *argv[])
797771
}
798772
break;
799773

800-
case SW_FORCEEEP:
801-
strlower(optarg);
802-
force_smarteeprom_config = (strstr(optarg, "y") != NULL) ? FORCE_YES : FORCE_NO;
803-
break;
804-
805774
default:
806775
command = CMD_ABORT;
807776
break;

mdloader_common.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ void list_devices(char *first);
187187
// helpers
188188
void strupper(char *str);
189189
void strlower(char *str);
190-
uint8_t prompt_yes_no(const char* msg);
191190

192191
// Smart EEPROM specific
193192
#define NVMCTRL 0x41004000
@@ -205,12 +204,6 @@ uint8_t prompt_yes_no(const char* msg);
205204

206205
#define SLEEP_BETWEEN_WRITES 200
207206

208-
enum eep_force_type {
209-
FORCE_NONE = 0,
210-
FORCE_NO,
211-
FORCE_YES,
212-
};
213-
214207
typedef union {
215208
struct {
216209
uint32_t SBLK : 4; /* bit: 35:32 - Number of NVM Blocks composing a SmartEEPROM sector */

0 commit comments

Comments
 (0)