pio: generate second hex file with target name
@@ -7,12 +7,14 @@ import serial.tools.list_ports
Import("env", "projenv")
+
def before_upload(source, target, env):
for port in serial.tools.list_ports.grep("USB VID:PID=0483:5740"):
with serial.Serial(port.device) as ser:
ser.write(b'R\r\n')
time.sleep(2)
+
env.AddPreAction("upload", before_upload)
env.AddPostAction(
@@ -23,6 +25,14 @@ env.AddPostAction(
]), "Building $BUILD_DIR/${PROGNAME}.hex")
)
+env.AddPostAction(
+ "$BUILD_DIR/${PROGNAME}.elf",
+ env.VerboseAction(" ".join([
+ "$OBJCOPY", "-O", "ihex",
+ "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PIOENV}.hex\""
+ ]), "Building $BUILD_DIR/${PIOENV}.hex")
+)
+
git_version = "unknown"
if 'DRONE_TAG' in os.environ:
@@ -31,7 +41,8 @@ elif 'DRONE_COMMIT' in os.environ:
git_version = os.environ.get('DRONE_COMMIT')
else:
try:
- ret = subprocess.run(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE, text=True)
+ ret = subprocess.run(['git', 'rev-parse', 'HEAD'],
+ stdout=subprocess.PIPE, text=True)
full_hash = ret.stdout.strip()
git_version = full_hash[:7]
except Exception:
