Skip to content

Commit

Permalink
contrib: usrp_emb: flash correct SCU firmware for x4xx
Browse files Browse the repository at this point in the history
Read compat_rev value from eeprom and use it for determining
the filename of the firmware binary to be flashed.

Signed-off-by: Jörg Hofrichter <joerg.hofrichter@emerson.com>
  • Loading branch information
joergho committed Jan 15, 2025
1 parent 4a1dd2e commit f3d475f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion contrib/test/usrp_emb/usrp_emb/crosec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import re
import subprocess
import tempfile
from pathlib import Path
Expand Down Expand Up @@ -106,7 +107,7 @@ def set_bootmode(self, mode):
self.uart.expect(self.prompt)

def flash_scu(self, filename):
assert Path(filename).exists()
assert Path(filename).exists(), f"{filename} does not exist"
serial = self.ftdi_serial

script = f'''
Expand Down Expand Up @@ -146,3 +147,17 @@ def flash_scu(self, filename):
f.write(script.encode('ascii'))
f.flush()
subprocess.run(['openocd', '-f', f.name], check=True)

def get_board_compat_rev(self):
self.uart.sendline('eepromdump mb')
re_compat_rev = re.compile(r'usrp_eeprom_board_info.*compat_rev: (0x[0-9]+)')
compat_rev = None
while True:
line = self.uart.readline()
match_compat_rev = re_compat_rev.search(line.decode())
if match_compat_rev is not None:
compat_rev = int(match_compat_rev.group(1), 16)
break
self.uart.expect(self.prompt)
assert compat_rev is not None, 'Failed to get board compat_rev'
return compat_rev
3 changes: 2 additions & 1 deletion contrib/test/usrp_emb/usrp_emb/test_x4xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

def flash_scu():
with Titanium(FTDI_SERIAL) as ti:
ti.crosec.flash_scu(BRINGUP_PATH / 'ec-titanium-rev5.bin')
compat_rev = ti.crosec.get_board_compat_rev()
ti.crosec.flash_scu(BRINGUP_PATH / f'ec-titanium-rev{compat_rev}.bin')
time.sleep(5)
print("Version after flashing")
print(ti.crosec.version())
Expand Down

0 comments on commit f3d475f

Please sign in to comment.