jjcarstens

jjcarstens

Nerves Core Team

Using default firmware.gen.script exits 255 (even though upload is successful)

I was having issues using the mix firmware.push to send new fw to my device, so I followed the guide and ran mix firmware.gen.script and have be using the upload.sh it generated which has worked great. Firmware deploys great and all seemed well.

So, I started scripting this process and ended up getting warnings and failures in scripts. After investigating, it looks like the last line of generated upload.sh script returns 255, but technically it did what it was supposed to.

jonjon@ šŸ“‚ {grub} $ MIX_ENV=dev MIX_TARGET=rpi3 ./upload.sh
Uploading ./_build/rpi3/dev/nerves/images/grub.fw to grub-dev.local...
X11 forwarding request failed on channel 0
Running fwup...
fwup: Upgrading partition A
|====================================| 100% (30.31 / 30.31) MB
Success!
Elapsed time: 5.925 s
Rebooting...
jonjon@ šŸ“‚ {grub} $ echo $?
255

ssh man pages state that it will exit with remote command status or 255 on an error. In this case, I believe the remote exits -1 and shell transposes to 255 which is the code to use with an ā€œout of rangeā€ status (which are expected to be 0-255)

Anyone know why it might be completing successfully but returning an error? I basically have no idea what to look for with ssh or nerves_firmware_ssh, so any help would be appreciated.

I’ll even supply some ssh -v output :wink:¬

jonjon@ šŸ“‚ {grub} $ MIX_ENV=dev MIX_TARGET=rpi3 ./upload.sh grub-dev.local
Uploading ./_build/rpi3/dev/nerves/images/grub.fw to grub-dev.local...
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/jonjon/.ssh/config
debug1: /Users/jonjon/.ssh/config line 5: Applying options for grub*.local
debug1: /Users/jonjon/.ssh/config line 57: Applying options for *.local
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: /etc/ssh/ssh_config line 52: Applying options for *
debug1: Connecting to grub-dev.local port 8989.
debug1: Connection established.
debug1: identity file /Users/jonjon/.ssh/mx type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jonjon/.ssh/mx-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: Remote protocol version 2.0, remote software version aqxe
debug1: no match: aqxe
debug1: Authenticating to grub-dev.local:8989 as 'jonjon'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:s6rDEVL9YH3LaEDRxRX4qStknwY3560Vs5wkQ4wQMmA
debug1: Host '[grub-dev.local]:8989' is known and matches the RSA host key.
debug1: Found key in /Users/jonjon/.ssh/known_hosts:694
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive,password
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:jNF/Vgr6H6cxSehszXW5cmb3TM6E3oZCNOxp4NklsoA /Users/jonjon/.ssh/mx
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug1: Authentication succeeded (publickey).
Authenticated to grub-dev.local ([10.0.1.67]:8989).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: exec
debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Requesting authentication agent forwarding.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending subsystem: nerves_firmware_ssh
X11 forwarding request failed on channel 0
Running fwup...
fwup: Upgrading partition B
|====================================| 100% (30.31 / 30.31) MB
Success!
Elapsed time: 5.869 s
Rebooting...
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 28187168, received 13960 bytes, in 6.4 seconds
Bytes per second: sent 4422327.5, received 2190.2
debug1: Exit status -1

Most Liked

fhunleth

fhunleth

Co-author of Nerves

Jon - Justin Schneck and I released nerves_firmware_ssh v0.3.3 that fixes the exit code issue and a includes a couple minor changes since the previous release. (Details on the Github project) Thanks again for letting me know about it.

fhunleth

fhunleth

Co-author of Nerves

Good catch. I reproduced this. It turns out that nerves_firmware_ssh is missing a call to :ssh_connection.exit_status to send the return code. I’ll PR it tomorrow morning.

Thanks,
Frank

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
Trevoke
I have an umbrella app. Some of the apps inside depend on other apps in the umbrella, unsurprisingly. I’m writing a test for one of the...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
nobody
Hi! In PHP: $_SERVER[ā€˜SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement