[PATCH 03/13] board: dragonboard410c: Fix BD address

Neil Armstrong neil.armstrong at linaro.org
Mon Apr 7 20:11:21 CEST 2025


On 07/04/2025 18:59, Stephan Gerhold wrote:
> local-bd-address in the device tree needs to be formatted with the least
> significant byte first (i.e. little endian). We're not doing this when
> adding it to the DT, which means the MAC address ends up being reversed in
> Linux. Fix this by reversing the array before setting it in the DT.
> 
> We're also flipping the wrong bit when generating the BD address. Before
> reversing the array, the least significant bit is in the last byte.
> 
> Fixes: ff06dc240325 ("db410: alter WLAN/BT MAC address fixup")
> Signed-off-by: Stephan Gerhold <stephan.gerhold at linaro.org>
> ---
>   board/qualcomm/dragonboard410c/dragonboard410c.c | 27 ++++++++++++++++++------
>   1 file changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
> index fcbf2c3fe60f21bae1c6d64b542a4d9867c33826..c33529d31869b17c7a30ec83af1199d01db472f5 100644
> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
> @@ -97,9 +97,9 @@ int qcom_late_init(void)
>   	return 0;
>   }
>   
> -/* Fixup of DTB for Linux Kernel
> - * 1. Fixup installed DRAM.
> - * 2. Fixup WLAN/BT Mac address:
> +/*
> + * Fixup of DTB for Linux Kernel
> + * 1. Fixup WLAN/BT Mac address:
>    *	First, check if MAC addresses for WLAN/BT exists as environemnt
>    *	variables wlanaddr,btaddr. if not, generate a unique address.
>    */
> @@ -107,6 +107,7 @@ int qcom_late_init(void)
>   int ft_board_setup(void *blob, struct bd_info *bd)
>   {
>   	u8 mac[ARP_HLEN];
> +	int i;
>   
>   	if (!eth_env_get_enetaddr("wlanaddr", mac)) {
>   		msm_generate_mac_addr(mac);
> @@ -118,12 +119,24 @@ int ft_board_setup(void *blob, struct bd_info *bd)
>   	if (!eth_env_get_enetaddr("btaddr", mac)) {
>   		msm_generate_mac_addr(mac);
>   
> -/* The BD address is same as WLAN MAC address but with
> - * least significant bit flipped.
> - */
> -		mac[0] ^= 0x01;
> +		/*
> +		 * The BD address is same as WLAN MAC address but with
> +		 * least significant bit flipped.
> +		 */
> +		mac[ARP_HLEN - 1] ^= 0x01;
>   	};
>   
> +	/*
> +	 * Reverse array since local-bd-address is formatted with least
> +	 * significant byte first (little endian).
> +	 */
> +	for (i = 0; i < ARP_HLEN / 2; ++i) {
> +		u8 tmp = mac[i];
> +
> +		mac[i] = mac[ARP_HLEN - 1 - i];
> +		mac[ARP_HLEN - 1 - i] = tmp;
> +	}
> +
>   	do_fixup_by_compat(blob, "qcom,wcnss-bt",
>   			   "local-bd-address", mac, ARP_HLEN, 1);
>   	return 0;
> 

Reviewed-by: Neil Armstrong <neil.armstrong at linaro.org>


More information about the U-Boot mailing list