LWIP is not working when IRAM 10000000 is selected

nileshtha wrote on Wednesday, March 18, 2015:


     I am using lpcopen_2_10_keil_iar_ea_devkit_1788(lpc1788 with 96k ram) free rtos code for communicating via tcip.In this keil project IRAM1 is selected from 0x20000000 with size 0x8000(32k)for lpc1788 cortex M3.If I am going to use more ram from 10000000 with size 0x10000 in keil project my rtos tasks are working but i am not getting any ip by dhcp.My tcpip part totally stop.Please give me any solution.  

Thanks & Regards


rtel wrote on Wednesday, March 18, 2015:

I’m afraid it would probably take a few hours familiarising myself with your application and stepping through the code to give you a solution, but I can make some suggestions…

Where is the lwIP RAM coming from? If it is the FreeRTOS heap then consider using heap_5.c as it allows you to spread the heap across multiple RAM regions - that is what I normally do on LPC devices.

Have you turned logging on in lwIP to see if any error messages pop out?

Have you determined if it is incoming or outgoing messages that are not working with lwIP.

I know some RAM on LPC devices has to be explicitly enabled to give application code access to it - have you done that if it is necessary in this case?


nileshtha wrote on Thursday, March 19, 2015:


Thanks for the reply.I am currently using
( lpcopen_2_10_keil_iar_ea_devkit_1788\applications\lpc17xx_40xx\keil_uvision_projects\ea_devkit_1788\lwip\webserver_freertos )this example code…This code working fine and uses ram approximately 28k.My controller have 96 k ram and i want use local part of the ram for other purpose. but when i am selecting iram 10000000 with size 10000(64k) dhcp and tcp working stop.router not assigning the ip via dhcp to my embedded artist board.If i want to use other 64k ram then what i need to do?(I want to use Ethernet ram for Ethernet and other ram for my own purpose).If anyone know any setting for this example let me know please. I also attached example code with this letter.

thanks and regards

rtel wrote on Thursday, March 19, 2015:

I don’t think this is a FreeRTOS related question. It is related to both lwIP and how to use the linker script and linker commands to use all the RAM on the device.

If you were using GCC then and the RAM on the chip was not in contiguous memory (which I don’t think it is) then you would most likely need to place the variables into the RAM manually as the linker will not be able to do it very intelligently for you. If you are using IAR or Keil (I don’t think you say) then the linker may have a better attempt at it.

If all the RAM is in contiguous memory then the linker would be able to do it all for you in any case.

Have a look at the user manual to determine if the RAM is in contiguous memory or not, and if not, whether you have to explicitly enable separate blocks before you can use them.


andymcc0 wrote on Friday, March 20, 2015:

The NXP LPC1788 Ethernet DMA engine requires the descriptors and the data buffers to be in the 32kB of Peripheral SRAM between 0x2000 0000 - 0x2000 7FFF. I found it easiest to do this explicitly, rather than using the linker.

/* AWM - A comment in the original LPCOpen code example from which this was developed, stated:
 * "The Ethernet Block can only access Peripheral SRAM and External Memory. In this example,
 * Peripheral SRAM is selected for storing descriptors, status arrays and send/receive buffers." 
 * so I am going to use the statically allocated BufferAllocation_1 method.
 * See vNetworkInterfaceAllocateRAMToBuffers() below for more detail */

#define ENET_RX_STAT_BASE        (0x20000000UL)		/* Base of peripheral RAM */

The comment referred to is in enet.c in the periph_ethernet example.
Then you use these #defines when setting up the buffers and descriptors. Note this was done for the FreeRTOS+TCP stack, not the lwip, but the principle should remain the same.
I don’t doubt that there are better ways to do this, but it worked for me.

Andy McC

nileshtha wrote on Saturday, March 21, 2015:


Andy Thanks for the reply. I got my problem . When i am selected iram 10000000 that time Ethernet memory is allocated from local ram but for working it need to allocated from peripheral ram that’s why its not working.In IAR if you want use local ram you need to write some command in #pragma… then define the buffer or variable then end of the command.So you can allocated the memory from local ram.In keil anyone knows such command?This code (lpcopen_2_10_keil_iar_ea_devkit_1788\applications\lpc17xx_40xx\keil_uvision_projects\ea_devkit_1788\lwip\webserver_freertos) alredy consume 28 k peripheral ram.If i want to allocated the the buffer of 10k from local ram then what i need to do in keil?If anyone knows about this thing let me know.

rtel wrote on Saturday, March 21, 2015:

I would suggest consulting the Keil documentation, and if you can’t find
it there, submitting a support request to Keil.


nileshtha wrote on Wednesday, May 20, 2015:


I am using lpcopen_2_10_keil_iar_ea_devkit_1788 free rtos code for communicating via tcip.In this project IRAM1 is selected from 0x20000000 with size 0x8000(32k).The heap_size in the scatter file is 0x6000.When I am define 4 tasks with configMINIMAL_STACK_SIZE=1000 bytes.I got an error freertos malloc failure.I am going to use both the tcp and udp sockets.my questions are given below please answer me if anyone know about this things.
1)How to use sram(0x10000000 to 10010000=64K) to allocate the tasks size.
2)how can I use LWIP_RAM_HEAP_POINTERto allocate the heap memory from sram(0x10000000 to 10010000=64K) of lpc1788.
3)if i made the changes in the #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0 ) ) there is no effect.
4)If I made the changes in the #ifndef MEM_SIZE #define MEM_SIZE (12*1024) there is no effect.
5)currently I am using heap_3.c.How i can use heap_5.c to use multiple ram regions.

davedoors wrote on Wednesday, May 20, 2015:

Dont know about lwip configuration but guess you can use the linker to place its memory in a named section that is at the address you need.

5)currently I am using heap_3.c.How i can use heap_5.c to use multiple ram regions.

Just replace heap_3.c with heap_5.c in the project. You will need to add the init call for heap_5 also. If you use heap_5 then any heap allocated by the linker can be removed so long as no other code calls malloc.

nileshtha wrote on Thursday, May 21, 2015:

I implement the heap_4.c and allocate the memory from sram of the lpc1788. It working fine but after some time 5-10mins my code stops executing and watchdog event occur and controller goes to reset.sometime its not goes to reset but it allocates the ip address again and again by dhcp.