Writing to a flash page using nvm in samd21

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

Hi,

 

Here's what I'm trying to do-

1. Load hex file of bootloader as is (taken from http://www.microchip.com/wwwAppN...

2. Use example project of NVM as an application.

3. Load the .bin file of application code at 0x2000.

 

Now, the problem is why NVM is writing starting from address 0x00000000 and also giving one value to whole page. Please check attachment.

 

NOTE- I have tried

1. Insert command -Wl,--section-start=.text=0x2000 in Toolchain

2. In samd21j18a_flash.ld, change rom (rx)  : ORIGIN = 0x00000000, LENGTH = 0x00040000 to rom      (rx)  : ORIGIN = 0x00002000, LENGTH = 0x00040000

Attachment(s): 

This topic has a solution.
Last Edited: Fri. Aug 17, 2018 - 04:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do you check this (i.e., where are the memory dump pictures from)? If from debugging what are you debugging (you would have to ensure the flash is not rewritten by the debugging session).

/Lars

 

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

bop123 wrote:
2. In samd21j18a_flash.ld,

change rom (rx)  : ORIGIN = 0x00000000, LENGTH = 0x00040000

to 

 

rom      (rx)  : ORIGIN = 0x00002000, LENGTH = 0x00040000

 

This doesn't look right. The length needs to be  (0x00040000 - 0x00002000) = 0x3E000

 

rom      (rx)  : ORIGIN = 0x00002000, LENGTH = 0x0003E000

 

 

 

"When all else fails, read the directions"

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

Thankyou all!! It worked..

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

bop123 wrote:
Thankyou all!! It worked..

What worked?  Please either mark the solution or provide the solution so it may help someone else in the future yes

"When all else fails, read the directions"

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

PhillyNJ wrote:
mark the solution

If you need help with that, see Tip #5

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just used -Wl,--section-start=.text=0x2000 and my code was working since the beginning, I was just checking in the wrong place.