mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 15:58:53 +08:00
Updated IO firmware upgrade strategy and locations
This commit is contained in:
@@ -82,6 +82,27 @@ PX4IO_Uploader::upload(const char *filenames[])
|
||||
#error Must define PX4IO_SERIAL_DEVICE in board configuration to support firmware upload
|
||||
#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);
|
||||
|
||||
if (_io_fd < 0) {
|
||||
@@ -106,26 +127,6 @@ PX4IO_Uploader::upload(const char *filenames[])
|
||||
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;
|
||||
if (stat(filename, &st) != 0) {
|
||||
log("Failed to stat %s - %d\n", filename, (int)errno);
|
||||
|
||||
Reference in New Issue
Block a user