From 9a0c8f468706f231e6a615a485916d0d5b3fe7d7 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 12 Oct 2017 12:17:04 +0200 Subject: [PATCH] build: introduce PRODUCTION flag --- Makefile | 6 ++++-- SConscript.boardloader | 2 +- SConscript.bootloader | 2 +- embed/boardloader/main.c | 2 +- embed/bootloader/main.c | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 12f161de..72582108 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ ifeq ($(DISPLAY_VSYNC), 0) CFLAGS += -DDISPLAY_VSYNC=0 endif +PRODUCTION ?= 0 + STLINK_VER ?= v2 OPENOCD = openocd -f interface/stlink-$(STLINK_VER).cfg -c "transport select hla_swd" -f target/stm32f4x.cfg @@ -76,10 +78,10 @@ style: ## run code style check on application sources build: build_boardloader build_bootloader build_firmware build_unix build_cross ## build all build_boardloader: ## build boardloader - $(SCONS) CFLAGS="$(CFLAGS)" build/boardloader/boardloader.bin + $(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" build/boardloader/boardloader.bin build_bootloader: ## build bootloader - $(SCONS) CFLAGS="$(CFLAGS)" build/bootloader/bootloader.bin + $(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" build/bootloader/bootloader.bin build_firmware: res build_cross ## build firmware with frozen modules $(SCONS) CFLAGS="$(CFLAGS)" build/firmware/firmware.bin diff --git a/SConscript.boardloader b/SConscript.boardloader index 4121b49f..31c85e6b 100644 --- a/SConscript.boardloader +++ b/SConscript.boardloader @@ -87,7 +87,7 @@ SOURCE_TREZORHAL = [ 'embed/trezorhal/vectortable.s', ] -env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', '')) +env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) env.Replace( AS='arm-none-eabi-as', diff --git a/SConscript.bootloader b/SConscript.bootloader index c367fdc4..244afb3e 100644 --- a/SConscript.bootloader +++ b/SConscript.bootloader @@ -104,7 +104,7 @@ SOURCE_TREZORHAL = [ 'embed/trezorhal/vectortable.s', ] -env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', '')) +env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) env.Replace( AS='arm-none-eabi-as', diff --git a/embed/boardloader/main.c b/embed/boardloader/main.c index cf4f2405..8cab160e 100644 --- a/embed/boardloader/main.c +++ b/embed/boardloader/main.c @@ -113,7 +113,7 @@ bool copy_sdcard(void) const uint8_t BOARDLOADER_KEY_M = 2; const uint8_t BOARDLOADER_KEY_N = 3; static const uint8_t * const BOARDLOADER_KEYS[] = { -#ifdef PRODUCTION_KEYS +#if PRODUCTION (const uint8_t *)"\x0e\xb9\x85\x6b\xe9\xba\x7e\x97\x2c\x7f\x34\xea\xc1\xed\x9b\x6f\xd0\xef\xd1\x72\xec\x00\xfa\xf0\xc5\x89\x75\x9d\xa4\xdd\xfb\xa0", (const uint8_t *)"\xac\x8a\xb4\x0b\x32\xc9\x86\x55\x79\x8f\xd5\xda\x5e\x19\x2b\xe2\x7a\x22\x30\x6e\xa0\x5c\x6d\x27\x7c\xdf\xf4\xa3\xf4\x12\x5c\xd8", (const uint8_t *)"\xce\x0f\xcd\x12\x54\x3e\xf5\x93\x6c\xf2\x80\x49\x82\x13\x67\x07\x86\x3d\x17\x29\x5f\xac\xed\x72\xaf\x17\x1d\x6e\x65\x13\xff\x06", diff --git a/embed/bootloader/main.c b/embed/bootloader/main.c index 4869640b..7643dcc8 100644 --- a/embed/bootloader/main.c +++ b/embed/bootloader/main.c @@ -44,7 +44,7 @@ void display_vendor(const uint8_t *vimg, const char *vstr, uint32_t vstr_len, ui const uint8_t BOOTLOADER_KEY_M = 2; const uint8_t BOOTLOADER_KEY_N = 3; static const uint8_t * const BOOTLOADER_KEYS[] = { -#ifdef PRODUCTION_KEYS +#if PRODUCTION (const uint8_t *)"\xc2\xc8\x7a\x49\xc5\xa3\x46\x09\x77\xfb\xb2\xec\x9d\xfe\x60\xf0\x6b\xd6\x94\xdb\x82\x44\xbd\x49\x81\xfe\x3b\x7a\x26\x30\x7f\x3f", (const uint8_t *)"\x80\xd0\x36\xb0\x87\x39\xb8\x46\xf4\xcb\x77\x59\x30\x78\xde\xb2\x5d\xc9\x48\x7a\xed\xcf\x52\xe3\x0b\x4f\xb7\xcd\x70\x24\x17\x8a", (const uint8_t *)"\xb8\x30\x7a\x71\xf5\x52\xc6\x0a\x4c\xbb\x31\x7f\xf4\x8b\x82\xcd\xbf\x6b\x6b\xb5\xf0\x4c\x92\x0f\xec\x7b\xad\xf0\x17\x88\x37\x51",