14 firmware = open(target[0].path,
"rb")
15 lengthfirmware = os.path.getsize(target[0].path)
16 bootloader_dir =
"buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin"
17 bootloader = open(bootloader_dir,
"rb")
18 lengthbootloader = os.path.getsize(bootloader_dir)
19 firmware_with_boothloader_dir = target[0].dir.path +
'/firmware_with_bootloader.bin'
20 if os.path.exists(firmware_with_boothloader_dir):
21 os.remove(firmware_with_boothloader_dir)
22 firmwareimage = open(firmware_with_boothloader_dir,
"wb")
24 while position < lengthbootloader:
25 byte = bootloader.read(1)
26 firmwareimage.write(byte)
29 while position < lengthfirmware:
30 byte = firmware.read(1)
31 firmwareimage.write(byte)
36 firmware_without_bootloader_dir = target[0].dir.path+
'/firmware_for_sd_upload.bin'
37 if os.path.exists(firmware_without_bootloader_dir):
38 os.remove(firmware_without_bootloader_dir)
39 os.rename(target[0].path, firmware_without_bootloader_dir)
42 env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.bin", addboot);