ATSAMD51 reflashing himself every time

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Dimitree
 
Posts: 8
Joined: Fri Nov 08, 2019 10:13 am

ATSAMD51 reflashing himself every time

Post by Dimitree »

hi everyone
I designed my own board with ATSAMD51J20A and decided to use the UF2 Bootloader (v3.14.0) compiled for Metro M4 Express.
So I successfully flashed the bootloader using Openocd, and when using Arduino IDE I can see the board and upload the code into it.
But once the code has been upload, the board cannot be seen again/doesn't work until I don't press twice the reset button, and when I do that, the original code come back (1 sec flash led on pin 13).
I also tried to manually place a .uf2 into the USB storage, but again the old code come back.
Tried with both Win and MacOs

Is there a reason for this? am I doing something wrong?
thank you
Screenshot 2022-12-02 at 18.47.21.png
Screenshot 2022-12-02 at 18.47.21.png (118.2 KiB) Viewed 158 times

User avatar
Dimitree
 
Posts: 8
Joined: Fri Nov 08, 2019 10:13 am

Re: ATSAMD51 reflashing himself every time

Post by Dimitree »

I just noticed that the ATSAMD51J19 used by Metro M4 has 512 KB of flash memory, as opposed to the chip I'm using that has 1024 KB. I didn't notice this difference before and I thought the difference between the two chips was the RAM amount.
Could this be the cause? probably the address where user programs are stored is wrong so it can't work. If this is the case, I may need to recompile the bootloader for my chip, as far as I know there are no Adafruit boards using the chip that I am using

User avatar
Dimitree
 
Posts: 8
Joined: Fri Nov 08, 2019 10:13 am

Re: ATSAMD51 reflashing himself every time

Post by Dimitree »

so I noticed that PyPortal M4 uses the same microcontroller that I'm using, so I customized the bootloader (since PyPortal appears to use CRYSTALLESS 1 definition, while my board have a crystal). Built the bootloader with "make" and programmed it onto my board, now everything is fine and working!
but I have some questions:

1) in Arduino IDE, now I should use PyPortal M4 board definition, right? Has this any consequences on the pinouts I choose on my custom board?
2) I noticed that the .bin produced by "make" is called "bootloader-pyportal_m4-v3.14.0-10-gb17ca18-dirty". Why is called "dirty"? does it indicate some error?
3) what does BOOT_GCLK_ID_CORE and BOOT_GCLK_ID_SLOW (in the bootloader configurations) do?

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”