Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/14147


Change subject: add make DEFINE to remove assert ERASE code
......................................................................

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
---
M firmware/Makefile
M firmware/README.txt
M firmware/libboard/qmod/source/board_qmod.c
3 files changed, 17 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/47/14147/1

diff --git a/firmware/Makefile b/firmware/Makefile
index c0f53f3..fa72bd3 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -120,6 +120,10 @@
 # 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 += -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 dcbafb2..fa7f60a 100644
--- a/firmware/README.txt
+++ b/firmware/README.txt
@@ -76,6 +76,10 @@
 ```
 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 cab5271..4d75b98 100644
--- a/firmware/libboard/qmod/source/board_qmod.c
+++ b/firmware/libboard/qmod/source/board_qmod.c
@@ -184,10 +184,12 @@
 /* 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 @@
                }
                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 @@
                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 @@
                        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 @@
                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)

--
To view, visit https://gerrit.osmocom.org/14147
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f88ecf1e2dcf00c0297597f88dd361a6e088c1e
Gerrit-Change-Number: 14147
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kre...@sysmocom.de>

Reply via email to