2016-12-15 18 views
2

ATSAMW25 칩이있는 Arduino MKR1000이 있는데 코드에 크래시 버그를 디버그하려고합니다. 당신이 출력특정 주소에서 플래시 읽기가 작동하지 않습니다. ATSAMW25

Drawing 8AB1 (267, 14; 300, 41) 
8AB1[0] = 

이 플래시 메모리 위치에서 볼 수 있듯이, data에서 읽기

void GuiDisplay::drawBitmap(rect_t frame, const uint16_t *data, rgb565_filter filter) { 

    point_t origin = adjustPoint(frame.origin, _origin); 
    uint16_t x = origin.x; 
    uint16_t y = origin.y; 

    tft->setAddrWindow(x, y, x + frame.width() - 1, y + frame.height() - 1); 

    Serial.print("Drawing "); Serial.print((unsigned int)data, HEX); Serial.print(" ("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print("; "); Serial.print(x + frame.width() - 1); Serial.print(", "); Serial.print(y + frame.height() - 1); Serial.println(")"); 

    for (int ii = 0; ii < frame.width() * frame.height(); ii++) { 

     Serial.print(" "); Serial.print((unsigned int)data, HEX); Serial.print("["); Serial.print(ii); Serial.print("] = "); 

     uint16_t word = *(data + ii); 

     Serial.println(word); 

     tft->pushColor(word); 
    } 

    Serial.println("Done"); 
} 

가 충돌이 발생합니다 :

는 잘못된 기능입니다. ATSAMW25에는 선언이 필요하지 않으며 단지 const입니다.

나를 괴롭힌 이유는 일부 메모리 범위에서만 오류가 발생하는 것입니다.

// Header 

typedef struct bitmap_data_def { 
    size_tt size; 
    uint8_t count; 
    const byte *data; 
} bitmap_data_t; 

extern const bitmap_data_t projector_bitmap; 
extern const bitmap_data_t power_bitmap; 
extern const bitmap_data_t slides_bitmap; 
extern const bitmap_data_t camera_bitmap; 
... and so on. 


// CPP file 

const byte power_bitmap_data[] = { [very long string!] } 

const bitmap_data_t power_bitmap = { 
    size_tt(26, 26), 
    1, 
    power_bitmap_data 
}; 

그들은 모두 같은 파일에 선언하고, 그들의 대부분은 잘 작동 : 등등

Drawing 86A0 (199, 193; 224, 212) 
    86A0[0] = 0 
    86A0[1] = 65535 
    ... and so on ... 
    86A0[519] = 0 
Done 

Drawing AB44 (199, 133; 224, 151) 
    AB44[0] = 0 
    AB44[1] = 38034 
    ... and so on ... 
    AB44[493] = 0 
Done 

하고이 같은 정의의 번호를 가지고있다.

지금까지 0x8A00과 0x8B00 사이의 메모리 위치와 0x95BD 주변의 위치에서 충돌이 발생하는 것을 확인했습니다. 위에서 볼 수 있듯이, 위와 아래의 메모리 위치는 괜찮습니다.

일부 선언을 추가하거나 제거하여 컴파일러에서 메모리를 재정렬하면 다른 선언이 실패합니다. 충돌을 야기하는 위의 메모리 범위 중 어느 것이 든 떨어질 수 있습니다.

프로그램 메모리를 덮어 쓸 수있는 방법을 볼 수 없으며 읽었을 때 충돌이 없어야합니다. 미스 한 미묘한 메모리 카피가 있습니까? 그렇다면 32KB의 SRAM 한도를 초과 할 수도 있지만 어디에서/어떻게/왜 그런 일이 일어날 지 알 수 없습니다.

다른 MKR1000을 시도한 결과 똑같은 결과를 얻었 기 때문에 문제가 하드웨어 오류로 보이지 않습니다.

도움이 될 것입니다. 고맙습니다.

답변

0

좋아, 그래서 내 자신의 문제를 해결했습니다. 나는 이것이 다른 사람을 위해 얼마나 유용할지는 모르지만 충돌은 1 또는 3 바이트 경계에서 메모리를 읽었 기 때문에 발생했다. 이는 ARM Cortex M0 + 프로세서 제품군에는 허용되지 않습니다.

http://www.sumidacrossing.org/Musings/files/160606_Memory_and_the_Arduino.php

내가 실제 문제를 해결하기 위해 그리고 Adafruit의 제안을 사용 :

https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500/adapting-sketches-to-m0#aligned-memory-access

은 기본적으로 내가 교체를

이 문서 주소 요구 사항 메모리를 이해하는 데 매우 도움이되었다 위반 라인 :

uint16_t word = *(data + ii); 

다음으로 :

uint16_t word; 
memcpy(&word, &(data[ii]), 2);