Skip to content

Commit 2abc1d5

Browse files
committed
Barebox/UBoot/SmallUBootDriver: handle hex arguements properly
Checks to see if the interrupt string starts with \x and when that is the case, converts the remained of the string to a bytearray before sending the interrupt to the boot loader. fixes #1622 Signed-off-by: Perry Melange <[email protected]>
1 parent 2ce9e24 commit 2abc1d5

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

labgrid/driver/bareboxdriver.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ def _await_prompt(self):
164164

165165
elif index == 1:
166166
# we need to interrupt autoboot
167-
self.console.write(self.interrupt.encode('ASCII'))
167+
interrupt = self.interrupt.encode('ASCII')
168+
if self.interrupt.startswith('\\x'):
169+
try:
170+
interrupt = bytearray.fromhex(self.interrupt[2:])
171+
except ValueError:
172+
pass
173+
self.console.write(interrupt)
168174

169175
elif index == 2:
170176
# we need to enter the password

labgrid/driver/smallubootdriver.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,18 @@ def _await_prompt(self):
6161

6262
# wait for boot expression. Afterwards enter secret
6363
self.console.expect(self.boot_expression, timeout=self.login_timeout)
64+
65+
secret = self.boot_secret.encode('ASCII')
66+
if self.boot_secret.startswith('\\x'):
67+
try:
68+
secret = bytearray.fromhex(self.boot_secret[2:])
69+
except ValueError:
70+
pass
71+
6472
if self.boot_secret_nolf:
65-
self.console.write(self.boot_secret.encode('ASCII'))
73+
self.console.write(secret)
6674
else:
67-
self.console.sendline(self.boot_secret)
75+
self.console.sendline(secret)
6876
self._status = 1
6977

7078
# wait until UBoot has reached it's prompt

labgrid/driver/ubootdriver.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ def _await_prompt(self):
163163
break
164164

165165
elif index == 1:
166-
self.console.write(self.interrupt.encode('ASCII'))
166+
interrupt = self.interrupt.encode('ASCII')
167+
if self.interrupt.startswith('\\x'):
168+
try:
169+
interrupt = bytearray.fromhex(self.interrupt[2:])
170+
except ValueError:
171+
pass
172+
self.console.write(interrupt)
167173

168174
elif index == 2:
169175
if not self.password:

0 commit comments

Comments
 (0)