|
| 1 | +.. _android-m2-wifi-bt: |
| 2 | + |
| 3 | +###################################### |
| 4 | +M.2 Wi-Fi and Bluetooth module setup |
| 5 | +###################################### |
| 6 | + |
| 7 | +This application note describes the Android build system modifications required |
| 8 | +to integrate third-party M.2 Wi-Fi and Bluetooth modules. |
| 9 | + |
| 10 | +.. warning:: |
| 11 | + |
| 12 | + This guide assumes the kernel already includes the required drivers and |
| 13 | + device tree overlays. For kernel configuration, see :ref:`android-build-kernel`. |
| 14 | + |
| 15 | +************ |
| 16 | +Introduction |
| 17 | +************ |
| 18 | + |
| 19 | +The AM62Px-SK and AM62x-SK Evaluation Modules (EVMs) include an M.2 Key E |
| 20 | +connector that supports Wi-Fi and Bluetooth combo modules. These modules |
| 21 | +typically use: |
| 22 | + |
| 23 | +- **SDIO (Secure Digital Input/Output)** interface for Wi-Fi |
| 24 | +- **UART (Universal Asynchronous Receiver-Transmitter)** interface for Bluetooth |
| 25 | + |
| 26 | +This guide lists the files you need to change in the Android build system |
| 27 | +to add support for a new Wi-Fi and Bluetooth module. |
| 28 | + |
| 29 | + |
| 30 | +********************* |
| 31 | +Wi-Fi firmware setup |
| 32 | +********************* |
| 33 | + |
| 34 | +.. note:: |
| 35 | + |
| 36 | + Depending on your Wi-Fi module, you might also need to change the Wi-Fi |
| 37 | + Hardware Abstraction Layer (HAL) configuration in :file:`device/ti/am62x/shared/wifi/`. |
| 38 | + The default configuration uses TI-specific libraries (``lib_driver_cmd_ti``). |
| 39 | + For other modules, you might need to update :file:`BoardConfig.mk` to use the appropriate driver library |
| 40 | + (e.g., ``lib_driver_cmd_nl80211`` for generic NL80211 drivers). |
| 41 | + |
| 42 | +Adding firmware files |
| 43 | +===================== |
| 44 | + |
| 45 | +Copy the firmware files to the appropriate directory: |
| 46 | + |
| 47 | +.. code-block:: console |
| 48 | +
|
| 49 | + $ cp <firmware_file> \ |
| 50 | + ${YOUR_PATH}/ti-aosp-16/vendor/ti/am62x/wifi/vendor/firmware/<vendor_dir>/ |
| 51 | +
|
| 52 | +Common vendor directories: |
| 53 | + |
| 54 | +- ``mrvl/`` for Marvell/NXP |
| 55 | +- ``ti-connectivity/`` for TI |
| 56 | +- ``brcm/`` for Broadcom/Cypress |
| 57 | +- ``nxp/`` for NXP Bluetooth firmware |
| 58 | + |
| 59 | + |
| 60 | +Change Android.bp |
| 61 | +================= |
| 62 | + |
| 63 | +Edit :file:`vendor/ti/am62x/wifi/Android.bp` and add a prebuilt_firmware module. |
| 64 | + |
| 65 | +.. code-block:: text |
| 66 | +
|
| 67 | + prebuilt_firmware { |
| 68 | + name: "<package_name>", |
| 69 | + vendor: true, |
| 70 | + src: "vendor/firmware/<vendor_dir>/<firmware_file>", |
| 71 | + filename: "<firmware_file>", |
| 72 | + sub_dir: "<vendor_dir>", |
| 73 | + proprietary: true, |
| 74 | + } |
| 75 | +
|
| 76 | +
|
| 77 | +Change the product Makefile |
| 78 | +=========================== |
| 79 | + |
| 80 | +.. ifconfig:: CONFIG_part_variant in ('AM62PX') |
| 81 | + |
| 82 | + Edit :file:`vendor/ti/am62x/am62p.mk` and add the firmware to PRODUCT_PACKAGES. |
| 83 | + |
| 84 | +.. ifconfig:: CONFIG_part_variant in ('AM62X') |
| 85 | + |
| 86 | + Edit :file:`vendor/ti/am62x/am62x.mk` and add the firmware to PRODUCT_PACKAGES. |
| 87 | + |
| 88 | +.. code-block:: makefile |
| 89 | +
|
| 90 | + PRODUCT_PACKAGES += \ |
| 91 | + <package_name> |
| 92 | +
|
| 93 | +
|
| 94 | +*********************** |
| 95 | +Bluetooth configuration |
| 96 | +*********************** |
| 97 | + |
| 98 | +M.2 Wi-Fi and Bluetooth combo modules typically use UART for Bluetooth communication. |
| 99 | +Change the following files to enable Bluetooth. |
| 100 | + |
| 101 | + |
| 102 | +Change shared/bluetooth/device_vendor.mk |
| 103 | +========================================= |
| 104 | + |
| 105 | +Edit :file:`device/ti/am62x/shared/bluetooth/device_vendor.mk` to enable Bluetooth |
| 106 | +permissions and HAL. |
| 107 | + |
| 108 | +Change from disabled Bluetooth: |
| 109 | + |
| 110 | +.. code-block:: makefile |
| 111 | +
|
| 112 | + PRODUCT_COPY_FILES += \ |
| 113 | + device/generic/car/common/android.hardware.disable.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth.xml \ |
| 114 | + device/generic/car/common/android.hardware.disable.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml |
| 115 | +
|
| 116 | +To enabled Bluetooth: |
| 117 | + |
| 118 | +.. code-block:: makefile |
| 119 | +
|
| 120 | + # Bluetooth configuration |
| 121 | +
|
| 122 | + # Enable Bluetooth permissions |
| 123 | + PRODUCT_COPY_FILES += \ |
| 124 | + frameworks/native/data/etc/android.hardware.bluetooth.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth.xml \ |
| 125 | + frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml |
| 126 | +
|
| 127 | + # Bluetooth HAL (AIDL) |
| 128 | + PRODUCT_PACKAGES += \ |
| 129 | + android.hardware.bluetooth-service.default |
| 130 | +
|
| 131 | +
|
| 132 | +Change product.prop |
| 133 | +=================== |
| 134 | + |
| 135 | +Edit :file:`device/ti/am62x/product.prop` and add Bluetooth properties. |
| 136 | + |
| 137 | +Example configuration (adjust profiles based on your module capabilities): |
| 138 | + |
| 139 | +.. code-block:: text |
| 140 | +
|
| 141 | + # Bluetooth configuration |
| 142 | + # Set the Bluetooth Class of Device |
| 143 | + # Service Field: 0x5A -> 90 |
| 144 | + # Bit 17: Networking |
| 145 | + # Bit 19: Capturing |
| 146 | + # Bit 20: Object Transfer |
| 147 | + # Bit 22: Telephony |
| 148 | + # MAJOR_CLASS: 0x01 -> 1 (Computer) |
| 149 | + # MINOR_CLASS: 0x04 -> 4 (Desktop workstation) |
| 150 | + bluetooth.device.class_of_device=90,1,4 |
| 151 | +
|
| 152 | + # Set supported Bluetooth profiles to enabled |
| 153 | + bluetooth.profile.asha.central.enabled?=true |
| 154 | + bluetooth.profile.a2dp.source.enabled?=true |
| 155 | + bluetooth.profile.avrcp.target.enabled?=true |
| 156 | + bluetooth.profile.gatt.enabled?=true |
| 157 | + bluetooth.profile.hfp.ag.enabled?=true |
| 158 | + bluetooth.profile.hid.device.enabled?=true |
| 159 | + bluetooth.profile.hid.host.enabled?=true |
| 160 | + bluetooth.profile.map.server.enabled?=true |
| 161 | + bluetooth.profile.opp.enabled?=true |
| 162 | + bluetooth.profile.pan.nap.enabled?=true |
| 163 | + bluetooth.profile.pan.panu.enabled?=true |
| 164 | + bluetooth.profile.pbap.server.enabled?=true |
| 165 | +
|
| 166 | + # Disable LeAudio profiles (requires specific hardware support) |
| 167 | + bluetooth.profile.bap.broadcast.assist.enabled=false |
| 168 | + bluetooth.profile.bap.unicast.client.enabled=false |
| 169 | + bluetooth.profile.bas.client.enabled=false |
| 170 | + bluetooth.profile.ccp.server.enabled=false |
| 171 | + bluetooth.profile.csip.set_coordinator.enabled=false |
| 172 | + bluetooth.profile.hap.client.enabled=false |
| 173 | + bluetooth.profile.vcp.controller.enabled=false |
| 174 | +
|
| 175 | +.. note:: |
| 176 | + |
| 177 | + The ``bluetooth.profile.*.enabled?=true`` syntax (with ``?``) enables the profile |
| 178 | + by default but allows overriding. Profiles disabled with ``=false`` |
| 179 | + (without ``?``) cannot be overridden. |
| 180 | + |
| 181 | + |
| 182 | +Change ueventd.rc |
| 183 | +================= |
| 184 | + |
| 185 | +.. ifconfig:: CONFIG_part_variant in ('AM62PX') |
| 186 | + |
| 187 | + Edit :file:`device/ti/am62x/am62p/ueventd.am62p.rc` and add UART permissions: |
| 188 | + |
| 189 | +.. ifconfig:: CONFIG_part_variant in ('AM62X') |
| 190 | + |
| 191 | + Edit :file:`device/ti/am62x/am62x/ueventd.am62x.rc` and add UART permissions: |
| 192 | + |
| 193 | +.. code-block:: text |
| 194 | +
|
| 195 | + # Bluetooth UART |
| 196 | + /dev/ttyS1 0660 bluetooth bluetooth |
| 197 | +
|
| 198 | +.. note:: |
| 199 | + |
| 200 | + The UART device name (``ttyS1``, ``ttyS2``, and so on) depends on your device tree |
| 201 | + overlay configuration. |
| 202 | + |
| 203 | + |
| 204 | +Change file_contexts |
| 205 | +==================== |
| 206 | + |
| 207 | +Edit :file:`device/ti/am62x/sepolicy/common/file_contexts` and add: |
| 208 | + |
| 209 | +.. code-block:: text |
| 210 | +
|
| 211 | + # Bluetooth UART |
| 212 | + /dev/ttyS1 u:object_r:hci_attach_dev:s0 |
| 213 | +
|
| 214 | +
|
| 215 | +Adding SELinux policy |
| 216 | +===================== |
| 217 | + |
| 218 | +Create :file:`device/ti/am62x/sepolicy/common/hal_bluetooth_default.te`: |
| 219 | + |
| 220 | +.. code-block:: text |
| 221 | +
|
| 222 | + # Allow Bluetooth HAL to access UART device |
| 223 | + allow hal_bluetooth_default hci_attach_dev:chr_file rw_file_perms; |
| 224 | +
|
| 225 | +
|
| 226 | +*************** |
| 227 | +Build and flash |
| 228 | +*************** |
| 229 | + |
| 230 | +Rebuild the Android image |
| 231 | +========================= |
| 232 | + |
| 233 | +.. code-block:: console |
| 234 | +
|
| 235 | + $ cd ${YOUR_PATH}/ti-aosp-16 |
| 236 | + $ source build/envsetup.sh |
| 237 | + $ lunch <BUILD_TARGET> |
| 238 | + $ m |
| 239 | +
|
| 240 | +Flash the device |
| 241 | +================ |
| 242 | + |
| 243 | +After building, flash the device again following the standard |
| 244 | +flashing procedure documented in :ref:`android-flashing`. |
| 245 | + |
| 246 | +Configure the Device Tree Blob Overlay (DTBO) |
| 247 | +============================================= |
| 248 | + |
| 249 | +After flashing, configure the DTBO index from U-Boot: |
| 250 | + |
| 251 | +.. code-block:: console |
| 252 | +
|
| 253 | + => env set adtbo_idx <your_dtbo_index> |
| 254 | + => saveenv |
| 255 | + => reset |
| 256 | +
|
| 257 | +See :ref:`android-dtbo` for the list of available DTBO overlays and their indices. |
| 258 | + |
| 259 | + |
| 260 | +******* |
| 261 | +Summary |
| 262 | +******* |
| 263 | + |
| 264 | +Change the following files to add Wi-Fi and Bluetooth support: |
| 265 | + |
| 266 | +.. ifconfig:: CONFIG_part_variant in ('AM62PX') |
| 267 | + |
| 268 | + .. list-table:: |
| 269 | + :header-rows: 1 |
| 270 | + :widths: 50 50 |
| 271 | + |
| 272 | + * - File |
| 273 | + - Purpose |
| 274 | + |
| 275 | + * - :file:`vendor/ti/am62x/wifi/Android.bp` |
| 276 | + - Add prebuilt_firmware module for Wi-Fi/BT firmware |
| 277 | + |
| 278 | + * - :file:`vendor/ti/am62x/am62p.mk` |
| 279 | + - Add firmware to PRODUCT_PACKAGES |
| 280 | + |
| 281 | + * - :file:`device/ti/am62x/shared/bluetooth/device_vendor.mk` |
| 282 | + - Enable Bluetooth permissions XML and HAL |
| 283 | + |
| 284 | + * - :file:`device/ti/am62x/product.prop` |
| 285 | + - Add Bluetooth properties (class of device, profiles) |
| 286 | + |
| 287 | + * - :file:`device/ti/am62x/am62p/ueventd.am62p.rc` |
| 288 | + - Set UART device permissions for Bluetooth |
| 289 | + |
| 290 | + * - :file:`device/ti/am62x/sepolicy/common/file_contexts` |
| 291 | + - Add SELinux context for Bluetooth UART |
| 292 | + |
| 293 | + * - :file:`device/ti/am62x/sepolicy/common/hal_bluetooth_default.te` |
| 294 | + - Add SELinux policy for Bluetooth HAL UART access |
| 295 | + |
| 296 | +.. ifconfig:: CONFIG_part_variant in ('AM62X') |
| 297 | + |
| 298 | + .. list-table:: |
| 299 | + :header-rows: 1 |
| 300 | + :widths: 50 50 |
| 301 | + |
| 302 | + * - File |
| 303 | + - Purpose |
| 304 | + |
| 305 | + * - :file:`vendor/ti/am62x/wifi/Android.bp` |
| 306 | + - Add prebuilt_firmware module for Wi-Fi/BT firmware |
| 307 | + |
| 308 | + * - :file:`vendor/ti/am62x/am62x.mk` |
| 309 | + - Add firmware to PRODUCT_PACKAGES |
| 310 | + |
| 311 | + * - :file:`device/ti/am62x/shared/bluetooth/device_vendor.mk` |
| 312 | + - Enable Bluetooth permissions XML and HAL |
| 313 | + |
| 314 | + * - :file:`device/ti/am62x/product.prop` |
| 315 | + - Add Bluetooth properties (class of device, profiles) |
| 316 | + |
| 317 | + * - :file:`device/ti/am62x/am62x/ueventd.am62x.rc` |
| 318 | + - Set UART device permissions for Bluetooth |
| 319 | + |
| 320 | + * - :file:`device/ti/am62x/sepolicy/common/file_contexts` |
| 321 | + - Add SELinux context for Bluetooth UART |
| 322 | + |
| 323 | + * - :file:`device/ti/am62x/sepolicy/common/hal_bluetooth_default.te` |
| 324 | + - Add SELinux policy for Bluetooth HAL UART access |
0 commit comments