Hi Marco
I think that you may be complicating things by using LWIP since the uTasker TCP/IP stack that is integrated into the framework has all the features (and much more) that you need and works immediately with Modbus TCP, plus it works with FreeRTOS (as does the the Modbus RTU interface).
If I understand the reasoning for LWIP it is that you have it operating with your HW, using MII and the LAN8740, whereby it is also easy to use your HW with the uTasker Ethernet because it is a question of configuration. A small amount of time to configure it so that you have a complete solution will almost certainly be much faster than the present route.
If you would like to get the project with TCP/IP, Modbus, web server, telnet, FTP etc. (you can reduce the features as a second simple step) you just need to get the LAN8740 operating. This is how it is possible:
1) In app_hw_kinetis.h find the FRDM_66F Ethernet configuration (which is of course for the Micrel KSZ8081RNA in RMII mode)
2) Now change it to this configuration instead
#define _LAN8740
#define PHY_ADDRESS 0x00
#define VNDR_MDL 0x011
#define MDL_REV 0x0
#define PHY_IDENTIFIER (0x0007c000 | (VNDR_MDL << 4) | MDL_REV)
#define MII_MANAGEMENT_CLOCK_SPEED 2500000
#define PHY_POLL_LINK
#define INTERRUPT_TASK_PHY TASK_NETWORK_INDICATOR
#define FNRESETPHY()
3) I never used this PHY with Kinetis parts but have with STM32 parts (but in RMII mode) so I have the settings for polling its link state (since I don't know how you have connected its interrupt).
In kinetis_ENET.h you can add the following just before the line with
#elif defined _KSZ8081RNA || defined _KSZ8051RNL // {84}{102}
#elif defined _LAN8720 || defined _LAN8740 || defined _LAN8742
#define PHY_INTERRUPT_REGISTER (0x1d)
#define PHY_LINK_STATE_CHANGE (0x0050)
#define PHY_LINK_STATUS_REG (0x1f)
#define PHY_LINK_MASK (0x0014)
#define PHY_LINK_10BASE_T_FULL_DUPLEX 0x0014
#define PHY_LINK_100BASE_TX_FULL_DUPLEX 0x0018
#define PHY_LINK_100BASE_TX_HALF_DUPLEX 0x0008
#define PHY_LINK_10BASE_T_HALF_DUPLEX 0x0004
4) You will also need to verify that the PHY connections are correct. It will do this but you may also need to connect a clock [ENET_1588_CLKIN?] (it depends on the HW which I haven't seen).
In fnConfigEthernet() in kinetis_ENET.h
_CONFIG_PERIPHERAL(B, 0, PB_0_MII0_MDIO);
_CONFIG_PERIPHERAL(B, 1, PB_1_MII0_MDC);
_CONFIG_PERIPHERAL(A, 5, PA_5_MII0_RXER);
_CONFIG_PERIPHERAL(A, 12, PA_12_MII0_RXD1);
_CONFIG_PERIPHERAL(A, 13, PA_13_MII0_RXD0);
_CONFIG_PERIPHERAL(A, 14, PA_14_RMII0_CRS_DV);
_CONFIG_PERIPHERAL(A, 15, PA_15_MII0_TXEN);
_CONFIG_PERIPHERAL(A, 16, PA_16_MII0_TXD0);
_CONFIG_PERIPHERAL(A, 17, PA_17_MII0_TXD1);
_CONFIG_PERIPHERAL(A, 9, PA_9_MII0_RXD3);
_CONFIG_PERIPHERAL(A, 10, PA_10_MII0_RXD2);
_CONFIG_PERIPHERAL(A, 11, PA_11_MII0_RXCLK);
_CONFIG_PERIPHERAL(A, 24, PA_24_MII0_TXD2);
_CONFIG_PERIPHERAL(A, 25, PA_25_MII0_TXCLK);
_CONFIG_PERIPHERAL(A, 26, PA_26_MII0_TXD3);
_CONFIG_PERIPHERAL(A, 27, PA_27_MII0_CRS);
_CONFIG_PERIPHERAL(A, 28, PA_28_MII0_TXER);
_CONFIG_PERIPHERAL(A, 29, PA_29_MII0_COL);
It may work first time but it may also need some further adjustment, but it should be possible to identify if there is still something not matching.
If this step is possible you will then have complete FreeRTOS, Ethernet TCP/IP with Modbus TCP and Modbus RTU. You will then be able to work with the rest of the project that you already have too.
Good luck
Regards
Mark