2023-11-06 03:04 AM
Hello. I have the Riverdi 7' display with PoE addon. While I am working with a project for this display, where I am trying to implement the MQTT protocol, I am facing an issue that cannot understand. It has to do with the keep alive parameter, if I set it to zero then it acting normal. For instance it is able to read messages and also to print them to the UI. Nonetheless, if the keep alive parameter is greater to zero then the UI cannot render to the screen. The only thing I see is a black screen. I am using the LwIP library.
The way that I am connecting the screen with the broker is that :
void StartDefaultTask(void *argument)
{
/* init code for USB_HOST */
MX_USB_HOST_Init();
/* init code for LWIP */
MX_LWIP_Init();
/* USER CODE BEGIN StartDefaultTask */
flag0.clear_flags = 0; // Clear all flags.
struct mqtt_connect_client_info_t ci; // Create an information parameter about the client.
client = mqtt_client_new(); // Initialize the new client instance.
/* Infinite loop */
for(;;)
{
if (mqtt_client_is_connected(client) == 0){// If the client is not connected with the server.
mqtt_init(client, ci); // Attempt connection.
}
osDelay(1);
}
/* USER CODE END StartDefaultTask */
}
and the mqtt_init() function:
void mqtt_init(mqtt_client_t *client, struct mqtt_connect_client_info_t ci)
{
err_t err;
ip_addr_t mqttIP;
memset(&ci, 0, sizeof(ci)); // Initialize the parameter for client information and set the all 0 to entire size of ci.
/* Declare information about the client */
ci.keep_alive = 0; // With this value to zero means that the client will never checks after the connection with the broker if they are still connected after a period of time.
ci.client_id = "STM32H7-R"; // It is important to be unique. It doesn't matter if it is a random string but it must be unique as I said.
ci.will_qos = 0;
ci.will_retain = 0;
ci.will_msg = NULL;
ci.will_topic = NULL;
ci.client_user = NULL; // Set user name if you have connection options.
ci.client_pass = NULL; // Set password if you have connection options.
err = dns_gethostbyname(BROKER_IP, &mqttIP, mqtt_resolved_cb, NULL); // Declare the server IP:192.168.10.26
if (err != ERR_OK)
{
printf("Error, in declaring the IP address to the proper variable <mqttIP>, in order to establish connection with the broker\n\r");
}
mqtt_set_inpub_callback(client, mqtt_incoming_publish_cb, mqtt_incoming_data_cb, &ci); // Define callback functions.
mqtt_client_connect(client, &mqttIP, BROKER_PORT, mqtt_connection_cb, 0, &ci); // Connect with the server IP:192.168.10.26
}
Solved! Go to Solution.
2023-11-07 04:33 AM
Update: I have found the issue that causes the hard fault. It was wrong the address in linkerscript, which I had set for Rxpool buffers. Now it is rendering properly and also MQTT, is connecting to the broker.
2023-11-06 03:50 AM
Sounds like something is blocking or crashing
2023-11-06 04:05 AM
When I use the debug mode, I show that this functions was called and the code had been in the loop so that is the reason that I am not getting the UI in the screen. Although, why is happening that? I will be back if I notice something else.
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
I should mention also that when I am flashing the code to the board, it automatically opens a source file
which is called startup_stm32h747xihx.s and it is pointing a line of the below code:
/**
* @brief This is the code that gets called when the processor first
* starts execution following a reset event. Only the absolutely
* necessary set is performed, after which the application
* supplied main() routine is called.
* @PAram None
* @retval : None
*/
.thumb_func
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
ldr sp, =_estack /* set stack pointer */ Pointing to this line!!
2023-11-06 04:12 AM
I set a small delay before the call of the function mqtt_client_connect and then it renders the UI to the screen correctly, although the mqtt subscription is not showing any more to the screen.
2023-11-06 05:51 AM
Just an update: Using debbuger I have found that when I have the keep alive param > 0, then it shows this as a log output msg:
Failed to assign value 800623d, to register 0
Failed to assign value 3000404c, to register 0
Failed to assign value 2407ffb8, to register 0
Failed to assign value 80314e8, to register 0
Failed to assign value 800623d, to register 0
Failed to assign value 3000404c, to register 0
Failed to assign value 2407ffb8, to register 0
Failed to assign value 80314e8, to register 0. Do you know what might could be?
2023-11-06 02:23 PM
The fact that your code ended up in the fault handler means something is broken in your code. Adding that delay is just masking the problem, not (necessarily) fixing it. Use the CubeIDE fault handler to look at the fault registers and see what instruction caused the fault.
As for those "Failed to assign" messages, who or what code is printing those? What "log output" message?
2023-11-07 12:36 AM
I used the debugger mode in the IDE and found that output into the code when I am using a value greater to zero in keep.alive. I should mention that I use demical and hex value and the same issue happens (I didn't know if this dummy approach would work so I give it a try). As far as you can see, also I have not used any king of log outputs and that msg, which is about "failed to write into reg 0" it printing it by itself (or with a reason that I cannot explain). I am posting an image from the debugger. Despite I have use a client id a keep alive value and other stuff like that, debugger says that Cannot access memory at address 0xa5a5a5a5>. As you can see I have the code where I am manipulating the ci param and also
the mqtt connection. I cannot explain this behavior and I don't also have the experience to dig into it and trace the problem further
that's why I ask for help and at this point I should thank you all of you for your reply at my topic!
2023-11-07 04:33 AM
Update: I have found the issue that causes the hard fault. It was wrong the address in linkerscript, which I had set for Rxpool buffers. Now it is rendering properly and also MQTT, is connecting to the broker.