Skip to content

Commit

Permalink
Fix crash if no bootloader given & hex is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
vintagepc committed Jul 20, 2021
1 parent 2bdd92c commit aaa4252
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions MK404.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,31 @@ int main(int argc, char *argv[])
strFW = argFW.getValue();
}

if (!argStrBoot.isSet())
std::string strBoot {""};
{
std::cout << "No bootloader specified, using default: " << argStrBoot.getValue() << '\n';
} else if (argStrBoot.getValue().empty())
{
std::cout << "Empty bootloader filename provided. NOT loading a bootloader.\n";
} else {
std::cout << "Using Bootloader: " << argStrBoot.getValue() << '\n';
auto ifBL = std::ifstream(argStrBoot.getValue());
if (!argStrBoot.isSet() && ifBL.good())
{
std::cout << "No bootloader specified, using default: " << argStrBoot.getValue() << '\n';
strBoot = argStrBoot.getValue();
}
else if (argStrBoot.getValue().empty())
{
std::cout << "Empty bootloader filename provided. NOT loading a bootloader.\n";
}
else if (ifBL.good())
{
std::cout << "Using Bootloader: " << argStrBoot.getValue() << '\n';
strBoot = argStrBoot.getValue();
}
else
{
std::cout << "No bootloader specified, or specified file not found. Skipping!\n";
}
}

void *pRawPrinter = PrinterFactory::CreatePrinter(argModel.getValue(),pBoard,printer,argBootloader.isSet(),bArgHacks,argSerial.isSet(), argSD.getValue() ,
strFW,argSpam.getValue(), argGDB.isSet(), argVCDRate.getValue(),argStrBoot.getValue()); // this line is the CreateBoard() args.
strFW,argSpam.getValue(), argGDB.isSet(), argVCDRate.getValue(),strBoot); // this line is the CreateBoard() args.

pBoard->SetPrimary(true); // This is the primary board, responsible for scripting/dispatch. Blocks contention from sub-boards, e.g. MMU.

Expand Down

0 comments on commit aaa4252

Please sign in to comment.