Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mix burn cannot be operated from Docker container #1

Open
takasehideki opened this issue Nov 26, 2020 · 5 comments
Open

mix burn cannot be operated from Docker container #1

takasehideki opened this issue Nov 26, 2020 · 5 comments

Comments

@takasehideki
Copy link
Member

takasehideki commented Nov 26, 2020

NOTE:
Although think it is hard to fix this issue due to the restriction of Docker especially for Windows and macOS, we leave this open because this report is useful information for new people. And we believe that technology will evolve well:pray:

It is nature that burning firmware to microSD from Docker container is hard to support.
But it become awesome if mix burn can be operated from docker dev-container.

Please also see NervesJP/nerves-devcontainer#5

@takasehideki
Copy link
Member Author

(Copied from NervesJP/nerves-devcontainer#5 (comment))

Status on macOS

root@be6d80382017:/workspaces/nerves-devcontainer/test# mix burn 
==> nerves
==> test

Nerves environment
  MIX_TARGET:   rpi4
  MIX_ENV:      dev

** (Mix) Could not auto detect your SD card

This is because Docker container cannot access/detect microSD on host PC. One possible solution is calling fwup on host PC from Docker container. Alternatively, binding microSD device to docker container filesystem. But, are they possible?

@takasehideki
Copy link
Member Author

(Copied from NervesJP/nerves-devcontainer#5 (comment))

status on windows:

root@923930b7aad1:/workspaces/nerves-devcontainer/test# mix burn 
==> nerves
==> test

Nerves environment
  MIX_TARGET:   rpi4
  MIX_ENV:      dev

** (ErlangError) Erlang error: :enoent
    (nerves 1.7.0) lib/nerves/port.ex:88: Nerves.Port.validate("cmd.exe", ["/c", "echo %TEMP%"], [])
    (nerves 1.7.0) lib/nerves/port.ex:25: Nerves.Port.do_cmd/4
    (nerves 1.7.0) lib/nerves/utils/wsl.ex:94: Nerves.Utils.WSL.get_temp_file_location/1
    (nerves 1.7.0) lib/nerves/utils/wsl.ex:237: Nerves.Utils.WSL.make_file_accessible/3
    (nerves 1.7.0) lib/mix/tasks/burn.ex:66: Mix.Tasks.Burn.run/1
    (mix 1.11.2) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.2) lib/mix/cli.ex:84: Mix.CLI.run_task/2

This is because current Nerves supports (native) WSL2 environment for Windows users. We may modify Nerves environment to resolve this situation.
The way to detect whether a container is based on WSL2 or native docker is uname -r and ls /.dockerenv
Ref: https://github.com/ETrobocon/etrobo/blob/master/scripts/etroboenv.sh#L55

@takasehideki
Copy link
Member Author

@jasonmj suggested the useful information on ElixirForum.
https://elixirforum.com/t/nerves-development-environment-with-docker-and-vs-code/35973/3

When the host is Linux, I've surely checked this method works well.
However, I've also found it is not possible to pass through a USB device (or a serial port) to a container as it requires support at the hypervisor level both in Windows and macOS as the host.

I've added these info to README at 0a0262d

@takasehideki
Copy link
Member Author

I also found an alternative way to use docker-machine and VirtualBox to pass through devices.
https://christopherjmcclellan.wordpress.com/2019/04/21/using-usb-with-docker-for-mac/

However, this operation is complicated and unacceptable as a guide for beginners.

@takasehideki
Copy link
Member Author

takasehideki commented Dec 8, 2020

(Copied from NervesJP/nerves-devcontainer#5 (comment))

status on windows:

root@923930b7aad1:/workspaces/nerves-devcontainer/test# mix burn 
==> nerves
==> test

Nerves environment
  MIX_TARGET:   rpi4
  MIX_ENV:      dev

** (ErlangError) Erlang error: :enoent
    (nerves 1.7.0) lib/nerves/port.ex:88: Nerves.Port.validate("cmd.exe", ["/c", "echo %TEMP%"], [])
    (nerves 1.7.0) lib/nerves/port.ex:25: Nerves.Port.do_cmd/4
    (nerves 1.7.0) lib/nerves/utils/wsl.ex:94: Nerves.Utils.WSL.get_temp_file_location/1
    (nerves 1.7.0) lib/nerves/utils/wsl.ex:237: Nerves.Utils.WSL.make_file_accessible/3
    (nerves 1.7.0) lib/mix/tasks/burn.ex:66: Mix.Tasks.Burn.run/1
    (mix 1.11.2) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.2) lib/mix/cli.ex:84: Mix.CLI.run_task/2

This is because current Nerves supports (native) WSL2 environment for Windows users. We may modify Nerves environment to resolve this situation.
The way to detect whether a container is based on WSL2 or native docker is uname -r and ls /.dockerenv
Ref: https://github.com/ETrobocon/etrobo/blob/master/scripts/etroboenv.sh#L55

This has been fixed at #2
The situation on Windows is now same as on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant