Hi guys, I have recently started to work with Keil uVision and I am porting my code that I have previously coined with SW4STM32. I bumped into some problems with the network component (I would like to switch from previously used LwIP to keil’s network implementation, so I need to rewrite this part). Fore some reason only reception works but board does not respond with anything. I work with NUCLEO 144 and STM32H743IT. Here I give you the description of how I included a network component into a default project and my minimal implementation to start the network interface with IPv4. Then I describe the problem more closely, also the debug log is attached. I use cubeMX API for peripherals configuration and have done following things: 1. In “STM32Cube Framework (API)” -> CubeMX enabled ETH perhiperal and configured it like in www.keil.com/.../stm32f7_emac.html, that is: RMII mode, in configuration parameters I left default MAC 00:80:E1:00:00:00 and TX/RX descriptors, from 0x30040000 and on. Rx buffer length 1524 (default), I enabled global ETH interrupt. In GPIO all pins speed set to high, only PC1 (ETH_MDC) to low (high is not available for some reason). Chip is running at 400MHz and peripherals are running at either 200 or 100Mhz. I generated the project files. *_hal_eth.c and *_hal_eth_ex.c as well as IT, MSP and other core files are generated. 2. In uVision component selection: Network->CORE enabled, IPv4 Debug STDIO Network->Interface->ETH to 1 Network->Socket-> UDP and TCP enabled Device->STM32Cube HAL-> enabled ETH and DMA CMSIS Driver->Ethernet MAC (API)-> Ethernet MAC enabled CMSIS Driver->Ethernet PHY (API)->LAN8742A enabled (and checked that it is physically the one on the board) 3. In RTX config (I use RTX5 with RTOS2 API) I set global dynamic memory size to 16k, thread stack to 4k 4. In Net_Debug.c enabled Full Debug under IPv4 Core Debug 5. Net_Config_TCP.c and *UDP.c left as default 6. In Net_Config_ETH_0.h driver set to 0, MAC default 1E-30-6C-A2-45-5E (I assume it overwrites the cubemx default), Ip address 192.168.137.10, mask 255.255.255.0, gateway 192.168.137.1, IGMP on DHCP off, only IPv4, netbios off, interface thread stack size 1024, rest as default 7. In startup script set the heap to 0x1000 and stack to 0x16000 like suggested in www.keil.com/.../nw_resource_requirements.html 8. Caches D and I are disabled 9. In main I call the MX_ETH_Init() 10. In a separate thread I call the netInitialize() 11. Compilation is ok After the startup the chip boots ok, and starts the netInitalize routine after which I have a list of debug messages which indicate the interface reads data from the Ethernet (board is connected to a pc with a static address 192.168.137.2) which sends some ARP requests. The problem is it does not seem to be sending any responses. Also looking at wireshark dump there is nothing coming out from my board. When I try to ping the board and a following ARP request appear on wireshark: 259 371.999350 AsustekC_ac:66:3f Broadcast ARP 42 Who has 192.168.137.10? Tell 192.168.137.2 , then I see that that the chip executes SendFrame (EMAC_STM32H7xx.c) and the transfer complete HAL_ETH_TxCpltCallback (stm32h7xx_hal_eth.c) is called afterwards but no data ever reaches my host (nor does eth transmit diode blink). Other than during my ping attempt, these functions are never called. I would be glad for some insights on what could I be missing. Btw. Hardware interface, cables etc. etc. are ok, as my “old” code works well on the same board. Thanks, Jeremi Key parts of main:
#include "main.h" #include "stm32h7xx_hal.h" #include "string.h" /* USER CODE BEGIN Includes */ #include "cmsis_os2.h" // ::CMSIS:RTOS2 #include "rl_net.h" __attribute__((at(0x30040000))) ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; __attribute__((at(0x30040060))) ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; __attribute__((at(0x30040200))) uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_MAX_PACKET_SIZE]; ETH_TxPacketConfig TxConfig; ETH_HandleTypeDef heth; void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_ETH_Init(void); uint32_t tcp_cb_server (int32_t socket, netTCP_Event event, const NET_ADDR *addr, const uint8_t *buf, uint32_t len); __NO_RETURN void LED_Thread (void *argument) { netInitialize (); uint8_t ip4_addr[NET_ADDR_IP4_LEN]; char ip_ascii[40]; for (;;) { osDelay(1000); HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin); netIF_GetOption (NET_IF_CLASS_ETH | 0, netIF_OptionIP4_Address, ip4_addr, sizeof (ip4_addr)); netIP_ntoa (NET_ADDR_IP4, &ip4_addr[0], ip_ascii, sizeof (ip_ascii)); printf ("Current IP address: %s\n", ip_ascii); } } int main(void) { osKernelInitialize(); HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_ETH_Init(); osThreadNew(LED_Thread, NULL, NULL); osKernelStart(); while (1){} }
Debug console:
000.0 SYS:Network 7.9.0 000.0 SYS:Init system 000.0 MEM:Init MemPool 12000 bytes 000.0 MEM: Limit0=9000, Limit1=6000 bytes 000.0 ETH:Init interface 000.0 ETH:MAC (1E-30-6C-A2-45-5E) 000.0 ARP:Init Cache, 10 entries 000.0 LOOP:Init interface 000.0 IP4:Init IPv4 core 000.0 ICMP:Init Client 000.0 IGMP:Init Table, 5 entries 000.9 SYS:GetOption ETH, IP4-Addr Current IP address: 192.168.137.10 001.9 ETH:Link up 001.9 ETH: 100M, Full duplex 001.9 MEM:Alloc 72 bytes 001.9 MEM: Used 72 bytes (1 blocks) 001.9 MEM:Free 72 bytes 001.9 MEM: Used 0 bytes (0 blocks) 001.9 ARP:Send_Request 001.9 MEM:Alloc 56 bytes 001.9 MEM: Used 56 bytes (1 blocks) 001.9 ARP: Opcode ARP-REQUEST 001.9 ARP: SendIp 192.168.137.10 001.9 ARP: TargIp 192.168.137.10 001.9 ARP: SendMac 1E-30-6C-A2-45-5E 001.9 ARP: TargMac 00-00-00-00-00-00 001.9 MEM:Free 56 bytes 001.9 MEM: Used 0 bytes (0 blocks) 001.9 SYS:GetOption ETH, IP4-Addr Current IP address: 192.168.137.10 002.0 MEM:Alloc 72 bytes 002.0 MEM: Used 72 bytes (1 blocks) 002.0 ETH:*** Processing frame *** 002.0 ETH: DstMAC FF-FF-FF-FF-FF-FF 002.0 ETH: SrcMAC D0-17-C2-AC-66-3F 002.0 ETH: Proto ARP, 60 bytes 002.0 ARP:*** Processing frame *** 002.0 ARP: Opcode ARP-REQUEST 002.0 ARP: SendIp 0.0.0.0 002.0 ARP: TargIp 192.168.137.2 002.0 ARP: SendMac D0-17-C2-AC-66-3F 002.0 ARP: TargMac 00-00-00-00-00-00 002.0 ARP: Discarded, SendAddr invalid 002.0 MEM:Free 72 bytes 002.0 MEM: Used 0 bytes (0 blocks)
At least I can offer here a reference to the "HTTP Server IPv4/IPv6" example project offered by the Pack Installer for the STM32H7 series.
This example project also uses STCubeMX configuration.
Just install the corresponding Keil::STM32H7xx_DFP 2.1.0
Probably this helps, Jeremy
Hi Jeremy,
I am experience a similar problem with a custom STM32H7 board. In my case the network components are running and communicating with the MAC but no traffic is generated on the RMII signals to the external PHY.
Can you share how you resolved your problem?
Thanks.
Hi R. Kopsch,
Sorry for late reply, but I was out of office for a while. I have followed your suggestion, importing the HTTP Server example, which is for STM32H753I-EVAL board. The problem is that the Nucleo board I have has STM32H743ZIT chip on it. I can change the chip in the target configuration in uVision but not in the CubeMX configuration (the chip field is locked), so in the end I cannot use that project on my device... Specifically that there are different pinout configurations for the PHY connection, between these boards.
What I did is to compare configuration of the network component and they are pretty much the same. I checked communication between uC and the PHY and what I see is that there is only one frame, being sent after the chip reset on the TXD0 and TXD1 lines (for some reason voltage level at TXD1 reaches barely 1.6V, but I don't know if it has anything to do with the main problem). Instead on the RXD0 and RXD1 there is continous traffic and the EventRecorder shows me that frames are being received by the network component. I really dont know what could be wrong here, the network component just not seem to be interested in sending anything or sth blocks after the first framje transmission between uC and PHY.
Thanks, Jeremi
Hi Letizia,
Unfortunately the problem is not solved yet. Similarly to you I have checked the TXD lines of the PHY and there is only one frame transmitted after the reset and then nothing more. RXD lines are OK. I do not know which board you are using but the pin configuration between EVAL and Nucleo boards for H7 are different and you should modify them accordingly in the cubeMX. Please tell me if you bump into a solution, however I have a feeling that there might be a bug sitting somewhere in the pack for H7.
Best, Jeremi
Actually, the problem has been solved as I has described before (I just needed to regenerate and rebuild the project). Reassigning the pins properly for the Nucleo board was the key issue here, because by default they are configured for the EVAL board:
/**ETH GPIO Configuration
PC1 ------> ETH_MDC
PA1 ------> ETH_REF_CLK
PA2 ------> ETH_MDIO
PA7 ------> ETH_CRS_DV
PC4 ------> ETH_RXD0
PC5 ------> ETH_RXD1
PB13 ------> ETH_TXD1
PG11 ------> ETH_TX_EN
PG13 ------> ETH_TXD0
*/
Thanks for sharing the solution to this problem, Jeremy