Software access (erase/write) to flash on Xmega

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

Hi all,
In AVR1008 they mention a bug affecting Flash accessing for the ATXMEGA256A3B (they state that revision B only is affected).

I'm dealing with a ATXMEGA256A3U micro, and trying to perform a flash page erase operation. For the purpose I'm referring to AVR1316.zip sample code.

I'm using GDB to dump the memory and see the outcome of the operation. I'm observing that GDB shifts all addresses by forcefully adding an offset of size 0x800000 to all of them except address zero (0x00), so I cannot use that to print flash addresses starting above zero.

I'm also seeing that GDB is not able to perform "dump memory" operations (it hangs into the operation forever).

The current solution to print flash memory is to call this command:

x /512bx 0x0

The printed data corresponds to the binary image that I had flashed the micro with.

A) Can I assume that gdb is really inspecting Flash memory on target and is not just returning the loaded elf embedded instruction code locally?

B) If the above assumption holds, I'm not beeing able to erase a flash page with the following asm code:

; Input:
; R25:R24:R23:R22 - Byte address into Flash page.
;
; Returns:
; Nothing.


erase_flashpage:
	in	r21, __RAMPZ__ 
	out	__RAMPZ__, r24						
	ldi	r20, NVM_CMD_ERASE_APP_PAGE_gc
	jmp	SP_CommonSPM	

SP_CommonSPM:
	mov	__Z_H__, r23
	mov __Z_L__, R22 			
	sts	NVM_CMD, r20
	ldi	r16, CCP_SPM_gc
	sts	CCP, r16
	spm
	out	__RAMPZ__, r21
	ret

Code comes directly from AVR1316.zip from Atmel website.
Can you address me to some other sample code proved to work?

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

I confirm that reading from the FLASH is real as I'm now doing it through __ELPM instructions and the outcome matches the binary image.
Therefore I must assume that the page erase procedure is not working..

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

Wrong forum.

[so moved - BTW there's a thread in Housekeeping that is a better place to report threads that need moving]

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

I see that *probably* my problem has to do with invoking the SPM instruction from outside the boot section.
I'm now changing linker script to place the function in there (address 0x400000 on Xmega256).