SAM-BA / SAMC21 / Problem writing to FLASH

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

Hello!

 

i've here a SAMC21E15A microcontroller which i want to program over UART.
On the ATMEL website i found the SAM-BA v2.18 project and start to customize it for the controller.
I used as a basis the example project for the xplained pro board (samc21_xplained_pro). After adjusting the memory/ram, i was able to run the applet and connect via the SAM-BA tool.
With the tool i'm able to read/write ram values, delete application section and so on. I can also read the complete flash and save it to file.
The only thing i can't do, is to flash a new program. When i try to do this, the controller hang up. After some seconds i get a timeout from the tool.
It's exactly the same problem like here: https://www.avrfreaks.net/forum/...
The controller is unlocked.

 

Output when flashing a file:

 

(sam-ba_2.18) 1 % send_file {Flash} "GccApplication1.bin" 0x02000 0
-I- Send File GccApplication1.bin at address 0x02000
File size : 1952
Flash size : 0x8000 Flash page size : 64 First page : 128
Dest : 8192
-I- 	Writing: 0x100 bytes at 0x2000 (buffer addr : 0x20000EF8)
-E- Generic::Write returned error (expected integer but got "-E- Timeout: The applet did not return.
Please ch")

 

What i'm doing wrong?

 

This topic has a solution.
Last Edited: Sun. Jan 9, 2022 - 03:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ATMEL website

? Microchip I guess, it's the  SAM-BA_MONITOR_ROMLESS_v2.18 download right?

I tried it with a SAMC21E18 and that works, no need for "adjusting the memory/ram" in this case however so how did you do that?

/Lars

 

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

Lajon wrote:

? Microchip I guess, it's the  SAM-BA_MONITOR_ROMLESS_v2.18 download right?

 

Yes - The "ROMLESS" Version smiley

 

 

Lajon wrote:

I tried it with a SAMC21E18 and that works, no need for "adjusting the memory/ram" in this case however so how did you do that?

Unfortunately i have to change the settings, because i have only 4KB of RAM

I've attached the diff of my changes and also the project with the applet. Can you please test it on your controller with my changed applet?

The uart port was changed from SERCOM4 to SERCOM0.

 

 

 

 

 

 

 

Attachment(s): 

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

Yes that fails the same way for me. 

--- C:/Program Files (x86)/Atmel/sam-ba_2.18.orig/applets/samc21/sam-ba_applets/linker_script/sram_samba.lds	Tue Aug 25 11:36:24 2015
+++ C:/Program Files (x86)/Atmel/sam-ba_2.18/applets/samc21/sam-ba_applets/linker_script/sram_samba.lds	Sat Jan  8 19:09:17 2022
@@ -40,3 +40,3 @@
     romcodesram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x1000
-    sram (W!RX) : ORIGIN = 0x20001000, LENGTH = 0x00001000 /* sram, 4K - sizeof(romcodesram) */
+    sram (W!RX) : ORIGIN = 0x20000500, LENGTH = 0x00001000 /* sram, 4K - sizeof(romcodesram) */
 }
@@ -85,3 +85,3 @@
     /* Stack in SRAM */
-    _sstack = 0x20001FFF;
+    _sstack = 0x200005FF;
     /DISCARD/ : { *(.note.gnu.*) }

The applet code starts at 0x20000500 but there is not space enough for the applet because the stack is at 0x200005FF (is how I read that but I have no real knowledge about the applet implementation).
/Lars

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found the issue. The memory mapping was incorrect.

I've attached the changes and the working applet.

 

Thank you for your help! smiley

Attachment(s):