pulp-platform / pulp-sdk

Apache License 2.0
98 stars 74 forks source link

Running applications on fpga #109

Open simple86 opened 2 years ago

simple86 commented 2 years ago

The application runs well with platform=gvsoc, but not when I put it on fpga. I checkout the branch to sup_fpga. The application was successfully built by $make clean all platform=fpga. FPGA board zcu102 is connected using JTAG, and the bitstream of pulpemu is flashed into the board. It's the log after I run the command $make run platform=fpga.

gapy --target=pulp --platform=fpga --work-dir=/home/jzh/pulp-sdk/applications/MobileNetV1/BUILD/PULP/GCC_RISCV/ --config-opt=cluster/nb_pe=8  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu0_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu1_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu2_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu3_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu4_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu5_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu6_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu7_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu8_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu9_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu10_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu11_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu12_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu13_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu14_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu15_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu16_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu17_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu18_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu19_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu20_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu21_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu22_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu23_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu24_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvDWBNRelu25_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/ConvBNRelu26_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/Gemm28_weights.hex  --config-opt=flash/content/partitions/readfs/files=DORY_network/inputs.hex   run --exec-prepare --exec --binary=/home/jzh/pulp-sdk/applications/MobileNetV1/BUILD/PULP/GCC_RISCV//main/main 
Launching execution with command:
openocd -c 'gdb_port disabled; telnet_port disabled; tcl_port disabled' -f None -f None -f tcl/jtag_boot_entry.tcl -c 'gap8_jtag_load_binary_and_start "/home/jzh/pulp-sdk/applications/MobileNetV1/BUILD/PULP/GCC_RISCV//main/main" elf 0x1c008080'
Open On-Chip Debugger 0.11.0+dev-02060-g857b5ce (2021-10-19-21:04)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:26: Error: Can't find None
in procedure 'script' 
at file "embedded:startup.tcl", line 26
Traceback (most recent call last):
  File "/home/jzh/pulp-sdk/tools/gapy/gapy", line 162, in <module>
    main()
  File "/home/jzh/pulp-sdk/tools/gapy/gapy", line 152, in main
    operationFunc(args, config)
  File "/home/jzh/pulp-sdk/tools/gapy/run.py", line 146, in operationFunc
    raise RuntimeError('Runner has failed with value: %d' % status)
RuntimeError: Runner has failed with value: -1
/home/jzh/pulp-sdk/rtos/pulpos/common/rules/pulpos/default_rules.mk:312: recipe for target 'run' failed
make: *** [run] Error 1

The openocd command is located in pulp-sdk/tools/gapy/runner/board/board_runner.py.

I'm pretty new to FPGA, and it's hard for me to figure out the problem.

Many thanks!

NBruschi commented 2 years ago

Dear @simple86. Many thanks for your report. Do you notice the problem even if you try the test in the folder tests/hello with make clean all run platform=fpga?

simple86 commented 2 years ago

Dear @simple86. Many thanks for your report. Do you notice the problem even if you try the test in the folder tests/hello with make clean all run platform=fpga?

Yes. The problem occurs even when running the test hello.

NBruschi commented 2 years ago

Ok thanks. Could you also include io=uart like this make clean all run platform=fpga io=uart to redirect the prints on uart and then try again with hello test?

simple86 commented 2 years ago

Ok thanks. Could you also include io=uart like this make clean all run platform=fpga io=uart to redirect the prints on uart and then try again with hello test?

Thanks. I tried io=uart just now, but it prints the same log.

NBruschi commented 2 years ago

Ok good. How did you connect your fpga? did you correctly install openocd on your host machine and use the right cable configurations for openocd?

simple86 commented 2 years ago

Ok good. How did you connect your fpga? did you correctly install openocd on your host machine and use the right cable configurations for openocd?

The board is connected by JTAG. I installed riscv-openocd as the guide of https://github.com/riscv/riscv-openocd. I just don't know how to set cable configurations for openocd. Apology for bothering you, but could you direct me for setting the right configurations? Thanks!

NBruschi commented 2 years ago

Dear @simple86

Have you followed the guide here: https://github.com/pulp-platform/pulp/tree/master/fpga#fpga to setup your environment? If not, please try doing it and then we will have a look together if you are still stuck

simple86 commented 2 years ago

Dear @simple86

Have you followed the guide here: https://github.com/pulp-platform/pulp/tree/master/fpga#fpga to setup your environment? If not, please try doing it and then we will have a look together if you are still stuck

Thanks. I followed the guide and tried again. Now I'm still stuck at the same place.

Here is what I found. The openocd command is located Line 140 in pulp-sdk/tools/gapy/runner/board/board_runner.py. There is no openocd/cable and openocd/script in self.config.


90 openocd = self.config.get_str("openocd/path")
91 cable = self.config.get_str('openocd/cable')
92 script = self.config.get_str('openocd/script')
93 binary = self.config.get_str('runner/boot-loader')

140 cmd = "%s -c 'gdb_port disabled; telnet_port disabled; tcl_port disabled' -f %s -f %s -f tcl/jtag_boot_entry.tcl -c 'gap8_jtag_load_binary_and_start \"%s\" elf 0x%x'    " % (openocd, cable, script, binary, entry)
luca-valente commented 2 years ago

Hi @simple86 :smile: Your setup is not entirely clear to me, but I'll try to give some inputs. The openocd configuration file you need to use is here. However, you cannot launch an application directly from the sdk when you are using the fpga. You need:

Keep us updated! :smile:

simple86 commented 2 years ago

Hi @simple86 😄 I have not entirely clear your setup, but I'll try to give some inputs. The openocd configuration file you need to use is here. However, you cannot launch an application directly from the sdk when you are using the fpga. You need:

  • 1 terminal with openocd up and running
  • 1 terminal connected to the screen to see the output of the uart (the default baudrate is 115200)
  • 1 terminal from which you launch riscv32-unknown-elf-gdb <path/to/the/binary> and follow the passages listed here

Thanks a lot for your guide! It's the very cause that I tried to directly launch an application. However, I'm now having problem connecting the board with the PC host. While connecting it only with a Micro-USB cable from the J2 connector (USB JTAG) on the ZCU102 board to a USB port on the host, I failed to launch openocd and was noticed as following.

Open On-Chip Debugger 0.11.0+dev-02060-g857b5ce (2021-10-19-21:04)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter speed' not 'adapter_khz'
DEPRECATED! use 'adapter driver' not 'interface'
DEPRECATED! use 'ftdi device_desc' not 'ftdi_device_desc'
DEPRECATED! use 'ftdi vid_pid' not 'ftdi_vid_pid'
DEPRECATED! use 'ftdi layout_init' not 'ftdi_layout_init'
DEPRECATED! use 'ftdi layout_signal' not 'ftdi_layout_signal'
DEPRECATED! use 'ftdi layout_signal' not 'ftdi_layout_signal'
DEPRECATED! use 'ftdi layout_signal' not 'ftdi_layout_signal'
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Warn : `riscv set_prefer_sba` is deprecated. Please use `riscv set_mem_access` instead.
Error: no device found
Error: unable to open ftdi device with vid 15ba, pid 002b, description 'Olimex OpenOCD JTAG ARM-USB-OCD-H', serial '*' at bus location '*'

Do I need a hardware debugger or adapter (like Olimex ARM-USB-OCD-H, Digilent JTAG-HS2 adapter) as a bridge for connection? Is pulpissimo-zcu102 the proper board specific README file?

luca-valente commented 2 years ago

Hi @simple86 glad I could help. Yes, we use an Olimex ARM-USB-OCD-H. Indeed, that README is updated.