Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    【FAQ】Wi-Fi/BT MAC地址定制

    其它全志芯片讨论区
    wifi bt mac faq 技术支持
    1
    1
    331
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • q1215200171
      budbool LV 8 last edited by

      问题背景
      很多Wi-Fi/BT模组默认出厂是不带MAC地址的,整机厂需要根据需求,烧写特定的MAC地址。

      MAC地址通路
      Linux-4.9后,全志平台模组MAC地址定制流程如下

      f0b99d68a48d47fb86bbcd973ef20647.jfif

      系统启动后,引导程序会加载env中定义的key,并传递给cmdline和内核dts。 如果安全存储中没有mac/wifi_mac/bt_mac这几个key,或者值解析失败,我们将尝试从私有分区加载并解析这些key。在内核空间中,addr_mgt驱动程序读取cmdline或dts中与Mac相关的键,对其进行解析并导出到其他驱动程序以使用。 为了让用户空间可以访问这些地址值,创建了sysfs来保存地址值。

      配置
      uboot env
      请确保env.cfg中有如下配置项存在:
      5893A71A-C707-4fa3-85B5-4ACC192916E8.png

      dts
      dts配置参考如下
      123dd43781e34e049277b1fe4f600f50.jfif
      其中,type_addr_xx表示mac地址的来源,值含义如下

      • 0: 不指定类型
      • 1: 使用烧写的mac地址
      • 2: 使用chipid生成的mac地址
      • 3: 使用sysfs写入的地址
      • 其他: 不提供地址

      烧写
      使用全志烧号工具DragonSN或DragonKey烧写mac/wifi_mac/bt_mac到私有分区或secure storge中。合法的mac地址格式为xx:xx:xx:xx:xx:xx, x 是16禁止值,0-9,a-f。

      使用

      内核空间

      Linux-4.9

      • 读取Wi-Fi MAC地址
      int get_wifi_custom_mac_address(char *addr_str)
      
      • 读取BT MAC地址
      int get_bt_custom_mac_address(char *addr_str)
      
      • 读取以太网 MAC地址
      int get_eth_custom_mac_address(char *addr_str)
      

      Linux-5.4

      int get_custom_mac_address(int fmt, char *name, char *addr)
      

      fmt: 0为str,1为16进制值
      name: “wifi”、“bt”、“eth”

      用户空间
      可以通过sysfs文件节点访问对应值,linux-4.9下主要节点如下:

      root@venus-a1:/sys/class/addr_mgt# ls -l
      total 0
      -rw-r--r-- 1 root root 4096 2019-01-15 17:22 addr_bt
      -rw-r--r-- 1 root root 4096 2019-01-15 17:22 addr_eth
      -r--r--r-- 1 root root 4096 2019-01-15 17:22 addr_type
      -rw-r--r-- 1 root root 4096 2019-01-15 17:22 addr_wifi
      

      linux-5.4下主要节点如下:

      console:/ # ls -l /sys/class/addr_mgt/
      total 0
      -rw-r--r-- 1 bluetooth net_bt_admin 4096 2020-12-22 19:33 addr_bt
      -rw-r--r-- 1 root      root         4096 2020-12-23 13:10 addr_eth
      -rw-r--r-- 1 root      root         4096 2020-12-23 13:10 addr_wifi
      -r--r--r-- 1 root      root         4096 2020-12-23 13:10 summary
      
      1 Reply Last reply Reply Quote Share 0
      • 1 / 1
      • First post
        Last post

      Copyright © 2022 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策