Author Topic: SAMD51 selfmain.c samd51j19a_self.ld  (Read 931 times)

0 Members and 1 Guest are viewing this topic.

Offline sperselsTopic starter

  • Newbie
  • Posts: 1
  • Country: us
SAMD51 selfmain.c samd51j19a_self.ld
« on: May 30, 2020, 01:45:04 am »
Working to understand how ARM bootloaders work by doing a bit of perusing the uf2-samdx1 bootloader code.

I see a couple of files selfmain.c and samd51j19a_self.ld that I'm confused what they are used for.   They seem to have corresponding files main.c and samd51j19a.ld and have similar content.

Can someone shed some light on the purpose for these files?

Thanks,

Shawn
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4416
  • Country: us
Re: SAMD51 selfmain.c samd51j19a_self.ld
« Reply #1 on: May 30, 2020, 04:36:43 am »
I think one has main for a self-programming thing, and one had the normal mail.I have no idea what the difference is, or what they do.
The .ld file is a linker script.  You might figure out something from comparing it to the non-self linker script.  It defines some extra memory sections:
Code: [Select]
Regular:
-  rom      (rx)  : ORIGIN = 0x00000000, LENGTH = 16K
-  ram      (rwx) : ORIGIN = 0x20000000, LENGTH = 192K
_Self version:
+  rom      (rx)  : ORIGIN = 0x00004000, LENGTH = 0x00080000 - 0x4000
+  ram      (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
+  bkupram  (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+  qspi     (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
main.c says it contains the SAM-BA code (which is the Atmel Bootloader.)  selfmain.c is entirely different?  Note the different start addresses for ROM.
As a guess, the chip winds up with two bootloaders - the normal SAM-BA bootloader that starts first, and later in rom the UF2 (disk emulating) bootloader - that's consistent with the way the Adafruit SAMD51 boards behave.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf