From: Michel Pollet Date: Thu, 23 Feb 2017 10:59:06 +0000 (+0000) Subject: run_avr: A bit of cosmetic Also, standardize '--' for all long options X-Git-Tag: v1.6~48^2~9^2~1 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=d1cf4ae7d16196a3a585fce2e348829aa1eaa3f0;p=sx%2Fsimavr.git run_avr: A bit of cosmetic Also, standardize '--' for all long options This had to be done at some point Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/run_avr.c b/simavr/sim/run_avr.c index 6841f8b..0a539fa 100644 --- a/simavr/sim/run_avr.c +++ b/simavr/sim/run_avr.c @@ -32,23 +32,31 @@ #include "sim_core_decl.h" -void display_usage(char * app) +static void +display_usage( + const char * app) { - printf("Usage: %s [--list-cores] [--help] [-t] [-g] [-v] [-m ] [-f ] firmware\n", app); - printf( " --list-cores List all supported AVR cores and exit\n" - " --help, -h Display this usage message and exit\n" - " -trace, -t Run full scale decoder trace\n" - " -ti Add trace vector at \n" - " -gdb, -g Listen for gdb connection on port 1234\n" - " -ff Load next .hex file as flash\n" - " -ee Load next .hex file as eeprom\n" - " -v Raise verbosity level (can be passed more than once)\n"); + printf("Usage: %s [...] \n", app); + printf( " [--freq|-f ] Sets the frequency for an .hex firmware\n" + " [--mcu|-m ] Sets the MCU type for an .hex firmware\n" + " [--list-cores] List all supported AVR cores and exit\n" + " [--help|-h] Display this usage message and exit\n" + " [--trace, -t] Run full scale decoder trace\n" + " [-ti ] Add traces for IRQ vector \n" + " [--gdb|-g] Listen for gdb connection on port 1234\n" + " [-ff <.hex file>] Load next .hex file as flash\n" + " [-ee <.hex file>] Load next .hex file as eeprom\n" + " [-v] Raise verbosity level\n" + " (can be passed more than once)\n" + " A .hex or an ELF file. ELF files are\n" + " prefered, and can include debugging syms\n"); exit(1); } -void list_cores() { - printf( - " Supported AVR cores:\n"); +static void +list_cores() +{ + printf( "Supported AVR cores:\n"); for (int i = 0; avr_kind[i]; i++) { printf(" "); for (int ti = 0; ti < 4 && avr_kind[i]->names[ti]; ti++) @@ -58,9 +66,9 @@ void list_cores() { exit(1); } -avr_t * avr = NULL; +static avr_t * avr = NULL; -void +static void sig_int( int sign) { @@ -70,14 +78,17 @@ sig_int( exit(0); } -int main(int argc, char *argv[]) +int +main( + int argc, + char *argv[]) { elf_firmware_t f = {{0}}; - long f_cpu = 0; + uint32_t f_cpu = 0; int trace = 0; int gdb = 0; int log = 1; - char name[16] = ""; + char name[24] = ""; uint32_t loadBase = AVR_SEGMENT_OFFSET_FLASH; int trace_vectors[8] = {0}; int trace_vectors_count = 0; @@ -90,12 +101,12 @@ int main(int argc, char *argv[]) list_cores(); } else if (!strcmp(argv[pi], "-h") || !strcmp(argv[pi], "--help")) { display_usage(basename(argv[0])); - } else if (!strcmp(argv[pi], "-m") || !strcmp(argv[pi], "-mcu")) { + } else if (!strcmp(argv[pi], "-m") || !strcmp(argv[pi], "--mcu")) { if (pi < argc-1) - strcpy(name, argv[++pi]); + strncpy(name, argv[++pi], sizeof(name)); else display_usage(basename(argv[0])); - } else if (!strcmp(argv[pi], "-f") || !strcmp(argv[pi], "-freq")) { + } else if (!strcmp(argv[pi], "-f") || !strcmp(argv[pi], "--freq")) { if (pi < argc-1) f_cpu = atoi(argv[++pi]); else @@ -105,7 +116,7 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[pi], "-ti")) { if (pi < argc-1) trace_vectors[trace_vectors_count++] = atoi(argv[++pi]); - } else if (!strcmp(argv[pi], "-g") || !strcmp(argv[pi], "-gdb")) { + } else if (!strcmp(argv[pi], "-g") || !strcmp(argv[pi], "--gdb")) { gdb++; } else if (!strcmp(argv[pi], "-v")) { log++;