On Apr 29, 2021, at 10:12 AM, Frank-Christian Kruegel <nu...@istda.com> wrote: > > Am 29.04.2021 um 15:23 schrieb Gregory Nutt: >> There are several Microchip/Atmel boards that come with an Atmel MAC in >> AT24MAC402 EEPROM. You should be able to clone that logic (including >> setting the MAC address). See: >> samv7/samv71-xult/src/sam_ethernet.c >> samv7/same70-xplained/src/sam_ethernet.c >> These keep the MAC address in the AT24MAC402 which requires some special >> operations. > > Thank you for your suggestions. > > I can't use the method shown in in the samv7 boards. The main reason is that > the AT24XX MTD driver only can handle one type of devices on a single bus. My > hardware however has got an AT24MAC402 on #50 and an AT24C256 on #51 on a > single bus. My plan is to use the AT24XX MTD driver for the 24C256 and put a > NuttFS on it, and use the i2c_xx24xx char driver for the 24MAC402, which is > too small for a fs anyway. The char driver already has support for the UUID > area on the 24MAC402, and I patched the driver with minimal effort also to > export another device for the MAC of an AT24MAC402 (48 bit) or AT24MAC602 (64 > bit). > > The (yet untested) patch is appended to this posting. I can make a pull > request if you like it. > > The stm32_ethernet drivers for STM32F7 and STM32H7 don't accept an external > MAC but hash one out internally from the STM32 uid. I guess I need to add a > stm32_emac_setmacaddr(uint8_t mac[6]) function to these drivers. Do you like > me to upload these patches as well?
Why not use the ic2 char driver to support the bus, and register /dev/i2c0, for example. Then the I2C slaves can be handled with EEPROM drivers which open /dev/i2c0 and are properly serialized. You’d also have the benefit of using the ‘i2c’ app to test slaves.