关于GD32F107的eth、mac、phy的问题

  由于项目需要,由STM32F107更换到了GD32F107,传说中,完全PIN2PIN,代码基本不用改,这也是吸引人的地方。于是。。。。。

但是移植到ETH的时候,发现跑不通,数据只进不出,后面发现是DMA发送不了数据。可是,为什么DMA会发送不了?于是,就不是简单的移植了,只能从最基本的下手了,数据怎么进来?数据怎么处理?数据怎么出去?然后利用Wireshark抓包工具来,用STM32F107的旧板,抓取了上电之后,Lwip首先需要发出的数据是一个ARP请求包。GD32F107这个包怎么都发不出去,后来无意在百度的时候看到一段配置代码,COPY下来放到我的代码里,一运行,竟然发出去了,然后细细对比一番,原来是GD32F107不能采用自动协商模式。选定了100M模式后,一切正常,真是折腾死人,三天,整整折腾了三天。GD的工程师如果看到这文章,希望能给出解决办法,或者如果读者在自动协商下能正常运行的,欢迎指教指教。下面,我贴出配置代码。

/*------------------------   MAC   -----------------------------------*/
// ETH_InitStruct.ETH_AutoNegotiation = ETH_AutoNegotiation_Enable  ;
ETH_InitStruct.ETH_AutoNegotiation = ETH_AutoNegotiation_Disable;
ETH_InitStruct.ETH_Mode = ETH_Mode_FullDuplex;
ETH_InitStruct.ETH_Speed = ETH_Speed_100M;
ETH_InitStruct.ETH_LoopbackMode = ETH_LoopbackMode_Disable;
ETH_InitStruct.ETH_RetryTransmission = ETH_RetryTransmission_Disable;
ETH_InitStruct.ETH_AutomaticPadCRCStrip = ETH_AutomaticPadCRCStrip_Disable;
ETH_InitStruct.ETH_ReceiveAll = ETH_ReceiveAll_Disable;
ETH_InitStruct.ETH_BroadcastFramesReception = ETH_BroadcastFramesReception_Enable;
ETH_InitStruct.ETH_PromiscuousMode = ETH_PromiscuousMode_Disable;
ETH_InitStruct.ETH_MulticastFramesFilter = ETH_MulticastFramesFilter_Perfect;
ETH_InitStruct.ETH_UnicastFramesFilter = ETH_UnicastFramesFilter_Perfect;
#ifdef CHECKSUM_GEN_ICMP
ETH_InitStruct.ETH_ChecksumOffload = ETH_ChecksumOffload_Enable;
#endif


/*------------------------   DMA   -----------------------------------*/  
  
/* When we use the Checksum offload feature, we need to enable the Store and Forward mode: 
the store and forward guarantee that a whole frame is stored in the FIFO, so the MAC can insert/verify the checksum, 
if the checksum is OK the DMA can handle the frame otherwise the frame is dropped */
ETH_InitStruct.ETH_DropTCPIPChecksumErrorFrame = ETH_DropTCPIPChecksumErrorFrame_Enable; 
ETH_InitStruct.ETH_ReceiveStoreForward = ETH_ReceiveStoreForward_Enable;         
ETH_InitStruct.ETH_TransmitStoreForward = ETH_TransmitStoreForward_Enable;     


ETH_InitStruct.ETH_ForwardErrorFrames = ETH_ForwardErrorFrames_Disable;       
ETH_InitStruct.ETH_ForwardUndersizedGoodFrames = ETH_ForwardUndersizedGoodFrames_Disable;   
ETH_InitStruct.ETH_SecondFrameOperate = ETH_SecondFrameOperate_Enable;                                                          
ETH_InitStruct.ETH_AddressAlignedBeats = ETH_AddressAlignedBeats_Enable;      
ETH_InitStruct.ETH_FixedBurst = ETH_FixedBurst_Enable;                
ETH_InitStruct.ETH_RxDMABurstLength = ETH_RxDMABurstLength_32Beat;          
ETH_InitStruct.ETH_TxDMABurstLength = ETH_TxDMABurstLength_32Beat;                                                                 
ETH_InitStruct.ETH_DMAArbitration = ETH_DMAArbitration_RoundRobin_RxTx_2_1;

你可能感兴趣的:(sofeware,note)