WinAVR Boot.h extended address functions are all wrong

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

I am amazed that for over the years nobody has picked up on the fact that the boot.h code for extended addresses is all wrong. Maybe not enough people using a bootloader that requires these extended address routines.

Anyway, every time I install the latest winavr, I land up overwriting my code and then the painstaking exercise of finding backups to fix the boot.h file.

So if someday would like to get these routines included, I am sure we can all benefit.

Brian

The corrected function are as follows ....
enjoy :wink:

#define __boot_page_fill_extended(address, data) \
({ \
__asm__ __volatile__ \
( \
"movw r0, %4\n\t" \
"movw r30, %A3\n\t" \
"sts %1, %C3\n\t" \
"sts %0, %2\n\t" \
"spm\n\t" \
"clr r1\n\t" \
: \
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
"i" (_SFR_MEM_ADDR(RAMPZ)), \
"r" ((uint8_t)__BOOT_PAGE_FILL), \
"r" ((uint32_t)address), \
"r" ((uint16_t)data) \
: "r0", "r30", "r31" \
); \
})

#define __boot_page_erase_extended(address) \
({ \
__asm__ __volatile__ \
( \
"mov R31, %A3\n\t" \
mov r30, %C3\n\t" \
"sts %1, %B3\n\t" \
"sts %0, %2\n\t" \
"spm\n\t" \
: \
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
"i" (_SFR_MEM_ADDR(RAMPZ)), \
"r" ((uint8_t)__BOOT_PAGE_ERASE), \
"r" ((uint32_t)address) \
: "r30", "r31" \
); \
})

#define __boot_page_write_extended(address) \
({ \
__asm__ __volatile__ \
( \
"mov R31, %A3\n\t" \
"mov r30, %C3\n\t" \
"sts %1, %B3\n\t" \
"sts %0, %2\n\t" \
"spm\n\t" \
: \
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
"i" (_SFR_MEM_ADDR(RAMPZ)), \
"r" ((uint8_t)__BOOT_PAGE_WRITE), \
"r" ((uint32_t)address) \
: "r30", "r31" \
);

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

This would be more helpful if you posted it in the avr-libc Patch Tracker, so that way we can get the project fixed. Emails, and posts here on AVR Freaks tend to get lost very quickly.

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

Hmm .. don't seem to find the Patch Tracker. I find a bug list, but not somewhere to post/report the detail above. Anybody got a link to this page?

Brian

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

The avr-libc project is here:
https://savannah.nongnu.org/proj...
The Patch Tracker link is towards the bottom of the page.

Or go here to submit a new item:
https://savannah.nongnu.org/patc...

The only catch is that you have to register a username and login to submit a new item. This is so you'll get emails about when the item is updated/fixed, etc.