Sam4S bootloader implementation With Atmel Studio

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

Hello All

I wanted to make a bootloader for a sam4s with atmel studio, do you have any advice on how to proceed?

I liked doing that the SD memory was seen as Mass storage to copy the application file to us.

Do you have any advice on what I could do?

I'm new to atmel, i have some experience with keil only

Thank you all

Last Edited: Sat. May 1, 2021 - 12:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is an excellent application note on that on Microchip's homepage (http://ww1.microchip.com/downloads/en/Appnotes/Atmel-42476-SAM4L-USB-Host-MSC-Bootloader-with-Optional-AES_ApplicationNote_AT04155.pdf), that will guide you through that process. The process applies to both the ATSAM4L and ATSAM4S, so it should be an excellent starting point

 

Ilya

Last Edited: Sat. May 1, 2021 - 01:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for the link
It is very useful.
But do you think I can show an SD as a mass device via USB by connecting with the PC?

nemoscaos

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

Yes, you can - for that you will most likely use the USB's composite+MSC+CDC classes (it is available within the ASF software in the Studio, along with the examples of how to use it )

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

Ok thank you!!!
Now i try It.
In the next time , i will tell you if it's ok

Thanks!!!

nemoscaos

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

Hi Ilya
Hi everyone

it's still me ...

.... I downloaded the guide as suggested and perfect and very well done, thanks.

 

the guide is for the micro ATSAM4L, you told me it was fine for the ATSAM4S, actually they are very similar, but not the same enough :)

So I should port to ATSAM4S, I'm not sure I can do that.

do you have any advice? it's not enough to change the micro, right? :)

nemoscaos

 

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

nemoscaos wrote:

Hi Ilya
Hi everyone

it's still me ...

.... I downloaded the guide as suggested and perfect and very well done, thanks.

 

the guide is for the micro ATSAM4L, you told me it was fine for the ATSAM4S, actually they are very similar, but not the same enough :)

So I should port to ATSAM4S, I'm not sure I can do that.

do you have any advice? it's not enough to change the micro, right? :)

nemoscaos

 

Yes it is also applicable to SAM4S as well - with some slight adjustments:

  1. The first adjustment that you have to make is that you will need to know where the SAM-BA bootloader ends on your SAM4S system so that you can put your bootloader on top of it. I have several boards that I am working with so I couldnt pull that address value out of my memory. But I myself will be working with that bit in the next few weeks so I would share this info once I got the grip of it all 
  2. You may need to make adjustments to the code since the register names etc, may be different. You can actually download the ASF code as a standalone archive (https://www.microchip.com/mplab/avr-support/avr-and-sam-downloads-archive) and poke around with it. It should also include the example projects that are mentioned in that application note. The only thing you will need to do is to create a user account on the Microchip website before itll allow you to download (creating the account and downloading the ASF sources are both free of charge to you)

 

Hopefully it will at least get you started in the right direction for the time being

 

Ilya

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

One moment

in the example SAM4L is configured as a USB host but are we sure that the SAM4S supports host mode ??

I do not think so...

 

nemoscaos

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

nemoscaos wrote:

One moment

in the example SAM4L is configured as a USB host but are we sure that the SAM4S supports host mode ??

I do not think so...

 

nemoscaos

 

Well technically both families only support the Full Speed usb mode (I just checked), so the terminology used in this case is misleading because you connect them both to your host PC for downloading the new bootloader - youd do the software upgrade in the same manner if you are using SAM-BA and not hardware programmers/debuggers like Atmel ICE

 

Ilya

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

OK then I cannot simply connect a USB and update,

but I have to connect the device to the PC via a SAM-BA or similar software (or to the programmer).

 

thanks Ilya you are very kind

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

nemoscaos wrote:

OK then I cannot simply connect a USB and update,

but I have to connect the device to the PC via a SAM-BA or similar software (or to the programmer).

 

thanks Ilya you are very kind

 

Realistically you have 2 possible approaches here:

  1.  Use SAM-BA/own software (SAM-BA had example code of how you create your own software for PC side)/hardware programmer to flash your SAM4s with the binaries
  2. There is an option of adding the self-programming feature to SAM4 family - I havent researched it in detail but from my experience with other Atmel microcontrollers it should be doable

 

So the choice of the flashing method will depend on the technical details of your project

 

Ilya

EDIT: I also remembered one thing that you have to watch out for as far as SAM4S are concerned - some SAM4S parts have more than 512K flash memory which means that you need to make sure you also take account of the fact that there may be 2 memory banks and not 1

Last Edited: Wed. May 5, 2021 - 12:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

shtirka wrote:

 

  1. There is an option of adding the self-programming feature to SAM4 family - I havent researched it in detail but from my experience with other Atmel microcontrollers it should be doable

 

So the choice of the flashing method will depend on the technical details of your project

 

 

then my initial idea comes back:

1 - connect the usb as a slave to the pc

2 - show the sd card to the PC as a mass device (HELP ME)

3 - copy the .bin file to the SD card

4 - reset and start the update on the flash, also using the example of SAM4L that you kindly provided me!

 

it's ok?

go to work !!! :)

 

thanks

nemoscaos

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

nemoscaos wrote:

shtirka wrote:

 

  1. There is an option of adding the self-programming feature to SAM4 family - I havent researched it in detail but from my experience with other Atmel microcontrollers it should be doable

 

 

So the choice of the flashing method will depend on the technical details of your project

 

 

 

then my initial idea comes back:

1 - connect the usb as a slave to the pc

2 - show the sd card to the PC as a mass device (HELP ME)

3 - copy the .bin file to the SD card

4 - reset and start the update on the flash, also using the example of SAM4L that you kindly provided me!

 

it's ok?

go to work !!! :)

 

thanks

nemoscaos

 

If you already have Atmel studio installed, then most likely you also have installed the ASF - Advanced Software Framework, it contains all sorts of code examples and projects (unless you downloaded the standalone archive from the link I provided you with). USB isnt exactly an easy component to deal with so I strongly recommend starting an example project with Atmel studio that is specifically dedicated to usb - you can start one with "Start example project... " on Atmel studios start page or File->New->Example project. (You will also find examples in the ASF standalone archive I was referring to in my earlier posts)

 

Ilya

Last Edited: Wed. May 5, 2021 - 12:51 PM