Page 1 of 2
Broadcast Ethernet from F405 and DP83848
Posted: Tue Jan 31, 2023 7:36 am
by hybridA
I wanted to test broadcasting ethernet using a f405 discovery board connected to a DP83848 PHY.
Pins are connected as such:

board.h has pins properly configured and mii_find_phy(ÐD1) is able to detect the phy.
However, wireshark shows no packets being sent.
Here's my sample code:
Code: Select all
lwipInit(nullptr);
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock == -1) {
return -1;
}
/* broadcast */
int broadcast = 1;
setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof(broadcast));
// build the broadcast address
struct sockaddr_in broadcast_address;
broadcast_address.sin_family = AF_INET;
broadcast_address.sin_port = htons(1234);
broadcast_address.sin_addr.s_addr = INADDR_BROADCAST;
char data[] = "Hello world";
sendto(sock, data, sizeof(data), 0, (struct sockaddr*) &broadcast_address, sizeof(broadcast_address));
Am I missing any init steps? or should this work?
Thank you
Re: Broadcast Ethernet from F405 and DP83848
Posted: Tue Jan 31, 2023 2:31 pm
by Giovanni
Hi,
Not enough info for me to tell. I suggest making the normal LWIP demo (the one with HTTP server) work on that board, that would prove correct functionality of the whole stack.
Once it works add that code and try it.
Giovanni
Re: Broadcast Ethernet from F405 and DP83848
Posted: Wed Feb 01, 2023 8:16 am
by hybridA
Thank you, I will give that a shot. Just to verify, it's the RT-STM32F107-OLIMEX_P107-LWIP demo you want me to test?
Re: Broadcast Ethernet from F405 and DP83848
Posted: Wed Feb 01, 2023 11:30 am
by Giovanni
This one /demos/STM32/RT-STM32-LWIP-FATFS-USB
One of the targets is an F4 like in your case. You could simplify it by removing the FatFS and USB stuff if you don't have those peripherals on board.
The easiest approach would be to get one the boards supported out of the box, on the F4 Discovery you could have conflicts between MAC and the other things on-board (it happened in the past), be very careful in choosing pins and configuring them.
Also, the PHY clock is very critical, probably clocks generated by the PLL have too much jitter.
Giovanni
Re: Broadcast Ethernet from F405 and DP83848
Posted: Fri Feb 03, 2023 7:58 am
by hybridA
Thank you Giovanni! I'll get some verified demo boards to rule out any hardware issues.
Re: Broadcast Ethernet from F405 and DP83848
Posted: Thu Mar 02, 2023 5:28 am
by hybridA
Finally got my Olimex STM32-E407 (rev. F) board in the mail.
I tested it with the /demos/STM32/RT-STM32-LWIP-FATFS-USB demo, and it didn't work.
This is running 21.11 stable branch on github.
I single-stepped it and found that macInit() ends in an error "Mac Failure' during mii_find_phy()
Is there anything else I can try?
Re: Broadcast Ethernet from F405 and DP83848
Posted: Thu Mar 02, 2023 7:18 am
by Giovanni
Hi,
Probably it is because revision F, I have a very early board. You should compare schematics and see where differences are, probably there is a different PHY, this is usually easy to address.
Giovanni
Re: Broadcast Ethernet from F405 and DP83848
Posted: Fri Mar 03, 2023 2:30 pm
by mikeprotts
Giovanni wrote:Hi,
Probably it is because revision F, I have a very early board. You should compare schematics and see where differences are, probably there is a different PHY, this is usually easy to address.
Giovanni
I have been using revision E with the config for revision D, so it's likely a change from E to F that would be the issue.
Mike
Re: Broadcast Ethernet from F405 and DP83848
Posted: Fri Mar 03, 2023 2:33 pm
by Giovanni
Probably it is just a different PHY, this is why it is not found, it searches for a specific ID.
Giovanni
Re: Broadcast Ethernet from F405 and DP83848
Posted: Fri Mar 03, 2023 2:48 pm
by mikeprotts
Giovanni wrote:Probably it is just a different PHY, this is why it is not found, it searches for a specific ID.
Giovanni
A quick check of the docs suggests using the revision D board file is likely to work, that is when the PHY changed.
https://www.olimex.com/Products/ARM/ST/ ... 2-E407.pdfTherefore in the example file demos/STM32/RT-STM32-LWIP-FATFS-USB/make/stm32f407_olimex.make change the board file:
include $(CHIBIOS)/os/hal/boards/OLIMEX_STM32_E407/board.mk
with
include $(CHIBIOS)/os/hal/boards/OLIMEX_STM32_E407_REV_D/board.mk
Mike