<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/14147">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add make DEFINE to remove assert ERASE code<br><br>remove code to assert peer ERASE line by default.<br>see README for more information.<br><br>Change-Id: I5f88ecf1e2dcf00c0297597f88dd361a6e088c1e<br>---<br>M firmware/Makefile<br>M firmware/README.txt<br>M firmware/libboard/qmod/source/board_qmod.c<br>3 files changed, 17 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/Makefile b/firmware/Makefile</span><br><span>index c0f53f3..fa72bd3 100644</span><br><span>--- a/firmware/Makefile</span><br><span>+++ b/firmware/Makefile</span><br><span>@@ -120,6 +120,10 @@</span><br><span> # TRACE_LEVEL_NO_TRACE   0</span><br><span> TRACE_LEVEL ?= 4</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+# allow asserting the peer SAM3S ERASE signal to completely erase the flash</span><br><span style="color: hsl(120, 100%, 40%);">+# only applicable for qmod board</span><br><span style="color: hsl(120, 100%, 40%);">+ALLOW_PEER_ERASE?=0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> DEBUG_PHONE_SNIFF?=0</span><br><span> </span><br><span> #CFLAGS+=-DUSB_NO_DEBUG=1</span><br><span>@@ -163,7 +167,7 @@</span><br><span> #CFLAGS += -Wa,-a,-ad</span><br><span> CFLAGS += -D__ARM</span><br><span> CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb # -mfix-cortex-m3-ldrd</span><br><span style="color: hsl(0, 100%, 40%);">-CFLAGS += -ffunction-sections -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -DTRACE_LEVEL=$(TRACE_LEVEL) -DDEBUG_PHONE_SNIFF=$(DEBUG_PHONE_SNIFF)</span><br><span style="color: hsl(120, 100%, 40%);">+CFLAGS += -ffunction-sections -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -DTRACE_LEVEL=$(TRACE_LEVEL) -DDEBUG_PHONE_SNIFF=$(DEBUG_PHONE_SNIFF) -DALLOW_PEER_ERASE=$(ALLOW_PEER_ERASE)</span><br><span> CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"</span><br><span> CFLAGS += -DBOARD=\"$(BOARD)\" -DBOARD_$(BOARD)</span><br><span> CFLAGS += -DAPPLICATION=\"$(APP)\" -DAPPLICATION_$(APP)</span><br><span>diff --git a/firmware/README.txt b/firmware/README.txt</span><br><span>index dcbafb2..fa7f60a 100644</span><br><span>--- a/firmware/README.txt</span><br><span>+++ b/firmware/README.txt</span><br><span>@@ -76,6 +76,10 @@</span><br><span> ```</span><br><span> Accepted values: 0 (NO_TRACE) to 5 (DEBUG)</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+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.</span><br><span style="color: hsl(120, 100%, 40%);">+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.</span><br><span style="color: hsl(120, 100%, 40%);">+Setting `ALLOW_PEER_ERASE` to 1 enables back the debug command and should be used only for debugging or development purposes.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> = Flashing</span><br><span> </span><br><span> To flash a firmware image follow the instructions provided in the [wiki](https://projects.osmocom.org/projects/simtrace2/wiki/).</span><br><span>diff --git a/firmware/libboard/qmod/source/board_qmod.c b/firmware/libboard/qmod/source/board_qmod.c</span><br><span>index cab5271..4d75b98 100644</span><br><span>--- a/firmware/libboard/qmod/source/board_qmod.c</span><br><span>+++ b/firmware/libboard/qmod/source/board_qmod.c</span><br><span>@@ -184,10 +184,12 @@</span><br><span> /* returns '1' in case we should break any endless loop */</span><br><span> void board_exec_dbg_cmd(int ch)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+#if (ALLOW_PEER_ERASE > 0)</span><br><span>         /* this variable controls if it is allowed to assert/release the ERASE line.</span><br><span>            this is done to prevent accidental ERASE on noisy serial input since only one character can trigger the ERASE.</span><br><span>     */</span><br><span>  static bool allow_erase = false;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span>         switch (ch) {</span><br><span>        case '?':</span><br><span>@@ -209,9 +211,11 @@</span><br><span>             }</span><br><span>            printf("\tX\tRelease peer SAM3 from reset\n\r");</span><br><span>           printf("\tx\tAssert peer SAM3 reset\n\r");</span><br><span style="color: hsl(120, 100%, 40%);">+#if (ALLOW_PEER_ERASE > 0)</span><br><span>          printf("\tY\tRelease peer SAM3 ERASE signal\n\r");</span><br><span>                 printf("\ta\tAllow asserting peer SAM3 ERASE signal\n\r");</span><br><span>                 printf("\ty\tAssert peer SAM3 ERASE signal\n\r");</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>          printf("\tU\tProceed to USB Initialization\n\r");</span><br><span>          printf("\t1\tGenerate 1ms reset pulse on WWAN1\n\r");</span><br><span>              printf("\t2\tGenerate 1ms reset pulse on WWAN2\n\r");</span><br><span>@@ -245,6 +249,7 @@</span><br><span>                printf("Setting _SIMTRACExx_RST -> SIMTRACExx_RST low (active)\n\r");</span><br><span>           PIO_Set(&pin_peer_rst);</span><br><span>          break;</span><br><span style="color: hsl(120, 100%, 40%);">+#if (ALLOW_PEER_ERASE > 0)</span><br><span>        case 'Y':</span><br><span>            printf("Clearing SIMTRACExx_ERASE (inactive)\n\r");</span><br><span>                PIO_Clear(&pin_peer_erase);</span><br><span>@@ -261,6 +266,7 @@</span><br><span>                        printf("Please first allow setting SIMTRACExx_ERASE\n\r");</span><br><span>                 }</span><br><span>            break;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>       case '1':</span><br><span>            printf("Resetting Modem 1 (of this SAM3)\n\r");</span><br><span>            wwan_perst_do_reset_pulse(0, 300);</span><br><span>@@ -283,10 +289,12 @@</span><br><span>           break;</span><br><span>       }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#if (ALLOW_PEER_ERASE > 0)</span><br><span>         // set protection back so it can only run for one command</span><br><span>    if ('a' != ch) {</span><br><span>             allow_erase = false;</span><br><span>         }</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> }</span><br><span> </span><br><span> void board_main_top(void)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/14147">change 14147</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/14147"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I5f88ecf1e2dcf00c0297597f88dd361a6e088c1e </div>
<div style="display:none"> Gerrit-Change-Number: 14147 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: K√©vin Redon <kredon@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>