+ uint16_t len;
+ struct firmware *fw;
+ char *serial = NULL;
+ char *filename = NULL;
+ int block;
+ int pfd;
+ int opt;
+ int debug = 0;
+
+ while((opt = getopt(argc, argv, "S:V")) != -1) {
+ switch (opt) {
+ case 'S':
+ serial = optarg;
+ break;
+ case 'V':
+ printf("flash-hmcfgusb " VERSION "\n");
+ printf("Copyright (c) 2013-16 Michael Gernoth\n\n");
+ exit(EXIT_SUCCESS);
+ case 'h':
+ case ':':
+ case '?':
+ default:
+ flash_hmcfgusb_syntax(argv[0]);
+ exit(EXIT_FAILURE);
+ break;
+ }
+ }
+
+ if (optind == argc - 1) {
+ filename = argv[optind];
+ }
+
+ printf("HM-CFG-USB flasher version " VERSION "\n\n");
+
+ if (!filename) {
+ fprintf(stderr, "Missing firmware filename!\n\n");
+ flash_hmcfgusb_syntax(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ fw = firmware_read_firmware(filename, debug);
+ if (!fw)
+ exit(EXIT_FAILURE);