def autobuild_arm_program(elfname, test_dir=os.path.join('firmware', 'test'), patch=True, objcopy_flags=""): """ Build the an ARM module for all targets and build all unit tests. If pcb files are given, also build those. """ try: #Build for all targets family = utilities.get_family('module_settings.json') family.for_all_targets( family.tile.short_name, lambda x: arm.build_program(family.tile, elfname, x, patch=patch, objcopy_flags=objcopy_flags)) #Build all unit tests unit_test.build_units(os.path.join('firmware', 'test'), family.targets(family.tile.short_name)) Alias('release', os.path.join('build', 'output')) Alias('test', os.path.join('build', 'test', 'output')) Default(['release', 'test']) autobuild_release(family) if os.path.exists('doc'): autobuild_documentation(family.tile) except IOTileException as e: print(e.format()) sys.exit(1)
def autobuild_onlycopy(): """Autobuild a project that does not require building firmware, pcb or documentation """ try: # Build only release information family = utilities.get_family('module_settings.json') autobuild_release(family) Alias('release', os.path.join('build', 'output')) Default(['release']) except unit_test.IOTileException as e: print(e.format()) Exit(1)
def autobuild_arm_library(libname): try: # Build for all targets family = utilities.get_family('module_settings.json') family.for_all_targets( family.tile.short_name, lambda x: arm.build_library(family.tile, libname, x)) # Build all unit tests unit_test.build_units(os.path.join('firmware', 'test'), family.targets(family.tile.short_name)) Alias('release', os.path.join('build', 'output')) Alias('test', os.path.join('build', 'test', 'output')) Default(['release', 'test']) autobuild_release(family) if os.path.exists('doc'): autobuild_documentation(family.tile) except unit_test.IOTileException as e: print(e.format()) Exit(1)
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() + " 2019 Georgi Angelov >>>>>>>>>>>>") #print( env.Dump ) #################################################### # Build executable and linkable program #################################################### elf = env.BuildProgram() AlwaysBuild(elf) upload = env.Alias("upload", elf, [ env.VerboseAction("$UPLOADCMD", '\033[93m' + "Runing $PROGNAME"), ]) AlwaysBuild(upload) Default(elf)
########################################################################## # # WizIO 2020 Georgi Angelov # http://www.wizio.eu/ # https://github.com/Wiz-IO/platform-sam-lora # ########################################################################## from os.path import join from SCons.Script import (AlwaysBuild, Default, DefaultEnvironment) from colorama import Fore env = DefaultEnvironment() print(Fore.GREEN + '<<<<<<<<<<<< ' + env.BoardConfig().get("name").upper() + " 2019 Georgi Angelov >>>>>>>>>>>>" + Fore.BLACK) elf = env.BuildProgram() bin = env.CreateBin(join("$BUILD_DIR", "${PROGNAME}"), elf) hex = env.CreateHex(join("$BUILD_DIR", "${PROGNAME}"), elf) AlwaysBuild(hex, bin) #env.Depends(hex, env.CreateBin( join("$BUILD_DIR", "${PROGNAME}"), elf )) upload = env.Alias( "upload", hex, [env.VerboseAction("$UPLOADCMD", "\n"), env.VerboseAction("", "\n")]) AlwaysBuild(upload) Default(hex, bin)
env.Append(ARFLAGS=[], ASFLAGS=[], CCFLAGS=[], CXXFLAGS=[], LINKFLAGS=[], CPPDEFINES=[], LIBS=[], BUILDERS=dict(ElfToBin=Builder(action=" ".join( ["$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET"]), suffix=".bin"))) # # Target: Build executable and linkable firmware # target_elf = env.BuildProgram() # # Target: Build the .bin file # target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) # # Target: Upload firmware # upload = env.AddPlatformTarget("upload", target_bin, upload_actions, "Upload") # # Target: Define targets # Default([target_bin, upload])
# Target: Upload env.Replace(UPLOAD_PORT='"Launchpad Pro"') upload = env.VerboseAction( ' '.join(['python3', '$SENDSYSEX', '-p', '$UPLOAD_PORT', '$SOURCE']), 'Uploading $SOURCE') env.AddPlatformTarget( 'upload', target_syx, upload, 'Upload', 'Send firmware to Launchpad Pro over MIDI', ) # Target: Restore env.AddPlatformTarget( 'restore', join(PLATFORM_DIR, 'resources/Launchpad Pro.syx'), upload, 'Restore', 'Restore Launchpad Pro original firmware', ) # Default Targets Default([target_syx, target_size])
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default, DefaultEnvironment) from colorama import Fore from pioasm import dev_pioasm env = DefaultEnvironment() print('<<<<<<<<<<<< ' + env.BoardConfig().get("name").upper() + " 2021 Georgi Angelov >>>>>>>>>>>>") dev_pioasm(env) elf = env.BuildProgram() src = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), elf) prg = env.Alias("buildprog", src, [env.VerboseAction("", "DONE")]) AlwaysBuild(prg) upload = env.Alias("upload", prg, [ env.VerboseAction("$UPLOADCMD", "Uploading..."), env.VerboseAction("", " DONE"), ]) AlwaysBuild(upload) debug_tool = env.GetProjectOption("debug_tool") if None == debug_tool: Default(prg) else: if 'cmsis-dap' in debug_tool: Default(upload) else: Default(prg)
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"), ]) AlwaysBuild( target_upload ) Default( src )
target_elf = env.BuildProgram() # # Target: Build the .hex # if "uploadlazy" in COMMAND_LINE_TARGETS: target_firm = join("$BUILD_DIR", "firmware.hex") else: target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), 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, "$UPLOADCMD") AlwaysBuild(upload) # # Target: Define targets # Default([target_firm, target_size])
# # Target: Verify verilog code # vout = env.IVerilog(TARGET, src_synth) target_verify = env.Alias('verify', vout) AlwaysBuild(target_verify) # # Target: Simulate testbench # sout = env.IVerilog(TARGET_SIM, src_sim) vcd_file = env.VCD(sout) target_sim = env.Alias( 'sim', vcd_file, 'gtkwave {0} {1}.gtkw'.format(vcd_file[0], join(env['PROJECTSRC_DIR'], SIMULNAME))) AlwaysBuild(target_sim) # # Setup default targets # Default([binf]) # # Target: Clean generated files # if GetOption('clean'): env.Default([t, vout, sout, vcd_file])
# 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) # # Target: Print binary size # target_size = env.Alias( "size", target_elf, env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) AlwaysBuild(target_size) AlwaysBuild(target_lst) AlwaysBuild(target_hex) AlwaysBuild(target_bin) # # Target: Define targets # Default(target_bin, target_lst)
(platform.get_package_dir("tool-teensy") or ""), "-board=%s" % env.BoardConfig().id.upper(), "-reboot" ], UPLOADCMD="$UPLOADER $UPLOADERFLAGS") AlwaysBuild( env.Alias("upload", target_firm_hex, [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")])) else: sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol) AlwaysBuild(env.Alias("nobuild", target_firm)) #target_buildprog = env.Alias("buildprog", target_firm) # # Target: Print binary size # target_size = env.Alias( "size", target_firm_elf, env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) AlwaysBuild(target_size) # # Default targets # Default([ env.Alias("buildprog", target_firm), env.Alias("hex", target_firm_hex), env.Alias("dumpDis", object_dump_dis), target_size ])
if "UPLOAD_FLAGS" in env: env.Prepend(UPLOADERFLAGS=["$UPLOAD_FLAGS"]) if env.GetProjectOption("upload_command"): env.Replace(UPLOADCMD=env.GetProjectOption("upload_command")) for item in env.GetExtraScripts("post"): env.SConscript(item, exports="env") ############################################################################## # Checking program size if env.get("SIZETOOL") and "nobuild" not in COMMAND_LINE_TARGETS: env.Depends(["upload", "program"], "checkprogsize") # Replace platform's "size" target with our _new_targets = [t for t in DEFAULT_TARGETS if str(t) != "size"] Default(None) Default(_new_targets) Default("checkprogsize") # Print configured protocols env.AddPreAction( ["upload", "program"], env.VerboseAction( lambda source, target, env: env.PrintUploadInfo(), "Configuring upload protocol...", ), ) AlwaysBuild(env.Alias("debug", DEFAULT_TARGETS)) AlwaysBuild(env.Alias("__test", DEFAULT_TARGETS))
] uploading = [ env.VerboseAction( BTAsize_create, "Generating " + join(env.subst("$BUILD_DIR"), "BTAsize.gdb")), env.VerboseAction( fwsize_create, "Generating " + join(env.subst("$BUILD_DIR"), "fwsize.gdb")), env.VerboseAction( replace_rtl, "Generating " + join(env.subst("$BUILD_DIR"), "rtl_gdb_flash_write.txt")), env.VerboseAction( "$CP $BOOTALL_BIN " + join(env.subst("$BUILD_DIR"), "boot_all.bin"), '.'), env.VerboseAction( env.subst("$UPLOADCMD").replace("\\", "\\\\") + env["OPENOCD_KILL"], "Uploading binary to flash"), ] env.Append(BUILDERS=dict(Manipulate=Builder( action=env.VerboseAction(manipulating, "Manipulating images")), )) program_b = env.BuildProgram() manipulate_images_b = env.Manipulate("$BUILD_DIR/image2_all_ota1.bin", [program_b]) upload = env.Alias("upload", manipulate_images_b, uploading) AlwaysBuild(upload) Default([manipulate_images_b])
env.PrependENVPath('PATH', LOCALBIN) # -- Add this path to the PATH env variable. First the building tools will be # -- searched in the local PATH. If they are not founde, the global ones will # -- be executed (if installed) env.PrependENVPath('PATH', bin_dir) # -- Get a list of all the asm files in the src folfer, in ASCII, with # -- the full path # -- All these programs will be assembled asm_nodes = Glob(join(env['PROJECTSRC_DIR'], '*.asm')) # -- Builder (.asm --> .list) assembler = Builder(action='sasm $SOURCE -o $TARGET', suffix='.list', src_suffix='.asm') env.Append(BUILDERS={'Assemble': assembler}) progs = env.Assemble(asm_nodes) try: prog = progs[0] except IndexError: prog = None print("Warning: NO .asm files!!!") upload = env.Alias('upload', prog, 'sboot $SOURCE') AlwaysBuild(upload) Default(progs)
CORELIBS = env.ProcessGeneral() # # Target: Build executable and linkable firmware # target_elf = env.BuildFirmware(CORELIBS + ["c", "gcc", "m"]) # # Target: Build the .bin file # if "uploadlazy" in COMMAND_LINE_TARGETS: target_bin = join("$BUILD_DIR", "firmware.bin") else: target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) # # Target: Upload firmware # upload = env.Alias(["upload", "uploadlazy"], target_bin, "$UPLOADCMD") AlwaysBuild(upload) # # Target: Define targets # Default(target_bin)
'sim', vcd_file, 'gtkwave {0} {1}.gtkw'.format(vcd_file[0], join(env['PROJECTSRC_DIR'], SIMULNAME))) AlwaysBuild(target_sim) # -- Verilator builder verilator = Builder( action= 'verilator --lint-only -v {0}/ecp5/cells_sim.v -DNO_INCLUDES {1} {2} {3} {4} $SOURCES' .format(YOSYS_PATH, '-Wall', '-Wno-style', '', ''), src_suffix='.v') env.Append(BUILDERS={'Verilator': verilator}) # --- Lint lout = env.Verilator(TARGET, src_synth) lint = env.Alias('lint', lout) AlwaysBuild(lint) # # Setup default targets # Default([bit]) # # Target: Clean generated files # if GetOption('clean'): env.Default([t, vout, sout, vcd_file])
--exclude=lib/aquarium_lights/src/main.cpp \ --lib="test_lib/unity" \ test Problems: - Adding multiple test files does NOT work, bc the compilation of 'program' lumps together every testfile in one executable and fails with duplicate symbols """ import os env = DefaultEnvironment() #env.Dump() def builder_unit_test(target, source, env): app = str(source[0].abspath) return os.spawnl(os.P_WAIT, app, app) # Create a builder for tests bld = Builder(action=builder_unit_test) env.Append(BUILDERS={'Test': bld}) # Test test_lib1 = env.Program('test_color_exec', 'color/test_color.cpp') tests = [env.Test("test.passed.1", test_lib1)] Default(tests)
UPLOADERFLAGS=openocd_args, UPLOADCMD="$UPLOADER $UPLOADERFLAGS") upload_source = join("$BUILD_DIR", "wm_w600_dbg.img") upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] # custom upload tool elif upload_protocol == "custom": upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] else: sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol) AlwaysBuild(env.Alias("upload", upload_source, upload_actions)) # # Information about obsolete method of specifying linker scripts # if any("-Wl,-T" in f for f in env.get("LINKFLAGS", [])): print( "Warning! '-Wl,-T' option for specifying linker scripts is deprecated. " "Please use 'board_build.ldscript' option in your 'platformio.ini' file." ) # # Default targets: Build, create compressed images, print size # Default([target_buildprog, imaging_action, target_size])
"loadbin %s, %s" % (source, board.get("upload.offset_address", "0x08000000")), "r", "q" ] with open(script_path, "w") as fp: fp.write("\n".join(commands)) return script_path env.Replace( __jlink_cmd_script=_jlink_cmd_script, UPLOADER="JLink.exe" if system() == "Windows" else "JLinkExe", UPLOADERFLAGS=[ "-device", board.get("debug", {}).get("jlink_device"), "-speed", env.GetProjectOption("debug_speed", "4000"), "-if", ("jtag" if upload_protocol == "jlink-jtag" else "swd"), "-autoconnect", "1", "-NoGui", "1" ], UPLOADCMD= '$UPLOADER $UPLOADERFLAGS -CommanderScript "${__jlink_cmd_script(__env__, SOURCE)}"' ) upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] upload = env.Alias("upload", upload_source, upload_actions) AlwaysBuild(upload) # # Target: Define targets # Default(target_firm)
# WizIO 2021 Georgi Angelov # http://www.wizio.eu/ # https://github.com/Wiz-IO/wizio-pico from __future__ import print_function from os.path import join from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default, DefaultEnvironment) from colorama import Fore from pioasm import dev_pioasm env = DefaultEnvironment() print( '<<<<<<<<<<<< ' + env.BoardConfig().get("name").upper() + " 2021 Georgi Angelov >>>>>>>>>>>>" ) dev_pioasm(env) elf = env.BuildProgram() src = env.ElfToBin( join("$BUILD_DIR", "${PROGNAME}"), elf ) prg = env.Alias( "buildprog", src, [ env.VerboseAction("", "DONE") ] ) AlwaysBuild( prg ) upload = env.Alias("upload", prg, [ env.VerboseAction("$UPLOADCMD", "Uploading..."), env.VerboseAction("", " DONE"), ]) AlwaysBuild( upload ) Default( prg )
OBJCOPY="aarch64-none-elf-objcopy", RANLIB="aarch64-none-elf-ranlib", SIZETOOL="aarch64-none-elf-size", SIZEPRINTCMD='$SIZETOOL $SOURCES') env.Append(ASFLAGS=["-g"], LINKFLAGS=["-nostdlib", "-nostartfiles", "-Ttext=0x80000"]) env.Append(BUILDERS=dict(ElfToHex=Builder(action=env.VerboseAction( " ".join(["$OBJCOPY", "-O", "ihex", "$SOURCES", "$TARGET"]), "Building $TARGET"), suffix=".ihex"))) target_elf = env.BuildProgram() target_hex = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf) # # Target: Print binary size # target_size = env.Alias( "size", target_elf, env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) AlwaysBuild(target_size) # # Default targets # Default([target_hex])
CORELIBS = env.ProcessGeneral() # # Target: Build executable and linkable firmware # target_elf = env.BuildFirmware(CORELIBS + ["m"]) # # Target: Build the .hex # if "uploadlazy" in COMMAND_LINE_TARGETS: target_hex = join("$BUILD_DIR", "firmware.hex") else: target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) # # Target: Upload firmware # upload = env.Alias(["upload", "uploadlazy"], target_hex, "$UPLOADCMD") AlwaysBuild(upload) # # Target: Define targets # Default(target_hex)
"-v", "--imagepackage", "$SOURCE" ]), ] ) ) ) # # Target: Build executable and linkable firmware # target_elf = env.BuildProgram() # # Target: Build the .imagepackage file # target_approot = env.CreateAppRoot(join("$BUILD_DIR", "approot"), target_elf) target_imagepackage = env.CreateImagePackage(join("$BUILD_DIR", "firmware"), target_approot) # # Target: Upload firmware # upload = env.Alias(["upload"], env.DeployImagePackage(target_imagepackage)) AlwaysBuild(upload) # # Target: Define targets # Default(target_imagepackage)
CXX="${_BINPREFIX}g++", OBJCOPY="${_BINPREFIX}objcopy", RANLIB="${_BINPREFIX}ranlib", SIZETOOL="${_BINPREFIX}size", SIZEPRINTCMD='"$SIZETOOL" $SOURCES', PROGSUFFIX=".exe") if get_systype() == "darwin_x86_64": env.Replace(_BINPREFIX="i586-mingw32-") elif get_systype() in ("linux_x86_64", "linux_i686"): env.Replace(_BINPREFIX="i686-w64-mingw32-") # # Target: Build executable program # target_bin = env.BuildProgram() # # Target: Print binary size # target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD") AlwaysBuild(target_size) # # Target: Define targets # Default([target_bin])
elif (family == "XMC4700" or family == "XMC4800"): commands = [ "setbmi 3", "loadbin %s,0x08000000" % source, "r", "g", "exit" ] with open(script_path, "w") as fp: fp.write("\n".join(commands)) return script_path __jlink_cmd_script = _jlink_cmd_script(env, target_hex[0]) env.Append(jlink_script=__jlink_cmd_script) print "script path", __jlink_cmd_script env.Replace( UPLOADER="JLink.exe" if system() == "Windows" else "JLinkExe", UPLOADERFLAGS=[ "-device", env.BoardConfig().get("debug", {}).get("jlink_device"), "-speed", "4000", "-if", "swd", "-autoconnect", "1" ], UPLOADCMD="$UPLOADER $UPLOADERFLAGS -CommanderScript $jlink_script") upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] AlwaysBuild(env.Alias("upload", target_hex, upload_actions)) # # Target: Define targets # Default([target_hex, target_size])
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] else: sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol) env.AddPlatformTarget("upload", target_firm, upload_actions, "Upload") # # Target: Erase Flash # env.AddPlatformTarget("erase", None, env.VerboseAction("$ERASECMD", "Erasing..."), "Erase Flash") # # Information about obsolete method of specifying linker scripts # if any("-Wl,-T" in f for f in env.get("LINKFLAGS", [])): print( "Warning! '-Wl,-T' option for specifying linker scripts is deprecated. " "Please use 'board_build.ldscript' option in your 'platformio.ini' file." ) # # Default targets # Default([target_buildprog, target_size])
target_bin, sizePrintCMD, "Program Size", "Calculate program size", ) # # Target: Upload firmware # upload_protocol = env.subst("$UPLOAD_PROTOCOL") upload_port = env.subst("$UPLOAD_PORT") upload_actions = [] if upload_protocol == "easy-pdk-programmer": env.Replace(UPLOADER="easypdkprog", UPLOADERFLAGS=['-n', board_config.get("build.mcu")], UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS write $SOURCE') if upload_port: env.Append(UPLOADERFLAGS=["--port", upload_port]) upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] else: sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol) AlwaysBuild(env.Alias("upload", target_ihx, upload_actions)) # # Target: Define targets # Default(target_bin, target_size)