You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2019/10/28 22:08:09 UTC

[mynewt-core] branch master updated: OTP Tool : Add TEST_ALIVE command

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new cc0206d  OTP Tool : Add TEST_ALIVE command
cc0206d is described below

commit cc0206df142da211e6b7c3e13c3412b4c704fb04
Author: Naveen Kaje <na...@juul.com>
AuthorDate: Mon Oct 14 17:00:10 2019 -0500

    OTP Tool : Add TEST_ALIVE command
    
    TEST_ALIVE is a basic test to check if the device has booted
    by exchanging data over serial port. The host sends TEST_ALIVE
    command via the otp_tool.py script and in response, the payload
    is 20 bytes (0x0 - 0x13)
    
    Signed-off-by: Naveen Kaje <na...@juul.com>
---
 hw/bsp/dialog_da1469x-dk-pro/otp_tool.py | 35 ++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py b/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py
index 6ece358..34feafc 100755
--- a/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py
+++ b/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py
@@ -43,6 +43,7 @@ class Cmd(object):
     OTP_APPEND_VALUE = 5
     OTP_INIT = 6
     FLASH_ERASE = 7
+    TEST_ALIVE = 8
 
 
 class cmd_no_payload(NamedTuple):
@@ -570,6 +571,39 @@ def init_config_script(uart):
     print("Successfully initialized blank OTP")
 
 
+@click.option('-u', '--uart', required=True, help='uart port')
+@click.command(help='Test if the board is alive by sending and receving data')
+def test_alive_target(uart):
+    try:
+        ser = serial.Serial(port=uart, baudrate=1000000, timeout=1,
+                            bytesize=8, stopbits=serial.STOPBITS_ONE)
+    except serial.SerialException:
+        raise SystemExit("Failed to open serial port")
+
+    # length is unused, so set to 0
+    cmd = cmd_append_value(0xaa55aa55, Cmd.TEST_ALIVE, 0)
+    msg = struct.pack('III', *cmd)
+    # 20 payload bytes and 16 header bytes
+    rlen = 36
+
+    try:
+        ser.write(msg)
+    except serial.SerialException:
+        raise SystemExit("Failed to write to %s" % uart)
+
+    data = ser.read(rlen)
+    print(data)
+    if len(data) != rlen:
+        raise SystemExit("Failed to receive response, exiting")
+
+    response = cmd_response._make(struct.unpack_from('IIII', data))
+    if response.status != 0:
+        raise SystemExit('Failed to verify system status over UART: %d'
+                         % response.status)
+    else:
+        SystemExit("Successfully communicated with target")
+
+
 @click.group()
 def cli():
     pass
@@ -594,6 +628,7 @@ cli.add_command(disable_cmac_debugger)
 cli.add_command(disable_swd_debugger)
 cli.add_command(close_config_script)
 cli.add_command(init_config_script)
+cli.add_command(test_alive_target)
 
 
 if __name__ == '__main__':