2017-03-29 2 views
0

J'écris une application pour Mbed OS qui fonctionnera sur une carte K64F. J'ai différents threads en cours d'exécution, en utilisant les capacités RTOS du système.mbed Région m_data_2 débordé avec pile et tas

Je dois gérer une chaîne relativement grande pour afficher les résultats dans un format JSON. Je l'ai défini comme un tableau char. Dans un premier temps, il a été défini comme 256 caractères de long et a été correclty fonctionne, mais quand je l'ai augmenté la taille à 2048 pour adapter réellement les besoins de l'application

char rData[2048];

Je reçois cette erreur sur la compilation:

c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: ./BUILD/K64F/GCC_ARM/02_device.elf section `.heap' will not fit in region `m_data_2' 
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: Region m_data_2 overflowed with stack and heap 
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: region `m_data_2' overflowed by 22944 bytes 
collect2.exe: error: ld returned 1 exit status 
[ERROR] c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: ./BUILD/K64F/GCC_ARM/02_device.elf section `.heap' will not fit in region `m_data_2' 
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: Region m_data_2 overflowed with stack and heap 
c:/program files (x86)/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: region `m_data_2' overflowed by 22944 bytes 
collect2.exe: error: ld returned 1 exit status 

Je n'ai trouvé aucune référence sur la façon d'augmenter l'espace réservé à ce besoin.

Qu'est-ce qui me manque?

Répondre

1

Déclarez la variable sur le tas, pas sur la pile:

char* rData = (char*)malloc(2048); 
// potentially, don't always malloc 2048 bytes, but only the amount you need 

Ne pas oublier d'appeler free(rData) lorsque vous avez terminé.