This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

RTT freeze after writing to UICR

I have a test suite connecting to a nRF52832dk using RTT. This one test writes random data to the UICR config area, resets the chip, then reads back the config.

When running this test only, all is fine. So is running the test several times in a row.

However, when I run any other of my tests before the config test, it freezes. I could narrow it down to MultiAPI.rtt_write() in pynrfjprog returning 0, RTT seems not accessible.

In the working situation (testing only UICR config), the command passed through RTT sends the first 15 bytes, then 2 extra. This is as expected, given the default size of the RTT buffer.

However, when the config test fails, the first 15 bytes are passed (15 is returned by the function rtt_write()), but the 2 following bytes are not (0 is returned by the function rtt_write()). No further bytes can be sent, even after reflashing the firmware. Hard reset is required.

To summarize, the RTT seems to have troubles running after a config set, until hard reset. This only happens after running other tests first, but I cannot find out why. My question is: what could possibly make the RTT stop flushing its buffer, or fail to write?

Parents
  • It seems the issue wasn't with UICR, but had to do with timing between calls to pynrfjprog's rtt_write. Sorry about being misleading.

    The original code failed when splitting a RTT command into several strings (sending max 15 chars at a time):

    while command_string != '' and retries > 0:
        try:
            sent = self.api.rtt_write(0, bytes(command_string))
        except:
            BuiltIn().log_to_console("rtt_write error!")
        command_string = command_string[sent:]
        retries -= 1
    
    if retries == 0:
        raise RpcError("Could not write command \""+command_string+"\"");
    

    Adding a sleep after rtt_write helped:

    while command_string != '' and retries > 0:
        try:
            sent = self.api.rtt_write(0, bytes(command_string))
            if sent == 0:               # Give time for a missed write to recover!
                time.sleep(0.1)
        except:
            BuiltIn().log_to_console("rtt_write error!")
        command_string = command_string[sent:]
        retries -= 1
    
    if retries == 0:
        raise RpcError("Could not write command \""+command_string+"\"");
    

    This seems to work for now, but I wonder about the implications.

    The previous version tried to send 100 times in a row, I've tested 1000 as well, but the RTT never recovered. It seems that retrying too fast kept it in a state of inability.

    pynrfjprog is 9.6.0.

    nrfjprog 9.6.0

    JLinkARM.dll version: 6.32c

    Tagging helpful 

  • Thank you for providing more details. We have been able to reproduce the issue internally. It seems there is some issue with the J-Link pack. We will investigate further, and/or report issue to Segger if this is a bug.

Reply Children
Related