🐛 Fix Configuration Embedding (#25688)

This commit is contained in:
Giuliano Zaro 2023-04-16 03:26:08 +02:00 committed by GitHub
parent 78bdf34b7b
commit cc35cb3876
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -66,11 +66,19 @@ void GcodeSuite::M502() {
#if ENABLED(CONFIGURATION_EMBEDDING) #if ENABLED(CONFIGURATION_EMBEDDING)
if (parser.seen_test('C')) { if (parser.seen_test('C')) {
SdBaseFile file; MediaFile file;
const uint16_t size = sizeof(mc_zip);
// Need to create the config size on the SD card // Need to create the config size on the SD card
if (file.open(card.getroot(), "mc.zip", O_WRITE|O_CREAT) && file.write(pgm_read_ptr(mc_zip), size) != -1 && file.close()) MediaFile root = card.getroot();
SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'"); if (file.open(&root, "mc.zip", O_WRITE|O_CREAT)) {
bool success = true;
for (uint16_t i = 0; success && i < sizeof(mc_zip); ++i) {
const uint8_t c = pgm_read_byte(&mc_zip[i]);
file.write(c);
}
success = file.close() && success;
if (success) SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'");
}
} }
#endif #endif
} }

View file

@ -56,13 +56,14 @@ def compute_build_signature(env):
files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ] files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ]
build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
build_path_relative = Path('.pio', 'build', env['PIOENV'])
# Check if we can skip processing # Check if we can skip processing
hashes = '' hashes = ''
for header in files_to_keep: for header in files_to_keep:
hashes += get_file_sha256sum(header)[0:10] hashes += get_file_sha256sum(header)[0:10]
marlin_json = build_path / 'marlin_config.json' marlin_json = build_path_relative / 'marlin_config.json'
marlin_zip = build_path / 'mc.zip' marlin_zip = build_path / 'mc.zip'
# Read existing config file # Read existing config file