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

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews