cancel
Showing results for 
Search instead for 
Did you mean: 

MQTT Client Problem

Charlie CHEN
Associate III

Hi ,

 

Recently, I`m using STM32H7 MCU to implement Ethernet Application. I have try TCP Client Echo from example code and it works. Then I want to try with MQTT and it always gets fault.

And using mqtt_client_connect function, it will return ERR_RTE (Routing Problem)

 

I have doing the works like,

- Ping from PC to my board, so it seems well connection.
- Set the static IP for connection port.

- Open the 1883 port from firewall.

- Set the MQTT broker and test at local PC with static IP Address.

 

So I think is there something I miss. Setting? or  Connection?

I`m a beginner on internet knowledge.

 

Appreciate any help!

 
4 REPLIES 4
STea
ST Employee

Hello @Charlie CHEN ,

If you can share with us more details about the example used for the implementation of MQTT client from MCU side (library used ...) and the exact STM32H7 microcontroller used.

in the meanwhile, her are some general advice about the implementation of MQTT client you should take into consideration:

  • The ETH TX And RX descriptors are accessed by the CPU and the ETH DMA IP, thus they should not be allocated into the DTCM RAM "0x20000000".
  • Make sure to allocate them into a "Non-Cacheable" memory region to always ensure data coherency between the CPU and ETH DMA.
  • Depending on the application scenario, the total TX and RX descriptors may need to be increased by updating respectively the "ETH_TX_DESC_CNT" and "ETH_RX_DESC_CNT" in the "stm32h7xx_hal_conf.h", to guarantee the application correct behavior, but this will cost extra memory to allocate.

you can get inspired from some implementations:

x-cube-azrtos-h7/Projects/STM32H735G-DK/Applications/NetXDuo/Nx_MQTT_Client at main · STMicroelectronics/x-cube-azrtos-h7 · GitHub

GitHub - eziya/STM32F4_HAL_ETH_MQTT_CLIENT: STM32 + FREERTOS + LWIP + MQTT example

Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @STea,

 

Sorry for lately busy.

Thanks for your reply.

 

For more information below,

1. Set MPU in 0x30040000 region for protect as the most setting.

2. Enable LWIP in all default setting. Only set the Static IP Address

3. API Reference to Erik Andersson Example.

New client space > Connect to Broker address(Failed here) > Publish to a topic

Up the operation, it always get ERR_RTE back.

 

And I`m not sure about your advice.

  • The ETH TX And RX descriptors are accessed by the CPU and the ETH DMA IP, thus they should not be allocated into the DTCM RAM "0x20000000".
    >> Do you mean about ETH - Parameter Settings?
     CharlieCHEN_0-1725516222704.png

     

  • Make sure to allocate them into a "Non-Cacheable" memory region to always ensure data coherency between the CPU and ETH DMA.
    >> Can you give an easy example about how to allocate it?
  • Depending on the application scenario, the total TX and RX descriptors may need to be increased by updating respectively the "ETH_TX_DESC_CNT" and "ETH_RX_DESC_CNT" in the "stm32h7xx_hal_conf.h", to guarantee the application correct behavior, but this will cost extra memory to allocate.
    >> Now I set it by default 4. Is it fine for it?

 

Thanks again.

Hello @Charlie CHEN ,
Which microcontroller are you using H723 or H743 for example.

Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @STea ,

 

I work with H750. And using external flash with bootloader.

And as attachment, is my setting for MQTT applicatoin.

 

Best regards,