Assistance needed with lwIP + PEx + KSDK

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Assistance needed with lwIP + PEx + KSDK

跳至解决方案
2,750 次查看
dave408
Senior Contributor II

I'm trying to put together a PEx test app that integrates lwIP.  I'm starting from scratch, but pulling code as-needed from the lwip_tcpecho demo application.

I think I've got everything together.  I pulled in the fsl_enet PEx component to get the ENET_DRV_* functions, and found the PHY_DRV_* functions defined in /boards/common/phyksz8041 so I added that folder as well.  Everything compiles, and I can run, but I can't initialize TCP/IP.  The call to tcpip_init(NULL,NULL) fails.  I've stepped into the code and it doesn't get very far.  Ultimately, I think it comes down to the MQX configuration, because of the following info:

Call Stack before hang:

pastedImage_3.png

OSA_MemAlloc doesn't want to allocate any memory:

pastedImage_4.png

and this causes subsequent functions to fail due to the null pointer.

Looked at MQXCFG_ALLOCATOR, it's related to the mqx_sdk_config settings, which then include small, lite, and max ram configurations depending upon the setting.  However, when using the MQX PEx component, there isn't any analog to this setting.  Or is there?  Maybe someone here can help steer me in the right direction with the correct settings.  I was thinking that I could just #define MQXCFG_ALLOCATOR, but then I fully expect the problem to crop up somewhere else down the road.

Can anyone please explain the ins an outs of getting lwip and the MQX PEx component to co-exist?  This question equally applies to RTCS, because I haven't been able to get my RTCS project upgraded to MQX and PEx.

1 解答
1,667 次查看
marek_neuzil
NXP Employee
NXP Employee

Hello Dave,

I have noticed that you have not configured pins in the PinSettings (ENET pins are not routed), see below:

pastedImage_0.png

The current configure_enet_pins function contains the following code only.

void configure_enet_pins(uint32_t instance)

{

  /* Affects PORTA_PCR18 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,18u,kPortPinDisabled);

}

Select required (used) pins and generate Processor Expert code again.

The configure_enet_pins function will be updated and this function should contains for example the following code (FRDM-K64F board configuration from KSDK board support):

void configure_enet_pins(uint32_t instance)

{

  /* Affects PORTC_PCR16 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,16u,kPortMuxAlt4);

  /* Affects PORTC_PCR17 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,17u,kPortMuxAlt4);

  /* Affects PORTC_PCR18 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,18u,kPortMuxAlt4);

  /* Affects PORTC_PCR19 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,19u,kPortMuxAlt4);

  /* Affects PORTB_PCR1 register */

  PORT_HAL_SetMuxMode(PORTB_BASE,1u,kPortMuxAlt4);

  /* Affects PORTB_PCR0 register */

  PORT_HAL_SetMuxMode(PORTB_BASE,0u,kPortMuxAlt4);

  PORT_HAL_SetOpenDrainCmd(PORTB_BASE,0u,true);

  PORT_HAL_SetPullMode(PORTB_BASE,0u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTB_BASE,0u,true);

  /* Affects PORTA_PCR13 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,13u,kPortMuxAlt4);

  /* Affects PORTA_PCR12 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,12u,kPortMuxAlt4);

  /* Affects PORTA_PCR14 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,14u,kPortMuxAlt4);

  /* Affects PORTA_PCR5 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,5u,kPortMuxAlt4);

  /* Affects PORTA_PCR16 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,16u,kPortMuxAlt4);

  /* Affects PORTA_PCR17 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,17u,kPortMuxAlt4);

  /* Affects PORTA_PCR15 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,15u,kPortMuxAlt4);

  /* Affects PORTA_PCR28 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,28u,kPortMuxAlt4);

}

Best Regards,

Marek Neuzil

在原帖中查看解决方案

8 回复数
1,667 次查看
dave408
Senior Contributor II

I've attached my entire project here.  Can anyone at FSL please take a look at it and let me know if there's anything obviously misconfigured?  Thank you!

0 项奖励
回复
1,668 次查看
marek_neuzil
NXP Employee
NXP Employee

Hello Dave,

I have noticed that you have not configured pins in the PinSettings (ENET pins are not routed), see below:

pastedImage_0.png

The current configure_enet_pins function contains the following code only.

void configure_enet_pins(uint32_t instance)

{

  /* Affects PORTA_PCR18 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,18u,kPortPinDisabled);

}

Select required (used) pins and generate Processor Expert code again.

The configure_enet_pins function will be updated and this function should contains for example the following code (FRDM-K64F board configuration from KSDK board support):

void configure_enet_pins(uint32_t instance)

{

  /* Affects PORTC_PCR16 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,16u,kPortMuxAlt4);

  /* Affects PORTC_PCR17 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,17u,kPortMuxAlt4);

  /* Affects PORTC_PCR18 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,18u,kPortMuxAlt4);

  /* Affects PORTC_PCR19 register */

  PORT_HAL_SetMuxMode(PORTC_BASE,19u,kPortMuxAlt4);

  /* Affects PORTB_PCR1 register */

  PORT_HAL_SetMuxMode(PORTB_BASE,1u,kPortMuxAlt4);

  /* Affects PORTB_PCR0 register */

  PORT_HAL_SetMuxMode(PORTB_BASE,0u,kPortMuxAlt4);

  PORT_HAL_SetOpenDrainCmd(PORTB_BASE,0u,true);

  PORT_HAL_SetPullMode(PORTB_BASE,0u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTB_BASE,0u,true);

  /* Affects PORTA_PCR13 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,13u,kPortMuxAlt4);

  /* Affects PORTA_PCR12 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,12u,kPortMuxAlt4);

  /* Affects PORTA_PCR14 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,14u,kPortMuxAlt4);

  /* Affects PORTA_PCR5 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,5u,kPortMuxAlt4);

  /* Affects PORTA_PCR16 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,16u,kPortMuxAlt4);

  /* Affects PORTA_PCR17 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,17u,kPortMuxAlt4);

  /* Affects PORTA_PCR15 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,15u,kPortMuxAlt4);

  /* Affects PORTA_PCR28 register */

  PORT_HAL_SetMuxMode(PORTA_BASE,28u,kPortMuxAlt4);

}

Best Regards,

Marek Neuzil

1,667 次查看
dave408
Senior Contributor II

In addition to Marek's extremely helpful and correct answer, the other piece to the puzzle to make my project work involved getting the proper include paths.  Despite building without errors, the code wouldn't work.  I believe that some of the include paths had header files that fulfilled some of the needed declarations, but I was missing some lwIP-specific ones.  I pared down the list of duplicate entries, favored Generated_Code wherever possible, and also used my shared KSDK_PATH instead of the SDK files that get copied into my local project.  For example:

"${KSDK_PATH}\boards\common\phyksz8041"

"${KSDK_PATH}\boards\frdmk64f"

"${KSDK_PATH}\tcpip\lwip"

"${KSDK_PATH}\tcpip\lwip\src\include"

"${KSDK_PATH}\tcpip\lwip\port\arch"

"${KSDK_PATH}\tcpip\lwip\src"

"${KSDK_PATH}\tcpip\lwip\src\include\ipv4"

"${KSDK_PATH}\tcpip\lwip\port"

"${KSDK_PATH}\tcpip\lwip\src\include\ipv4\lwip"

"${KSDK_PATH}\tcpip\lwip\src\include\ipv6"

"${KSDK_PATH}\tcpip\lwip\src\include\ipv6\lwip"

"${KSDK_PATH}\tcpip\lwip\src\include\lwip"

"${KSDK_PATH}\tcpip\lwip\src\include\netif"

"${KSDK_PATH}\tcpip\lwip\src\include\posix"

"${KSDK_PATH}\tcpip\lwip\src\include"

"${KSDK_PATH}\platform\CMSIS\Include"

"${KSDK_PATH}\platform\CMSIS\Include\device"

"${KSDK_PATH}\platform\CMSIS\Include\device\MK64F12"

"${KSDK_PATH}\platform\hal\inc"

"${KSDK_PATH}\platform\drivers\inc"

"${KSDK_PATH}\platform\drivers\src\mpu"

"${KSDK_PATH}\platform\osa\inc"

"${KSDK_PATH}\platform\startup"

"${KSDK_PATH}\platform\system\inc"

"${KSDK_PATH}\platform\utilities\inc"

"${KSDK_PATH}\rtos\mqx\config\board\frdmk64f"

"${KSDK_PATH}\rtos\mqx\config\common"

"${KSDK_PATH}\rtos\mqx\config\mcu\mk64f120m"

"${KSDK_PATH}\rtos\mqx\mqx\source\bsp"

"${KSDK_PATH}\rtos\mqx\mqx\source\include"

"${KSDK_PATH}/platform/drivers/src/enet"

"${KSDK_PATH}/platform/drivers/src/uart"

"${KSDK_PATH}/platform/hal/src/sim/MK64F12"

"${KSDK_PATH}/platform/hal/src/uart"

"${KSDK_PATH}/platform/system/src/clock/MK64F12"

"${KSDK_PATH}/platform/utilities/inc"

"${KSDK_PATH}/rtos/mqx/config/common"

"${KSDK_PATH}/rtos/mqx/mqx/source/string"

"${KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m"

"${KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m/cpu"

"${KSDK_PATH}/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm"

"${KSDK_PATH}/rtos/mqx/mqx/source/nio"

"${KSDK_PATH}/rtos/mqx/mqx/source/nio/src"

"${KSDK_PATH}/rtos/mqx/mqx/source/nio/fs"

"${KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_dummy"

"${KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_serial"

"${KSDK_PATH}/rtos/mqx/mqx/source/nio/drivers/nio_tty"

"${KSDK_PATH}/rtos/mqx/mqx_stdlib/source/include"

"${KSDK_PATH}/rtos/mqx/mqx_stdlib/source/stdio"

"${ProjDirPath}/Generated_Code/SDK/rtos/mqx/config/board"

"${ProjDirPath}/Generated_Code/SDK/rtos/mqx/config/mcu"

"${ProjDirPath}/Generated_Code/SDK/platform/startup/MK64F12"

"${ProjDirPath}/Sources"

"${ProjDirPath}/Generated_Code"

1,667 次查看
dave408
Senior Contributor II

Marek, I'm hoping you have some more debugging tips for me -- I made the changes you had recommended and now my configure_enet_pins() function looks like yours, with the exception of PTC19 and PTA28, which don't seem to be available on my chip.  Now when I debug my project, the call to netconn_accept() hangs.  When I step in, it's stuck in lwmsgq.c in the _lwmsgq_receive function:

pastedImage_0.png

I'm at the point now where I need to learn ARM assembly, because this function is defined in the M4-specific dispatch.S assembly file.

Can you think of anything that might cause this, or recommend any other course of action while I work on understanding what _sched_execute_scheduler_internal() is intended to do?

Thanks,

Dave

0 项奖励
回复
1,667 次查看
dave408
Senior Contributor II

Thanks, Marek, I will take a look at this!  I guess I am still making bad newbie mistakes.  I had assumed that since I was picking the FRDM-K64F in the project creation options, that PEx would have already "wired" up the pins for me as they are laid out on the board.  I will be more careful about this in the future!  I'll make the changes now and we'll see where I end up.  Thank you so much for looking at my project!

0 项奖励
回复
1,667 次查看
dave408
Senior Contributor II

More progress!  But now I'm really stumped because everything seems like it should be working.  At least all of the functions get called and don't error out.  :smileyhappy:  The previous call to OSA_MutexCreate was freezing up because of the call to disable interrupts.  I didn't really understand what was going on here, but the documentation implied that this function should get called from a task, and I was calling it in main.  So I moved the code to my tcp listener task, and everything "succeeded".

Now the problem is that I am sitting here waiting on netconn_accept to accept my connection, but when I try to telnet or ping, I don't get anything back from the IP address that I have specified.  Running Wireshark and pinging, I don't see any traffic to the board...

0 项奖励
回复
1,667 次查看
dave408
Senior Contributor II

Ok, I have MQX Standard setup now.  I just had to disable the debug console component and setup the UART for the new MQX configuration.  But now I'm not even getting past lwip_init!  It looks like it's getting stuck in OSA_MutexCreate.

pastedImage_1.png

I looked at my MQX configuration settings, and it looks like Mutexes are enabled, so I'm not sure where to go from here.

pastedImage_2.png

0 项奖励
回复
1,667 次查看
dave408
Senior Contributor II

I started to play around, and then found through experimentation that using the default MQX Lite setting for the PEx component will generate the same mqx_sdk_config.h file I was referring to in my original post.  So it looks like the next step is to go to MQX instead.  I was under the impression that MQX Lite and lwIP would work together, but maybe not.

0 项奖励
回复