Rev 309 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 309 | Rev 310 | ||
|---|---|---|---|
| Line 100... | Line 100... | ||
| 100 | uint16_t offset; |
100 | uint16_t offset; |
| 101 | #endif |
101 | #endif |
| 102 | uint16_t data; |
102 | uint16_t data; |
| 103 | 103 | ||
| 104 | eeprom_busy_wait(); // Make sure any current writes to eeprom |
104 | eeprom_busy_wait(); // Make sure any current writes to eeprom |
| 105 |
|
105 | boot_spm_busy_wait(); // or flash has completed before updating. |
| 106 | 106 | ||
| 107 | cli(); // From this point we're on our own |
107 | cli(); // From this point we're on our own |
| 108 | 108 | ||
| 109 | #if 0 |
109 | #if 0 |
| 110 | for (offset = 0; offset < ((len | (SPM_PAGESIZE - 1)) + 1); offset += 2) { |
110 | for (offset = 0; offset < ((len | (SPM_PAGESIZE - 1)) + 1); offset += 2) { |
| Line 125... | Line 125... | ||
| 125 | len = (len | (SPM_PAGESIZE - 1)) + 3; // Round len up to a whole page + 2 |
125 | len = (len | (SPM_PAGESIZE - 1)) + 3; // Round len up to a whole page + 2 |
| 126 | 126 | ||
| 127 | while (len -= 2) { |
127 | while (len -= 2) { |
| 128 | wdt_reset(); |
128 | wdt_reset(); |
| 129 | 129 | ||
| 130 | boot_spm_busy_wait(); // Wait until the memory is erased. |
- | |
| 131 | data = pgm_read_word(src); // Read source word |
130 | data = pgm_read_word(src); // Read source word |
| 132 | boot_spm_busy_wait(); // Wait until the memory is erased. |
- | |
| 133 | boot_page_fill_safe(dst, data); // Write word to destination |
131 | boot_page_fill_safe(dst, data); // Write word to destination |
| - | 132 | boot_spm_busy_wait(); // Make sure spm is ready. |
|
| 134 | 133 | ||
| 135 | if ((dst + 2) % SPM_PAGESIZE == 0) { // If we just wrote the last word of a page |
134 | if (((uint8_t)dst + 2) % SPM_PAGESIZE == 0) { // If we just wrote the last word of a page |
| - | 135 | boot_page_erase(dst); |
|
| 136 | boot_spm_busy_wait(); // Wait until the memory is erased. |
136 | boot_spm_busy_wait(); // Wait until the memory is erased. |
| 137 |
|
137 | boot_page_write(dst); // Store buffer in flash page. |
| 138 | boot_spm_busy_wait(); // Wait until the memory is written. |
138 | boot_spm_busy_wait(); // Wait until the memory is written. |
| 139 |
|
139 | boot_rww_enable(); |
| 140 | } |
140 | } |
| 141 | 141 | ||
| 142 | src += 2; |
142 | src += 2; |
| 143 | dst += 2; |
143 | dst += 2; |
| 144 | } |
144 | } |