hdl / containers

Building and deploying container images for open source electronic design automation (EDA)
https://hdl.github.io/containers/
Apache License 2.0
107 stars 24 forks source link

Issues accessing USB from container #60

Closed turbinenreiter closed 2 years ago

turbinenreiter commented 2 years ago

I'm using the command

podman run --rm -it -v /$(pwd)://wrk --security-opt label=disable -w //wrk gcr.io/hdl-containers/conda/f4pga/xc7

and was able to build without issues. However, flashing/downloading using openocd fails with this error message:

Error: libusb_init() failed with LIBUSB_ERROR_OTHER

I tried mapping in the device using --device=/dev/ttyUSB1 but got the same error message.

First of all, I'm not sure how to correctly map the device into the container -> the docs don't contain information about this and I think it would help a lot of people if it was added. Second, I'm not entirely sure if the error is a bug or a user problem, as a result of the incorrect device mapping.

umarcor commented 2 years ago

Hi @turbinenreiter! Which OS are you running podman on?

I've tried programming boards on Fedora, using either docker-ce or podman (with the docker compatibility package). I can confirm it's possible. On Windows, USB/IP is required. That is also an option on GNU/Linux.

However, I don't use openocd for programming bitstreams. I find openFPGALoader (trabucayre.github.io/openFPGALoader: Programming a development board) much easier to use. For instance:

docker run \
  --rm \
  --privileged \
  -itv $(pwd):/wrk -w /wrk \
  gcr.io/hdl-containers/openfpgaloader \
  openFPGALoader -b arty_a7_35t mybitstream.bit

Is your board supported by openFPGALoader? Can you give it a try?

For context, are you using make download from https://f4pga-examples.readthedocs.io/en/latest/building-examples.html ?

turbinenreiter commented 2 years ago

Which OS are you running podman on?

Fedora 36

docker run \
  --rm \
  --privileged \
  -itv $(pwd):/wrk -w /wrk \
  gcr.io/hdl-containers/openfpgaloader \
  openFPGALoader -b arty_a7_35t mybitstream.bit

This worked! Thanks a lot!

For context, are you using make download from https://f4pga-examples.readthedocs.io/en/latest/building-examples.html ?

It's a custom project by a colleague, but the Makefiles are taken from that example, yes.

umarcor commented 2 years ago

Nice! At least we know it's possible on your setup. Now, you might want to try finding a set of permissions which allows sharing the device you want only (instead of "everything" through privileged). I suggest to have a look at https://github.com/mviereck/x11docker/#security.

It's a custom project by a colleague, but the Makefiles are taken from that example, yes.

We might want to update the docs and the makefiles in f4pga-examples to use openFPGALoader, as done in https://f4pga.readthedocs.io/projects/arch-defs/en/latest/getting-started.html#openfpgaloader. Do you want to create an issue there to track it?

turbinenreiter commented 2 years ago

Sure, but nor sure which repo this would be.

umarcor commented 2 years ago

@turbinenreiter see chipsalliance/f4pga-examples#328.

umarcor commented 2 years ago

I'm closing this issue, since https://github.com/chipsalliance/f4pga-examples/issues/328 is done (see https://github.com/chipsalliance/f4pga-examples/pull/329). Feel free to open another issue for tracking usage of openocd.

turbinenreiter commented 2 years ago

Thank you very much for the help and fixes, much appreciated.