def toolchain_flash(self, products, name="top"): """ Programs the LUNA board's flash via its sideband connection. """ from luna.apollo import ApolloDebugger from luna.apollo.flash import ensure_flash_gateware_loaded # Create our connection to the debug module. debugger = ApolloDebugger() ensure_flash_gateware_loaded(debugger, platform=self.__class__()) # Grab our generated bitstream, and upload it to the . bitstream = products.get("{}.bit".format(name)) with debugger.flash as flash: flash.program(bitstream) debugger.soft_reset()
def __init__(self): """ Creates our connection to the USBAnalyzer. """ # For now, we'll connect to the target via the Apollo debug controller. # This should be replaced by a high-speed USB link soon; but for now # we'll use the slow debug connection. self._debugger = ApolloDebugger() self._serial = self._find_serial_connection()
def main(): commands = { # Info queries 'info': print_device_info, 'jtag-scan': print_chain_info, 'flash-scan': print_flash_info, # JTAG commands 'svf': play_svf_file, 'configure': configure_ecp5, 'reconfigure': reconfigure_ecp5, # SPI debug exchanges 'spi': debug_spi, 'spi-inv': debug_spi_inv, 'spi-reg': debug_spi_register, # SPI flash commands 'erase': erase_config_flash, 'program': program_config_flash, 'readback': read_out_config_flash } # Set up a simple argument parser. parser = argparse.ArgumentParser( description= "Utility for LUNA development via an onboard Debug Controller.", formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('command', metavar='command:', choices=commands, help=COMMAND_HELP_TEXT) parser.add_argument( 'argument', metavar="[argument]", nargs='?', help='the argument to the given command; often a filename') parser.add_argument('value', metavar="[value]", nargs='?', help='the value to a register write command') args = parser.parse_args() device = ApolloDebugger() # Set up python's logging to act as a simple print, for now. logging.basicConfig(level=logging.INFO, format="%(message)-s") # Execute the relevant command. command = commands[args.command] command(device, args)
def toolchain_program(self, products, name): """ Programs the relevant LUNA board via its sideband connection. """ from luna.apollo import ApolloDebugger from luna.apollo.ecp5 import ECP5_JTAGProgrammer # Create our connection to the debug module. debugger = ApolloDebugger() # Grab our generated bitstream, and upload it to the FPGA. bitstream = products.get("{}.bit".format(name)) with debugger.jtag as jtag: programmer = ECP5_JTAGProgrammer(jtag) programmer.configure(bitstream)
def toolchain_program(self, products, name): """ Programs the relevant Daisho board via its sideband connection. """ from luna.apollo import ApolloDebugger from luna.apollo.intel import IntelJTAGProgrammer # If the user has opted to use their own programming cable, use it instead. if os.environ.get("PROGRAM_WITH_QUARTUS", False): self._toolchain_program_quartus(products, name) return # Create our connection to the debug module. debugger = ApolloDebugger() # Grab our generated bitstream, and upload it to the FPGA. bitstream = products.get("{}.rbf".format(name)) with debugger.jtag as jtag: programmer = IntelJTAGProgrammer(jtag) programmer.configure(bitstream)
def main(): commands = { # Info queries 'jtag-scan': print_chain_info, 'flash-scan': print_flash_info, # JTAG commands 'svf': play_svf_file, 'configure': configure_ecp5, 'reconfigure': reconfigure_ecp5, # SPI debug exchanges 'spi': debug_spi, 'spi-reg': debug_spi_register, # SPI flash commands 'erase': erase_config_flash, 'program': program_config_flash, 'readback': read_out_config_flash } # Set up a simple argument parser. parser = argparse.ArgumentParser(description="Utility for LUNA development via an onboard Debug Controller.", formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('command', metavar='command:', choices=commands, help=COMMAND_HELP_TEXT) parser.add_argument('argument', metavar="[argument]", nargs='?', help='the argument to the given command; often a filename') parser.add_argument('value', metavar="[value]", nargs='?', help='the value to a register write command') args = parser.parse_args() device = ApolloDebugger() # Grab our log functions. # FIXME: select these log_function, log_error = print, print # Execute the relevant command. command = commands[args.command] command(device, log_function, log_error, args)
# Create a simple SFR that will trigger an ILA capture when written, # and which will display our sample status read. spi_registers.add_sfr(REGISTER_ILA, read=self.ila.complete, write_strobe=self.ila.trigger) # Attach the LEDs and User I/O to the MSBs of our counter. leds = [platform.request("led", i, dir="o") for i in range(0, 6)] m.d.comb += Cat(leds).eq(self.counter[-7:-1]) # Return our elaborated module. return m if __name__ == "__main__": example = top_level_cli(ILASharedBusExample) # Create a debug and ILA connection. debugger = ApolloDebugger() ila = ApolloILAFrontend(debugger, ila=example.ila, use_inverted_cs=True) # Trigger an ILA capture. debugger.spi.register_write(REGISTER_ILA, 0) # Wait for the capture to be complete. while not debugger.spi.register_read(REGISTER_ILA): time.sleep(0.001) # Finally, read back the capture and display it on-screen. ila.interactive_display()
def toolchain_program(self, products, name): openocd = os.environ.get("OPENOCD", "openocd") interface = os.environ.get("INTERFACE", "/dev/ttyACM0") if interface == "SiPEED" or interface == "busblaster": if interface == "SiPEED": args = [ "-c", """ interface ftdi ftdi_vid_pid 0x0403 0x6010 ftdi_layout_init 0x0018 0x05fb ftdi_layout_signal nSRST -data 0x0010 """ ] elif interface == "busblaster": args = ["-f", "interface/ftdi/dp_busblaster.cfg"] with products.extract("{}.svf".format(name)) as vector_filename: subprocess.check_call([ openocd, *args, "-c", "transport select jtag; adapter_khz 10000; init; svf -quiet {}; exit" .format(vector_filename) ]) elif interface == "pergola_bringup": # Early bringup code with products.extract("{}.bit".format(name)) as (bitstream): print( subprocess.check_call([ "bash", "-c", """ stty -F {} 300 raw -clocal -echo icrnl; sleep 0.01; cat {} & > /dev/null; CATPID=$! ; echo -n "$(stat -c%s {})\n" > {}; cp {} {}; sync; sleep 1; """.format(interface, interface, bitstream, interface, bitstream, interface) ])) # kill $CATPID || true; elif interface == "h2": with products.extract("{}.bit".format(name)) as (bitstream): print( subprocess.check_call([ "hf2", "-v", "0x239a", "-p", "0x0058", "flash", "--file", bitstream, "--address", "0x70000000", "-s" ])) else: """ Programs the board using the Apollo firmware """ from luna.apollo import ApolloDebugger from luna.apollo.ecp5 import ECP5_JTAGProgrammer # Create our connection to the debug module. debugger = ApolloDebugger() # Grab our generated bitstream, and upload it to the FPGA. bitstream = products.get("{}.bit".format(name)) with debugger.jtag as jtag: programmer = ECP5_JTAGProgrammer(jtag) programmer.configure(bitstream)