diff --git a/external/ckcc-protocol b/external/ckcc-protocol index 52b59501..7887bd21 160000 --- a/external/ckcc-protocol +++ b/external/ckcc-protocol @@ -1 +1 @@ -Subproject commit 52b5950105af3c40dc2e6ab7c0b3a161667db787 +Subproject commit 7887bd21b5a328dc7e97fccc2c8685f53803df70 diff --git a/external/micropython b/external/micropython index d680d41b..97d35f05 160000 --- a/external/micropython +++ b/external/micropython @@ -1 +1 @@ -Subproject commit d680d41bb547f6d81e09fa8ce6ddcea14ea97ee0 +Subproject commit 97d35f058f504a354fc6df79a8b3db5c91862501 diff --git a/stm32/bootloader/sigheader.h b/stm32/bootloader/sigheader.h deleted file mode 100644 index 9bc0b036..00000000 --- a/stm32/bootloader/sigheader.h +++ /dev/null @@ -1,92 +0,0 @@ -// (c) Copyright 2018 by Coinkite Inc. This file is covered by license found in COPYING-CC. -// -#pragma once -#include - -// Our simple firmware header. -// -// Although called a header, this data is placed into the middle of the binary. -// It is located at start of firmware + 16k - sizeof(heaer). This is a gap unused in normal -// micropython layout. Exactly the last 64 bytes (signature) should be left out of -// the checksum. We do checksum areas beyond the end of the last byte of firmware (up to length) -// and expect those regions to be unprogrammed flash (ones). -// -// - timestamp must increase with each upgrade (downgrade protection) -// - version_string is for humans only -// - pubkey_num indicates which pubkey was used for signature -// - firmware_length, must be: -// - bigger than minimum length, less than max -// - 512-byte aligned -// - bootloader assumes the flash filesystem (FAT FS) follows the firmware. -// - this C header file is somewhat parsed and used by python signature-adding code -// - timestamp is YYMMDDHHMMSS0000 in BCD -// - -typedef struct { - uint32_t magic_value; // fixed magic value - uint8_t timestamp[8]; // for downgrade protection, this must increase - uint8_t version_string[8]; // zero-terminated string: "1.0.0ab7" for humans - uint32_t pubkey_num; // which pubkey was used to sign binary - uint32_t firmware_length; // must be 512-aligned, and marks start of flash filesystem - uint32_t install_flags; // flags about this release - uint32_t hw_compat; // which hardware can run this release - uint8_t best_ts[8]; // for downgrade protection, recommended min timestamp - uint32_t future[5]; // reserved words - uint8_t signature[64]; // signature over secp256k1 -} coldcardFirmwareHeader_t; - -#define FW_HEADER_SIZE 128 -#define FW_HEADER_OFFSET (0x4000-FW_HEADER_SIZE) - -#define FW_HEADER_MAGIC 0xCC001234 - -// Firmware Image Size - -// arbitrary min size -#define FW_MIN_LENGTH (256*1024) - -// (mk1-3) absolute max size: 1MB flash - 32k for bootloader = 1,015,808 -// - but practical limit for our-protocol USB upgrades: 786432 (or else settings damaged) -#define FW_MAX_LENGTH (0x100000 - 0x8000) - -// .. for Mk4: 2Mbytes, less bootrom of 128k. -#define FW_MAX_LENGTH_MK4 (0x200000 - 0x20000) - -// Arguments to be used w/ python's struct module. -#define FWH_PY_FORMAT " + +// Our simple firmware header. +// +// Although called a header, this data is placed into the middle of the binary. +// It is located at start of firmware + 16k - sizeof(heaer). This is a gap unused in normal +// micropython layout. Exactly the last 64 bytes (signature) should be left out of +// the checksum. We do checksum areas beyond the end of the last byte of firmware (up to length) +// and expect those regions to be unprogrammed flash (ones). +// +// - timestamp must increase with each upgrade (downgrade protection) +// - version_string is for humans only +// - pubkey_num indicates which pubkey was used for signature +// - firmware_length, must be: +// - bigger than minimum length, less than max +// - 512-byte aligned +// - bootloader assumes the flash filesystem (FAT FS) follows the firmware. +// - this C header file is somewhat parsed and used by python signature-adding code +// - timestamp is YYMMDDHHMMSS0000 in BCD +// + +typedef struct { + uint32_t magic_value; // fixed magic value + uint8_t timestamp[8]; // for downgrade protection, this must increase + uint8_t version_string[8]; // zero-terminated string: "1.0.0ab7" for humans + uint32_t pubkey_num; // which pubkey was used to sign binary + uint32_t firmware_length; // must be 512-aligned, and marks start of flash filesystem + uint32_t install_flags; // flags about this release + uint32_t hw_compat; // which hardware can run this release + uint8_t best_ts[8]; // for downgrade protection, recommended min timestamp + uint32_t future[5]; // reserved words + uint8_t signature[64]; // signature over secp256k1 +} coldcardFirmwareHeader_t; + +#define FW_HEADER_SIZE 128 +#define FW_HEADER_OFFSET (0x4000-FW_HEADER_SIZE) + +#define FW_HEADER_MAGIC 0xCC001234 + +// Firmware Image Size + +// arbitrary min size +#define FW_MIN_LENGTH (256*1024) + +// (mk1-3) absolute max size: 1MB flash - 32k for bootloader = 1,015,808 +// - but practical limit for our-protocol USB upgrades: 786432 (or else settings damaged) +#define FW_MAX_LENGTH (0x100000 - 0x8000) + +// .. for Mk4: 2Mbytes, less bootrom of 128k. +#define FW_MAX_LENGTH_MK4 (0x200000 - 0x20000) + +// Arguments to be used w/ python's struct module. +#define FWH_PY_FORMAT "