Broadcast Ethernet from F405 and DP83848

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

hybridA
Posts: 40
Joined: Wed Jan 12, 2022 7:15 am
Has thanked: 10 times
Been thanked: 5 times

Broadcast Ethernet from F405 and DP83848

Post by hybridA »

I wanted to test broadcasting ethernet using a f405 discovery board connected to a DP83848 PHY.
Pins are connected as such:
Image
board.h has pins properly configured and mii_find_phy(&ETHD1) 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broadcast Ethernet from F405 and DP83848

Post 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
hybridA
Posts: 40
Joined: Wed Jan 12, 2022 7:15 am
Has thanked: 10 times
Been thanked: 5 times

Re: Broadcast Ethernet from F405 and DP83848

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broadcast Ethernet from F405 and DP83848

Post 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
hybridA
Posts: 40
Joined: Wed Jan 12, 2022 7:15 am
Has thanked: 10 times
Been thanked: 5 times

Re: Broadcast Ethernet from F405 and DP83848

Post by hybridA »

Thank you Giovanni! I'll get some verified demo boards to rule out any hardware issues.
hybridA
Posts: 40
Joined: Wed Jan 12, 2022 7:15 am
Has thanked: 10 times
Been thanked: 5 times

Re: Broadcast Ethernet from F405 and DP83848

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broadcast Ethernet from F405 and DP83848

Post 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
mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: Broadcast Ethernet from F405 and DP83848

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broadcast Ethernet from F405 and DP83848

Post by Giovanni »

Probably it is just a different PHY, this is why it is not found, it searches for a specific ID.

Giovanni
mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: Broadcast Ethernet from F405 and DP83848

Post 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.pdf

Therefore 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
Post Reply