|
|
@ -82,6 +82,27 @@ PX4IO_Uploader::upload(const char *filenames[]) |
|
|
|
#error Must define PX4IO_SERIAL_DEVICE in board configuration to support firmware upload |
|
|
|
#error Must define PX4IO_SERIAL_DEVICE in board configuration to support firmware upload |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* allow an early abort and look for file first */ |
|
|
|
|
|
|
|
for (unsigned i = 0; filenames[i] != nullptr; i++) { |
|
|
|
|
|
|
|
_fw_fd = open(filenames[i], O_RDONLY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_fw_fd < 0) { |
|
|
|
|
|
|
|
log("failed to open %s", filenames[i]); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log("using firmware from %s", filenames[i]); |
|
|
|
|
|
|
|
filename = filenames[i]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (filename == NULL) { |
|
|
|
|
|
|
|
log("no firmware found"); |
|
|
|
|
|
|
|
close(_io_fd); |
|
|
|
|
|
|
|
_io_fd = -1; |
|
|
|
|
|
|
|
return -ENOENT; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_io_fd = open(PX4IO_SERIAL_DEVICE, O_RDWR); |
|
|
|
_io_fd = open(PX4IO_SERIAL_DEVICE, O_RDWR); |
|
|
|
|
|
|
|
|
|
|
|
if (_io_fd < 0) { |
|
|
|
if (_io_fd < 0) { |
|
|
@ -106,26 +127,6 @@ PX4IO_Uploader::upload(const char *filenames[]) |
|
|
|
return -EIO; |
|
|
|
return -EIO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; filenames[i] != nullptr; i++) { |
|
|
|
|
|
|
|
_fw_fd = open(filenames[i], O_RDONLY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_fw_fd < 0) { |
|
|
|
|
|
|
|
log("failed to open %s", filenames[i]); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log("using firmware from %s", filenames[i]); |
|
|
|
|
|
|
|
filename = filenames[i]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (filename == NULL) { |
|
|
|
|
|
|
|
log("no firmware found"); |
|
|
|
|
|
|
|
close(_io_fd); |
|
|
|
|
|
|
|
_io_fd = -1; |
|
|
|
|
|
|
|
return -ENOENT; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct stat st; |
|
|
|
struct stat st; |
|
|
|
if (stat(filename, &st) != 0) { |
|
|
|
if (stat(filename, &st) != 0) { |
|
|
|
log("Failed to stat %s - %d\n", filename, (int)errno); |
|
|
|
log("Failed to stat %s - %d\n", filename, (int)errno); |
|
|
|