#!/usr/bin/env python3 # Tool to check final CanBoot binary size # # Copyright (C) 2022 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. import sys, argparse, struct ERR_MSG = """ The CanBoot binary is too large for the configured APPLICATION_START. Rerun "make menuconfig" and either increase the APPLICATION_START or disable features to reduce the final binary size. """ def update_lpc176x_checksum(data): data28 = data[:28] words = struct.unpack(' max_size: msg = "\nMaximum size %d. Current size %d.\n\n" % (max_size, len(data)) sys.stderr.write(ERR_MSG + msg) sys.exit(-1) if args.lpc176x: data = update_lpc176x_checksum(data) f = open(args.output_file, 'wb') f.write(data) f.close() if __name__ == '__main__': main()