Добрый день!
Чтобы не плодить топики, задам вопрос здесь.
Не получается записать данные в Flash. Код следующий:
CODE
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/boot.h>
#include <inttypes.h>
#include <avr/interrupt.h>
void BOOTLOADER_SECTION boot_program_page (uint32_t page, uint8_t *buf);
uint8_t buffer[128] = "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq";
int main()
{
boot_program_page(0x30, buffer);
while(1)
{
}
return 0;
}
void BOOTLOADER_SECTION boot_program_page(uint32_t page, uint8_t *buf)
{
uint16_t i;
uint8_t sreg;
// Disable interrupts.
sreg = SREG;
cli();
eeprom_busy_wait ();
boot_page_erase (page);
boot_spm_busy_wait (); // Wait until the memory is erased.
for (i=0; i<SPM_PAGESIZE; i+=2)
{
// Set up little-endian word.
uint16_t w = *buf++;
w += (*buf++) << 8;
boot_page_fill (page + i, w);
}
boot_page_write (page); // Store buffer in flash page.
boot_spm_busy_wait(); // Wait until the memory is written.
// Reenable RWW-section again. We need this if we want to jump back
// to the application after bootloading.
boot_rww_enable ();
// Re-enable interrupts (if they were ever enabled).
SREG = sreg;
}
контроллер ATmega16L;
функция boot_program_page скопирована из документации к avr-libc;
линкеру задано -Wl,-section-start=.bootloader=0x1F80;
по hex-файлу видно, что код размещается в нужной области памяти.
В считанной прошивке никаких изменений не наблюдается...
Подскажите, пожалуйста, чего ему не хватает?