XMEGA128A1 broken read access to Flash Constants above 32K

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everybody,

maybe i missed something with WinAVR-20100110 (4.4.3 ?)
and XMega128A1 but there seems to be a bug when accessing a ROM constant placed in Program memory above address 0x7fff.

Example Code (from List File):

const uint8_t  cui8TestArray[] PROGMEM = {	32,	29,	0xF0, 0x0F, 0x00, 0x00};


uint8_t  FlashBug(void)
    a26e:	df 93       	push	r29
    a270:	cf 93       	push	r28
    a272:	cd b7       	in	r28, 0x3d	; 61
    a274:	de b7       	in	r29, 0x3e	; 62
    a276:	2a 97       	sbiw	r28, 0x0a	; 10
    a278:	cd bf       	out	0x3d, r28	; 61
    a27a:	de bf       	out	0x3e, r29	; 62
{
  uint32_t  ui32Tdat;
  uint8_t   ui8Result;


  ui32Tdat = (uint32_t)&cui8TestArray;
    a27c:	82 e9       	ldi	r24, 0x92	; 146
    a27e:	92 e0       	ldi	r25, 0x02	; 2
    a280:	aa 27       	eor	r26, r26
    a282:	97 fd       	sbrc	r25, 7
    a284:	a0 95       	com	r26
    a286:	ba 2f       	mov	r27, r26
    a288:	8f 83       	std	Y+7, r24	; 0x07
    a28a:	98 87       	std	Y+8, r25	; 0x08
    a28c:	a9 87       	std	Y+9, r26	; 0x09
    a28e:	ba 87       	std	Y+10, r27	; 0x0a
  ui8Result = pgm_read_byte_far(ui32Tdat);
    a290:	8f 81       	ldd	r24, Y+7	; 0x07
    a292:	98 85       	ldd	r25, Y+8	; 0x08
    a294:	a9 85       	ldd	r26, Y+9	; 0x09
    a296:	ba 85       	ldd	r27, Y+10	; 0x0a
    a298:	8a 83       	std	Y+2, r24	; 0x02
    a29a:	9b 83       	std	Y+3, r25	; 0x03
    a29c:	ac 83       	std	Y+4, r26	; 0x04
    a29e:	bd 83       	std	Y+5, r27	; 0x05
    a2a0:	8a 81       	ldd	r24, Y+2	; 0x02
    a2a2:	9b 81       	ldd	r25, Y+3	; 0x03
    a2a4:	ac 81       	ldd	r26, Y+4	; 0x04
    a2a6:	bd 81       	ldd	r27, Y+5	; 0x05
    a2a8:	0b b6       	in	r0, 0x3b	; 59
    a2aa:	ab bf       	out	0x3b, r26	; 59
    a2ac:	fc 01       	movw	r30, r24
    a2ae:	87 91       	elpm	r24, Z+
    a2b0:	0b be       	out	0x3b, r0	; 59
    a2b2:	89 83       	std	Y+1, r24	; 0x01
    a2b4:	89 81       	ldd	r24, Y+1	; 0x01
    a2b6:	8e 83       	std	Y+6, r24	; 0x06
  return(ui8Result);
    a2b8:	8e 81       	ldd	r24, Y+6	; 0x06
  
}
    a2ba:	2a 96       	adiw	r28, 0x0a	; 10
    a2bc:	cd bf       	out	0x3d, r28	; 61
    a2be:	de bf       	out	0x3e, r29	; 62
    a2c0:	cf 91       	pop	r28
    a2c2:	df 91       	pop	r29
    a2c4:	08 95       	ret

Problem:
At address 0xA27c to 0xA288 the address translation to a uint32_t is done.
This will work fine if address of the FLASH ROM Constant is below 0x8000.
But if this Constant is located at 0x8001 for example the code will convert it to 0xFFFF8001. This is caused by command at addr 0xA282 and 0xA284.
The following code with pgm_read_byte_far will then access this wrong address.

Question:
Is this a known bug?
Or where is my mistake ?

Any suggestions ?