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

Change burn task to Upgrade by default #682

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jjcarstens
Copy link
Member

This changes the mix burn (and subsequently mix firmware.burn) to use the FWUP upgrade task by default. If the upgrade fails because the device does not actually have upgradable firmware on it, then the task will fallback to using the complete task to overwrite the device.

You can also now specify --overwrite to force the complete task and wipe the data on the device with the new firmware.

see #679

@fhunleth
Copy link
Member

This is really cool. I think this will help so many people. I'll give it a try later today.

lib/mix/tasks/burn.ex Outdated Show resolved Hide resolved
defp format_result({_, 0}, _task), do: :ok

defp format_result({%FwupStream{output: o}, _}, "upgrade") do
if o =~ ~r/fwup: Expecting platform=#{mix_target()} and/ do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This messages comes from whatever the user puts in their fwup.config, so it seems fragile. Does this work with a FAT-formatted MicroSD card? Like one that you get fresh from a store?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, didn't think about that. I will try with a fresh card shortly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting the same message on a newly FAT formatted microSD and USB drive.

I'm wondering if they change here is to not be automatic and just prompt again asking for a confirmation to run the complete task? Or...we just always run complete if the upgrade task fails?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, even the task can be defined by the user as well and there may not even be an upgrade or complete task. Maybe this is considered a pure convenience and the only support for this "auto" work is with what's defined in official systems which all have this message and these tasks?

Copy link
Member

@fhunleth fhunleth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The switch to the complete task isn't working on my MBP:

Use 7.4 GiB memory card found at /dev/rdisk5? [Yn]
  0% [                                    ]
fwup: Expecting platform=rpi0 and architecture=arm

FWUP upgrade was attempted but /dev/rdisk5 does not have a previous firmware.
Switching to use the complete task to format the entire card.


  0% [                                    ]
fwup: Cannot open '/dev/rdisk5' for output.
Check file permissions or the read-only tab if this is an SD Card.

I think there's a race condition and there needs to be a pause?

mix burn --overwrite works, though.

This changes the `mix burn` (and subsequently `mix firmware.burn`) to
use the FWUP `upgrade` task by default. If the upgrade fails because
the device does not actually have upgradable firmware on it, then the
task will fallback to using the `complete` task to overwrite the device.

You can also now specify `--overwrite` to force the `complete` task
and wipe the data on the device with the new firmware.

see #679
@jjcarstens
Copy link
Member Author

I think there's a race condition and there needs to be a pause?

Did you MBP prompt you a second time for a password? I've been unable to reproduce on 3 machines (Linux, MBP, and Mac mini M1), but I get prompted for a password a second time when it does the next task. I'm more just curious now and can easily add in a quick pause to be safe.

@fhunleth
Copy link
Member

fhunleth commented Jan 2, 2022

Before you add a pause, there might be another way. For example, the logic could be put in the fwup.config or fwup could be extended to let you specify a "fallback" task if the main one errors out. That would prevent the need to authenticate twice. I'm not sure if authenticating twice is bad, though, so long as it works the second time.

I should show you live what I ran into when we pair on the ssh issue in case I'm doing something silly.

jjcarstens added a commit to jjcarstens/fwup that referenced this pull request Jan 17, 2022
In very specific cases, it might be desirable to fallback to another
task when the target task fails. Most commonly this will be falling
back to the `complete` task when the `upgrade` fails due to the firmware
not having a previous firmware.

The fallback will only occur if the failure is withing the tasks functions
so checks before and after the task do not trigger a fallback (i.e. issues
with archive or config file)

This is inspired by nerves-project/nerves#682
jjcarstens added a commit to jjcarstens/fwup that referenced this pull request Jan 17, 2022
In very specific cases, it might be desirable to fallback to another
task when the target task fails. Most commonly this will be falling
back to the `complete` task when the `upgrade` fails due to the firmware
not having a previous firmware.

The fallback will only occur if the failure is withing the tasks functions
so checks before and after the task do not trigger a fallback (i.e. issues
with archive or config file)

This is inspired by nerves-project/nerves#682
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

Successfully merging this pull request may close these issues.

2 participants