-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/ble-out-of-band
- Loading branch information
Showing
41 changed files
with
963 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
FROM ghcr.io/philips-software/amp-devcontainer-cpp:v5.5.0@sha256:7ae21bad4d2ad32497e8d395615742074598c829f5c0a575ebfc8cf35ea14a0e | ||
FROM ghcr.io/philips-software/amp-devcontainer-cpp:v5.5.1@sha256:d4c3ac71b832a967d5de37fa115679fc1c9f22313deac2d2bf8d8f575be85062 | ||
|
||
HEALTHCHECK NONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
add_executable(integration_test.flasher) | ||
emil_build_for(integration_test.flasher HOST All) | ||
|
||
target_sources(integration_test.flasher PRIVATE | ||
Main.cpp | ||
) | ||
|
||
target_link_libraries(integration_test.flasher PRIVATE | ||
args | ||
integration_test.logic | ||
hal.generic | ||
services.network_instantiations | ||
) | ||
|
||
if (EMIL_BUILD_WIN) | ||
target_link_libraries(integration_test.flasher PRIVATE hal.windows) | ||
endif() | ||
|
||
if (EMIL_BUILD_UNIX OR EMIL_BUILD_DARWIN) | ||
target_link_libraries(integration_test.flasher PRIVATE hal.unix) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#include "args.hxx" | ||
#include "generated/echo/Testing.pb.hpp" | ||
#include "generated/echo/TracingFlash.pb.hpp" | ||
#include "generated/echo/TracingTesting.pb.hpp" | ||
#include "hal/generic/FileSystemGeneric.hpp" | ||
#include "hal/generic/TimerServiceGeneric.hpp" | ||
#include "integration_test/logic/Flash.hpp" | ||
#include "services/network_instantiations/EchoInstantiation.hpp" | ||
#include "services/network_instantiations/NetworkAdapter.hpp" | ||
#include "services/tracer/GlobalTracer.hpp" | ||
#include "services/tracer/TracerOnIoOutputInfrastructure.hpp" | ||
|
||
namespace | ||
{ | ||
const std::array<uint32_t, 12> stm32f767SectorSizes{ { 32 * 1024, | ||
32 * 1024, | ||
32 * 1024, | ||
32 * 1024, | ||
128 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024, | ||
256 * 1024 } }; | ||
} | ||
|
||
class FirmwareSender | ||
{ | ||
public: | ||
FirmwareSender(const std::vector<uint8_t>& firmware, services::Echo& echo) | ||
: firmware(firmware) | ||
, flash(echo, infra::MakeRange(stm32f767SectorSizes)) | ||
, tester(echo) | ||
{ | ||
tester.RequestSend([this]() | ||
{ | ||
tester.SetTestedMode(testing::TestedMode::reset); | ||
tester.RequestSend([this]() | ||
{ | ||
tester.SetTestedMode(testing::TestedMode::programming); | ||
|
||
services::GlobalTracer().Trace() << "Erasing chip..."; | ||
flash.EraseAll([this]() | ||
{ | ||
services::GlobalTracer().Trace() << "Writing firmware..."; | ||
flash.WriteBuffer(infra::MakeRange(this->firmware), 0, [this]() | ||
{ | ||
services::GlobalTracer().Trace() << "Uploading done"; | ||
done = true; | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
bool Done() const | ||
{ | ||
return done; | ||
} | ||
|
||
private: | ||
std::vector<uint8_t> firmware; | ||
application::FlashProxy flash; | ||
testing::TesterProxy tester; | ||
bool done = false; | ||
|
||
infra::TimerSingleShot timeoutTimer{ std::chrono::minutes(2), [this]() | ||
{ | ||
done = true; | ||
} }; | ||
}; | ||
|
||
struct FlashTracer | ||
{ | ||
FlashTracer(services::TracingEchoOnStreams& echoTracer) | ||
: testerTracer(echoTracer) | ||
, testerObserverTracer(echoTracer) | ||
, flashTracer(echoTracer) | ||
, flashResultTracer(echoTracer) | ||
{} | ||
|
||
testing::TesterTracer testerTracer; | ||
testing::TesterObserverTracer testerObserverTracer; | ||
flash::FlashTracer flashTracer; | ||
flash::FlashResultTracer flashResultTracer; | ||
}; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
args::ArgumentParser parser("Flasher"); | ||
args::Group positionals(parser, "Positional arguments:"); | ||
args::Positional<std::string> targetArgument(positionals, "target", "COM port or hostname", args::Options::Required); | ||
args::Positional<std::string> firmwareArgument(positionals, "firmware", "Binary firmware with which the target attached to Postmaster is upgraded"); | ||
args::HelpFlag help(parser, "help", "display this help menu.", { 'h', "help" }); | ||
|
||
try | ||
{ | ||
parser.ParseCLI(argc, argv); | ||
|
||
static hal::TimerServiceGeneric timerService; | ||
static main_::TracerOnIoOutputInfrastructure tracer; | ||
static main_::NetworkAdapter network; | ||
static hal::FileSystemGeneric fileSystem; | ||
|
||
auto firmware = firmwareArgument ? fileSystem.ReadBinaryFile(args::get(firmwareArgument)) : std::vector<uint8_t>{}; | ||
auto [echo, echoTracer] = application::OpenTracingEcho(args::get(targetArgument), network.ConnectionFactoryWithNameResolver(), tracer.tracer); | ||
|
||
FlashTracer flashTracer(*echoTracer); | ||
FirmwareSender sender(firmware, *echo); | ||
|
||
network.ExecuteUntil([&]() | ||
{ | ||
return sender.Done(); | ||
}); | ||
} | ||
catch (const args::Help&) | ||
{ | ||
std::cout << parser; | ||
return 1; | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
std::cout << ex.what() << std::endl; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.