Reflash the Arduino M0 Bootloader/Wemos Arduino Zero SAMD21 Clone wrong Bootloa

Hello everyone,

i am currently programming on a arduino "Zero" board which is essentially a M0 variant from a vendor calle wemos.
This Board:
http://http://api.riot-os.org/group__boards__wemos-zero.html#details

Is it possible to reflash the stock "Arduino M0" Bootloader over the 'wrong' preinstalled "Zero" version?
If don't own a Atmel-ice is it possible to just use the arduino ide to forceflash it to M0

I do have the SWD(EDBG) connector on it and would buy a JLink board if necessary because i can fix future board with it.

Why?
if i use the current Arduino 1.8.13 IDE Digital Port Nr. 2. and 4. are mixed up and i have found someone with the same problems here: https://forum.arduino.cc/index.php?topic=594634.0
PWM on Pin 2 is not availible (fade.ino example no output with led+resistor :-/ )

If i try to use the included tft library i get lot of errors about the display controller of my 1,8"TFT (not on arduino uno board there it works nicely)

Just to line this clone up to the ide, i started with it because i tend to fry 3,3V boards more often

i have found this website which shows how to flash these boards:

That's why i believe the bootloader is wrong it needs to be the M0 one

But defined Port 4 is 2 and 2 is 4 so it is mixed :-/

If i flash i can only do it with Zero ("Native USB Port") and not M0 which i expeted

Okay according to this post Nr #14 by elliotwoods i only need a JLink..
https://forum.arduino.cc/index.php?topic=532385.0

the bootloader has nothing to do with the swapped pin. but of course you must select Zero to upload so the variant has the pins swapped.
the Zero bootloader is better.
to burn the bootloader you need a cable with connector for the SWD header, which next to the SPI header.

Thank you! i will look into the Jlink usb adapters to restore the bootloader if i destroy it somehow..

@Juraj
"of course you must select Zero to upload so the variant has the pins swapped"
Current:
if i select "Zero" the pins are swapped and wrong
Should be:
if i select "M0" which should be right from the hardware "looks" i can't flash...

Fade.ino fails with avrdude: stk500v2_ReceiveMessage(): timeout

Der Sketch verwendet 12248 Bytes (4%) des Programmspeicherplatzes. Das Maximum sind 262144 Bytes.
Globale Variablen verwenden 2984 Bytes des dynamischen Speichers.
Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port COM20
PORTS {COM1, COM3, COM20, } / {COM1, COM3, } => {}
PORTS {COM1, COM3, } / {COM1, COM3, COM19, } => {COM19, }
Found upload port: COM19
K:\arduino-1.8.13\hardware\tools\avr/bin/avrdude -CK:\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf -v -v -patmega2560 -cstk500v2 -PCOM19 -b57600 -Uflash:w:C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_300085/Fade.ino.hex:i 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "K:\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM19
         Using Programmer              : stk500v2
         Overriding Baud Rate          : 57600
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
...
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
....

yes you can't upload over Zero bootloader if you have M0 selected and via versa.
as strange as it is, the USB upload to M0 uses avrdude, because the bootloader is made to use STK500.

@Juraj
or anyone else

is there a dissadvantage that my board comes with the "Zero" Bootloader? Swapping pins is already an annoyance, thats why i figured i change the bootloader to the "M0" that looks 1:1 the same from the chip count and micro usb options it should fit better..

Why are the ports then swapped in the first place if the "Zero" bootlader is the right version for this board? I can imagine that it is a rounting error, more like a china upgarde which went wrong

as I wrote in my first comment the pin mapping is not related to bootloader. it is related to selected board variant. but the upload method is too related to selected board. if you could compile for M0 variant and upload to Zero variant then the pins would not be swapped

(it is possible to define own board with mixed properties of M0 and Zero)

I can't remember. I think that the M0 clone board comes with the Zero bootloader but has M0 pinout (i.e. digital #2, #4 are swapped)

Run the Windows "Device Manager". It should tell you the COM# and any "device name"

Or just look at "Port" in Tools->Ports

The M0 clone should work fine with the Zero bootloader. You just need to edit the variant.h to explain the swapped D2, D4 pins. All the other pins are the same as Zero.

Note that you use SerialUSB instead of Serial for UART comms to a Terminal.

You can change bootloaders but it is not necessary. You need an ATMEL-ICE, SNAP, PICKIT4, JLINK, ... with a 10-way SWD ribbon cable.

David.

david_prentice:
Note that you use SerialUSB instead of Serial for UART comms to a Terminal.

only for M0

Hello every one again ::slight_smile:

I do use the board and it works fine, just one interrupt is not working

attachInterrupt(digitalPinToInterrupt(3), funcInterrupt2, FALLING);

If i set it to its own 3,3V and then just dump the toggle switch to ground the funcInterrupt2 is not called :-/

i have seen the picture from the M0/Pro Pin out where Pin 3 is also "EXTINT9" does that interfere with the interrupt?

I did connect my tft(1.8 TFT 128 x160) to the ICSP with PB11/SCK and PB12/MISO/PB10/MOSI does it block interrupt? It works as expected with the tft library, nothing else connected!