utzig commented on a change in pull request #2239: dialog_da1469x: enhance otp 
and serial loader tools.
URL: https://github.com/apache/mynewt-core/pull/2239#discussion_r392469994
 
 

 ##########
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_serial.py
 ##########
 @@ -51,21 +52,32 @@ def load(infile, uart):
     # - If XOR matches, host sends 0x6 as final ack
     # - board boots image after receiving ACK from host
 
-#    if len(msg) == 0:
-#        raise SystemExit("Read timed out, exiting")
-
-    print("Please reset board to enter ROM uart recovery")
+    som_detected = False
+    reset_triggered = False
+    now = datetime.datetime.now()
+    reset_delay_us = 250000
 
     while True:
+        elapsed = datetime.datetime.now() - now
+        if elapsed.seconds >= 15:
+            raise SystemExit("Failed to receive SOM, aborting")
+        if not som_detected and not reset_triggered:
+            if elapsed.microseconds >= reset_delay_us:
+                print("Triggering SWD reset...")
+                os.system("./reset.sh &")
 
 Review comment:
   I am not a big run of `os.system` either, so I would use subprocess module. 
You could fix this with:
   
   ```
   import os.path as path
   import subprocess
   
   reset = path.join(path.dirname(__file__), 'reset.sh')
   subprocess.call(reset.split())
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to