Hi all,
thanks to the guys on the FreeRTOS forum, I did some step further into the issue...
At first I was focusing on the ENET_INT pun, but analyzing again the LwIP demo code I found that it wasn't used at all for detecting new packets incoming.
It seems instead that the phy component/driver (fsl_phyksz8081.c) i was using from the SDK 2.12 was lacking some of the function regarding the interrupts:
#define PHY_INTR_CONTROL_STATUS_REG (0x1BU) /*!< The PHY interrupt control/status register. */
...
status_t PHY_KSZ8081_EnableLinkInterrupt(phy_handle_t *handle, phy_interrupt_type_t type)
status_t PHY_KSZ8081_ClearInterrupt(phy_handle_t *handle)
which were present into the driver used into the LwIP demo.
Infact, upon reanalyzing the MDIO transaction that occurs during the LwIP demo execution, compared to my own, it seems that my code is missing a poll to the aforementioned register (the register address is 0b11011 or 0x1B).
By using the latest version of the SDK for VSCode (mcux-sdk), it presents the missing functions, but a phy_handle structure that is not compatible.
Essentially, the NetworkInterface.c file requires that phy_handle has a structure like this:
/*! @brief PHY device handle. */
struct _phy_handle
{
uint32_t phyAddr; /*!< PHY address. */
mdio_handle_t *mdioHandle; /*!< The MDIO handle used by the phy device, it is specified by device. */
const phy_operations_t *ops; /*!< The device related operations. */
};
instead, I find myself with this:
/*! @brief PHY device handle. */
struct _phy_handle
{
uint8_t phyAddr; /*!< PHY address. */
void *resource; /*!< PHY specific resource supporting operation of PHY hardware. */
const phy_operations_t *ops; /*!< PHY operational method. */
};
After importing such driver, i found that the code fails in NetworkInterface.c at this lines:
// r. 202
static phy_handle_t phyHandle = { .phyAddr = 0x00, .mdioHandle = &mdioHandle, .ops = &EXAMPLE_PHY_OPS };
// r. 852
sysClock = phyHandle.mdioHandle->resource.csrClock_Hz;
which I tried to readapt like this (based on the assumption that the member mdio_handle_t *mdioHandle is changed to void *resource) :
// r. 202
static phy_handle_t phyHandle = { .phyAddr = 0x00, .resource = ( void * )&mdioHandle, .ops = &EXAMPLE_PHY_OPS };
// r. 852
mdio_handle_t *mdioHandle = ( mdio_handle_t * )( phyHandle.resource );
sysClock = mdioHandle->resource.csrClock_Hz;
the code builds but it crashes when executing this:
static inline status_t PHY_Init(phy_handle_t *handle, const phy_config_t *config)
{
handle->ops = config->ops;
return handle->ops->phyInit(handle, config);
}
this is what I get into the debug console:
Temporary breakpoint 18, main () at ../source/MIMXRT1021_Project.c:199
199 BOARD_ConfigMPU();
Breakpoint 14, pxNXP1060_FillInterfaceDescriptor (xEMACIndex=0, pxInterface=0x2000608c <xInterfaces>) at ../source/external/freertos-plus-tcp/source/portable/NetworkInterface/NXP1060/NetworkInterface.c:311
311 return pxInterface;
Breakpoint 8, main () at ../source/MIMXRT1021_Project.c:249
249 vTaskStartScheduler();
Breakpoint 10, PHY_Init (handle=0x2000000c <phyHandle>, config=0x2000001c <xConfig>) at ..\source\external\phy/fsl_phy.h:202
202 handle->ops = config->ops;
Program received signal SIGSTOP, Stopped (signal).
HardFault_Handler () at ../source/semihost_hardfault.c:53
53 __asm( ".syntax unified\n"
I’m not so skilled in C to identify the issue, but I hope that someone will be able to catch the issue with the provided information...
EDIT:
moreover, I tried to update the Driver > Enet from the last version of mcux-sdk (i was still using the driver from v.2.12 in the previous build).
But, after changing the driver, I'm not able anymore to build, receiving the following error:
../source/external/phy/mdio/enet/fsl_enet_mdio.c: In function 'ENET_MDIO_WriteExt':
../source/external/phy/mdio/enet/fsl_enet_mdio.c:125:5: error: too few arguments to function 'ENET_StartExtC45SMIWriteReg'
125 | ENET_StartExtC45SMIWriteReg(base, phyAddr, devAddr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../source/external/phy/mdio/enet/fsl_enet_mdio.h:11,
from ../source/external/phy/mdio/enet/fsl_enet_mdio.c:8:
..\source\external\enet/fsl_enet.h:1061:20: note: declared here
1061 | static inline void ENET_StartExtC45SMIWriteReg(ENET_Type *base, uint8_t portAddr, uint8_t devAddr, uint16_t regAddr)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../source/external/phy/mdio/enet/fsl_enet_mdio.c: In function 'ENET_MDIO_ReadExt':
../source/external/phy/mdio/enet/fsl_enet_mdio.c:155:5: error: too few arguments to function 'ENET_StartExtC45SMIWriteReg'
155 | ENET_StartExtC45SMIWriteReg(base, phyAddr, devAddr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
..\source\external\enet/fsl_enet.h:1061:20: note: declared here
1061 | static inline void ENET_StartExtC45SMIWriteReg(ENET_Type *base, uint8_t portAddr, uint8_t devAddr, uint16_t regAddr)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [source/external/phy/mdio/enet/subdir.mk:20: source/external/phy/mdio/enet/fsl_enet_mdio.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Finished building: ../startup/startup_mimxrt1021.c
I also tried to use the IDE SDK (downloaded from MCUXpresso SDK Builder) but in that case also the MDIO driver disappear, making the NetworkInterface unusable.
Is possible that drivers and components are not compatible if pulled from the same version of the repository?
Thanks