Hi all,
I was looking the ARM7-AT91SAM7X-LWIP-GCC example, and i saw that there is a thread called < msg_t lwip_thread(void *p) >
This is normaly not needed by the Lwip (I mean that only the ethernetif.c, sys_arch.c etc files need to be ported)
Then why is this thread used? Is there any complication in porting Lwip into Chibios? (so some kind of hack is needed)?
Also, in the same thread the declarations below are done:
sys_init();
mem_init();
memp_init();
pbuf_init();
netif_init();
ip_init();
tcpip_init(NULL, NULL);
These are normally done by lwip_init(). Why we call them here?
Thanx,
Nick
Chibios+Lwip
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Chibios+Lwip
That thread is the interface between the MAC driver and lwIP, that work could be done in the main thread but usually you want to use the main thread for your application and do the TCP/IP stuff at a lower priority. I would be interested in learning a better solution, I am not a huge lwIP expert.
About initializations, this is how it was done in the example when I first ported lwIP 1.2, probably I missed the general initialization function, thank for suggesting this.
Giovanni
About initializations, this is how it was done in the example when I first ported lwIP 1.2, probably I missed the general initialization function, thank for suggesting this.
Giovanni
-
pacoblackxx
- Posts: 10
- Joined: Sat Mar 10, 2012 6:49 pm
Re: Chibios+Lwip
In lwip, i have a thread that is waiting for a semaphore, and a vector routine that is called every time the ethernet receives a packet. I use stm32f4 drivers, without the hall. Some times the system freezes, and no thread is working. Is something wrong with the way the interrupt communicates with the thread?
Code: Select all
/* Interrupt routine */
/* NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; */
/* NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; */
void Vector134(void)
{
CH_IRQ_PROLOGUE();
chSysLockFromIsr();
inInterrupts++;
/* Frame received */
if ( ETH_GetDMAFlagStatus(ETH_DMA_FLAG_R) == SET)
{
inPackets++;
/* Give the semaphore to wakeup LwIP task */
chSemSignalI(ðernetInputSematophore);
}
/* Clear the interrupt flags. */
/* Clear the Eth DMA Rx IT pending bits */
ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
chSysUnlockFromIsr()
CH_IRQ_EPILOGUE();
}
/* Ethrenet input monitoring (normal prio) */
msg_t ethernetInputMonitoringThread(void *arg)
{
struct pbuf *p;
(void)arg;chRegSetThreadName("ethernetInputMonitoringThread");
print("Ehthernet Input Monitoring Thread Started@%dms\r\n",chTimeNow());
for( ;; )
{
//print("Waiting for input...");
if (chSemWaitTimeout(ðernetInputSematophore,200)==RDY_OK)
{
//packet received, pass it to lwip..
p = low_level_input( s_pxNetIf );
if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf))
{
pbuf_free(p);
p=NULL;
}
}
else{}
}
while (TRUE) {}
}
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Chibios+Lwip
Signaling looks correct, just keep in mind that a counter semaphore is unbounded and can overflow if signaled faster than it is taken. Binary semaphores are better in this role.
I doubt this is your problem anyway. Make sure to enable all the debug options and see if something is caught.
Giovanni
I doubt this is your problem anyway. Make sure to enable all the debug options and see if something is caught.
Giovanni