Hi, and.. sorry . exactly say, It is lwip stack question in SDK(2.13 EVK-MIMXRT1020), but . Please help ..
I am developting project by using SDK with RT1020, so , really .. I do not know what I have to do..
. I will make 4ea tcp/udp task with 8 connections, each port. 2connection.
Question1.
I can not understand differences between [udp_new -> udp bind -> udp_recv-> udp_remove ] and
[sock(for udp) -> bind -> recvfrom -> close.] process. . tcpip case. same. tcp_new ~ tcp_bind~~~~
what is the difference ?? Purpose of use (TCP/UDP)_new() ??
Question 2.
From SDK example, (evkmimxrt1020_lwip_ipv4_ipv6_echo_freertos),
#define LWIP_TCPIP_CORE_LOCKING 1 in lwipopts.h so. After adding new task on stack_init.
static void stack_init(void *arg)
{
~~~
shell_task_init(NULL, 0);
xTaskCreate( Start_xxx, ( const char * const )"xxxLauncher",
configMINIMAL_STACK_SIZE + 4096 , NULL, INIT_THREAD_PRIO, NULL );
vTaskDelete(NULL);
}
static void Start_xxx(void *arg) {
~~~
udp_new();
udp_bind();
while(~~) {
udp_recv();
~~~ }
}
this code is stuck, with message "function called without core lock"
so, Every calling of udp_xxx() function group, I need to attach locking like below
LOCK_TCPIP_CORE();
udp_new();
UNLOCK_TCPIP_CORE();
LOCK_TCPIP_CORE();
udp_bind();
UNLOCK_TCPIP_CORE();
LOCK_TCPIP_CORE();
udp_recv();
UNLOCK_TCPIP_CORE();
But It is so uncomfortable... Why locking sentence is not inside udp_xxx();
and From googling with keyword "udp_new", nealy, I cannot find this uncomfortable code including lock/unlock before-after udp_xxxx()
So, Is there any good example (from SDK, or not) using tcp/udp_xxxx() func. ??
And Really , Do I need to add lock/unlock code back and forth of every tcp/udp_xxxx() func?
or How about this ? In lwipopts.h
/* ---------- Core locking ---------- */
#define LWIP_TCPIP_CORE_LOCKING 0
void sys_lock_tcpip_core(void);
#define LOCK_TCPIP_CORE() //sys_lock_tcpip_core()
void sys_unlock_tcpip_core(void);
#define UNLOCK_TCPIP_CORE() //sys_unlock_tcpip_core()
void sys_check_core_locking(void);
#define LWIP_ASSERT_CORE_LOCKED() //sys_check_core_locking()
void sys_mark_tcpip_thread(void);
#define LWIP_MARK_TCPIP_THREAD() //sys_mark_tcpip_thread()
Solved! Go to Solution.
Q1. The main difference is the Transport protocol used, I suggest you use netconn_xxx functions as you can specify the parameter for transport protocol.
Q2. Unfortunately, we don’t have a specific example where tcp/udp_xxx() is used.
Best regards,
Omar
thanks. In the middle of finding netconn API, I found page about sequential API, Raw API, and Also, SDK Example already includs raw, sequential examples. \lwip\contrib\apps\tcpecho & tcpecho_raw... etc from example - evkmimxrt1020_lwip_ipv4_ipv6_echo_freertos.
anyway , Before your answer,
In my project,... in spite of using Locking macro, Program halt Occured. It would be from too many packet receive, just my opinion, so
In lwipopts.h, opt.h, after enlarging kind of buffer size option, task stack Size, ... But. also halt is occured agin. during receive-packets
so I used DisableIRQ(ENET_IRQn) just during process_received_packet function . like below...
{
LOCK_TCPIP_CORE()
udp_recv( callback_fn )
UNLOCK~
while(1) { DisableIRQ(ENET_IRQn); receiveProcess( xQueueReceive ); EnableIRQ(ENET_IRQn); }
}
callbakc_fn { xQueueCreate, and push packet }
It`s like sequential.API.. anyway thanks, I will consider netconn API.
Q1. The main difference is the Transport protocol used, I suggest you use netconn_xxx functions as you can specify the parameter for transport protocol.
Q2. Unfortunately, we don’t have a specific example where tcp/udp_xxx() is used.
Best regards,
Omar