Dhcp


#1

I use W5500 with STM32F051R8T6, my IDE is Keil. I ported some part of code to this chip and communication by SPI works well. I also have succes with STM32F103X CooCox CoIDE Project Loopback Test - works perfect.
I have problem with DHCP client. When I run this project I have go HardFault. Here is my console output:

[code]=== W5500 NET CONF : DHCP ===
MAC: 00:08:DC:00:AB:CD
SIP: 192.168.1.123
GAR: 192.168.1.1
SUB: 255.255.255.0
DNS: 0.0.0.0

Send DHCP_DISCOVER
DHCP message : 192.168.1.1(67) 345 received.
Receive DHCP_OFFER
Send DHCP_REQUEST
DHCP message : 192.168.1.1(67) 345 received.
Receive DHCP_ACK
HardFault[/code]

during debug I have found that hardfault is occur in this line:

in function

What could be the problem?


#2

Hi,
addr address assigned in memory maybe not 32-bit address value. That is, The addr is not divided by 4.
ex) addr = 0x0003;
((uint32)addr) = 0x11223344; <— Maybe Hardfault.

Check addr value.

Thank you.


#3

Hi,

I checked and addr = 0x2000016B - address of variable DHCP_allocated_ip.

You are right. This addr is not divied by 4.

I change code to:

and now everything is OK.


#4

Hi,
I’m glad to solve your problem, too.
Thank you.