From fb505709943fc1049aa6e135312ddd2eb663d0cd Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 28 Jul 2022 10:59:55 -0400 Subject: [PATCH] buildbinary: Add support for building lpc176x checksum The lpc176x internal rom checks that the first 8 words of the flash sum to zero. Many flash writing tools for the lpc176x will automatically add the appropriate checksum. However, it can be useful to build the checksum locally so that the image supports direct flash writing. Signed-off-by: Kevin O'Connor --- scripts/buildbinary.py | 13 ++++++++++++- src/lpc176x/Makefile | 4 ++-- src/stm32/Makefile | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/buildbinary.py b/scripts/buildbinary.py index bb2f49c..6660349 100644 --- a/scripts/buildbinary.py +++ b/scripts/buildbinary.py @@ -4,7 +4,7 @@ # Copyright (C) 2022 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. -import sys, argparse +import sys, argparse, struct ERR_MSG = """ The CanBoot binary is too large for the configured APPLICATION_START. @@ -13,10 +13,18 @@ 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('