boot loader function

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

in the following code from boot library what is the page?

Is it the value of the pages in micro eg:0 to 32 for mega32

thank you

#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
void 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;
}

 

 

 

 

https://www.nongnu.org/avr-libc/...

This topic has a solution.
Last Edited: Thu. Feb 20, 2020 - 06:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I remember when I first used this I too thought "page " meant a whole page number like 0, 1, 2, 3 but it really means page_address so 0000, 0020, 0040 etc

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

ie you say it is word address?

ie pagenumber*64 ??

am I right?

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends on SPM_PAGESIZE.  My example numbers above assumed small 32 byte pages but yeah, page_num * page_size