Added option to just use dfu tool without issuing reboot command
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2ecdbf6d1f
commit
6a0da17d54
10
src/main.cpp
10
src/main.cpp
|
@ -130,7 +130,8 @@ void read_data(std::unique_ptr<serial::Serial>& ser, uint8_t* data, uint16_t len
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo We need to check if we are already in the bootloader
|
// @todo We need to check if we are already in the bootloader
|
||||||
void program_dfu(std::unique_ptr<serial::Serial>& ser, std::string filename) {
|
void program_dfu(std::unique_ptr<serial::Serial>& ser, std::string filename, bool no_reboot) {
|
||||||
|
if (!no_reboot) {
|
||||||
ser->flushInput();
|
ser->flushInput();
|
||||||
ser->flushOutput();
|
ser->flushOutput();
|
||||||
ser->flush();
|
ser->flush();
|
||||||
|
@ -141,6 +142,7 @@ void program_dfu(std::unique_ptr<serial::Serial>& ser, std::string filename) {
|
||||||
// @todo Can we somehow check if the device is present
|
// @todo Can we somehow check if the device is present
|
||||||
std::cout << "Waiting for device to reboot...\n";
|
std::cout << "Waiting for device to reboot...\n";
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||||
|
}
|
||||||
|
|
||||||
// @todo We need some sort of dfu library because this is terrible
|
// @todo We need some sort of dfu library because this is terrible
|
||||||
std::string cmd = "dfu-util -a 0 -D " + filename + " -s 0x08000000:leave";
|
std::string cmd = "dfu-util -a 0 -D " + filename + " -s 0x08000000:leave";
|
||||||
|
@ -283,13 +285,15 @@ int main(int argc, const char** argv) {
|
||||||
std::string device;
|
std::string device;
|
||||||
uint16_t address;
|
uint16_t address;
|
||||||
std::unique_ptr<serial::Serial> ser = nullptr;
|
std::unique_ptr<serial::Serial> ser = nullptr;
|
||||||
|
bool no_reboot;
|
||||||
|
|
||||||
app.add_option("filename", filename, "File to upload")->required();
|
app.add_option("filename", filename, "File to upload")->required();
|
||||||
app.add_option("--dev,-d", device, "Serial device to use")->default_val("/dev/ttyUSB0");
|
app.add_option("--dev,-d", device, "Serial device to use")->default_val("/dev/ttyUSB0");
|
||||||
|
|
||||||
app.add_subcommand("dfu", "Program STM32 mcu using dfu mode")->callback([&] {
|
CLI::App* dfu = app.add_subcommand("dfu", "Program STM32 mcu using dfu mode")->callback([&] {
|
||||||
program_dfu(ser, filename);
|
program_dfu(ser, filename, no_reboot);
|
||||||
});
|
});
|
||||||
|
dfu->add_option("--no-reboot,-r", no_reboot, "Base address")->default_val(false);
|
||||||
|
|
||||||
CLI::App* rom = app.add_subcommand("rom", "Program ROM/RAM")->callback([&] {
|
CLI::App* rom = app.add_subcommand("rom", "Program ROM/RAM")->callback([&] {
|
||||||
program_rom(ser, filename, address);
|
program_rom(ser, filename, address);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user