From 6228d187da6752d25748a2db5bc9da13edf2f365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Thu, 23 May 2019 17:33:45 +0200 Subject: [PATCH] add make DEFINE to remove assert ERASE code remove code to assert peer ERASE line by default. see README for more information. Change-Id: I5f88ecf1e2dcf00c0297597f88dd361a6e088c1e --- firmware/Makefile | 6 +++++- firmware/README.txt | 4 ++++ firmware/libboard/qmod/source/board_qmod.c | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/firmware/Makefile b/firmware/Makefile index c0f53f38..fa72bd34 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -120,6 +120,10 @@ C_OBJECTS = $(C_FILES:%.c=%.o) # TRACE_LEVEL_NO_TRACE 0 TRACE_LEVEL ?= 4 +# allow asserting the peer SAM3S ERASE signal to completely erase the flash +# only applicable for qmod board +ALLOW_PEER_ERASE?=0 + DEBUG_PHONE_SNIFF?=0 #CFLAGS+=-DUSB_NO_DEBUG=1 @@ -163,7 +167,7 @@ CFLAGS += -Wno-suggest-attribute=noreturn #CFLAGS += -Wa,-a,-ad CFLAGS += -D__ARM CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb # -mfix-cortex-m3-ldrd -CFLAGS += -ffunction-sections -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -DTRACE_LEVEL=$(TRACE_LEVEL) -DDEBUG_PHONE_SNIFF=$(DEBUG_PHONE_SNIFF) +CFLAGS += -ffunction-sections -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -DTRACE_LEVEL=$(TRACE_LEVEL) -DDEBUG_PHONE_SNIFF=$(DEBUG_PHONE_SNIFF) -DALLOW_PEER_ERASE=$(ALLOW_PEER_ERASE) CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" CFLAGS += -DBOARD=\"$(BOARD)\" -DBOARD_$(BOARD) CFLAGS += -DAPPLICATION=\"$(APP)\" -DAPPLICATION_$(APP) diff --git a/firmware/README.txt b/firmware/README.txt index dcbafb29..fa7f60a8 100644 --- a/firmware/README.txt +++ b/firmware/README.txt @@ -76,6 +76,10 @@ $ make TRACE_LEVEL=4 ``` Accepted values: 0 (NO_TRACE) to 5 (DEBUG) +The qmod specific option `ALLOW_PEER_ERASE` controls if the UART debug command to assert the peer SAM3S ERASE line is present in the code. +Per default this is set to 0 to prevent accidentally erasing all firmware, including the DFU bootloader, which would then need to be flashed using SAM-BA or JTAG/SWD. +Setting `ALLOW_PEER_ERASE` to 1 enables back the debug command and should be used only for debugging or development purposes. + = Flashing To flash a firmware image follow the instructions provided in the [wiki](https://projects.osmocom.org/projects/simtrace2/wiki/). diff --git a/firmware/libboard/qmod/source/board_qmod.c b/firmware/libboard/qmod/source/board_qmod.c index cab52714..4d75b98a 100644 --- a/firmware/libboard/qmod/source/board_qmod.c +++ b/firmware/libboard/qmod/source/board_qmod.c @@ -184,10 +184,12 @@ static void board_exec_dbg_cmd_st12only(int ch) /* returns '1' in case we should break any endless loop */ void board_exec_dbg_cmd(int ch) { +#if (ALLOW_PEER_ERASE > 0) /* this variable controls if it is allowed to assert/release the ERASE line. this is done to prevent accidental ERASE on noisy serial input since only one character can trigger the ERASE. */ static bool allow_erase = false; +#endif switch (ch) { case '?': @@ -209,9 +211,11 @@ void board_exec_dbg_cmd(int ch) } printf("\tX\tRelease peer SAM3 from reset\n\r"); printf("\tx\tAssert peer SAM3 reset\n\r"); +#if (ALLOW_PEER_ERASE > 0) printf("\tY\tRelease peer SAM3 ERASE signal\n\r"); printf("\ta\tAllow asserting peer SAM3 ERASE signal\n\r"); printf("\ty\tAssert peer SAM3 ERASE signal\n\r"); +#endif printf("\tU\tProceed to USB Initialization\n\r"); printf("\t1\tGenerate 1ms reset pulse on WWAN1\n\r"); printf("\t2\tGenerate 1ms reset pulse on WWAN2\n\r"); @@ -245,6 +249,7 @@ void board_exec_dbg_cmd(int ch) printf("Setting _SIMTRACExx_RST -> SIMTRACExx_RST low (active)\n\r"); PIO_Set(&pin_peer_rst); break; +#if (ALLOW_PEER_ERASE > 0) case 'Y': printf("Clearing SIMTRACExx_ERASE (inactive)\n\r"); PIO_Clear(&pin_peer_erase); @@ -261,6 +266,7 @@ void board_exec_dbg_cmd(int ch) printf("Please first allow setting SIMTRACExx_ERASE\n\r"); } break; +#endif case '1': printf("Resetting Modem 1 (of this SAM3)\n\r"); wwan_perst_do_reset_pulse(0, 300); @@ -283,10 +289,12 @@ void board_exec_dbg_cmd(int ch) break; } +#if (ALLOW_PEER_ERASE > 0) // set protection back so it can only run for one command if ('a' != ch) { allow_erase = false; } +#endif } void board_main_top(void)