Bootloader for ATSAMD10 - Page 1
Forum section: electronics / general

author: gussabina
author_rank: Newbie
timestamp: November 23, 2016, 08:26:14 am
content: Hello:I'm looking for a Bootloader for SAMD10 and reading "Atmel AVR2054: Serial Bootloader User Guide" which provides examples for different AVR and SAMR21 parts, there are some things not very clear to me. According the Application Note, the bootloader firmware is flashed in the device, and after reset it executes and connect to a PC program to download the user application. The downloaded user application is then flashed in the device (in a higher address space in flash) and executed once this process is finished.However, if the user application is not starting at flash address 0x00, then it should be linked to start in a different address... But there is no mention about this...I'm wondering how this really works...I would appreciate any comment on this.ThanksGus

author: stfsux
author_rank: Contributor
timestamp: November 23, 2016, 01:49:02 pm
content: I've never used any SAM microcontroller but I will try to guess.In most ARM cortex-M, at 0x0 from your application you will have a vector table for interruptions (generally the first DWORD is the initial stack value, then the next DWORD is the address of the RESET vector, etc.).So you can relocate your RESET vector at a specific address but your vector table must be located at 0x0.All this stuff is done by your linker.The bootloader doesnt have to known where your application will be loaded, it will load the stack pointer then branch to the reset vector (by reading and replacing PC register with the value of DWORD located at 0x0+4 from application address space).

author: ataradov
author_rank: Super Contributor
timestamp: November 23, 2016, 04:18:26 pm
content: Quote from: gussabina on November 23, 2016, 08:26:14 amThis is a very big bootloader designed for ZigBee stacks, it will take 1/4 of the entire flash of the device (even if it could work on D10).You are correct, application needs to be linked after the bootloader, there is no mention of this, because it is already taken care of by the ZigBee stack. There is some other stuff that is required in that case anyway.I have a number of very small (< 1K bootloader) bootloaders for those part, but I need to check if I can distribute them publicly.

author: ataradov
author_rank: Super Contributor
timestamp: November 23, 2016, 04:19:44 pm
content: Quote from: stfsux on November 23, 2016, 01:49:02 pmNo, the vector table can be moved in all Cortex devices, you jest need to update the SCB->VTOR register accordingly.

author: gussabina
author_rank: Newbie
timestamp: November 23, 2016, 04:26:29 pm
content: Hello Alex:Thanks, it would be great if you can share a light bootloader for SAMD10, because the one I'm looking takes like 4K of flash (from the 16K available).ThanksGus

author: gussabina
author_rank: Newbie
timestamp: November 23, 2016, 04:34:05 pm
content: Hello stfsux:Thanks for your help.Yes, agree the linker can create the image starting in any memory address (other than the default), but you need to tell the linker to do so.My point here is that the Application Note doesn't mention that requirement, so the user would assume that a normal application would run, and I dont's think this is the case because the application would be generated to start at address 0x00, but the bootloader is already sing that space. Even when the bootloader would download the application and flash it in other memory space, it won't work because it was linked to a specific memory address space to run At least, this is my understanding.Regards;Gus

author: andersm
author_rank: Super Contributor
timestamp: November 23, 2016, 06:27:40 pm
content: Quote from: ataradov on November 23, 2016, 04:19:44 pmIn ARMv6-M devices it is optional.

author: ataradov
author_rank: Super Contributor
timestamp: November 23, 2016, 06:28:45 pm
content: Quote from: andersm on November 23, 2016, 06:27:40 pmYes, but I doubt there is a single device out there with this option disabled.

author: ataradov
author_rank: Super Contributor
timestamp: November 23, 2016, 06:31:03 pm
content: Here is a small I2C bootloaderhttps://dl.dropboxusercontent.com/u/6121480/work/b/bootloader.zip. I recommend this one.Here is UART bootloader for D20, but it can be ported to D10 easilyhttps://dl.dropboxusercontent.com/u/6121480/work/b/bootloader_uart.zip. This one is a bit more elaborate and requires image preparation by Python scripts (included).

author: gussabina
author_rank: Newbie
timestamp: November 23, 2016, 07:51:18 pm
content: Hello Alex:Thanks for the links.I just found this one, which seems to be for SAMD10 and UART;http://atmel.force.com/support/articles/en_US/FAQ/Low-footprint-SERCOM-UART-bootloader-for-SAM-D10-SAM-D11-devicesI will take a look at all this material.Thanks againGus

author: stfsux
author_rank: Contributor
timestamp: November 23, 2016, 08:32:49 pm
content: Quote from: ataradov on November 23, 2016, 04:19:44 pmSure but in that case your bootloader need to change it and should mention it somewhere. Otherwise, I guess we have the default configuration.Quote from: gussabina on November 23, 2016, 04:34:05 pmYe, after a quick look (http://www.atmel.com/Images/Atmel-42366-SAM-BA-Bootloader-for-SAM-D21_ApplicationNote_AT07175.pdf) you're right.So that mean you have to dig some doc about that pre-programmed bootloader and check where you need to locate your application program.glhf

author: ataradov
author_rank: Super Contributor
timestamp: November 23, 2016, 09:00:11 pm
content: Quote from: stfsux on November 23, 2016, 08:32:49 pmNo, this must be done by the application, since only application knows how it is linked. I often have applications run from RAM, so beginning of the application (wherever it is located) only contains two values - initial stack pointer and reset vector. The rest of the table is in RAM.Quote from: stfsux on November 23, 2016, 08:32:49 pmThose devices don't come with a bootloader. Only CSP packages have pre-programmed bootloader and that is documented, but it is 4K in size.

author: Skerved
author_rank: Contributor
timestamp: May 31, 2017, 11:23:04 am
content: ataradov, is there a chance you could make that I2C bootloader available again? I have been looking for a simple non asf version that I can build upon.As a lurker, thanks for all your help with SAMDXX coding!

author: ataradov
author_rank: Super Contributor
timestamp: May 31, 2017, 04:04:23 pm
content: Here it ishttps://www.dropbox.com/s/qxa24frevwmb1ht/bootloader.zip?dl=0