Go Down

Topic: Bootloader Recovery (Read 1 time) previous topic - next topic

jwestmoreland

FWIW, I connected a Segger JTAG to the ATSAMD21G18A -

The connector for the Atmel JTAG:


MRK4K Upside Down:

      ===========================================

                                                                                               1 = =
===|              5      3     1                                                           = =
       |              ||    ||    ||                                                            = =
===|              ||    ||    ||                                                            = =
(USB)              6     4      2                                                           = =

      ===========================================
                       J7                                                                        J11

1 - VTref
2 - SWDIO
3 - Reset(n)
4 - SWCLK
5 - GND
6 - NC

I have also attached a .bin file of the Atmel memory.

Regards,
John W.
               



jwestmoreland

#16
Feb 05, 2019, 11:14 am Last Edit: Feb 05, 2019, 11:19 am by jwestmoreland
Hi,

In my PC, samd21_sam_ba_arduino_mkrvidor4000.bin is located here:
C:\Users\(your_login_name)\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.25\bootloaders\mkrvidor4000

On GitHub, it is in the beta branch:
https://github.com/arduino/ArduinoCore-samd/tree/beta/bootloaders/mkrvidor4000
It appears the .bin that's on github is an html file that has been converted to a .bin file -

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
  <link rel="dns-prefetch" href="https://github.githubassets.com">
  <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com">
  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">

That's at the top of that file- if you do a save-as.

Make sure you download from here:
https://github.com/arduino/ArduinoCore-samd/blob/beta/bootloaders/mkrvidor4000/samd21_sam_ba_arduino_mkrvidor4000.bin


Regards,
John W.

chelmich

#17
Feb 07, 2019, 06:19 pm Last Edit: Feb 07, 2019, 06:55 pm by chelmich
It appears the .bin that's on github is an html file that has been converted to a .bin file -
Good catch. I checked an embarrassingly I had the wrong binary. Now I have the correct one but I'm still encountering issues with OpenOCD. It seems to be able to communicate fine but fails to write anything to flash. Here is my openocd.cfg and a log from trying to program it:

Code: [Select]

source [find interface/raspberrypi2-native.cfg]
transport select swd

set CHIPNAME at91samd21g18
source [find target/at91samdXX.cfg]

# gpio pins
bcm2835gpio_swd_nums 25 24
bcm2835gpio_trst_num 7
bcm2835gpio_srst_num 18

reset_config srst_nogate

adapter_nsrst_delay 100
adapter_nsrst_assert_width 100

init
targets
reset halt

# write bootloader
at91samd bootloader 0
program samd21_sam_ba.bin verify
at91samd bootloader 8192

reset
shutdown

Code: [Select]

BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdo = 9
BCM2835 GPIO nums: swclk = 11, swdio = 25
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
BCM2835 GPIO nums: swclk = 25, swdio = 24
BCM2835 GPIO config: trst = 7
BCM2835 GPIO config: srst = 18
none separate
adapter_nsrst_delay: 100
adapter_nsrst_assert_width: 100
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : JTAG and SWD modes enabled
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 3333 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* at91samd21g18.cpu  cortex_m   little at91samd21g18.cpu  halted
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
Error: SAMD: NVM programming error
Error: Failed to erase row containing 00000100
Error: SAMD: failed to erase sector 1 at 0x00000100
Error: failed erasing sectors 0 to 31
embedded:startup.tcl:480: Error: ** Programming Failed **
in procedure 'script'
at file "embedded:startup.tcl", line 63
in procedure 'program' called at file "openocd.cfg", line 29
in procedure 'program_error' called at file "embedded:startup.tcl", line 539
at file "embedded:startup.tcl", line 480
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
shutdown command invoked


Based on the logs I suspect some issue with the NVM settings. I got the NVM user row with the command "at19samd nvmuserrow". The output was the following:

NVMUSERROW: 0xFFFFFC5DD8E00007

Would anyone with a functional board mind checking to compare? As far as I can tell, the way I'm invoking OpenOCD is identical to the way in the Arduino IDE scripts. I could potentially try that Adafruit SWD debugger although I would have to order it. I'm also open to any other suggestions.

Edit: I checked my flash dump against yours, John and unfortunately the section that should contain the bootloader (0x0 all the way up to 0x48F0) is filled entirely with ones. So this pretty much confirms that the bootloader got toasted somehow.

Edit 2: I checked the memory of the board using "mdw 0x804000 2" and checked the same location in your memory dump. They appear to be the same but with the endian-ness flipped. Specifically OpenOCD reported the following:

0x00804000: d8e00007 fffffc5d

I assume whatever tool you used to dump memory flipped the bytes. So that rules out issues with the NVM. Now I'm really confused as to what could be going wrong.

jwestmoreland

chelmich,

I used the tools that come with the Seggers - could be the classic PC byte swap that maybe those tools take care of automagically.

Just wondering - did you happen to install the bootloader update?  I assume you have.

In the file I posted - that particular board hadn't been updated - and I found that by looking at what I posted here!

Just make sure you've done the latest bootloader update.

Regards,
John W.

chelmich

John,

Thanks for the help with this. No, I didn't install the bootloader update before the board got bricked. Ironically that may have fixed the issues that I was fighting when it stopped working in the first place. I'm still struggling to understand why trying to flash a bootloader with OpenOCD doesn't work. The Arduino IDE runs a script that calls it and I'm matching their config exactly as far I can tell. I put in an order for the Adafruit SEGGER debugger to use instead of the Raspberry Pi. Hopefully that fixes things, but I'm not sure.

Charles

rrace001

Glad to hear it. Did you use OpenOCD? If so, would you mind posting your openocd.cfg? I seem to be having issues with mine.
I have never used OpenOCD. I use the Segger JLink edu mini I got from Adafruit.  Never had a problem with it. It is almost indestructible and it only costs $20.  I use the Segger JLinkExe command line tool for lInux that I downloaded from the Segger website.  Very easy to use. Highly recommend it. 

jwestmoreland

Charles,

Have you tried this:

http://downloads.arduino.cc/tools/VidorFPGARecovery.zip

I ran through it - works OK - had a couple of boards that appeared the NINA-W102 was unresponsive.
Ran that and I could talk to the NINA's again - of course this could be that serial port issue as well.

Give that a try if you haven't already.

Regards,
John W.

jwestmoreland

Charles,

Did you get your Segger I/F?

Have you unbricked your board?

Regards,
John

chelmich

John,

Not yet. I ordered a Segger debugger but forgot to include the breakout board, so I'll have to wait a bit longer. As far as the FPGARecovery procedure you mentioned I can't use it because it relies on getting the board into bootloader mode by double tapping the reset. Because my bootloader appears to be nonexistent that isn't an option. So for now the board is still bricked. I appreciate the help though.

Charles

jwestmoreland

Charles,

I assume you've soldered down the 6-pin surface mount header you need for the ARM, correct?

I have that P/N - but the schematic has those also - note Arrow has some really good deals right now - no shipping even on small orders - not sure if that applies to overseas and/or AL or HI.

I've actually bought more stuff from Arrow lately than Digikey or Mouser (I still love Digikey and Mouser) - Arrow has just got aggressive - and next day - no extra charge in a lot of cases - note this could apply only to continental US - not 100% sure.

Those in Europe could have a similar deal since Arrow is worldwide - not sure about places like Japan though.  Maybe in Japan they have plenty of DIY shops.

Regards,
John
PS - I don't work for Arrow nor do I get paid or compensated for any of the above comments. Just trying to pass on the 'news' to fellow DIYers.

chelmich

Thanks for the heads up.

And yeah, I soldered some wires onto the 6-pin header since I don't have a 0.5 pitch surface mount header lying around. It mostly worked with the Raspberry Pi but like I posted before I was having issues flashing anything. Perhaps I was doing something wrong with OpenOCD but I don't think so. Either way, hopefully the Segger fixes it.

jwestmoreland

Charles,

Actually - the header for the ARM is 0.1" pitch.  For the FPGA it is 0.05".  The ARM's is 6 pins and the USB Blaster I/F is 10 pins.

Regards,
John

chelmich

My bad, I was thinking of the debugger. The cable it has uses a 0.05 pitch which is why I need the breakout board. I did successfully solder onto the ARM header though. I'm pretty positive of this because I was able to read data off the SAMD through OpenOCD.

I'll be sure to keep this thread updated when I try the Segger.

Go Up