Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Coenen <manuel@duet3d.com>2021-02-15 14:43:30 +0300
committerManuel Coenen <manuel@duet3d.com>2021-02-15 14:43:30 +0300
commita0ad84462bc8dbe98204ade0e2f65cdb2a0fdd32 (patch)
tree801566bf51de732b12335d61acf077706c1701b2 /src/RepRap.cpp
parenta6c1e6f32ed60ae51a1abf2a66abf47343ba4ce2 (diff)
Add M997 P parameter to specify firmware binary to use
Diffstat (limited to 'src/RepRap.cpp')
-rw-r--r--src/RepRap.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/RepRap.cpp b/src/RepRap.cpp
index bb77f424..4b9253b2 100644
--- a/src/RepRap.cpp
+++ b/src/RepRap.cpp
@@ -2682,13 +2682,15 @@ bool RepRap::WriteToolParameters(FileStore *f, const bool forceWriteOffsets) noe
#else
// Check the prerequisites for updating the main firmware. Return True if satisfied, else print a message to 'reply' and return false.
-bool RepRap::CheckFirmwareUpdatePrerequisites(const StringRef& reply) noexcept
+bool RepRap::CheckFirmwareUpdatePrerequisites(const StringRef& reply, const StringRef& filenameRef) noexcept
{
#if HAS_MASS_STORAGE
- FileStore * const firmwareFile = platform->OpenFile(FIRMWARE_DIRECTORY, IAP_FIRMWARE_FILE, OpenMode::read);
+ FileStore * const firmwareFile = platform->OpenFile(FIRMWARE_DIRECTORY, filenameRef.IsEmpty() ? IAP_FIRMWARE_FILE : filenameRef.c_str(), OpenMode::read);
if (firmwareFile == nullptr)
{
- reply.printf("Firmware binary \"%s\" not found", FIRMWARE_DIRECTORY IAP_FIRMWARE_FILE);
+ String<MaxFilenameLength> firmwareBinaryLocation;
+ MassStorage::CombineName(firmwareBinaryLocation.GetRef(), FIRMWARE_DIRECTORY, filenameRef.IsEmpty() ? IAP_FIRMWARE_FILE : filenameRef.c_str());
+ reply.printf("Firmware binary \"%s\" not found", firmwareBinaryLocation.c_str());
return false;
}
@@ -2700,7 +2702,7 @@ bool RepRap::CheckFirmwareUpdatePrerequisites(const StringRef& reply) noexcept
firmwareFile->Seek(32) &&
#endif
- firmwareFile->Read(reinterpret_cast<char*>(&firstDword), sizeof(firstDword)) == (int)sizeof(firstDword);
+ firmwareFile->Read(reinterpret_cast<char*>(&firstDword), sizeof(firstDword)) == (int)sizeof(firstDword);
firmwareFile->Close();
if (!ok || firstDword !=
#if SAME5x
@@ -2727,7 +2729,7 @@ bool RepRap::CheckFirmwareUpdatePrerequisites(const StringRef& reply) noexcept
}
// Update the firmware. Prerequisites should be checked before calling this.
-void RepRap::UpdateFirmware() noexcept
+void RepRap::UpdateFirmware(const StringRef& filenameRef) noexcept
{
#if HAS_MASS_STORAGE
FileStore * const iapFile = platform->OpenFile(FIRMWARE_DIRECTORY, IAP_UPDATE_FILE, OpenMode::read);
@@ -2737,12 +2739,13 @@ void RepRap::UpdateFirmware() noexcept
return;
}
+
PrepareToLoadIap();
// Use RAM-based IAP
iapFile->Read(reinterpret_cast<char *>(IAP_IMAGE_START), iapFile->Length());
iapFile->Close();
- StartIap();
+ StartIap(filenameRef);
#endif
}
@@ -2798,7 +2801,7 @@ void RepRap::PrepareToLoadIap() noexcept
#endif
}
-void RepRap::StartIap() noexcept
+void RepRap::StartIap(const StringRef& filenameRef) noexcept
{
// Disable all interrupts, then reallocate the vector table and program entry point to the new IAP binary
// This does essentially what the Atmel AT02333 paper suggests (see 3.2.2 ff)
@@ -2827,7 +2830,9 @@ void RepRap::StartIap() noexcept
#if HAS_MASS_STORAGE
// Newer versions of IAP reserve space above the stack for us to pass the firmware filename
- static const char filename[] = FIRMWARE_DIRECTORY IAP_FIRMWARE_FILE;
+ String<MaxFilenameLength> firmwareFileLocation;
+ MassStorage::CombineName(firmwareFileLocation.GetRef(), FIRMWARE_DIRECTORY, filenameRef.IsEmpty() ? IAP_FIRMWARE_FILE : filenameRef.c_str());
+ const char* filename = firmwareFileLocation.c_str();
const uint32_t topOfStack = *reinterpret_cast<uint32_t *>(IAP_IMAGE_START);
if (topOfStack + sizeof(filename) <=
# if SAME5x
@@ -2839,7 +2844,7 @@ void RepRap::StartIap() noexcept
# endif
)
{
- memcpy(reinterpret_cast<char*>(topOfStack), filename, sizeof(filename));
+ strcpy(reinterpret_cast<char*>(topOfStack), filename);
}
#endif