summaryrefslogtreecommitdiff
path: root/test-cli/test/tasks/flashmemory.py
diff options
context:
space:
mode:
authorManel Caro <mcaro@iseebcn.com>2020-07-31 02:07:37 +0200
committerManel Caro <mcaro@iseebcn.com>2020-07-31 02:07:37 +0200
commitd46bce422fd03cd57d1ba336361da17d6efb48db (patch)
treee5ec7aa1ee5d53a655ce121a7c2ddd95888fc989 /test-cli/test/tasks/flashmemory.py
parent907b96801230e04d02575a3732a73e452089637b (diff)
downloadboard-d46bce422fd03cd57d1ba336361da17d6efb48db.zip
board-d46bce422fd03cd57d1ba336361da17d6efb48db.tar.gz
board-d46bce422fd03cd57d1ba336361da17d6efb48db.tar.bz2
TEST restructure
Diffstat (limited to 'test-cli/test/tasks/flashmemory.py')
-rw-r--r--test-cli/test/tasks/flashmemory.py50
1 files changed, 41 insertions, 9 deletions
diff --git a/test-cli/test/tasks/flashmemory.py b/test-cli/test/tasks/flashmemory.py
index 3be56d7..ad9d92a 100644
--- a/test-cli/test/tasks/flashmemory.py
+++ b/test-cli/test/tasks/flashmemory.py
@@ -1,12 +1,44 @@
import sh
+import os
+class NAND_Flasher:
+ __Name = None
+ __varlist = None
+ __xmlObj = None
+ __igepflashPath = None
+ __lastError = ''
+
+ def __init__(self, varlist):
+ self.__varlist = varlist
+ self.__xmlObj = varlist['xml']
+ self.__Name = varlist.get('name_flashnand', self.__xmlObj.getKeyVal('NAND_Flasher', 'name', 'NAND_Flasher'))
+ self.__igepflashPath = self.__xmlObj.getKeyVal('NAND_Flasher', 'igep_flash', '/usr/bin/igep-flash')
+ self.__ImagePath = varlist.get('flashimagepath', '')
+ self.__SkipNandtest = varlist.get('skipnandtest', self.__xmlObj.getKeyVal('NAND_Flasher', 'skipnandtest', '1'))
+
+ def getTaskName(self):
+ return self.__Name
+
+ def getError(self):
+ return self.__lastError
+
+ def Execute(self):
+ try:
+ self.__lastError = ''
+ if not os.path.isfile(self.__ImagePath):
+ self.__lastError('Not Image Found: {}'.format(self.__ImagePath))
+ return False, None
+ if self.__SkipNandtest == '1':
+ p = sh.bash('{}'.format(self.__igepflashPath), "--skip-nandtest", "--image", self.__ImagePath)
+ else:
+ p = sh.bash('{}'.format(self.__igepflashPath), "--image", self.__ImagePath)
+ if p.exit_code != 0:
+ return False, None
+ except OSError as e:
+ self.__lastError('Exception: {}'.format(e.strerror))
+ return False, None
+ except Exception as Error:
+ self.__lastError('Exception: {}'.format(Error))
+ return False, None
+ return True, None
-def flash_memory(imagepath):
- print("Start programming Nand memory...")
- p = sh.bash("/usr/bin/igep-flash", "--skip-nandtest", "--image", imagepath)
- if p.exit_code != 0:
- print("Flasher: Could not complete flashing task.")
- return 1
- else:
- print("Flasher: NAND memory flashed succesfully.")
- return 0