0

Adalogger M0 Boot Loader Update
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adalogger M0 Boot Loader Update

by OUNavCon on Sat Sep 18, 2021 8:58 am

The attempt to update my Adalogger to UF2 bootloader failed. Now I'm trying to recover the bootloader.

I've attached wires to the SWD pins on the underside and connected my Jlink. Using Microchip Studio (Previously Atmel Studio) I am able to down load the hex/bin files to the device successfully. Per this link, https://learn.adafruit.com/proper-step- ... bootloader.
I've tried the featherm0bootloader_160305.hex from that page.

If I disconnect the SWD and plug it into Win10, nothing happens. If I hold down the reset button until the led starts to blink, then double click the reset button a com port appears. However, when clicking on the com port in device manager, it says this device is not connected. This is supported by trying to use Arduino ide to download the UF2 ino project, found here: https://github.com/adafruit/uf2-samdx1/ ... ag/v3.13.0.

I feel like there is a step that I am missing. I believe this is a "feather m0" and not he express version.

I'd like to recover this back to the original Arduino functionality, but with the UF2 bootloader.

Any thoughts or ideas are welcomed.

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Re: Adalogger M0 Boot Loader Update

by mikeysklar on Sat Sep 18, 2021 7:07 pm

You have the right bootloader downloaded for the Feathe M0 Adalogger.

It looks like it is uploading and going correctly into bootloader mode afterwards where you see a COMs port. Can you upload a blink program from the Arduino IDE?

mikeysklar
 
Posts: 5834
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adalogger M0 Boot Loader Update

by OUNavCon on Sun Sep 19, 2021 3:01 pm

I did try that. However, the Arduino IDE says that it can't find the device.

To be clear, you say that it sounds like it is in bootloader mode. I enter that by holding the button long press, until the LED fades in and out. Then I double tap the reset button until I see a Com port in the Device Manager. This can take multiple attempts. When the COM port finally shows up under -> tools -> ports, I get the error below. Is this method of enabling boot load mode correct? I do not see a thumb drive being enumerated, which I would not expect with this bootloader.

I have attached the following files:
AdaLogger in DeviceManager_2021_09_19.PNG
Shows logger enumeration as com port in Win10 device manager.
AdaLogger in DeviceManager_2021_09_19.PNG (13.27 KiB) Viewed 79 times
- COM issue on device manager.
AdaLogger in Arduino_2021_09_19.PNG
Error Message from Arduino
AdaLogger in Arduino_2021_09_19.PNG (7.16 KiB) Viewed 79 times
- Arduino error message on transfer to uC
update-bootloader-feather_m0-v3.13.0.zip
Arduino Project I am trying to program. This is the .ino of the UF2 bootloader, from Github, unmodified.
(13.14 KiB) Not downloaded yet
- Arduino project file of the UF2, from github, unmodified.

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Re: Adalogger M0 Boot Loader Update

by mikeysklar on Mon Sep 20, 2021 11:59 am

To enter bootloader mode it is only necessary to press the 'reset' button twice. So avoid the initial long press you had been doing.

When you are in bootloader mode are you able to see the mounted BOOT drive mounted on your desktop?

Let's try manually uploading the bootloader (not from the IDE), but using the UF2 image.

If you can double press reset and see the BOOT drive mounted drop this UF2 image on the BOOT drive.

https://github.com/adafruit/uf2-samdx1/ ... 3.13.0.uf2

Should you not see the boot drive, but see the connected device you can use your jlink setup to update the bootloader.

https://learn.adafruit.com/how-to-progr ... 3016764-11

I don't see a reason to try and the use the INO bootloader update you have been experimenting with.

mikeysklar
 
Posts: 5834
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adalogger M0 Boot Loader Update

by OUNavCon on Mon Sep 20, 2021 9:16 pm

I do not see a BOOT drive, nor a connected device. Not with the previous method and not once the UF2 boot loader is installed.

I used the file from the link for the UF2 updater to get the "bootloader-feather_m0-v3.13.0.bin" file.
I followed the instructions you linked, however even the boot loader set to write to address zero (Using the Advanced Options -> Set programming address), or not I see nothing in device manager or the file system after plugging it into USB. I've tried double press on the reset button and holding it like I was before, but I don't see a BOOT drive or a com port.

All download and settings complete and verify ok. I've attached the value for the fuses in case there is something there. This image shows user word 0 with boot protect set for 0 Bytes.
Fuses.PNG
Fuses.PNG (7.23 KiB) Viewed 69 times


I disabled all reset events in the fuses, to ensure that it's not in a continuous reset loop. Which didn't change anything.

I'm not sure what else to try.

I tried an Atmel Start project that only reads an adc channel in Microchip Studio. I can single step through that code, so fundamentally I think the MCU is ok.

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Re: Adalogger M0 Boot Loader Update

by mikeysklar on Tue Sep 21, 2021 5:40 pm

I think the BOOTPROT is supposed to be set to 0x07 for SAMD21 based on the guide:

https://learn.adafruit.com/how-to-progr ... 3017004-16

It's good that you have jlink communication and a responsive processor. That certainly lowers the bricking chances.

Are you sure the USB cable you are using for the controller when you try to plug it in directly without any jlink devices is a good data cable? It works with other controllers or storage devices?

mikeysklar
 
Posts: 5834
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adalogger M0 Boot Loader Update

by OUNavCon on Tue Sep 21, 2021 7:13 pm

The fuses under Atmel Studio , as shown in the page you linked, don't seem to be valid in the latest version of the tool Microchip Studio (Ver. 7.0.2541). The acquisition by Microchip and the subsequent rebranding and updates have changed how that tool now looks. The hex values referenced in the webpage guide have been replaced by user readable text and with an explanation of the implications of the selection.
Microchip_Studio_Fuse_Setting_Page.png
Microchip_Studio_Fuse_Setting_Page.png (97.6 KiB) Viewed 59 times


NVM_BootProtectDatasheetPage.PNG
NVM_BootProtectDatasheetPage.PNG (121.25 KiB) Viewed 59 times

The uC datasheet, https://www.microchip.com/en-us/product/ATsamd21g18, shows that the setting of 0x7 corresponds to 0 bytes of the flash space being protected, as seen on page 348. This shows the NVM configuration settings that you mention. In "Table 22-1 Boot loader size" bits [2:0] should contain a value of 0x7, which would be the lower 3 bits of the lowest nibble in USER_WORD_0. As shown in the previous message, the setting is correct per the manufacturers datasheet to unlock the flash space so the new bootloader can be written.

The usb cable, I have tried three and all three work on the following eval boards, NRF52DK, FRDM-K22F, LCP845 Breakout, and a SAMD21 Xplained Pro.

At this point, I would be willing to restore the factory bootloader. I appreciate your help with this, but I am a little frustrated that I updated it. My hope is that will a little explanation and that finding the correct bootloader, would have this fixed this rather quickly. The AdaLogger is used by my kids for science and other school projects, as this doesn't require an EE degree to use.

What else can I try?

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Re: Adalogger M0 Boot Loader Update

by mikeysklar on Tue Sep 21, 2021 7:41 pm

You can also consider adalink for a simple CLI upload.

https://learn.adafruit.com/bluefruit-nr ... 2860644-14

Code: Select all | TOGGLE FULL SIZE
# First erase the device's flash contents
$ adalink nrf52832 -p jlink -w

# Then flash the bootloader and SoftDevice .hex file
$ adalink nrf52832 -p jlink -h feather52_bootloader_v050_s132_v201.hex


I've not tried 'bossac' with bootloader files, but I have used it with the M0 to update circuitpython releases. This might also be an option if you can get the device (a COM port to show up).

https://learn.adafruit.com/welcome-to-c ... 2978786-12

Code: Select all | TOGGLE FULL SIZE
bossac -p COMx -e -w -v -R --offset=0x2000 adafruit-circuitpython-boardname-version.bin

mikeysklar
 
Posts: 5834
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adalogger M0 Boot Loader Update

by OUNavCon on Sun Sep 26, 2021 8:23 pm

Do the methods you mentioned require a working bootloader? Does bossac contact the serial bootloader in the device? Until I can get a working bootloader, will either of these two methods work?

What values does Adafruit set for the Fuse Registers in the Adalogger in production? I'd like to ensure that those settings have the same values that Adafruit sets them to when it leaves the factory. Just to eliminate those variables.

I ask, because with the arduino bootloader I get a single long pulse on the red led and then short pulses. Almost like it started the bootloader and then existed on an error condition.

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Re: Adalogger M0 Boot Loader Update

by mikeysklar on Mon Sep 27, 2021 3:21 pm

The bossac method would require a working serial device to be found so yes to a functional boot loader.

We actually have a good guide for manual burning the bootloader with nrfjprog and adalink.

https://learn.adafruit.com/bluefruit-nr ... -2860639-8

Code: Select all | TOGGLE FULL SIZE
$ nrfjprog --program bootloader_binary.hex --chiperase -f nrf52 --reset


You won't need to deal with fuses or have a working bootloader for these.

mikeysklar
 
Posts: 5834
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adalogger M0 Boot Loader Update

by OUNavCon on Mon Sep 27, 2021 7:33 pm

Good News, I did get the UF2 bootloader to finally install, bad news is the hardware as designed doesn't ensure that the MCU will come out of reset on power-up.

The issue is in the reset circuit. The Reset is an active low input, typically shown as having a bar above the label. In order to ensure that the MCU comes up there are two things most MCU manufacturers recommend. First a pull-up resistor, typically about 10k, to VDD. Secondly, a small capacitor (0.1uF - 1uF) between the RESET pin and ground. The cap filters off any stray ripple or noise on VDD.
The adalogger schematic has neither of these. The reset pin floats until it is pulled down and could be at any voltage.
https://cdn-learn.adafruit.com/assets/a ... 1449699903
AdaLoggerSchematic_Missing_Reset_Circuit.PNG
AdaLoggerSchematic_Missing_Reset_Circuit.PNG (290.15 KiB) Viewed 38 times


If you look at page 1111 of the datasheet, you will see in the Schematic Checklist section that the external reset has these necessary components. It also shows a secondary resistor used to current limit the switch.
Microchip_Recommended_Reset_Circuit.PNG
Microchip_Recommended_Reset_Circuit.PNG (71.64 KiB) Viewed 38 times

https://www.microchip.com/content/dam/m ... 01882G.pdf

To rectify this, I connected a 10K resistor to between the Reset Pin and the 3.3V rail, I also attached a 0.1uF cap between the reset and ground. Then it worked as expected on the next power on. Turns out the UF2 bootloader had been in there for a while and it was a hardware design problem.
I hope this helps other people with the same problem. It would also be helpful if adafruit HW designers would incorporate standard and robust designs in future work.

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Re: Adalogger M0 Boot Loader Update

by mikeysklar on Tue Sep 28, 2021 11:48 am

Interesting observations on the pull-up resistor + decouple cap. I'll ask engineering to review your post as I suspect there was a reason for the current design choice that does not include them.

mikeysklar
 
Posts: 5834
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adalogger M0 Boot Loader Update

by OUNavCon on Tue Sep 28, 2021 10:16 pm

Thanks for the update and I’d love to hear the reasoning behind leaving them off.

I’ve been designing embedded control systems for over 20 years and these reset components are not left off, unless they are provided for internally to the microcontroller, which will be called out in the datasheet or hw design guide. I haven’t seen a evaluation or demo board from any mcu supplier, TI, NXP, ST, Microchip/Atmel, Nordic, Infineon/Cypress, that is missing this circuitry. It’s not in product designs that I’ve worked on or reviewed, at least not in automotive, marine, medical, industrial, or consumer goods. Seems people expect the devices to come out of reset at power up and start executing code.

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Re: Adalogger M0 Boot Loader Update

by adafruit2 on Wed Sep 29, 2021 10:56 am

there's an internal pullup. we think whatever is going on with your hardware is different than the reset line, messing with the fuses and brownout detect can make it act oddly. however, sounds like you got it working!

adafruit2
Site Admin
 
Posts: 20279
Joined: Fri Mar 11, 2005 7:36 pm

Re: Adalogger M0 Boot Loader Update

by OUNavCon on Wed Sep 29, 2021 1:26 pm

The cause of this effort has been to remedy why the bootloader failed to load on your default device while trying to update it. At that time no HW mods, modified fuse settings, or other things were connected to it. Let's not loose sight of the original issue. Updating the UF2 bootloader bricked it.

There is a 20k-60k internal pull up on the reset pin, however this doesn't guarantee that it will come out of reset in all cases. Which is why the uC manufacturer recommends a more robust circuit to the designer. The unit was sitting on my desk only plugged into the USB and it still wouldn't complete boot load mode, until a pull-up and filter cap was installed. It may be a one off issue, however the design is lacking in what would be considered principle circuitry.

As far as the BOD and default values of the fuses, I asked for that over a week ago. I'm open to ensuring that those are reset to factory defaults, if you can tell me what the Adafruit factory settings are. You can see in the Errata for that uC that of the 90 odd defects in the silicon, several are related to Reset issues. One specifically is the BOD hysteresis, but even this issue should go away with a power cycle and did not. See the Errata here: https://ww1.microchip.com/downloads/en/ ... 00760G.pdf
Those settings were changed to ensure that they were NOT the root cause!

OUNavCon wrote:Do the methods you mentioned require a working bootloader? Does bossac contact the serial bootloader in the device? Until I can get a working bootloader, will either of these two methods work?

What values does Adafruit set for the Fuse Registers in the Adalogger in production? I'd like to ensure that those settings have the same values that Adafruit sets them to when it leaves the factory. Just to eliminate those variables.

I ask, because with the arduino bootloader I get a single long pulse on the red led and then short pulses. Almost like it started the bootloader and then existed on an error condition.


Your value proposition is built around ease of use and the design worked fine before I updated the bootloader. However, you published documentation that shows the proper way to update the bootloader and it didn't work.
I have spent hours trying to debug this issue and I have a MSEE and over 20 years of experience. How is the average user going to be able to do that? So a $20 board, is now a $1500 version with the troubleshooting and engineering services.

My hope is that my efforts help someone overcome the same problem without the pain. If you want to take advantage of the recommendation and improve the robustness of this design and all others that are lacking in your catalog, that is your choice.

Thanks for the help and your time in remediation of this issue.

OUNavCon
 
Posts: 8
Joined: Sat Sep 18, 2021 8:43 am

Please be positive and constructive with your questions and comments.