2022-08-05 04:13 AM
Hello!
Recently I had problems with ping to my STM32 + LwIP + DP83848 + RMII. But the latest FW version 1.27.1, it works very well! But now I have problems with HTTP. Follow me and I show you how to create this bug.
First of all I'm using:
To reproduce this bug, do the following steps.
OK! It Working great!
#include "HTTP_Server/httpserver.h"
/* USER CODE BEGIN Header_StartDefaultTask */
/**
* @brief Function implementing the defaultTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
/* init code for LWIP */
MX_LWIP_Init();
/* USER CODE BEGIN 5 */
http_server_init();
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END 5 */
}
Question:
Why does this happen?
I have followed this tutorial 100% (except that he are using another processor) https://www.youtube.com/watch?v=haO8_eLIDeI&ab_channel=ControllersTech
This must be a bug, becase in FW 1.27.0 version, I had problems with ping my processor. In FW 1.27.1, the ping works like a charm. But now FW 1.27.1 resulting that my HTTPD won't work.
Thank you.
2023-01-06 02:31 AM
It was far away from a detailed instruction. Sorry.
ST have confirmed that this was a bug. Yes, it takes long time for them to fix the issue. Perhaps ST could pay you to write that little piece of code? You seems to know exactly how to do that in a couple of minutes.
2023-01-06 02:33 AM
I understand. I will learn to setup a proper FreeRTOS installation.
2023-01-06 03:40 AM
Yes, it was detailled enough.
What he said:
2023-01-06 04:02 AM
> Therefore, yes, this is a deficiency of the lwIP driver
You mean, the low-level ETH driver? Because LwIP is not aware of what memory the ETH driver can access.
2023-01-08 11:07 PM
static err_t low_level_output(struct netif *netif, struct pbuf *p) {
void *data = NULL;
uint32_t i = 0U;
struct pbuf *q = NULL;
err_t errval = ERR_OK;
ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT] = { 0 };
memset(Txbuffer, 0, ETH_TX_DESC_CNT * sizeof(ETH_BufferTypeDef));
for (q = p; q != NULL; q = q->next) {
if (i >= ETH_TX_DESC_CNT)
return ERR_IF;
Txbuffer[i].buffer = q->payload;
Txbuffer[i].len = q->len;
// check is it valid ram address {
if ((q->payload) < (void*)0x20000000) { // RAM starts at => $2000 0000
// FLASH is under => $0800 0000
// when not, allocate memory in ram
data = pvPortMalloc(q->len);
// then copy data
memcpy(data, q->payload, (q->len));
// replace data pointer to valid new address
Txbuffer[i].buffer = data;
}
if (i > 0) {
Txbuffer[i - 1].next = &Txbuffer[i];
}
if (q->next == NULL) {
Txbuffer[i].next = NULL;
}
i++;
}
TxConfig.Length = p->tot_len;
TxConfig.TxBuffer = Txbuffer;
TxConfig.pData = p;
pbuf_ref(p);
HAL_ETH_Transmit_IT(&heth, &TxConfig);
while (osSemaphoreAcquire(TxPktSemaphore, TIME_WAITING_FOR_INPUT) != osOK)
{
}
HAL_ETH_ReleaseTxPacket(&heth);
// we need to free memory after sending data
if (data != NULL) {
vPortFree(data);
}
return errval;
}
Messy, but seems to work well. I tested the whole 2 minutes so I can't guarantee to nothing...
2023-01-08 11:10 PM
btw, where is info about eth driver dont have access to flash memory space?
2023-01-09 01:51 AM
Hi @mmisz.1 ,
Thank you for sharing your solution.
The info about ETH access to flash memory is available in RM0090 page 60.
Regards
Mahdy
2023-01-09 02:02 AM
Hi,
Thank you everyone for your cooperation.
The solution of deleting the "const" and placing data on Ram instead of flash is just a workaround proposed to unlock customers which encounter the issue.
But of course, in the next release, the most suitable solution will be implemented.
Regards
Mahdy
2023-01-09 03:43 AM
And don't forget a .ioc example with FreeRTOS + LwIP + Ajax for each hardware!
Thank you.
2023-05-05 07:07 PM
Most likely it's better and more consistent to allocate memory with pbuf_alloc(PBUF_RAW, len, PBUF_RAM). The problem with this code is that a Pbuf is a chain of buffers - every buffer can point to a different memory and there can be several buffers to memories, to which the DMA has no access. A proper solution is not as trivial as this code.