Skip to content
This repository was archived by the owner on Aug 14, 2026. It is now read-only.
This repository was archived by the owner on Aug 14, 2026. It is now read-only.

Hostname Setting #2

Open
Open

Description

@TheGuyDanish

Currently, setting network.hostname() does not actually set a hostname that gets picked up in DHCP. I have not done a packet dump to investigate why, but I assume the WIZNET5K driver used in MicroPython ignores the setting when sending DHCP requests. Other MicroPython implementations of the W5500 exists where DHCP is handled outside of the built-in driver, likely fixing the issue, but developing an entire W5500 driver just for DHCP hostnames seems a bit extreme.

It doesn't seem like there's a register in the W5500 that stores a hostname, so any use of the hostname would have to be done in software, likely requiring the efforts like in the above example.

Activity

  1. added
    enhancement
    on Aug 17, 2024
  2. TheGuyDanish commented on Oct 9, 2024

    @TheGuyDanish
    ContributorAuthor

    I did some testing on the different implementation and while it works, it doesn't use the Pico Unique ID function to generate a MAC. This can be replicated though. The bigger issue is that asyncio (used by Microdot) uses the built-in socket library, where this custom implementation provides its own socket.

  3. DaveCorder commented on Mar 5, 2026

    @DaveCorder

    I don't know if you're still interested in this issue now that the C version is pretty much ready, but I stumbled on something today...

    Try changing this, so the hostname is set first:

    def w5500_init(spi):
        nic = network.WIZNET5K(spi, Pin(5), Pin(0))  # Bus, CSn, RSTn
        # Setting the hostname currently does nothing.
        # See https://github.com/OpenJBOD/software/issues/2
        network.hostname(CONFIG["network"]["hostname"])
    

    to:

    def w5500_init(spi):
        network.hostname(CONFIG["network"]["hostname"])
        nic = network.WIZNET5K(spi, Pin(5), Pin(0))  # Bus, CSn, RSTn
    

    The MicroPython docs say "... you must set the hostname before activating/connecting your network interfaces."

    This did the trick for me in another project (that's based on this one), however I am using a different microcontroller and Ethernet device, so not sure it applies here. Maybe worth trying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions