mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/3] ARM: boards: Add MyirTech MYD-YA15XC-T development board support
Date: Mon, 11 Sep 2023 18:01:11 +0200	[thread overview]
Message-ID: <0b35cba4-d0f8-a4b3-a6ae-f526530f40e1@pengutronix.de> (raw)
In-Reply-To: <e7894fe0-264f-93b1-b4b1-c4197a9b2400@pengutronix.de>

On 05.09.23 10:25, Ahmad Fatoum wrote:
> On 31.08.23 11:41, Alexander Shiyan wrote:
>>>> +struct id_eeprom {
>>>> +     u8 hrcw_primary[0x10];
>>>> +     u8 pn[64];
>>>> +     u8 sn[64];
>>>> +     u8 mac0[6];
>>>> +     u8 mac1[6];
>>>> +} __packed;
>>>
>>> You could describe this as nvmem-cells in the DT and you'd automatically
>>> get the MAC addresses assigned.
>> ...
>>>> +     if (!is_valid_ether_addr(eeprom.mac0)) {
>>>> +             int i, j;
>>>> +
>>>> +             /* Make fixed MAC-address based on serial number */
>>>> +             memcpy(eeprom.mac0, str, sizeof(eeprom.mac0));
>>>> +             for (i = sizeof(eeprom.mac0); i < len; i++)
>>>> +                     for (j = 0; j < sizeof(eeprom.mac0); j++)
>>>> +                             eeprom.mac0[j] ^= str[i];
>>>> +     }
>>>> +
>>>> +     eth_register_ethaddr(0, eeprom.mac0);
>>> You could check if the nvmem cell exists and only do the fixup
>>> if it doesn't. Check Marco's recent Debix patches for an example
>>> of how to call nvmem from board code.
>>
>> I can't find a way to know if an MAC address that was automatically
>> assigned via nvmem is valid.
>> So in this case we always need to use eth_register_ethaddr() manually?
> 
> You could fetch the nvmem cell and verify it yourself before MAC address
> is assigned. What I'd like to have eventually is a Kconfig option to
> generate a MAC address out of the serial number automatically if one was
> set and if not, only then fall back to randomization.
> 
> I even have patches somewhere. Let me check.

I reworked them a bit and just sent them out. Looking forward to your feedback.

> 
> Cheers,
> Ahmad
> 
>>
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2023-09-11 16:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 10:47 [PATCH 1/3] memory: Add driver for FMC2 External Bus Interface on STM32MP SoCs Alexander Shiyan
2023-08-30 10:47 ` [PATCH 2/3] mtd: nand: Add driver for NAND controller " Alexander Shiyan
2023-08-30 10:47 ` [PATCH 3/3] ARM: boards: Add MyirTech MYD-YA15XC-T development board support Alexander Shiyan
2023-08-30 14:41   ` Ahmad Fatoum
2023-08-31  6:40     ` Alexander Shiyan
2023-09-04  7:17       ` Sascha Hauer
2023-08-31  9:41     ` Alexander Shiyan
2023-09-05  8:25       ` Ahmad Fatoum
2023-09-11 16:01         ` Ahmad Fatoum [this message]
2023-09-11 16:09     ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b35cba4-d0f8-a4b3-a6ae-f526530f40e1@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=eagle.alexander923@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox