<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Turning on debug mode causes SPI to fail</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39664/turning-on-debug-mode-causes-spi-to-fail</link><description>I am trying to debug my nRF Secure Bootloader that was modified to DFU another microcontroller attached to the nRF over SPI. The bootloader works well and I can DFU the other microcontroller when I use the bootloader in &amp;quot;release&amp;quot; mode. 
 I have noticed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Oct 2018 08:02:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39664/turning-on-debug-mode-causes-spi-to-fail" /><item><title>RE: Turning on debug mode causes SPI to fail</title><link>https://devzone.nordicsemi.com/thread/153981?ContentTypeID=1</link><pubDate>Tue, 23 Oct 2018 08:02:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3d81a53-5f1b-4b97-9194-d4baedcbf4fc</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;What I mean was to test with unmodified bootloader, the one we provide in our sdk. You just add some very simple SPI code in and can reproduce the issue. So that we can test here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume that you changed the bootloader start address to fit the bigger size of the bootloader after you enable logging.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on debug mode causes SPI to fail</title><link>https://devzone.nordicsemi.com/thread/153951?ContentTypeID=1</link><pubDate>Tue, 23 Oct 2018 04:22:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1d9a099-5f50-441d-83cc-1fb6114982e4</guid><dc:creator>Andrew Ong</dc:creator><description>&lt;p&gt;I want to use a logic analyzer, but my PCB is really small and the SPI pins are not broken out.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The nRF is using the SPI master.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand what you mean by &amp;quot;adding SPI code that reproduces the issue&amp;quot;. I can already reproduce the issue 5 times by changing only my bootloader make command.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Works (SPI works):&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;make clean; make release; make flash sn=260102227&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  text	   data	    bss	    dec	    hex	filename
  25300	    184	   7640	  33124	   8164	bin/kiddo_secure_dfu_ble_s132.elf
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Does not work: (SPI reads zeroes): (but it compiles and flashes successfully)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;make clean; make flash sn=260102227&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;   text	   data	    bss	    dec	    hex	filename
  29956	    736	  13272	  43964	   abbc	bin/kiddo_secure_dfu_ble_s132.elf
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;These are the&amp;nbsp;parts of my makefile that mention &amp;quot;Debug&amp;quot; or &amp;quot;release&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
DEBUG_DEFINES += -DHARDFAULT_HANDLER_ENABLED
DEBUG_DEFINES += -DNRF_LOG_ENABLED=1
DEBUG_DEFINES += -DNRF_LOG_USES_RTT=1
DEBUG_DEFINES += -DNRF_LOG_BACKEND_RTT_ENABLED=1

RELEASE_DEFINES += -DNDEBUG  # turns off assert
RELEASE_DEFINES += -DNRF_LOG_ENABLED=0
RELEASE_DEFINES += -DNRF_LOG_USES_RTT=0
RELEASE_DEFINES += -DNRF_LOG_BACKEND_RTT_ENABLED=0

debug: DEFINES += $(DEBUG_DEFINES) 
debug: setup $(BIN) $(HEX)

release: DEFINES += $(RELEASE_DEFINES)
release: clean setup $(BIN) $(HEX)

flash: debug
	@echo Flashing: $(HEX)
	nrfjprog -f nrf52 --sectorerase $(NRFJPOG_SERIAL_NUMBER) --program $(HEX)
	nrfjprog -f nrf52 --reset $(NRFJPOG_SERIAL_NUMBER)

clean:
	@echo removing build and bin directories
	rm -rf $(BUILD_DIR)
	rm -rf $(OUTPUT_DIR)

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I even tried changing&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_LOG_DEFAULT_LEVEL&lt;/span&gt;&lt;span&gt;&amp;nbsp;from 3 to&amp;nbsp;&lt;/span&gt;&lt;span&gt;0 to see if it was just to logs causing the SPI issue, but the SPI still breaks when&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_LOG_DEFAULT_LEVEL =&amp;nbsp;&lt;/span&gt;&lt;span&gt;0. Now I don&amp;#39;t know what to do.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on debug mode causes SPI to fail</title><link>https://devzone.nordicsemi.com/thread/153859?ContentTypeID=1</link><pubDate>Mon, 22 Oct 2018 14:11:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d742702d-a666-4152-a3c8-6605439d5885</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andrew,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure why enabling logging can cause the issue. There could be some timing changed when you enable logging, but it should not cause SPI to stop working. Have you checked the output on the SPI pin with a logic analyzer ? Just to make sure it&amp;#39;s not the problem on the other side.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Are you using the bootloader as SPI Slave or Master ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you modify the original to add some SPI code that reproduce the issue (like can output some dummy SPI signal when in normal mode, but output/input all zero when in debug mode ) ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>