File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212import serial
1313import serial .tools .list_ports
14- from elftools .elf .elffile import ELFFile
1514
1615FTDI_PID : int = 0x6010
1716BAUD_RATE : int = 1_000_000
@@ -71,39 +70,18 @@ async def bootstrap(uart: serial.Serial | None) -> None:
7170 await set_pin (0 , True )
7271
7372
74- def get_load_addr (elf : Path ) -> int :
75- try :
76- with elf .open ("rb" ) as f :
77- elf = ELFFile (f )
78- load_addrs = [
79- seg ["p_paddr" ] for seg in elf .iter_segments () if seg ["p_type" ] == "PT_LOAD"
80- ]
81- if not load_addrs :
82- print (f"[{ RUNNER } ] no PT_LOAD segments found in ELF file { elf } " )
83- sys .exit (1 )
84- return min (load_addrs )
85- except OSError as e :
86- print (f"[{ RUNNER } ] error opening ELF file { elf } : { e } " )
87- sys .exit (1 )
88-
89-
9073async def load_fpga_binary (path : Path , uart : serial .Serial | None ) -> None :
91- load_address = get_load_addr (path )
92-
9374 await bootstrap (uart )
9475
9576 command = [
9677 "ftditool" ,
9778 "--pid" ,
9879 hex (FTDI_PID ),
99- "bootstrap" ,
100- "--addr" ,
101- hex (load_address ),
102- "--skip-erase" ,
80+ "bootstrap-elf" ,
81+ str (path ),
10382 "--ftdi" ,
10483 FTDI_DEVICE_DESC ,
10584 ]
106- command .append (str (path .with_suffix (".bin" )))
10785
10886 p = await asyncio .create_subprocess_exec (* command )
10987 if await p .wait () != 0 :
You can’t perform that action at this time.
0 commit comments