cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Network Component on STM32H7 (CubeMX) and Keil

Jeremi Wójcicki
Associate II
Posted on July 13, 2018 at 18:06

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

    https://community.st.com/external-link.jspa?url=https%3A%2F%2Fwww.keil.com%2Fpack%2Fdoc%2FSTM32Cube%2FGeneral%2Fhtml%2Fstm32f7_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

    http://www.keil.com/pack/doc/mw/Network/html/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)
3 REPLIES 3

Can't help you, bumping you off my feed

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Garnett.Robert
Senior III

Hi, have you had a look at the Linker scatter file used in the STM32H7 Nucleo 144 ethernet demo file.

I copied this in my project and that fixed it.

RJG

Frank H
Associate

Hello,

I am facing the same problem with H723. Have you been able to solve the problem. Could you describe what solved it please ?

Thanks

Frank