Hallo und Frohe Ostern euch allen!
Ich habe folgendes Problem:
Ab Byte-Adresse 0xE000 sind 4 Sections mit je einem Array drin,
teilweise hartcodiert mit Daten gefüllt.
1 | const uint8_t graphic0 [64][256] __attribute__ ((section (".gfx0"))) = {{
|
2 | ...
|
3 | }};
|
4 | const uint8_t graphic1 [64][256] __attribute__ ((section (".gfx1"))) = {{
|
5 | ...
|
6 | }};
|
7 | const uint8_t graphic2 [64][256] __attribute__ ((section (".gfx2"))) = {{
|
8 | ...
|
9 | }};
|
10 | const uint8_t graphic3 [64][256] __attribute__ ((section (".gfx3"))) = {{
|
11 | ...
|
12 | }};
|
Diese will ich im Betrieb beschreiben.
Dazu hab ich diese Funktion geschrieben, angelehnt an:
http://www.mikrocontroller.net/articles/AVR_Bootloader_in_C_-_eine_einfache_Anleitung
Header:
1 | #include <avr/boot.h>
|
2 | ...
|
3 | void storeGraphic(uint8_t graphicNumber) BOOTLOADER_SECTION;
|
C-Datei
1 | uint8_t tempGraphic [256] = {
|
2 | ...
|
3 | };
|
4 |
|
5 | ...
|
6 |
|
7 | void storeGraphic (uint8_t graphicNumber)
|
8 | {
|
9 | USART_Transmit('X');
|
10 | uint32_t pageAddr = graphicNumber * 256;
|
11 | pageAddr += (uint16_t) graphic0; //+= 0xE000
|
12 |
|
13 | uint8_t sreg = SREG;
|
14 | cli();
|
15 |
|
16 | // + evtl auf EEPROM warten, wenn genutzt
|
17 | boot_page_erase(pageAddr);
|
18 | boot_spm_busy_wait ();
|
19 | uint16_t i = 0;
|
20 | for (i=0; i<256; i+=2) //128 words in den Puffer
|
21 | {
|
22 | uint16_t dataWord = tempGraphic[i];
|
23 | dataWord |= (tempGraphic[i + 1]) << 8;
|
24 | boot_page_fill(pageAddr + i, dataWord);
|
25 |
|
26 | }
|
27 |
|
28 | boot_page_write (pageAddr);
|
29 | boot_spm_busy_wait();
|
30 |
|
31 | boot_rww_enable ();
|
32 | SREG = sreg; //Interrupts aktivieren
|
33 | USART_Transmit('Y');
|
34 | }
|
Das Array "tempGraphic" enthält zum testen bereits Daten und liegt im
SRAM. Später wirds über UART gefüllt.
Die hartcodierten Grafiken aus den graphic0 - graphic3 Arrays kann ich
lesen, d.H. Daten sind wirklich dort.
Wenn ich jetzt die Funktion mit storeGraphic(0); aufrufe, wird über UART
'X' und 'Y' ausgegeben. Der Flash bleibt aber unverändert, das Programm
läuft auch normal weiter. Hab auch mal den Speicher wieder ausgelesen,
in der HEX war nichts verändert.
Ich hoffe Ihr könnt mir da helfen bei dem Problem.
MfG Jurij