MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / installFromSdDynamic

Function installFromSdDynamic

src/sd_functions.cpp:547–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545}
546
547static bool installFromSdDynamic(
548 File &file, const String &path, uint32_t appSize, uint32_t appOffset, bool spiffs, uint32_t spiffsOffset,
549 uint32_t spiffsSize, uint32_t spiffsCopySize, std::vector<LauncherInstallFatPartition> &fatPartitions
550) {
551 String error;
552 LauncherPartitionTable table;
553 if (!launcherPartitionReadCurrent(table, &error)) {
554 displayRedStripe(error.length() ? error : "Partition read failed");
555 launcherDelayMs(2000);
556 return false;
557 }
558
559 if (appSize == 0 || appOffset + appSize > file.size()) {
560 displayRedStripe("Invalid app image");
561 launcherDelayMs(2000);
562 return false;
563 }
564
565 String appLabel = launcherPartitionNextAppLabel(table, installedAppNameFromPath(path));
566 LauncherPartitionEntry appEntry;
567 LauncherPartitionEntry spiffsEntry;
568 bool hasSpiffsEntry = false;
569
570 if (!launcherSelectInstallLayout(
571 table,
572 appSize,
573 appLabel,
574 spiffs,
575 spiffsSize,
576 fatPartitions,
577 appEntry,
578 spiffsEntry,
579 hasSpiffsEntry,
580 error
581 )) {
582 launcherConsolePrintf("SD install layout failed: %s\n", error.c_str());
583 displayRedStripe(error.length() ? error : "No install space");
584 launcherDelayMs(2000);
585 return false;
586 }
587 if (!launcherPartitionValidate(table, &error)) {
588 displayRedStripe(error.length() ? error : "Invalid table");
589 launcherDelayMs(2000);
590 return false;
591 }
592
593 pauseSdInstallInput();
594 bool success = false;
595 displayRedStripe("Installing APP");
596 prog_handler = 0;
597 if (!flashRawFromSd(file, appOffset, appSize, appEntry, true)) {
598 displayRedStripe(String("APP: ") + launcherUpdateLastErrorName());
599 launcherDelayMs(2000);
600 goto DONE;
601 }
602
603 if (hasSpiffsEntry && spiffsCopySize > 0) {
604 const uint32_t copySize = spiffsCopySize > spiffsEntry.size ? spiffsEntry.size : spiffsCopySize;

Callers 1

updateFromSDFunction · 0.85

Calls 15

displayRedStripeFunction · 0.85
launcherDelayMsFunction · 0.85
installedAppNameFromPathFunction · 0.85
launcherConsolePrintfFunction · 0.85
pauseSdInstallInputFunction · 0.85
flashRawFromSdFunction · 0.85

Tested by

no test coverage detected