LAN8720 configuration:
IP: 192.168.192.30
Gateway: 192.168.192.1
A high frequency of ARP packets is detected
The content of the packet asks for the mac address of 192.168.192.1, and asks the responder to send to 192.168.192.30.
It can be judged that LAN8720 may want to send packets across the network segment, but cannot find the network manager.
So the gateway of LAN8720 is changed to 192.168.192.15, which is the IP of the PC.
Then use wireshark to capture the packet.
You can see the high-frequency error packet information.
From the captured packet, you can see that the IP address and port are not what you want.
Find the IP address assignment in the sendto function, the atomic routine, the assignment method is as follows:
upcb->remote_ip=*addr;1
The type of remote_ip in pcb is the same as the type of addr, both are: struct ip_addr *
/* This is the aligned version of ip_addr_t, used as local variable, on the stack, etc. */ struct ip_addr { u32_t addr; };12345
So I changed my code to:
pcb->remote_ip.addr = 0x0FC0A8C0;1
So it was sent out.
When the content sent is an array, it will die in the sending function.
Call stack before sending:
The call stack after calling sendto:
Then it will crash when the stack is popped later.
If you try using an atomic routine, the code will also fall into a Hardfault.
Atomic routine:
//UDP server sends data
void udp_demo_senddata(struct udp_pcb *upcb)
{
struct pbuf *ptr;
ptr=pbuf_alloc(PBUF_TRANSPORT,strlen((char*)tcp_demo_sendbuf),PBUF_POOL); //Apply for memory
if(ptr)
{
ptr->payload=(void*)tcp_demo_sendbuf;
udp_send(upcb,ptr); //udp sends data
pbuf_free(ptr); //release memory
}
}
The strange thing is
ptr->payload = (void*)tcp_demo_sendbuf;
The payload does not use memcpy but is directly assigned by a pointer.
According to the example on the Internet, change this to:
memset(ptr->payload, 0, ptr->len);
memcpy(ptr->payload, dataptr, sendsize);
Then no error is reported. I don't know why the atomic one can run through.
The recvfrom function crashed
int len;
len = recvfrom(socket_n, _commandBuffer, len, MSG_DONTWAIT, (sockaddr *)&remoteaddr, &remoteaddrlen);
The problem is that the third parameter passed in, len, is the buffer length.
The requested len is mistakenly passed in as a value.
In the recvfrom function, memset is called to clear the buffer. Then the code crashes.
Previous article:STM32F407 and LAN8720 debug log (1)
Next article:Solution to the network failure when hot-plugging the network cable of STM32 transplantation LWIP
Recommended ReadingLatest update time:2024-11-23 01:47
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Study on frequency requirements for 5G NR-V2X direct communication
- Automatic Fingerprint Recognition System Based on DSP
- Solution to SensorTile.box not finding serial port using Unicleo-GUI
- The express delivery didn’t arrive for 6 days. I took a look and found out that the express delivery also misses home.
- [GD32L233C-START Review] - Transplanting Freertos real-time system
- protel99se learning tutorial
- Does anyone have the circuit diagram of the XELTEK programmer SuperPro.s?
- A new type of fuse to avoid melting shell and surge failure in switching power supply
- [Warehouse temperature and humidity automatic control simulation system] 3. RSL10 BLE Mesh networking first experience
- DSP 2812: GPIO encapsulation using C++