deployer: Add support for a CanBoot "deployer"
Support building a "flashing application" that one may run from an existing bootloader. This flashing application will then flash the main CanBoot binary to the start of flash. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
1 parent
ed2bf3e8b0
commit
f4ac6470bf
16 files changed
+505
-41
No files matched your search
@@ -13,6 +13,29 @@ Rerun "make menuconfig" and either increase the APPLICATION_START or
|
||||
disable features to reduce the final binary size.
|
||||
"""
|
||||
|
||||
C_TEMPLATE = """
|
||||
/* DO NOT EDIT! This is an autogenerated file. See scripts/buildbinary.py. */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "deployer.h"
|
||||
|
||||
const uint8_t deployer_canboot_binary[] = {
|
||||
%s
|
||||
};
|
||||
|
||||
const uint32_t deployer_canboot_binary_size = %d;
|
||||
"""
|
||||
|
||||
def format_c_code(data):
|
||||
ldata = len(data)
|
||||
data = data + (b"\xff" * (8 - (ldata % 8)))
|
||||
vals = [" "]
|
||||
for i, d in enumerate(data):
|
||||
vals.append("0x%02x," % (d,))
|
||||
if i % 14 == 13:
|
||||
vals.append("\n ")
|
||||
return C_TEMPLATE % ("".join(vals), ldata)
|
||||
|
||||
def update_lpc176x_checksum(data):
|
||||
data28 = data[:28]
|
||||
words = struct.unpack('<IIIIIII', data28)
|
||||
@@ -25,6 +48,7 @@ def main():
|
||||
parser.add_argument("-s", "--start", help="Address of application start")
|
||||
parser.add_argument("-l", "--lpc176x", action='store_true',
|
||||
help="Perform lpc176x checksum")
|
||||
parser.add_argument("-c", "--code", help="C code file containing binary")
|
||||
parser.add_argument("input_file", help="Raw binary filename")
|
||||
parser.add_argument("output_file", help="Final binary filename")
|
||||
args = parser.parse_args()
|
||||
@@ -45,6 +69,11 @@ def main():
|
||||
if args.lpc176x:
|
||||
data = update_lpc176x_checksum(data)
|
||||
|
||||
if args.code:
|
||||
f = open(args.code, 'w')
|
||||
f.write(format_c_code(data))
|
||||
f.close()
|
||||
|
||||
f = open(args.output_file, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
Reference in new issue
Block a user