SAML21 SAM-BA Example project help

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

Hi All,

 

I'd like to add the SAM-BA boot loader to a current project but things aren't working as I expected.  I was hoping someone could offer a little explanation/guidance into what I am seeing.  I am using an ATSAML21J18B chip and Atmel Studio 7.  I'm following the procedures detailed in AT10840.  I have created the new example project but I can't seem to make a connection via COM port and the SAM-BA gui.  I have compiled the code only for USART support, according to the documentation the boot loader should reside in the first 8k of flash 0x0 - 0x2000.  If I start the project with the debugger and look at the memory window or disassembly I'm seeing code all the way out to address 0x296A.  I rebuilt the project to check the build output and seemingly verified this finding:  

 

Program Memory Usage     :    10612 bytes   3.9 % Full

 

Does anyone have any idea what may be going on here?  I've read through several app notes and forum posts and have run out of ideas.  Any assistance would be greatly appreciated, thanks.

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

Don't you get a pre-built sam-ba that works with SAML? You do with SAMD. The SAMD application  note AT07175 also has this:
"To ensure minimal size for the bootloader, the source code as well as the project file is available only for the IAR compiler."
I guess it is still valid, i.e., if you actually have to re-build the bootloader then you need to get IAR (IAR Embedded Workbench for ARM) to get the code size down. It's free when the restricted code size license option is selected.

/Lars

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

All they provide is an example project in Atmel studio.  I opened a ticket with atmel support and they think there is an error in the documentation.  They recommended either increasing the optimization level or changing the start address in the SAM-BA code.  I'm going to try both to see if it makes a difference.  

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

Just an update to my previous response, The example project as supplied does not work.  It has a default optimization level of -O1.  It appears that a number of critical variables in the example code were not declared as volatile and get optimized out.  Setting optimization to -O0 and adjusting the start address got it working.

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

So much for the simple build the example project the app note suggests.

Did you resolve this? I am also having issue with the Example Project.

 

For me the SAM-BA tool (on the PC) does not start properly. It appears that the *ptr_data overwrites the length in getbytes (usart_sam_ba.c).

I cannot see anywhere that it reserves the SRAM for the applets.

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

After reviewing the source code that comes with AT07175​ - although it is for the SAM D21 and uses IAR - I was able to get this working by adjusting the memory and stack size.

 

/src/ASF/sam0/utils/linker_scripts/saml21/gcc/saml21j18b_flash.ld

/* Memory Spaces Definitions */

Memory

{

  rom      (rw)  : ORIGIN = 0x00000000, LENGTH = 0x00040000

  ram      (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00000FFF

  lpram    (rwx) : ORIGIN = 0x30000000, LENGTH = 0x00002000

}

 

/* The stack size used by the application. NOTE: you need to adjust according to your application. */

STACK_SIZE = 0x200;

 

(Sorry, didn't really want to hijack your thread, but thought it seemed relevant.)

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

bewster wrote:

After reviewing the source code that comes with AT07175​ - although it is for the SAM D21 and uses IAR - I was able to get this working by adjusting the memory and stack size.

 

/src/ASF/sam0/utils/linker_scripts/saml21/gcc/saml21j18b_flash.ld

/* Memory Spaces Definitions */

Memory

{

  rom      (rw)  : ORIGIN = 0x00000000, LENGTH = 0x00040000

  ram      (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00000FFF

  lpram    (rwx) : ORIGIN = 0x30000000, LENGTH = 0x00002000

}

 

/* The stack size used by the application. NOTE: you need to adjust according to your application. */

STACK_SIZE = 0x200;

 

(Sorry, didn't really want to hijack your thread, but thought it seemed relevant.)

No Worries, I have yet to resolve my issue.  I am waiting to hear back from support.  I'll report back any new progress.  

Last Edited: Thu. Feb 9, 2017 - 03:43 PM