__DATA Section Problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

__DATA Section Problem

574 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nkarakotas on Sat Mar 03 08:19:50 MST 2012
Hello,

Whenever I try to use the __DATA macro the system crashes. The value in debug is updated I cant understand what is going? I would like to add the ram_heap of LWIP on RAM2 as .data to separate them and know how much heap I have got. Only __BSS works.

__DATA(RAM2) char data_buffer[1024] ;

int main( void )
{

sys_sem_t lock;

data_buffer[0] = 'P';
data_buffer[1] = '\n';
data_buffer[2] = '\0';

      printf("%s",data_buffer);


}

Regards,
Nick
0 项奖励
回复
2 回复数

487 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nkarakotas on Sat Mar 03 10:57:25 MST 2012
Hi,

Thanks for the info. I was having major problem with the heap and apparently  heap fragmentation problems. I changed the LWIP ram to .bss RAM2

__BSS(RAM2)  u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT];


The heap showed that it was available but when I run a HTTP request it produced problems as it could not allocate the required size.

It now works better by having the lwip stack on the RAM2 location. I allocate memory dynamically when im loading files from sdcard to linked lists to parse json objects and then load it to a SYSTEM object around 2K.

I will upload the details you requested tomorrow.

Regards,
NIck
0 项奖励
回复

487 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sat Mar 03 10:05:55 MST 2012
Fundamentally, trying to place a BSS (zero initialised) variable into data doesn't make a whole lot of sense, as this will cause you to end up with a whole lot of zeroes stored in your flash. Whereas if you place the variable into bss, then the zeroes will be dynamically set up by the startup code - and won't consume space in flash. Thus using the __BSS macro here would certainly be the sensible thing to do.

As to why you are getting a crash when you use __DATA macro, it is hard to say what might be happening here without more information.

1) What are the details of your actual crash?

2) Which MCU are you using?

3) Are you using the managed linker script mechanism, or supplying your own linker script? If you are using your own, then please post it.

4) Can you provide the map file generated by the linker? [Suggest posting the file as a zipped attachment].

4) If possible please post an actual build able project. For details of how to export your project from LPCXpresso IDE, please see:

http://support.code-red-tech.com/CodeRedWiki/ImportExport

Regards,
CodeRedSupport.
0 项奖励
回复