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
This commit is contained in:
Kevin Redon 2019-05-23 17:33:45 +02:00 committed by Harald Welte
parent a634c0efee
commit 6228d187da
3 changed files with 17 additions and 1 deletions

View File

@ -120,6 +120,10 @@ C_OBJECTS = $(C_FILES:%.c=%.o)
# TRACE_LEVEL_NO_TRACE 0 # TRACE_LEVEL_NO_TRACE 0
TRACE_LEVEL ?= 4 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 DEBUG_PHONE_SNIFF?=0
#CFLAGS+=-DUSB_NO_DEBUG=1 #CFLAGS+=-DUSB_NO_DEBUG=1
@ -163,7 +167,7 @@ CFLAGS += -Wno-suggest-attribute=noreturn
#CFLAGS += -Wa,-a,-ad #CFLAGS += -Wa,-a,-ad
CFLAGS += -D__ARM CFLAGS += -D__ARM
CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb # -mfix-cortex-m3-ldrd 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 += -DGIT_VERSION=\"$(GIT_VERSION)\"
CFLAGS += -DBOARD=\"$(BOARD)\" -DBOARD_$(BOARD) CFLAGS += -DBOARD=\"$(BOARD)\" -DBOARD_$(BOARD)
CFLAGS += -DAPPLICATION=\"$(APP)\" -DAPPLICATION_$(APP) CFLAGS += -DAPPLICATION=\"$(APP)\" -DAPPLICATION_$(APP)

View File

@ -76,6 +76,10 @@ $ make TRACE_LEVEL=4
``` ```
Accepted values: 0 (NO_TRACE) to 5 (DEBUG) 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 = Flashing
To flash a firmware image follow the instructions provided in the [wiki](https://projects.osmocom.org/projects/simtrace2/wiki/). To flash a firmware image follow the instructions provided in the [wiki](https://projects.osmocom.org/projects/simtrace2/wiki/).

View File

@ -184,10 +184,12 @@ static void board_exec_dbg_cmd_st12only(int ch)
/* returns '1' in case we should break any endless loop */ /* returns '1' in case we should break any endless loop */
void board_exec_dbg_cmd(int ch) 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 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. this is done to prevent accidental ERASE on noisy serial input since only one character can trigger the ERASE.
*/ */
static bool allow_erase = false; static bool allow_erase = false;
#endif
switch (ch) { switch (ch) {
case '?': case '?':
@ -209,9 +211,11 @@ void board_exec_dbg_cmd(int ch)
} }
printf("\tX\tRelease peer SAM3 from reset\n\r"); printf("\tX\tRelease peer SAM3 from reset\n\r");
printf("\tx\tAssert peer SAM3 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("\tY\tRelease peer SAM3 ERASE signal\n\r");
printf("\ta\tAllow asserting 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"); printf("\ty\tAssert peer SAM3 ERASE signal\n\r");
#endif
printf("\tU\tProceed to USB Initialization\n\r"); printf("\tU\tProceed to USB Initialization\n\r");
printf("\t1\tGenerate 1ms reset pulse on WWAN1\n\r"); printf("\t1\tGenerate 1ms reset pulse on WWAN1\n\r");
printf("\t2\tGenerate 1ms reset pulse on WWAN2\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"); printf("Setting _SIMTRACExx_RST -> SIMTRACExx_RST low (active)\n\r");
PIO_Set(&pin_peer_rst); PIO_Set(&pin_peer_rst);
break; break;
#if (ALLOW_PEER_ERASE > 0)
case 'Y': case 'Y':
printf("Clearing SIMTRACExx_ERASE (inactive)\n\r"); printf("Clearing SIMTRACExx_ERASE (inactive)\n\r");
PIO_Clear(&pin_peer_erase); 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"); printf("Please first allow setting SIMTRACExx_ERASE\n\r");
} }
break; break;
#endif
case '1': case '1':
printf("Resetting Modem 1 (of this SAM3)\n\r"); printf("Resetting Modem 1 (of this SAM3)\n\r");
wwan_perst_do_reset_pulse(0, 300); wwan_perst_do_reset_pulse(0, 300);
@ -283,10 +289,12 @@ void board_exec_dbg_cmd(int ch)
break; break;
} }
#if (ALLOW_PEER_ERASE > 0)
// set protection back so it can only run for one command // set protection back so it can only run for one command
if ('a' != ch) { if ('a' != ch) {
allow_erase = false; allow_erase = false;
} }
#endif
} }
void board_main_top(void) void board_main_top(void)