Extracting ENET driver from RTM 3.0.2

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

Extracting ENET driver from RTM 3.0.2

178 次查看
danielnäslund
Contributor III

We have a product designed around a MPC5748G.

I want to extract the Ethernet driver from the provided SDK into a code base that was written before the SDK's were released.

Right now I have a proof-of-concept file with which I can send upd-packets and respond to pings.

I tried replacing that with the enet_driver.c, enet_irq.c, ... files,  but I run into problems when sending. The buffer descriptor control field is 0x8C00.

 

status_t ENET_DRV_SendFrame(uint8_t instance,
                            uint8_t queue,
                            const enet_buffer_t * buff,
                            enet_tx_options_t * options)
{
   // ...  
    base = s_enetBases[instance];

    bd = g_enetState[instance]->txBdCurrent[queue];

    if ((bd->control & ENET_BUFFDESCR_TX_READY_MASK) != 0U)
    {
        status = STATUS_ENET_TX_QUEUE_FULL;
    }

 

Which means it has TX_READY_MASK | TX_LAST_MASK | TX_TRANSMITCRC_MASK set.

The sending is aborted STATUS_ENET_TX_QUEUE_FULL is returned.

 

/*! @brief Control and status bit masks of the transmit buffer descriptor. */
#define ENET_BUFFDESCR_TX_READY_MASK        0x8000U
#define ENET_BUFFDESCR_TX_WRAP_MASK         0x2000U
#define ENET_BUFFDESCR_TX_LAST_MASK         0x0800U
#define ENET_BUFFDESCR_TX_TRANSMITCRC_MASK  0x0400U

 

The buffers are configured like this:

 

int main(void) {
   // ... 
   enet_config_t enetConfig;
    /* Use only one ring */
    enet_buffer_config_t enetBufferConfigs[ENET_QUEUE + 1];
    uint8_t macAddr[NETIF_MAX_HWADDR_LEN] = { LWIP_MAC_ADDR_BASE };
    uint8_t i;

    ENET_DRV_GetDefaultConfig(&enetConfig);

    enetConfig.miiMode = ENET_MIIMODE;
    enetConfig.miiSpeed = ENET_MIISPEED;

    enetConfig.rxConfig = (uint32_t)(ENET_RX_CONFIG_ENABLE_PAYLOAD_LEN_CHECK | ENET_RX_CONFIG_STRIP_CRC_FIELD | ENET_RX_CONFIG_REMOVE_PADDING | ENET_RX_CONFIG_ENABLE_FLOW_CONTROL);
    enetConfig.txConfig = 0;

    enetConfig.rxAccelerConfig = (uint8_t)(ENET_RX_ACCEL_ENABLE_IP_CHECK | ENET_RX_ACCEL_ENABLE_PROTO_CHECK | ENET_RX_ACCEL_REMOVE_PAD);
    enetConfig.txAccelerConfig = (uint8_t)(ENET_TX_ACCEL_INSERT_IP_CHECKSUM | ENET_TX_ACCEL_INSERT_PROTO_CHECKSUM);
    enetConfig.ringCount = sizeof(enetBufferConfigs) / sizeof (enet_buffer_config_t);
    enetBufferConfigs[ENET_QUEUE].rxRingSize = ENET_RXBD_NUM;
    enetBufferConfigs[ENET_QUEUE].txRingSize = ENET_TXBD_NUM;
    enetBufferConfigs[ENET_QUEUE].rxRingAligned = rxDescriptor;
    enetBufferConfigs[ENET_QUEUE].txRingAligned = txDescriptor;
    enetBufferConfigs[ENET_QUEUE].rxBufferAligned = rxBuffer;


    ENET_DRV_Init(ENET_INSTANCE, &enetState, &enetConfig, enetBufferConfigs, macAddr);
    ENET_DRV_EnableMDIO(ENET_INSTANCE, false);
    // ...
}

 

 Do you have suggestions on where to start troubleshooting?

0 项奖励
回复
1 回复

146 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

I can give 2 hints only...
- be sure buffer descriptors are properly aligned as mentioned in the device RM and shown in examples
- assume the data cache usage, if enabled, descriptors must be place in non cacheable area. Or try to disable dcache at all.

BR, Petr

0 项奖励
回复