<?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>Controlling GPIO within nrfjprog</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90576/controlling-gpio-within-nrfjprog</link><description>Hello, 
 I have a product with QSPI flash that I would like to use nrfjprog to program the flash part. However, the QSPI flash&amp;#39;s VCC is controlled (via a FET) from a GPIO line. I am looking for a way to have nrfjprog enable the GPIO line before attempting</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Aug 2022 12:09:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90576/controlling-gpio-within-nrfjprog" /><item><title>RE: Controlling GPIO within nrfjprog</title><link>https://devzone.nordicsemi.com/thread/380115?ContentTypeID=1</link><pubDate>Thu, 04 Aug 2022 12:09:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7968477-0341-42a2-b5b8-6fec38d53857</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I have created a feature request for this internally so we will hopefully get official support for this in a future nrfjprog release.&lt;/p&gt;
&lt;p&gt;Regarding resets during programming, feedback from the team is that in general you cannot expected the device not to be reset during programming. A reset will for instance be required if there are is any runtime memory block protection enabled on the device (BPROT, ACL, SPU, MPU etc.), which may be the case if you are not programming a blank chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Controlling GPIO within nrfjprog</title><link>https://devzone.nordicsemi.com/thread/379737?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 13:44:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d700dc9-76ef-416b-ae18-fc8aae994038</guid><dc:creator>Jon</dc:creator><description>&lt;p&gt;It seems to work okay and verifies ok, but understanding of the part might reset for some reason mid programming is important just in case it might happen occasionally. The main issue with the workaround I do is that it&amp;#39;s a bit slow since I have to call nrfjprog several times.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Controlling GPIO within nrfjprog</title><link>https://devzone.nordicsemi.com/thread/379731?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 13:29:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:107142a0-53e5-4f22-9068-bc90acf02815</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;1. Yes, it should be mostly the same except for the gpio addresses and device name (obviously).&lt;/p&gt;
&lt;p&gt;2 I did not think of doing it like that. This might be the simplest solution if it works. Are there any indications that it might be powering off? I.e. do you get any programming errors if you include the --verify argument?&lt;/p&gt;
[quote user="Jon Rhees"] You mention that the program_file API might allow the part to reset during programming. Can you explain why?[/quote]
&lt;p&gt;I am not familiar with the internals of this library, so I will have to check with the developers again and get back to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Controlling GPIO within nrfjprog</title><link>https://devzone.nordicsemi.com/thread/379729?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 13:22:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:700b401c-6cb9-4035-b6d8-35d23df4eff1</guid><dc:creator>Jon</dc:creator><description>&lt;p&gt;Thanks for the reply. A couple of questions:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. I assume this will be very similar for nRF52, correct?&lt;/p&gt;
&lt;p&gt;2. You mention that the program_file API might allow the part to reset during programming. Can you explain why? Would this potential reset happen on the nRf52 as well. Also, I currently found that I could program the gpio similarly with nrfjprog and the memwr command, followed by a second run of nrfjprog with the program command. However, now you have me concerned that with nrfjprog the part might reset losing the gpio seeing...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Jon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Controlling GPIO within nrfjprog</title><link>https://devzone.nordicsemi.com/thread/379690?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2022 11:12:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0316d479-adef-40ad-9186-0a8d5da2ee19</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Jon,&lt;/p&gt;
&lt;p&gt;Unfortunately, nrfjprog currently does not have a setting to let you define the IO state for a particular GPIO during QSPI programming. I will make a feature request for it internally. In the meantime, maybe you can use &lt;a href="https://github.com/NordicSemiconductor/pynrfjprog/"&gt;pynrfjprog &lt;/a&gt;instead. Here is an example script proposed by one of the developers:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;from pynrfjprog import LowLevel
from pathlib import Path
import logging
# Uncomment to enable verbose log output
# logging.basicConfig(level=logging.DEBUG)
target_cp = LowLevel.CoProcessor.CP_APPLICATION
debugger_snr = 960158306 # Update with your snr here
hex_to_flash = Path(&amp;#39;qspi_hex.hex&amp;#39;)
if not hex_to_flash.exists():
    raise AssertionError(f&amp;quot;Selected hex {hex_to_flash} file does not exist&amp;quot;)
with LowLevel.API(&amp;quot;NRF53&amp;quot;, log=True) as api:
    # Connect and halt target core
    print(&amp;quot;Connect to target&amp;quot;)
    api.connect_to_emu_with_snr(debugger_snr)
    api.enable_coprocessor(target_cp)
    api.select_coprocessor(target_cp)
    api.connect_to_device()
    api.halt()
    # Disable MPU/SPU if enabled. Behaviour is device spesific.
    # For nRF53 it will issue a system reset w/halt
    print(&amp;quot;Disable bprot&amp;quot;)
    api.disable_bprot()
    
    # Example set GPIO P0.31 low (will light up LED4 on nRF53 DK)
    # Refer to device datasheet for addresses and values
    print(&amp;quot;Set pin low&amp;quot;)
    pin = 31
    gpio_base = 0x50842500
    gpio_dirset = gpio_base + 0x018
    gpio_outclr = gpio_base + 0x00C
    val = (1 &amp;lt;&amp;lt; pin)
    api.write_u32(gpio_dirset, val, False)
    api.write_u32(gpio_outclr, val, False)
    # Enable qspi module
    api.qspi_init()
    
    # Do the programming yourself using QSPI functions
    addr = 0 # Address 0 is start of QSPI 
    data_len = 100
    data = list(range(0, data_len)) # data = [0,1,2,3 ... , 99]
    api.qspi_erase(addr, LowLevel.QSPIEraseLen.ERASE4KB) # Erase first page
    api.qspi_write(addr, data) # Write data
    # Read and verify
    device_data = api.qspi_read(addr, data_len) 
    assert data == list(device_data)
    # Optionally reset programmed device
    print(&amp;quot;Applying pin reset&amp;quot;)
    api.pin_reset()
    print(&amp;quot;Done&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Optionally you can try to use the program_file function. But we do not guarantee that there will not be a reset during programming (which will result in the GPIO being reset&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;from pynrfjprog import LowLevel
from pathlib import Path
import logging
# Uncomment to enable verbose log output
# logging.basicConfig(level=logging.DEBUG)
target_cp = LowLevel.CoProcessor.CP_APPLICATION
debugger_snr = 960158306 # Update with your snr here
hex_to_flash = Path(&amp;#39;qspi_hex.hex&amp;#39;)
if not hex_to_flash.exists():
    raise AssertionError(f&amp;quot;Selected hex {hex_to_flash} file does not exist&amp;quot;)
with LowLevel.API(&amp;quot;NRF53&amp;quot;, log=True) as api:
    # Connect and halt target core
    print(&amp;quot;Connect to target&amp;quot;)
    api.connect_to_emu_with_snr(debugger_snr)
    api.enable_coprocessor(target_cp)
    api.select_coprocessor(target_cp)
    api.connect_to_device()
    api.halt()
    # Disable MPU/SPU if enabled. Behaviour is device spesific.
    # For nRF53 it will issue a system reset w/halt
    print(&amp;quot;Disable bprot&amp;quot;)
    api.disable_bprot()
    
    # Example set GPIO P0.31 low (will light up LED4 on nRF53 DK)
    # Refer to device datasheet for addresses and values
    print(&amp;quot;Set pin low&amp;quot;)
    pin = 31
    gpio_base = 0x50842500
    gpio_dirset = gpio_base + 0x018
    gpio_outclr = gpio_base + 0x00C
    val = (1 &amp;lt;&amp;lt; pin)
    api.write_u32(gpio_dirset, val, False)
    api.write_u32(gpio_outclr, val, False)
    # Program your hex file
    print(&amp;quot;Programming device&amp;quot;)
    api.erase_file(hex_to_flash) # Optional: erase memory before writing
    api.program_file(hex_to_flash)
    api.verify_file(hex_to_flash) # Optional: verify after write
    # Optionally reset programmed device
    print(&amp;quot;Applying pin reset&amp;quot;)
    api.pin_reset()
    print(&amp;quot;done&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>