Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAMD51: UART support timing issues #22

Open
dhalbert opened this issue May 8, 2018 · 5 comments
Open

SAMD51: UART support timing issues #22

dhalbert opened this issue May 8, 2018 · 5 comments

Comments

@dhalbert
Copy link

dhalbert commented May 8, 2018

microsoft#42 from @MartinL1:

Thank you to everyone for the work on the UF2 bootloader.

I'm using a SAMD51 (SAMD51J20A) custom board. The USB CDC works perfectly with the Arduino IDE, however I've been having some trouble getting the UART support to work.

I powered the board without the native USB connection to prevent enumeration, put my custom board into bootloader mode with a double tap of the reset button, then attempted to upload a Blink sketch with the Arduino IDE, using an FTDI USB to serial board on a spare UART port, (in my case SERCOM5).

After looking at the code, I believe that line 128 of the "usart_sam_ba.c" file needs to be changed from:

// Baud rate 115200 - clock 8MHz -> BAUD value-50436
uart_basic_init(BOOT_USART_MODULE, 50436, BOOT_USART_PAD_SETTINGS);

to:

// Baud rate 115200 - clock 48MHz -> BAUD value-63018
uart_basic_init(BOOT_USART_MODULE, 63018, BOOT_USART_PAD_SETTINGS);

This is to account for GCLK0 now being set to 48MHz. The replacement line is taken from the Arduino Zero bootloader.

After this modification I'm now able to upload the sketch using the FTDI board, unfortunately though some timing issues still persist, as this only works on every second attempt.

@dominicjprice
Copy link

I'm seeing the same issue on a Trinket M0 board with the bootloader customised to use the UART on Sercom2. First attempt to upload fails, second succeeds.

@alexwhittemore
Copy link

@dominicjprice I don't mean to hijack the topic, but... How'd you customize the M0 to use a hardware UART for bootloading? I need to accomplish the same and I'm trying to dig in right now.

@dominicjprice
Copy link

dominicjprice commented Mar 22, 2019

Hi @alexwhittemore, have a look at my fork here https://github.com/dominicjprice/uf2-samdx1 and the projecthoop branch. The bootloader already contained the code for updating over UART, it just needed compiling in (and another method being left out due to size constraints).

@alexwhittemore
Copy link

What a guy, thank you!

@slyalfa
Copy link

slyalfa commented Jul 6, 2020

Both the baud rate problem and the not uploading on first try should now be fixed with the PR that went in today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants