2014-04-23 07:41 AM
Hello Everyone,
I wonder if anyone has been able to get lwIP work properly?My platform consists of Open407-D baseboard, STM32F4 Discovery and DP83848 Ethernet PHY. SysClk is clocked at 168 MHz.I have been struggling with generated code by STM32CubeMX for two days. During this time, I have found several issues. 1) In sys_mutex_lock function, mutex pointer seems incorrectly dereferenced.2) Priority of the ethernet interrupt is incorrectly configured. It is higher than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. That's why firmware hangs in one of FreeRTOS assertions.3) tcpip_thread is not created due to an incorrect parameter value. (TCPIP_THREAD_STACKSIZE equals to zero)These are the things I could find but still I cannot get it work. Even though the DHCP option is enabled, the device cannot get an IP address. Giving a static IP address does not work too.The worst thing is it does not even respond to pings. As an experiment, I created an UDP socket and sent data over it continuously. Green Ethernet LED blinks but of course the packets do not reach to anywhere. (checked with wireshark) What can be the problem? Do you have any ideas? #freertos-lwip #stm32-discovery #cube-lwip-+-stm32f107-+-lan8720a #ethernet2014-04-25 11:07 AM
Any ideas?
2014-04-25 12:13 PM
I'm not using Cube/Code Generators, but have FreeRTOS and lwIP working on a couple of my boards, for Cube stuff I suggest you try the [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx]other forum page
For pre-Cube stuff look at the Ethernet IAP examples, you'd have to review specifics of the PHYs and GPIOs with respect to your board.2014-04-27 05:30 AM
Hi clive1,
Actually, I have found a working project for my platform. Temporarily it's OK.However, I would like to debug the generated code (by STM32Cube) and find the reason behind the problem. Since Ethernet and TCP/IP take an important place for my current project, I need to investigate it deeply. Not today but someday I may come up against similarissues.For now, I use diff tools and try to understand what changes have been done. Unfortunately there are so many changes between two BSPs. I suspect of Ethernet/TX configuration but could not find any problem so far. (The device recives ping packets. However, when I try to initiate DHCP negotiation from the device, I cannot see anything on Wireshark.)As an experienced developer on ST platforms, can you please give me a clue to where to focus on?Thanks in advance2014-04-27 09:42 AM
If merge/diff tools are helpful you'll need to review the program logic.
I'd recommend starting with the: Clocks Pins PHY2015-01-29 03:23 PM
There are a number of PHY, such as LAN8720, KSZ8721, DP83848.
As a tool, how STM32Cube take different PHY into account for code generation?2015-03-11 07:16 AM
Hello, TheMeerd!
You could solve your problem with lwIP + FreeRTOS?I also came across these problems, I use the board open407 of Waveshare and have two PHY. and the DP83848 LAN8720. Commercially will use the LAN8720, so I focused my work.During testing, I noticed the following:1 - We must analyze the address of the PHY (pin PHYAD0) if the board of the DP83848 Waveshare is 0 and the board of the LAN8720 is 1. It is still a suggestion, I'm not absolutely sure.2 - If the discovery is initiated with the connected Ethernet cable, you can make pings, connect to the board. If, contrary not !!! here is where is my biggest problem. Have an idea?3 - I also noticed that after a certain time is generated hardFault, caused by pbuf_free () function. Have an idea? Already increased the size of the stack of tasks, increased the size of the heap FreeRTOS, but the problem persists ...2015-07-18 03:24 AM
I'm using DP83848. , I have connected :
16 PC1 ETH_MDC 24 PA1 ETH_REF_CLK 25 PA2 ETH_MDIO 32 PA7 ETH_CRS_DV 33 PC4 ETH_RXD0 34 PC5 ETH_RXD1 48 PB11 ETH_TX_EN 51 PB12 ETH_TXD0 52 PB13 ETH_TXD1 But I tried to ping it and no response, on PHY module and computer are blinking, Green and orange LED... Anything I missed here ? thanks2015-07-18 05:13 AM
On the face of it the pin numbers/connection seem to be reasonable. Assume you have a 50 MHz clock on the part.
The board I have which is like this as has the option to connect PA8 (MCO) and PB14 RMII_INT (PWR_DOWN/INT).Had a webserver running off that board without much effort using the SPL/ETH examples.Is this a board you built/designed? Have you tried your code, or simpler examples, on other similar boards?2015-07-18 06:42 PM
Yes, the board I build myself,
and it's working on LED test for every ports needed for Ethernet, so the chip can send signal properly... and I tested with UART it's doing ETH init properly as well Here's the code, I use DP83848 PHY and STM32CubeMx to generate this code:in ethernetif.c
void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
{
GPIO_InitTypeDef GPIO_InitStruct;
if(heth->Instance==ETH)
{
/* USER CODE BEGIN ETH_MspInit 0 */
/* USER CODE END ETH_MspInit 0 */
/* Enable Peripheral clock */
__HAL_RCC_ETH_CLK_ENABLE();
/**ETH GPIO Configuration
PC1 ------> ETH_MDC
PA1 ------> ETH_REF_CLK
PA2 ------> ETH_MDIO
PA7 ------> ETH_CRS_DV
PC4 ------> ETH_RXD0
PC5 ------> ETH_RXD1
PB11 ------> ETH_TX_EN
PB12 ------> ETH_TXD0
PB13 ------> ETH_TXD1
*/
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN ETH_MspInit 1 */
HAL_UART_Transmit(&huart1, ''Finished ETH INIT
'', 20, 1000);
/* USER CODE END ETH_MspInit 1 */
}
}
........
........
........
in main.c
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_LWIP_Init();
/* USER CODE BEGIN 2 */
HAL_UART_Transmit(&huart1, ''HI There...LwIP STM32F107!
'', 30, 1000);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/*
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11 , 1 );
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11 , 0 );
HAL_Delay(2000);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12 , 1 );
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12 , 0 );
HAL_Delay(2000);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13 , 1 );
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13 , 0 );
HAL_Delay(2000);
*/
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
/* Read a received packet from the Ethernet buffers and send it
to the lwIP for handling */
//ethernetif_input(&gnetif);
/* Handle LwIP timeouts */
//sys_check_timeouts();
}
/* USER CODE END 3 */
}
in lwip.c................
...................
/* init function */
void MX_LWIP_Init(void)
{
IP_ADDRESS[0] = 10;
IP_ADDRESS[1] = 0;
IP_ADDRESS[2] = 0;
IP_ADDRESS[3] = 11;
NETMASK_ADDRESS[0] = 255;
NETMASK_ADDRESS[1] = 255;
NETMASK_ADDRESS[2] = 255;
NETMASK_ADDRESS[3] = 0;
GATEWAY_ADDRESS[0] = 10;
GATEWAY_ADDRESS[1] = 0;
GATEWAY_ADDRESS[2] = 0;
GATEWAY_ADDRESS[3] = 1;
/* Initilialize the LwIP stack */
lwip_init();
IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
/* add the network interface */
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input);
/* Registers the default network interface */
netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif))
{
/* When the netif is fully configured this function must be called */
netif_set_up(&gnetif);
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}
/* USER CODE BEGIN 3 */
/* USER CODE END 3 */
}
in lwip.c, I set IP address to 0.0.11, gateway 0.0.1 and mask 0....my computer, I set the same only the IP address is 0.0..
Any ideas Clive ? thanks