[PATCH 10/11] rockchip: misc: Set eth1addr mac address

Jonas Karlman jonas at kwiboo.se
Wed Feb 22 23:46:21 CET 2023


Hi Chen-Yu,

On 2023-02-16 03:42, Chen-Yu Tsai wrote:
> On Thu, Feb 16, 2023 at 7:57 AM Jonas Karlman <jonas at kwiboo.se> wrote:
>>
>> Set eth1addr when there is an ethernet1 alias in the fdt.
> 
> Maybe it makes sense to set it regardless whether an alias is present
> or not?

Makes sense, changed to always set eth1addr in v2, thanks!

Regards,
Jonas

> 
> The user might be loading a custom FDT for the kernel, or have DT
> overlays stacked on, either could have the "ethernet1" alias while
> the U-boot DT doesn't.
> 
> ChenYu
> 
>> Also allow fdt fixup of ethernet mac addresses when CMD_NET is disabled.
>> Set ethaddr and eth1addr based on HASH and SHA256 options.
>>
>> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
>> ---
>>  arch/arm/mach-rockchip/misc.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
>> index b350f18f1140..aceaea6b29b7 100644
>> --- a/arch/arm/mach-rockchip/misc.c
>> +++ b/arch/arm/mach-rockchip/misc.c
>> @@ -21,9 +21,11 @@
>>
>>  #include <asm/arch-rockchip/misc.h>
>>
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>>  int rockchip_setup_macaddr(void)
>>  {
>> -#if IS_ENABLED(CONFIG_CMD_NET)
>> +#if CONFIG_IS_ENABLED(HASH) && CONFIG_IS_ENABLED(SHA256)
>>         int ret;
>>         const char *cpuid = env_get("cpuid#");
>>         u8 hash[SHA256_SUM_LEN];
>> @@ -52,6 +54,12 @@ int rockchip_setup_macaddr(void)
>>         mac_addr[0] &= 0xfe;  /* clear multicast bit */
>>         mac_addr[0] |= 0x02;  /* set local assignment bit (IEEE802) */
>>         eth_env_set_enetaddr("ethaddr", mac_addr);
>> +
>> +       if (gd->fdt_blob && fdt_get_alias(gd->fdt_blob, "ethernet1")) {
>> +               /* Make a valid MAC address for eth1 */
>> +               mac_addr[5] += 0x20;
>> +               eth_env_set_enetaddr("eth1addr", mac_addr);
>> +       }
>>  #endif
>>         return 0;
>>  }
>> --
>> 2.39.1
>>



More information about the U-Boot mailing list