lwIP mailbox issue on initialization
Posted: Wed Jul 29, 2015 4:25 pm
Hi, I'm trying to get something (anything) working with lwIP on a custom board with an STM32F107 using the stable_3.0.x branch. I've mostly built it off of the STM32F407 lwip demp. I'm now stuck, as I'm trying to debug in the middle of some rather large pieces that I don't fully understand, name lwIP and ChibiOS's mailboxes.
Once I call lwipInit(NULL), which then kicks off the lwip_thread, I see lwIP bailing out with "tcpip_thread: invalid message". It looks like the tcpip_thread is calling sys_timeouts_mbox_fetch and getting back a message which is trash (random-ish message type, etc). I can't figure out exactly what makes this mbox think that it has a message, but I'm trying to piece together how it's getting triggered (I'm learning how the mbox'es work).
Things that I checked that might be important:
- sys_mbox_new is getting called, and the mbox structure looks sane enough (to my untrained eye).
- doubling or quadrupling the stack sizes of lwIP doesn't seem to help.
- I haven't seen any calls to post to that mbox yet, but I might be failing to watch those calls.
- mbox->mb_fullsem.s_cnt goes from 0 to -1, then back to 0, but never goes positive.
(In fact, that semephore is incremented from -1 to 0 in chSemFastSignalI, triggered from a wakeup from a timer, even though that macro says "This macro can be used when the counter is known to be not negative". Should I be worried about that?)
Now, here's the really strange part. I have a very similar demo (basically the old ARMCM3-STM32F107-LWIP webdemo) from sometime in the ChibiOS 2.7.x range, and it works fine. It initializes lwIP, brings up the PHY, and serves packets, all on the exact same hardware.
So, I don't think it's my hardware (it works with this 2.7.x code), and I don't think that lwIP is the issue (the source is the same), and I don't think it's ChibiOS's mbox or semaphore code (or else everyone would have issues), so I'm out of ideas. How much changed with lwIP when we went to 3.0? From what I saw it was pretty minimal. Has anyone else had similar issues?
Any thoughts on where to look would be appreciated. I'm somewhat lost when watching all these calls go past - debugging a timed out mbox fetch is a rough way to learn how mbox'es and semaphores work in ChibiOS.
Once I call lwipInit(NULL), which then kicks off the lwip_thread, I see lwIP bailing out with "tcpip_thread: invalid message". It looks like the tcpip_thread is calling sys_timeouts_mbox_fetch and getting back a message which is trash (random-ish message type, etc). I can't figure out exactly what makes this mbox think that it has a message, but I'm trying to piece together how it's getting triggered (I'm learning how the mbox'es work).
Things that I checked that might be important:
- sys_mbox_new is getting called, and the mbox structure looks sane enough (to my untrained eye).
- doubling or quadrupling the stack sizes of lwIP doesn't seem to help.
- I haven't seen any calls to post to that mbox yet, but I might be failing to watch those calls.
- mbox->mb_fullsem.s_cnt goes from 0 to -1, then back to 0, but never goes positive.
(In fact, that semephore is incremented from -1 to 0 in chSemFastSignalI, triggered from a wakeup from a timer, even though that macro says "This macro can be used when the counter is known to be not negative". Should I be worried about that?)
Now, here's the really strange part. I have a very similar demo (basically the old ARMCM3-STM32F107-LWIP webdemo) from sometime in the ChibiOS 2.7.x range, and it works fine. It initializes lwIP, brings up the PHY, and serves packets, all on the exact same hardware.
So, I don't think it's my hardware (it works with this 2.7.x code), and I don't think that lwIP is the issue (the source is the same), and I don't think it's ChibiOS's mbox or semaphore code (or else everyone would have issues), so I'm out of ideas. How much changed with lwIP when we went to 3.0? From what I saw it was pretty minimal. Has anyone else had similar issues?
Any thoughts on where to look would be appreciated. I'm somewhat lost when watching all these calls go past - debugging a timed out mbox fetch is a rough way to learn how mbox'es and semaphores work in ChibiOS.