def prepare(address, ldname, fwname): def encrypt(source, target, env): marlin.encrypt_mks(source, target, env, fwname) marlin.relocate_firmware(address) marlin.custom_ld_script(ldname) marlin.add_post_action(encrypt)
def prepare(address, ldname, fwname): import pioutil if pioutil.is_pio_build(): import marlin def encrypt(source, target, env): marlin.encrypt_mks(source, target, env, fwname) marlin.relocate_firmware(address) marlin.custom_ld_script(ldname) marlin.add_post_action(encrypt)
# # buildroot/share/PlatformIO/scripts/custom_board.py # import marlin board = marlin.env.BoardConfig() address = board.get("build.address", "") if address: marlin.relocate_firmware(address) ldscript = board.get("build.ldscript", "") if ldscript: marlin.custom_ld_script(ldscript)
# # buildroot/share/PlatformIO/scripts/chitu_crypt.py # Customizations for Chitu boards # import os,random,struct,uuid,marlin # Relocate firmware from 0x08000000 to 0x08008800 marlin.relocate_firmware("0x08008800") def calculate_crc(contents, seed): accumulating_xor_value = seed; for i in range(0, len(contents), 4): value = struct.unpack('<I', contents[ i : i + 4])[0] accumulating_xor_value = accumulating_xor_value ^ value return accumulating_xor_value def xor_block(r0, r1, block_number, block_size, file_key): # This is the loop counter loop_counter = 0x0 # This is the key length key_length = 0x18 # This is an initial seed xor_seed = 0x4BAD # This is the block counter block_number = xor_seed * block_number #load the xor key from the file