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

Generate separate "update bootloader" image #29

Closed
dhalbert opened this issue Sep 7, 2018 · 17 comments
Closed

Generate separate "update bootloader" image #29

dhalbert opened this issue Sep 7, 2018 · 17 comments
Assignees

Comments

@dhalbert
Copy link
Contributor

dhalbert commented Sep 7, 2018

Right now the bootloader can self-update, but if there is no existing UF2 bootloader, or it's corrupted, you have to use the SWD interface to initially load the bootloader.

Generate an "update-bootloader" image that can be loaded with Nordic's bootloader or this bootloader, which will replace the existing bootloader.

https://github.com/adafruit/uf2-samdx1 provides this capability with the update-bootloader-*.{bin.uf2,ino} files it generates. See selfmain.c and the SELF targets in the Makefile for how it does this. The .ino is an Arduino sketch that does the same thing, so you can update the bootloader even if all you have is just the Arduino IDE and you don't know how to use the nrf command-line tools to load an image. That would be an optional feature for this issue.

Issue filed at @hathach 's request.

@hathach
Copy link
Member

hathach commented Sep 7, 2018

@dhalbert in case the bootloader is corrupted, we must use a jlink to debrick it :D since there is no way to load this app to rewrite the bootloader :D . This would be mainly use to replace whatever bootloader on the board (that could load this image) by our bootloader.

@hathach
Copy link
Member

hathach commented Sep 7, 2018

opps, I just realized you mean to run an in-place binary script in filesystem to update the bootloader ?

@dhalbert
Copy link
Contributor Author

dhalbert commented Sep 7, 2018

No, not in filesystem: we'd use the existing bootloader to load a program that rewrites the bootloader. This program would overwrite CircuitPython or an Arduino sketch or whatever was in flash. It would be supplied .uf2 and .hex format (and maybe .ino).

@hathach
Copy link
Member

hathach commented Sep 7, 2018

Ah ok, I was thinking on how to correct the current corrupted bootloader. But I guess it is jlink work, this application firmware is only to replace whatever an oem bootloader on a nrf52840 board to our bootloader.

@dhalbert
Copy link
Contributor Author

dhalbert commented Sep 7, 2018

Right, or to update the .uf2 bootloader to a newer version, for whatever reason.

@hathach
Copy link
Member

hathach commented Sep 7, 2018

This is a bit tricky and easy to brick, we will only create one version of this app for a specific board with current sd which is 6.1.0. User needs to go through normal dfu-flash afterward to upgrade bootloader to the latest. Hopefully nordic bootloadrr does not use locked, or any kind of memory protection :D

@dhalbert
Copy link
Contributor Author

dhalbert commented Dec 6, 2018

@hathach Does the bootloader protect itself from a user-program overwrite by using the ACL peripheral? I see that once you protect a region by writing the ACL registers, they can't be changed back until there's a hard reset.

I thought perhaps this is how the bootloader protects itself, and if we can get the bootloader to skip the ACL-setting step (e.g. via the second switch or a pin check or something), then we could enable a user-mode bootloader update.

@hathach
Copy link
Member

hathach commented Dec 6, 2018

@dhalbert currently ACL is not enabled yet, There is an issue to enable ACL here. #21 . So yeah, we are free to do user-mode bootloader update.

@jerryneedell
Copy link

jerryneedell commented Sep 26, 2019

Jus to clarify, Can a user now update the Bootloader by simply creating a .uf2 from the released .hex file and then dragging it to the device? If so, should the release assets include .uf2 versions?
I am mostly asking in regards to the circuit playground bluefruit since it does not have an SWD connector installed.

@hathach
Copy link
Member

hathach commented Sep 26, 2019

@jerryneedell current uf2 cannot be used to upgrade the bootloader, bootloader can only be upgraded using cdc interface. Best to use Arduino IDE to do so.

But we could add this feature in future release. Just making sure it doesn’t brick device 😁😁

@hathach
Copy link
Member

hathach commented Sep 26, 2019

you can also use the adafruit-nrfutil manually as well, i will update this comment with the correct syntax when I got home.

@jerryneedell
Copy link

@hathach Thank you! That would be very helpful!

@hathach
Copy link
Member

hathach commented Sep 26, 2019

@hathach Thank you! That would be very helpful!

here it is
adafruit-nrfutil dfu serial --package bootloader.zip -p /dev/ttyACM0 -b 115200 --singlebank --touch 1200

@jerryneedell
Copy link

jerryneedell commented Sep 26, 2019

@hathach Thanks -- before I try it, can you please confirm that I can do this with a CircuitPlayground Bluefruit connected to my system via a USB cable. Do I have to manually enter bootloader mode or any other pre-configuration?

That is, no J-link is necessary for this?

@hathach
Copy link
Member

hathach commented Sep 26, 2019

@hathach Thanks -- before I try it, can you please confirm that I can do this with a CircuitPlayground Bluefruit connected to my system via a USB cable. Do I have to manually enter bootloader mode or any other pre-configuration?

You don't need to force it into DFU mode, the command will does the that trick by connecting at baud 1200 bps then disconnect --touch 1200. It will then could upgrade the bootloader as normal. You can add --verbose option right after adafruit-nrfutil as well. Don't reset/disconnect or do anything until you see Device programmed

https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/updating-the-bootloader

@jerryneedell
Copy link

worked great! both on CircuitPlayground Bluefruit and feather_nrf52840_express

@hathach
Copy link
Member

hathach commented May 29, 2020

bootloader can be updated using uf2 and cdc now. For non-adafruit such as Nordic bootloader and other vendor bootloader, that will mostly use ACL to protect the bootloader. I feel this issue is out of date, could be reopened or create new one if needed.

@hathach hathach closed this as completed May 29, 2020
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

3 participants