SAMD21 Bootloader

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have Atmel SAMD21 Xplained Pro development board with ATSAMD21J18A on it. 
I have 2 codes for bootloader - 
1. File - New - Example Project and searching for “samba”
2. https://www.microchip.com/developmenttools/ProductDetails/atmel%20sam-ba%20in-system%20programmer

I load the bootloader through Debug USB. Then when I try to load any LED program, the SAM-BA application or the BOSSA application does not detect the port. I am trying to load the application using target USB and address as 0x1000, 0x2000 and 0x6000.

Please help!!

Last Edited: Fri. Aug 3, 2018 - 07:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Take a look at http://ww1.microchip.com/downloa...

 

Gives a great example.

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hey I have gone through this example. That too isnt working for me..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bop123 wrote:
That too isnt working for me..

What exactly isnt working? Did you modify the samd21j18a_flash.ld with the start address?

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My problem with AN-8185 doc is that I do not have OLED and USB cable to insert USB flash drive. So I was trying the other codes which I mentioned.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bop123 wrote:
My problem with AN-8185 doc is that I do not have OLED and USB cable to insert USB flash drive.

 

You don't need the OLED. You can just send the text to printf. As for the USB cable, you can pick one up for cheap. 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey I was trying to code as per AN-8185. I got compilation errors of 

1. recipe for target 'src/ASF/common/services/usb/class/msc/device/udi_msc.o' failed USB_HOST

2. uhi_msc_mem.h: No such file or directory

Where am I going wrong? Btw AN-8185 actually provides a good code!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I removed OLED stuff from the code. Now when I am debugging the code, it does not go beyond 

main_usb_sof_counter = 0;

line in main()

 

Please help!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bop123 wrote:
main_usb_sof_counter = 0; line in main()

Do have a USB thumb drive connected to the SAMD21?

"When all else fails, read the directions"

Last Edited: Thu. Aug 9, 2018 - 01:00 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I was trying to edit the applet but as lowlevelinit.tcl file is not available, do you know how to do it for samd21j18a?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I'm still working on this, I have a few questions-

1. I am unable to compile the file flash_app_main.c which resides in C:\Program Files (x86)\Atmel\sam-ba_2.15\applets\samd21j18a\sam-ba_applets\flash. This file is used by the applet in SRAM and comes with the SAM-BA software. I am getting a make error of sram_interrupt_sam_nvic.o file not found.

2. I am also trying to write to flash using nvm but unable to see any bytes getting written. I'm using the example code for this. 

Can you point out what exactly am I missing?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could also pgm via USART, if you have a FTDI adapter.  If not, you'll have to get hold of a USB cable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the SAMD21 examples, look for BOOTLOADER2 - that's the SAM-BA example for the SAMD21.  I built that then flashed it to my xplained-pro SAMD21 board and looks like it's working;  and, when I run SAM-BA 2.18, I can now connect to my board via the "target USB" connection, rather than having to use the "debug USB" connection.  The somewhat irritating thing I found out was that when ATMEL studio writes the bootloader to the board, it first erases entire flash.  So, I went in to the project properties-> build and looked at the tools area and there's a drop-down where you have various erase options.  Unfortunately the only two relevant one's are "erase all of flash" or only erase application area.  So, that's why when you build the SAM-BA bootloader2 app, it's going to wipe your application area and you'll have to put your app back out there.  Now there are probably other programmers which could be used which wouldn't erase any memory and you could write your SAM-BA bootloader out without having to reload your app.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i want to copy  my usb buffer data  to xml Buffer

if(usb_rx_buf != 0) //checking if data is available
            memcpy(xmlBuf,usb_rx_buf,usb_rx_buf+1);   //copying Usb data to xml Buffer      
            if(usb_rv_index >= sizeof(usb_rx_buf) )
            usb_rv_index ++;
            xmlReq = XMLparser_parse_str((uint8_t*)xmlBuf, &XMLParameter);
            clearXmlBuffer = 1;

but this not at all copying the usb buffer data .Please anyone can figure out my mistake

i want to writa a bootloader for firmware updation

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i want to copy  my usb buffer data  to xml Buffer

if(usb_rx_buf != 0) //checking if data is available
            memcpy(xmlBuf,usb_rx_buf,usb_rx_buf+1);   //copying Usb data to xml Buffer      
            if(usb_rv_index >= sizeof(usb_rx_buf) )
            usb_rv_index ++;
            xmlReq = XMLparser_parse_str((uint8_t*)xmlBuf, &XMLParameter);
            clearXmlBuffer = 1;

but this not at all copying the usb buffer data .Please anyone can figure out my mistake

i want to writa a bootloader for firmware updation

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 You are not calling memcpy with reasonable arguments here

  memcpy(xmlBuf,usb_rx_buf,usb_rx_buf+1);   //copying Usb data to xml Buffer      
void *memcpy(void *dest, const void *src, size_t n);

if usb_rx_buf is a source buffer then usb_rx_buf+1 is a pointer to the second character thus it can not be the length to be copied.

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you for your reply i have made some changes

*memcpy(*xmlBuf, *usb_rx_buf,usb_rx_buf[USB_RX_BUFFER_SIZE_BYTE]);  

but still am not getting usb data

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Still makes no sense, how many bytes are actually in the usb_rx_buf? That is what you need for the third argument.

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Usb-rx-buffer is defined as usb-rx-buffer[usb-rchd-size-buffe]
Which is 64 byte
Hard coded values are not allowed in my code
Thank you for your suggestions

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Guys, I have the same issue. I could burned the boot-loader (hex file) via atmel studio and USB is installed on windows. all is well. Next step. I want to use the SAM-BA v2.18 to upload the bin file to make sure all is good. I can write the file but no led blinks. I'm stuck here. Do I have to try something else ? I would appreciate if I can get help. It works fine when I use arduino IDE example codes and i can upload them via USb. but the thing is as I have projects from atmel studio and thats why I wana get it done. I think I miss might some steps in register address before burning the boot-loader- I would appreciate if I can get this done. Thanks.