-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add alternative flash method for Nice!Nano's #80
base: main
Are you sure you want to change the base?
Conversation
In order to build a nRF52 DFU package for flashing via DFU a HEX copy is required.
The CI failure has been caused by the license of Short of changing all the CI scripts to include I tried to use other implementations of |
Yeahh I noticed that. I'll figure something out for that when I get a chance to review this, hopefully within the next few days :) Thank you so much for working on this! <3 |
I'm working on an alternative method I'll push up in a separate PR along this one for consideration. It uses the block-device method, but I think I'll be able to address all my apprehensions to that method to the point it will not be scary to anyone. The downside to it is that it will require a udev rule to work, but it'll side-step the unfree issue for now. Thank you for this! It's amazing to be able to build locally without a massive Zephyr fight! |
nix/adafruit-nrfutil.nix
Outdated
# Nordic Semicondictor proprietary license | ||
license = licenses.unfree; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you source this for me, actually?
All of the files I see in https://github.com/adafruit/Adafruit_nRF52_nrfutil at a glance all look to have either BSD 3-clause (with "Nordic Semiconductor"/"Nordic Semiconductor ASA" listed as copyright holder) or MIT (some files sourced from other projects)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it's in the python package metadata in setup.py
And the header on nordicsemi/dfu/signing.py
There's an open issue on the Adafruit_nRF52_nrfutil project about this license issue: adafruit/Adafruit_nRF52_nrfutil#41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's unfortunate. I only spot checked a handful of files and that was not one of them
License here should probably be [ licenses.bsd3 licenses.mit locenses.unfreeRedistributable ]
with a comment describing unfreeRedistributable and linking to that issue, I suppose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this line to be this list.
I originally copy-and pasted it, so the list included the typo locenses
on unfreeRedistributable
, which actually didn't throw an error, so it looks like license
does not get evaluated properly when it's a list, as unfreeRedistributable
should still throw the unfree issue.
Something's been done to the adafruit version of the nrf52 bootloader that makes it incompatiable with the normal nrf dfu utilities, which means we can't use an open reimplementation. In theory if we throw out signing.py all the code in this is GPL as that is the only code that marked with Nordic Simi's custom license, all the others are marked with BSD. Nordic Simi's license pretty much says you can only use it to build for nordic simi chips, so no using this tool to flash a raspberry pi pico. This tool provides two useful uses. 1. It converts the hex into a bin, creates a header, and a json file and then packages all that into a zip. 2. Connects to the bootloader via a serial port and pushes that binary data onto the microcontroller, thus flashing with no mounting and no borking of the kernel when the device just decides to disappear without warning.
This is an alternative flashing method for the Nice Nano V2's. It will work with other nrf52 devices with some extending. The user only needs to put the n!n into bootloader mode and they will able to be flashed without requiring additional steps. As well, because the system no-longer has a mounted filesystem just up and disappearing there wont be left behind dead device references and the user doesn't have to worry about umount getting locked up into uninterruptible sleep, which means the user needs to reboot with a system that cannot cleanly unmount the root filesystem anymore.
The Nice!Nano's with the adafruit bootloader, the default one, have three ways they can be flashed that I know of.
dd
1 is what is currently used, it requires a mounting tool in user-space or root privileges to mount the device, and the user needs to know to mount it with options to give user permissions to access the filesystem, eg
mount -o rw,uid=$(id -u user),gid=$(id -g user) /dev/sdX /mnt/nn
.The most annoying part of this method however is that the device just disappears when the file copy is done. Sometimes it leaves the device in the kernel uncleanly, so the next disk that appears, such as the second n!n will be at
/dev/sdY
.If the user is copying the files manually and attempts to chain the umount command, this can regularly cause umount to stick in uninterruptible sleep, which is painful to correct as it requires rebooting and the reboot cannot be performed cleanly.
The dd method is pretty good, but it requires root privileges again, or possibly some custom udev rules to change the permissions on block device so a regular user can perform the action, but DDing the start of a disk is a bit scary and likely to raise eyebrows, so that method is probably best not used here.
Finally, the 3rd method. The bootloader exposes a serial port, this can be used via the
adafruit-nrfdfu
utility to write the application to the device as well, and that's what is being added here. The only requirement is the user is part of the dialout group so they have access to serial ports. The user puts the device into bootloader mode, and the flash proceeds without additional input.To use this, I update flash to:
and run