crispinb

crispinb

I thought I’d give Nerves a spin (to follow along with Build a Weather Station with Elixir and Nerves (PragProg)) but have thus far fallen at the first hurdle.

I’m doing all this under Windows 10, wsl2. I’ve managed to build the firmware but can’t burn it. Because of the oddities of how wsl2 accesses block devices (via p9) I gave up trying to write direct to the device. If I can just create the firmware image, that’s easy enough to get onto the SD card.

The mix burn help suggests I can create such an image, via mix burn --device <filename>, but that nets this error:

Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ Start-Process fwup -Verb runAs -Wait -ArgumentList "-a -i \\wsl$\Ubun ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

That’s obviously powershell output, so I thought as all I’m trying to do here is write to a file it might be simpler to use the linux fwup (which I also have installed). So I removed the windows fwup.exe from my path, and now I get:

❯ mix burn --device ./image.img
==> nerves
==> sensor_hub

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

** (Mix) fwup.exe is required by the Nerves tooling.

Please see https://hexdocs.pm/nerves/installation.html for installation
instructions.

Can I force mix burn to allow me to use the linux fwup so I can just write to a local filesystem image?

Showing Posts 1 to 9

crispinb

crispinb OP

I managed to force use of the linux fwup utility - a quick trawl through the nerves source revealed I could trick the mix task out of knowing I’m on wsl by touching a /.dockerenv. So I created and built the image (which boots fine so all good now ).

Two questions for future reference:

  1. Should I have been able to use mix burn to burn directly to the SD card? To get access to the latter at all from wsl I had to mount it (with -t drvfs). But I didn’t know what device to proffer to mix burn.
  2. Is it expected that writing instead to a file image would also fail under wsl?
03juan

03juan

I installed fwup.exe via chocolatey and then running mix burn from ubuntu wsl2 opens an elevated cmd.exe window and I see the following in bash:

juan:~/.../elixir/nerves_livebook (main *%=)$
mix burn
==> nerves
==> nerves_livebook

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

'\\wsl$\Ubuntu\home\juan\code\elixir\nerves_livebook'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Use 14.84 GiB memory card found at \\.\PhysicalDrive1? [Yn]

FYI chocolatey ensures it’s in you windows path and windows adds it to wsl2 path & mount

juan:~/.../elixir/nerves_livebook (main *%=)$
which fwup.exe
/mnt/c/ProgramData/chocolatey/bin/fwup.exe
crispinb

crispinb OP

Thanks. I assume then it’s something to do with the chocolatey install (or lack thereof in my case). I did have fwup.exe available in both windows & wsl paths, but set that up myself after a manual download. I avoid chocolatey/scoop/winget etc (I don’t want to maintain parallel toolsets, and keep all dev work exclusively within wsl).

Oh well. Perhaps something to dig into at some stage. At least I do have a working nerves image for now, though it has taken far longer than I expected.

03juan

03juan

I remember also banging my head around this issue and just decided to take the plunge with chocolatey as a last resort which worked. Also agree about having to juggle multiple tools but in this case this was the easiest way that let me just get on with it.

I think the main issue is that you can’t have direct access to the usb subsystem from wsl2, but I don’t know why we both had a hard time with the manual exe install. :man_shrugging:

Perhaps with some more time I’d revisit the subject and try to solve the issue once and for all using the manual way, and write a post about it for others.

03juan

03juan

Don’t know if you’ve come across this, but here’s a very roundabout way to get usb devices mounted in /dev/ jovton/USB-Storage-on-WSL2: This article describes how you can access your USB storage device from Microsoft’s Windows Subsystem for Linux 2 (WSL2) (github.com)

Frankly that is way too much work for me, but maybe others are willing to try this out and report back :sweat_smile:

crispinb

crispinb OP

That’s the crucial aspect I think. My manually installed win32 fwup.exe does auto-detect my SD card if I run it from an elevated windows command line. So there must be something amiss in the way it’s called from elixir. I might dig further, but now I have a booting nerves image I’m impatient to get it doing something!

Me too for now (thanks though for the pointer). I think nerves’ approach of getting native Windows to handle this is fine (WSL is a bit of a moving target). But in this particular case it’s getting something wrong when invoking a non-chocolatey install of fwup.exe. I think, anyway - I only have a very shallow grasp of the moving parts here.

crispinb

crispinb OP

Btw, do you ssh into your nerves device from a wsl shell, or from powershell/cmd? If the former, what do you do about mdns not bridging the network gap? Thus far I’ve had to ping nerves.local from powershell to get the IP, then just ssh to the latter in a wsl/zsh shell. It’s a bit irritating. Maybe I should just set up a static dhcp lease for the pi, & add an entry to /etc/hosts. But if there’s a neater solution I’d be interested.

crispinb

crispinb OP

Ok this is embarrassing - mix burn does work perfectly well with a manually-installed fwup.exe after all. I had a quick look at the chocolatey package - it doesn’t do anything substantially different from just plopping the .exe in the path, so I realised I must have done something daft. Which indeed I had - I had put fwup.exe in a directory that used to be on the path on my machine, but was no longer.

PEBKAC.

03juan

03juan

that’s what I did on my router because mDNS didn’t pick up the device when not connected via USB gadget mode

I must have messed up my paths as well, will have to check when I get a chance. Thanks for persevering to the root cause :clap:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews