target_firm = env.DataToBin( join("$BUILD_DIR", "spiffs"), "$PROJECTDATA_DIR") AlwaysBuild(target_firm) elif "uploadlazy" in COMMAND_LINE_TARGETS: if "PIOFRAMEWORK" not in env: target_firm = [ join("$BUILD_DIR", "firmware_00000.bin"), join("$BUILD_DIR", "firmware_40000.bin") ] else: target_firm = join("$BUILD_DIR", "firmware.bin") else: if "PIOFRAMEWORK" not in env: target_firm = env.ElfToBin( [join("$BUILD_DIR", "firmware_00000"), join("$BUILD_DIR", "firmware_40000")], target_elf) else: target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) # # Target: Print binary size # target_size = env.Alias( "size", target_elf, env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) AlwaysBuild(target_size) # # Target: Upload firmware or SPIFFS image
else: target_elf = env.BuildProgram() if "SOFTDEVICEHEX" in env: target_firm = env.MergeHex( join("$BUILD_DIR", "${PROGNAME}"), env.ElfToHex(join("$BUILD_DIR", "userfirmware"), target_elf)) elif "nrfutil" == upload_protocol and use_adafruit: target_firm = env.PackageDfu( join("$BUILD_DIR", "${PROGNAME}"), env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf)) elif "nrfjprog" == upload_protocol: target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf) elif "sam-ba" == upload_protocol: target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf) else: if "DFUBOOTHEX" in env: target_firm = env.SignBin( join("$BUILD_DIR", "${PROGNAME}"), env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf)) else: target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf) env.Depends(target_firm, "checkprogsize") AlwaysBuild(env.Alias("nobuild", target_firm)) target_buildprog = env.Alias("buildprog", target_firm, target_firm) if "DFUBOOTHEX" in env: env.Append(
if not env.get("PIOFRAMEWORK"): env.SConscript("frameworks/_bare.py", exports="env") # # Target: Build executable and linkable firmware # target_elf = None if "nobuild" in COMMAND_LINE_TARGETS: target_elf = os.path.join("$BUILD_DIR", "${PROGNAME}.elf") target_bin = os.path.join("$BUILD_DIR", "${PROGNAME}.bin") target_vh = os.path.join("$BUILD_DIR", "${PROGNAME}.vh") else: target_elf = env.BuildProgram() target_bin = env.ElfToBin(os.path.join("$BUILD_DIR", "${PROGNAME}"), target_elf) target_vh = env.BinToVh(os.path.join("$BUILD_DIR", "${PROGNAME}"), target_bin) AlwaysBuild(env.Alias("nobuild", target_bin)) target_buildprog = env.Alias("buildprog", target_bin, target_bin) env.AddPostAction( target_elf, env.VerboseAction(generate_disassembly, "Generating disassembly")) # # Target: Print binary size # target_size = env.AddPlatformTarget(
UPLOADCMD='$UPLOADER $UPLOADERFLAGS $UPLOADERPARAMS $PROJECT_DIR/$SOURCES') # # Target: Build executable and linkable firmware # target_elf = env.BuildProgram() # # Target: Build the .bin file # if "uploadlazy" in COMMAND_LINE_TARGETS: target_firm = join("$BUILD_DIR", "firmware.bin") else: target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) # # Target: Print binary size # target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") AlwaysBuild(target_size) # # Target: Upload by default .bin file # upload = env.Alias(["upload", "uploadlazy"], target_firm, [BeforeUpload, "$UPLOADCMD"])
# The source code of "platformio-build-tool" is here # https://github.com/platformio/platformio-core/blob/develop/platformio/builder/tools/platformio.py # # Target: Build executable and linkable firmware # target_elf = env.BuildProgram() AlwaysBuild(target_elf) # # Target: Build the .bin file # _name = env.get("PROGNAME") target_bin = env.ElfToBin(join("$BUILD_DIR", _name), target_elf) # Target: Build the .hex file # target_hex = env.ElfToHex(join("$BUILD_DIR", _name), target_elf) # Target: Build the .lst file # target_lst = env.ElfToLst(join("$BUILD_DIR", _name), target_elf) # # Target: Upload firmware # upload = env.Alias(["upload"], target_bin, "$UPLOADCMD") AlwaysBuild(upload) #
SIZEPROGREGEXP=r"^(?:\.text|\.data|\.bootloader)\s+(\d+).*", SIZEDATAREGEXP=r"^(?:\.data|\.bss|\.noinit)\s+(\d+).*", SIZECHECKCMD="$SIZETOOL -A -d $SOURCES", SIZEPRINTCMD='$SIZETOOL --mcu=$BOARD_MCU -C -d $SOURCES', PROGSUFFIX=".elf", UPLOADNAME=join("$BUILD_DIR", "${PROGNAME}.cfg"), ) #################################################### # Target: Build executable and linkable program #################################################### elf = None elf = env.BuildProgram() src = env.GFH( join("$BUILD_DIR", "${PROGNAME}"), env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), elf), ) AlwaysBuild( env.Alias("nobuild", src) ) #################################################### # Target: Upload BC66 #################################################### target_upload = env.Alias("upload", src, [ env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."), env.VerboseAction("", "--- WAITING MODULE ---"), env.VerboseAction("$UPLOADCMD", "RESET BOARD TO START FLASHING"), env.VerboseAction("", "POWER ON BOARD"), ])
" ".join(['"$PYTHONEXE"', '"$HEADERTOOL"', "$SOURCES", "$TARGET"]), "Adding NS2 header"), suffix=".bin"))) # # Target: Build executable and linkable program # target_elf = None if "nobuild" in COMMAND_LINE_TARGETS: target_prog = join("$BUILD_DIR", "${PROGNAME}.bin") else: target_elf = env.BuildProgram() target_prog = env.NS2Bin( join("$BUILD_DIR", "${PROGNAME}"), env.ElfToBin(join("$BUILD_DIR", "interim_program"), target_elf)) AlwaysBuild(env.Alias("nobuild", target_prog)) target_buildprog = env.Alias("buildprog", target_prog, target_prog) # # Target: Print binary size # target_size = env.Alias( "size", target_elf, env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) AlwaysBuild(target_size) # # Target: Upload by default .bin file
target_elf = env.BuildFirmware() # # Target: Build the .hex # if "uploadlazy" in COMMAND_LINE_TARGETS: target_firm = [ join("$BUILD_DIR", "firmware_00000.bin"), join("$BUILD_DIR", "firmware_%s.bin" % ("40000" if "FRAMEWORK" not in env else "10000")) ] else: target_firm = env.ElfToBin( [join("$BUILD_DIR", "firmware_00000"), join("$BUILD_DIR", "firmware_%s" % ("40000" if "FRAMEWORK" not in env else "10000"))], target_elf) # # Target: Print binary size # target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") AlwaysBuild(target_size) # # Target: Upload firmware # upload = env.Alias(["upload", "uploadlazy"], target_firm,
env.Replace( PARTITIONS_TABLE_CSV=full_partitions_csv if full_partitions_csv and isfile(full_partitions_csv) else abspath(partitions_csv)) partition_table = env.Command( join("$BUILD_DIR", "partitions.bin"), "$PARTITIONS_TABLE_CSV", env.VerboseAction('"$PYTHONEXE" "%s" -q $SOURCE $TARGET' % join( FRAMEWORK_DIR, "components", "partition_table", "gen_esp32part.py"), "Generating partitions $TARGET")) env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table) # # Compile bootloader # env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", env.ElfToBin( join("$BUILD_DIR", "bootloader"), build_espidf_bootloader())) # # Target: Build Core Library # libs = [] lib_build=[] build_dirs = [ "esp8266", "util", "nvs_flash", "newlib", "ssl", "bootloader_support", "log", "esp-tls", "lwip", "tcpip_adapter", "spi_flash", "heap", "freertos", "app_update", "json", "wpa_supplicant", "coap", "esp_http_client", "esp_http_server", "tcp_transport", "http_parser", "jsmn", "protobuf-c", "pthread", "smartconfig_ack", "spiffs", "vfs", "mdns", "libsodium", "mqtt",
# linker_script = env.Command( join("$BUILD_DIR", "esp32_out.ld"), join("$ESPIDF_DIR", "components", "esp32", "ld", "esp32.ld"), "$CC -I$PROJECTSRC_DIR -C -P -x c -E $SOURCE -o $TARGET") env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script) # # Compile bootloader # env.Depends( "$BUILD_DIR/$PROGNAME$PROGSUFFIX", env.ElfToBin(join("$BUILD_DIR", "bootloader"), build_espidf_bootloader())) # # Target: Build Core Library # libs = [] ignore_dirs = ("bootloader", "esptool_py", "idf_test", "newlib", "partition_table") for d in listdir(join(FRAMEWORK_DIR, "components")): if d in ignore_dirs: continue if isdir(join(FRAMEWORK_DIR, "components", d)): libs.append(
# # Support: Quectel # https://www.quectel.com/support/contact.htm # # Support: Comet Electronics # https://www.comet.bg/?cid=92 ########################################################################## from os.path import join from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default, DefaultEnvironment) from colorama import Fore env = DefaultEnvironment() print(Fore.GREEN + '<<<<<<<<<<<< '+env.BoardConfig().get("name").upper()+" 2018 Georgi Angelov >>>>>>>>>>>>") #################################################### # Build executable and linkable program #################################################### elf = env.BuildProgram() src = env.MakeHeader( join("$BUILD_DIR", "${PROGNAME}"), env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), elf) ) AlwaysBuild( src ) upload = env.Alias("upload", src, [ env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."), env.VerboseAction("$UPLOADCMD", '\033[93m'+"Uploading: $PROGNAME"), env.VerboseAction("", '\033[93m'+"Ready"), ]) AlwaysBuild( upload ) Default( src )
elif env.subst("$PIOFRAMEWORK") in ("arduino", "simba"): target_firm = join("$BUILD_DIR", "${PROGNAME}.bin") else: target_firm = [ join("$BUILD_DIR", "eagle.flash.bin"), join("$BUILD_DIR", "eagle.irom0text.bin") ] else: if set(["buildfs", "uploadfs", "uploadfsota"]) & set(COMMAND_LINE_TARGETS): target_firm = env.DataToBin(join("$BUILD_DIR", "spiffs"), "$PROJECTDATA_DIR") AlwaysBuild(target_firm) AlwaysBuild(env.Alias("buildfs", target_firm)) else: if env.subst("$PIOFRAMEWORK") in ("arduino", "simba"): target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf) else: target_firm = env.ElfToBin([ join("$BUILD_DIR", "eagle.flash.bin"), join("$BUILD_DIR", "eagle.irom0text.bin") ], target_elf) AlwaysBuild(env.Alias("nobuild", target_firm)) target_buildprog = env.Alias("buildprog", target_firm, target_firm) # update max upload size based on CSV file if env.get("PIOMAINPROG"): env.AddPreAction( "checkprogsize", env.VerboseAction( lambda source, target, env: _update_max_upload_size(env),
# # Target: Build executable and linkable firmware or SPIFFS image # def __tmp_hook_before_pio_3_2(): env.ProcessFlags(env.get("BUILD_FLAGS")) # append specified LD_SCRIPT if ("LDSCRIPT_PATH" in env and not any(["-Wl,-T" in f for f in env['LINKFLAGS']])): env.Append(LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"']) target_elf = env.BuildProgram() if "PIOFRAMEWORK" in env: target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) if "espidf" in env.subst("$PIOFRAMEWORK"): target_boot = env.ElfToBin( join("$BUILD_DIR", "bootloader"), build_espidf_bootloader()) env.Depends(target_firm, target_boot) target_buildprog = env.Alias("buildprog", target_firm, target_firm) # # Target: Print binary size # target_size = env.Alias( "size", target_elf,