mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
Add command line arguments to versionblob.py so that it is easier to use.
This commit is contained in:
parent
adb1e77869
commit
437d33526a
@ -3,9 +3,21 @@
|
||||
# Generate a version blob for
|
||||
# the OpenPilot firmware.
|
||||
#
|
||||
# By E. Lafargue (c) 2011 E. Lafargue & the OpenPilot team
|
||||
# Licence: GPLv3
|
||||
#
|
||||
###
|
||||
# Usage:
|
||||
# versionblob.py --append --firmware=<Firmware file name> --boardid=<Board code>
|
||||
#
|
||||
# append: if present, then append blob to firmware file directly, otherwise create "blob.bin"
|
||||
# firmware: the filename of the firmware binary
|
||||
# boardid: as a string, the board code, for example "0401" for CC board version 1.
|
||||
# should match the codes in firmware description files.
|
||||
#
|
||||
# We have 100 bytes for the whole description.
|
||||
#
|
||||
# Only the first 40 are used by the firmware, the remaining
|
||||
# Only the first 40 are visible on the FirmwareIAP uavobject, the remaining
|
||||
# 60 are ok to use for packaging and will be saved in the flash
|
||||
#
|
||||
# Structure is:
|
||||
@ -13,7 +25,7 @@
|
||||
# 4 bytes: GIT commit tag (short version of SHA1)
|
||||
# 4 bytes: Unix timestamp of compile time
|
||||
# 2 bytes: target platform. Should follow same rule as BOARD_TYPE and BOARD_REVISION in board define files.
|
||||
# 26 bytes: commit tag if it is there, otherwise "Unreleased". Zero-padded
|
||||
# 26 bytes: commit tag if it is there, otherwise branch name. Zero-padded
|
||||
# ---- 40 bytes limit ---
|
||||
# 20 bytes: SHA1 sum of the firmware.
|
||||
# 40 bytes: free for now.
|
||||
@ -21,8 +33,25 @@
|
||||
import binascii
|
||||
import os
|
||||
from time import time
|
||||
import argparse
|
||||
|
||||
# Do the argument parsing:
|
||||
parser = argparse.ArgumentParser(description='Generate firmware desciption blob')
|
||||
parser.add_argument('--append', action='store_true')
|
||||
parser.add_argument('--firmware', help='name of firmware binary file' , required=True)
|
||||
parser.add_argument('--boardid', help='ID of board model, for example 0401 for CopterControl', required=True)
|
||||
args = parser.parse_args()
|
||||
print args
|
||||
|
||||
if args.append == True:
|
||||
print 'Appending description blog directly to ' + args.firmware
|
||||
filename = args.firmware
|
||||
file = open(filename,"ab")
|
||||
else:
|
||||
filename = 'blob.bin'
|
||||
file = open(filename,"wb")
|
||||
|
||||
|
||||
file = open("test.bin","wb")
|
||||
# Write the magic value:
|
||||
file.write("OpFw")
|
||||
# Get the short commit tag of the current git repository.
|
||||
@ -39,7 +68,7 @@ hb = binascii.a2b_hex(hex(int(time())).lstrip('0x'))
|
||||
file.write(hb)
|
||||
|
||||
# Then write board type and board revision
|
||||
hb = binascii.a2b_hex("0401") # CopterControl revision 1
|
||||
hb = binascii.a2b_hex(args.boardid)
|
||||
file.write(hb)
|
||||
|
||||
# Last: a user-friendly description if it exists in GIT, otherwise
|
||||
|
Loading…
x
Reference in New Issue
Block a user