hello
I'm using MQX 4.2.0.2 DHCP Server on FRDM-K64F.
Sometimes DHCP Server can't receive discover/request packet after boot.
I added log at function DHCPSRV_task() in rtcs/source/apps/dhcpsrv.c
It seems that when problem occurred, select() cannot out itself.
Could anyone help me with this?
Thanks.
Solved! Go to Solution.
Forget to say, I'm also using NAT of RTCS.
And i found the reason of mem_alloc fail.
[reason]
In NAT_init_internal2() of rtcs\source\nat\nat.c,
Nat session use RTCS_part_create( PARTITION ALLOC ?) to get memory.
-----------------------------------------------------------------------------------------------------
nat_cfg_ptr->SESSION_PART = RTCS_part_create(sizeof(NAT_SESSION_STRUCT),
NAT_SESSION_INITIAL_COUNT, NAT_SESSION_GROW_COUNT, NAT_SESSION_MAX, NULL, NULL);
_rtcs_part RTCS_part_create
(
uint32_t size, /* [IN] size of one block */
uint32_t init, /* [IN] initial number of blocks */
uint32_t grow, /* [IN] number of blocks to grow by */
uint32_t max, /* [IN] maximum number of blocks */
int32_t (_CODE_PTR_ cons)(void *), /* [IN] block constructor */
int32_t (_CODE_PTR_ dest)(void *) /* [IN] block destroyer */
)
-----------------------------------------------------------------------------------------------------
Pay attention, the argument "max" of RTCS_part_create funtion is setted by NAT_SESSION_MAX.
But the value define of NAT_SESSION_MAX is 0 !!!
When "max" is 0, it will get memory without limit.
That's why i found RTCS_mem_alloc_system failed in UDP_process().
[Solution]
・Freescale_MQX_4_2\rtcs\source\include\nat_prv.h
change the value of NAT_SESSION_MAX to 1024
#define NAT_SESSION_MAX 1024
・Freescale_MQX_4_2\rtcs\source\nat\natftp.c
the argument "max" of RTCS_part_create setted with NAT_SESSION_MAX.
・Freescale_MQX_4_2\rtcs\source\include\rtcscfg.h
add the define below
#define IPROUTEALLOC_SIZE_MAX 256
#define IPGATEALLOC_SIZE_MAX 256
#define IPMCBALLOC_SIZE_MAX 256
#define RADIXALLOC_SIZE_MAX 256
・Freescale_MQX_4_2\rtcs\source\tcpip\ip.c
the argument "max" of RTCS_part_create functions setted with above definition.
Now DHCP server runs well about one week.
And the changes seems good.
Does someone has some experience of NAT session(NAT_SESSION_MAX) about RTCS_part_create?
Thanks.
Forget to say, I'm also using NAT of RTCS.
And i found the reason of mem_alloc fail.
[reason]
In NAT_init_internal2() of rtcs\source\nat\nat.c,
Nat session use RTCS_part_create( PARTITION ALLOC ?) to get memory.
-----------------------------------------------------------------------------------------------------
nat_cfg_ptr->SESSION_PART = RTCS_part_create(sizeof(NAT_SESSION_STRUCT),
NAT_SESSION_INITIAL_COUNT, NAT_SESSION_GROW_COUNT, NAT_SESSION_MAX, NULL, NULL);
_rtcs_part RTCS_part_create
(
uint32_t size, /* [IN] size of one block */
uint32_t init, /* [IN] initial number of blocks */
uint32_t grow, /* [IN] number of blocks to grow by */
uint32_t max, /* [IN] maximum number of blocks */
int32_t (_CODE_PTR_ cons)(void *), /* [IN] block constructor */
int32_t (_CODE_PTR_ dest)(void *) /* [IN] block destroyer */
)
-----------------------------------------------------------------------------------------------------
Pay attention, the argument "max" of RTCS_part_create funtion is setted by NAT_SESSION_MAX.
But the value define of NAT_SESSION_MAX is 0 !!!
When "max" is 0, it will get memory without limit.
That's why i found RTCS_mem_alloc_system failed in UDP_process().
[Solution]
・Freescale_MQX_4_2\rtcs\source\include\nat_prv.h
change the value of NAT_SESSION_MAX to 1024
#define NAT_SESSION_MAX 1024
・Freescale_MQX_4_2\rtcs\source\nat\natftp.c
the argument "max" of RTCS_part_create setted with NAT_SESSION_MAX.
・Freescale_MQX_4_2\rtcs\source\include\rtcscfg.h
add the define below
#define IPROUTEALLOC_SIZE_MAX 256
#define IPGATEALLOC_SIZE_MAX 256
#define IPMCBALLOC_SIZE_MAX 256
#define RADIXALLOC_SIZE_MAX 256
・Freescale_MQX_4_2\rtcs\source\tcpip\ip.c
the argument "max" of RTCS_part_create functions setted with above definition.
Now DHCP server runs well about one week.
And the changes seems good.
Does someone has some experience of NAT session(NAT_SESSION_MAX) about RTCS_part_create?
Thanks.
I found the reason about this problem.
In the function UDP_process() (Freescale_MQX_4_2\rtcs\source\tcpip\udp.c),
before SOCK_select_signal() called, RTCS_mem_alloc_system() was failed.
And mem_alloc fail keep going on.
It seems that memory leak occurred.
Could anyone give me some guidance ?
Thanks.