summaryrefslogtreecommitdiff
path: root/test-cli/test/flashers
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-13 12:17:51 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-19 21:31:03 +0100
commite74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283 (patch)
tree9532b642b798498ed46dea08623c08314c7c873f /test-cli/test/flashers
parent41ffba6a76a80a7ef4553cb8856393dd209d172e (diff)
downloadboard-e74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283.zip
board-e74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283.tar.gz
board-e74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283.tar.bz2
Added final flashing tasks: eeprom and nand.
Diffstat (limited to 'test-cli/test/flashers')
-rw-r--r--test-cli/test/flashers/flasheeprom.py36
-rw-r--r--test-cli/test/flashers/flasher.py10
-rw-r--r--test-cli/test/flashers/flasher_sopa0000.py13
-rw-r--r--test-cli/test/flashers/flashmemory.py12
4 files changed, 48 insertions, 23 deletions
diff --git a/test-cli/test/flashers/flasheeprom.py b/test-cli/test/flashers/flasheeprom.py
new file mode 100644
index 0000000..e427b87
--- /dev/null
+++ b/test-cli/test/flashers/flasheeprom.py
@@ -0,0 +1,36 @@
+import os
+import binascii
+
+
+def flash_eeprom(eeprompath, boarduuid, mac0, mac1=None):
+ print("Start programming Eeprom...")
+ # check if eeprompath is correct
+ if os.path.isfile(eeprompath):
+ # create u-boot data struct
+ data = bytearray()
+ data += (2029785358).to_bytes(4, 'big') # magicid --> 0x78FC110E
+ data += bytearray([0, 0, 0, 0]) # crc32 = 0
+ data += bytearray(boarduuid + "\0",
+ 'ascii') # uuid --> 'c0846c8a-5fa5-11ea-8576-f8b156ac62d7' and \0 at the end
+ data += binascii.unhexlify(mac0.replace(':', '')) # mac0 --> 'f8:b1:56:ac:62:d7'
+ if mac1 is not None:
+ data += binascii.unhexlify(mac1.replace(':', '')) # mac1 --> 'f8:b1:56:ac:62:d7'
+ else:
+ data += bytearray([0, 0, 0, 0, 0, 0]) # mac1 --> 0:0:0:0:0:0
+ # calculate crc
+ crc = (binascii.crc32(data, 0)).to_bytes(4, 'big')
+ data[4:8] = crc
+ # write into eeprom and read back
+ f = open(eeprompath, "r+b")
+ f.write(data)
+ f.seek(0)
+ data_rx = f.read(57)
+ for i in range(57):
+ if data_rx[i] != data[i]:
+ print("Error while programming eeprom memory.")
+ return 1
+ print("Eeprom programmed succesfully.")
+ return 0
+ else:
+ print("eeprom memory not found.")
+ return 1
diff --git a/test-cli/test/flashers/flasher.py b/test-cli/test/flashers/flasher.py
deleted file mode 100644
index d962fca..0000000
--- a/test-cli/test/flashers/flasher.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from test.flashers.flasher_sopa0000 import flash_sopa0000
-
-
-def flash(modelid):
- result = None
-
- if modelid.find("SOPA0000") == 0:
- result = flash_sopa0000()
-
- return result
diff --git a/test-cli/test/flashers/flasher_sopa0000.py b/test-cli/test/flashers/flasher_sopa0000.py
deleted file mode 100644
index 818be91..0000000
--- a/test-cli/test/flashers/flasher_sopa0000.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from test.helpers.syscmd import SysCommand
-
-
-def flash_sopa0000():
- print("Sart programming Nand memory...")
- str_cmd = "/usr/bin/igep-flash --skip-nandtest --image /opt/firmware/demo-ti-image-*-*.tar* >/dev/null 2>&1"
- sync_command = SysCommand("sync_command", str_cmd)
- if sync_command.execute() != 0:
- print("Flasher: Could not complete flashing task.")
- return 1
- else:
- print("Flasher: NAND memory flashed succesfully.")
- return 0
diff --git a/test-cli/test/flashers/flashmemory.py b/test-cli/test/flashers/flashmemory.py
new file mode 100644
index 0000000..ac59be5
--- /dev/null
+++ b/test-cli/test/flashers/flashmemory.py
@@ -0,0 +1,12 @@
+import sh
+
+
+def flash_memory(imagefile):
+ print("Sart programming Nand memory...")
+ p = sh.bash("/usr/bin/igep-flash", "--skip-nandtest", "--image", "/opt/firmware/" + imagefile)
+ if p.exit_code != 0:
+ print("Flasher: Could not complete flashing task.")
+ return 1
+ else:
+ print("Flasher: NAND memory flashed succesfully.")
+ return 0