Go Down

Topic: Atsamd21g18 Bootloader (Read 12653 times) previous topic - next topic

arzaman


oops...it was under my nose and I don't realize this "export compiled bianry" menu for so many time ( I think is there since few IDE releases ! great simple feature

I see the great work of Mattair and I try to adapt the bootlaoder to my platform that is based on SAMD21G version and I have alredy 4 push button connected to the micro ..I will try to use one as "bootlader button" during power on (hope not to have bouncing issue)

I think this approach for sw upgrade is more easy and relaible than SAM-BA bootlaoder and bossac sw uploader...no special USB driver, no specific load applicaiton sw, nothing to install PC side

hope it's working and is stable !

one more question..if i power the board via USB without entering the boot mode I expect I can start my serial connectio (COM port) as usual right ?

Davide

rickrcomm

@AloyseTech I've been tearing my hair out trying to program the Adafruit Feather M0 bootloader with the Segger JLink.  I have read the Adafruit debugging of ATSAMD21 processors https://learn.adafruit.com/proper-step-debugging-atsamd21-arduino-zero-m0/overview.

I have tried doing it via Atmel Studio 7 and directly with the JLink.exe software for the Segger JLink.  I get the attached error message.

Interestingly, I can read the memory of a fresh board that still has the Adafruit burned bootloader fine, but as soon as I try to use AS7 to debug a sketch, the bootloader is overwritten with 0xFF's.  I can also use the w1 command in JLink to write a byte in the M0 flash and it reads back successfully.  As soon as I try to write the whole bootloader .hex file, I get the attached error.  I have tried slowing the JLink speed down to 1000 kHz and even 500 kHz, but same error occurs.

I'd buy the Atmel-ICE Basic board if I have to, but the JLink should work too, shouldn't it?

Thanks for any ideas.

Rick

arzaman

@AloyseTech I've been tearing my hair out trying to program the Adafruit Feather M0 bootloader with the Segger JLink.

...........

I get the attached error.  I have tried slowing the JLink speed down to 1000 kHz and even 500 kHz, but same error occurs.


Rick
I follow up this since I have similar issue with one of my custom board with SAMD21G18
I was thinkig that could be my specifc and local issue (some HW problem or some corruption on the flash doing many experiments) but from Rick post seems a common issue

I connect SEGGER J-link via SWD interface and I try to load bootloader (modified SAM-BA from sparkfun) from location 0x000 but if I do Program&Verify  I'm propted that the program area is not empty and if I select to overwrite (answer YES to pup up) the programming process fails and here is the log

- Erasing affected sectors ...
    - Erasing bank 0, sectors 0-24
    - ERROR: Blank check after erase reports: Failed to erase sectors 0-24 (0x00 - 0x18FF) @ address 0x00
    - ERROR: Failed to erase sectors
 - ERROR: Failed to program and verify target



If I answer no to overwriting the area the process end successfully  :o

RAM tested O.K.
 - Programming target (6384 bytes, 1 range) ...
    - Target programmed successfully
 - Verifying target (6384 bytes, 1 range) ...
    - All loaded bytes verified OK!


But then when I load the application from address 2000 it doesn't work at all (same binary on another board works perfectly)

If I try to erase chip I got again an error :(

Erasing chip ...
 - Erasing 1025 sectors, 2 ranges, 0x0 - 0x3FFFF, 0x804000 - 0x80400F
 - RAM tested O.K.
 - Erasing bank 0, sectors 0-63
 - ERROR: Blank check after erase reports: Failed to erase sectors 0-63 (0x00 - 0x3FFF) @ address 0x00
 - ERROR: Failed to erase chip



Do I have something corrupted in the SAMD21? Is there any way to erase completely the flash?
I try also by command shell and command line but error are the same..

Attached some screenshots

Davide



AloyseTech

I'm not familiar with the J-Link devices, but one line that caught my eyes is :
Code: [Select]
WARNING : CPU is running at very low speed (1328kHz).

Maybe you have an hardware issue with the clocking system. I'm not sure though. Sorry I can't really help on that matter...

ericbaril72

The Bootloader section is fuse protected.  You need to disable it first in order to be able to "erase" that seciont.

In Atmel Studio: tools -> Device Programming
   Selct your J-link, Make sure it can read the device ID

   Look into the FUSES section, Edit the BOOTPROT...
       Section 22.6.5    http://www.atmel.com/Images/Atmel-42181-SAM-D21_Datasheet.pdf

I too postponed the ready of those 1000's pages until I could no longer avoid it !

Luckily for you, the boot prot section is the shortest   ;-)     1 paragraph and 1 table

BOOTLOADER WORK:
I just finished porting my project to ASF ( including the SD card bootloader ) so I can make good use of the J-link box in "debug" mode and LOVE the ability to search function declaration in the entire project.

If you intend to keep the Arduino IDE, I would suggest you leave the original bootloader alone ( addr: 0x0000 - 0x2000 ) and implement your own bootloading requirements into 0x2000 to 0xXYZ and finally put your arduino sketch at the end ...

I do not know of many sketches that would require the "original bootlodaer 8KB" when you have 256kB available. 

You could take the original arduino bootloader to burn yours ( and have a backup plan when it fails ).  No need for a J-link or Atmel-ICE as the bootprot fuses are not protecting further and you would still need to learn the dreaded TOOLCHAIN by playing with the "start address".

good luck .

WARNING : when using the J-LINK ( and other debuggers ), they seem to interact with the WDT and clocking scheme.  The Arduino platform on the Zero


boppana113

Can a segger J-link lite be used instead of an Atmel ICE? It looks like a cheaper alternative?
https://www.segger.com/jlink-lite-arm.html


Can the Segger J-link edu be used?
https://www.adafruit.com/products/1369

Thankd

sanotronics

#21
Jun 28, 2018, 09:15 pm Last Edit: Jun 28, 2018, 09:40 pm by sanotronics
Hello!

Does anyone here know for sure that the SAM-ICE works for ATSAMD21 uC?

https://www.microchip.com/DevelopmentTools/ProductDetails/AT91SAM-ICE#additional-summary


I can't find anywhere in the doc as "Supported uCs" or something similar that states they are compatible.

Quote
"SAM-ICE is a JTAG emulator designed for SAMA5, SAM3, SAM4, SAM7 and SAM9 ARM® core-based MCUs and MPUs, including Thumb mode."
I guess it's just another JTAG tool and it should work, but what most doubts gives me is the previous paragraph that doesn't list SAMD21.

In fact, the SAM-ICE user manual says it works with
Quote
Any Atmel AT91 core supported, including ARM® Thumb® mode
And I don't think the SAMD21G18 is an AT91 core, but I don't know for sure.

What's more confusing is that the Arduino IDE has SAM-ICE as a programmer, for the zero and such.

Does anyone know for sure?

Thanks!

sanotronics

All right, I found the answer in page 21 of the manual.

In the FAQ section:

Quote
Which CPUs are supported? SAM-ICE supports all ARM based Atmel microcontrollers.

westfw

Quote
SAM-ICE supports all ARM based Atmel microcontrollers.
Good Luck. Note that SAMD uses "SWD" rather than "real jtag."  The SAM-ICE does claim to support SWD.  And it says that various cortex M3 and M4 have had support added, so that's promising.  I don't see any note about Cortex M0+, though, which is ... disturbing.  (in theory, JTAG or SWD is relatively independent of actual core.)
I can say that Atmel Studio won't let you configure a debug tool for a project unless that tool is actually connected to your computer :-(
(it looks like some folks over on AVR-Freaks have gotten it to work...)

Phil-D

Hi

Good Luck. Note that SAMD uses "SWD" rather than "real jtag."  The SAM-ICE does claim to support SWD.  And it says that various cortex M3 and M4 have had support added, so that's promising.  I don't see any note about Cortex M0+, though, which is ... disturbing.  (in theory, JTAG or SWD is relatively independent of actual core.)
I can say that Atmel Studio won't let you configure a debug tool for a project unless that tool is actually connected to your computer :-(
(it looks like some folks over on AVR-Freaks have gotten it to work...)

If it is any help I've been using the Atmel SAM ICE and SWD no problems at all with a clone of the Arduino M0 board.

I've successfully opened Arduino projects in Atmel studio and programmed them across, which replaces the boot-loader, and debugged them fine.

I've been able to completely erase the flash from Atmel studio, then easily using the same programmer from the Arduino IDE put back the boot-loader and bring it back to how it was. 

Regards

Phil




sanotronics

Phil!

Thank you! That's great news.

Did you use any guide to go through all this?

Did you make one yourself?

It would be great if you can share that.

Phil-D

Hi

I'm waiting for some PCBs to see if my self made circuit for the SAMD21 works.  My tests were using a cheap Arduino clone of the M0 with ICE connected to test how easy it would be to get it up and running with a blank chip.  For example I've erased the flash entirely and re-instated a bootloader and had everything working again.

Some things I've learnt.

The Arduino IDE needs an update to burn some of the SAMD21 bootloaders, otherwise it errors, a fix is available, not sure why this fix hasn't been implemented by now, but this allowed me to successfully burn the bootloader from the Arduino IDE for Arduino M0 https://github.com/arduino/ArduinoCore-samd/issues/264. It adds some more boards just for burning the bootloader.

If using Visual Studio and Visual Micro with SAMD21 there is some bug somewhere that means it can take ages to program with lots of timeouts, but seems to work fine from the Arduino IDE in seconds.  There doesn't seem to be a solution yet.  Options are to wait the several minutes, which is a pain if debugging and trying things out which needs lots of flashes, or alternatively go bootloader-less for development using the ICE controller.

Info here on this issue https://www.visualmicro.com/forums/YaBB.pl?num=1498648612/1, and some really good info here on how to set up to flash without a bootloader, which is super fast when flashing, see post #4 here https://forum.arduino.cc/index.php?topic=452013#4

Regards

Phil


Go Up