Bluetooth

The phyCORE-AM65x SOM features a Sterling-LWB WiFi/Bluetooth module populated directly on-board, which can be ordered as either the 2.4 GHz or the 5 GHz variant. This guide shows you how to use this interface.

Tip

For information regarding the hardware configuration for this interface, see the phyCORE-AM65x Hardware Documents.

Software Setup

  • Run the brcm_patchram_plus utility. This patches the firmware to the radio.

    Target (Linux)
    brcm_patchram_plus -d --patchram /lib/firmware/brcm/bcm4343w/4343w.hcd --enable_hci --no2bytes --tosleep 1000 /dev/ttyS2 &
    
    Expected Output
    option patchram with arg /lib/firmware/brcm/bcm4343w/4343w.hcd
    option enable_hci
    option no2bytes
    option tosleep with arg 1000
    1000/dev/ttyS2
    writing
    01 03 0c 00
    received 7
    04 0e 04 01 03 0c 00
    writing
    01 2e fc 00
    received 7
    04 0e 04 01 2e fc 00
    writing
    01 4c fc 46 10 18 21 00 42 52 43 4d 63 66 67 53
    00 00 00 00 32 00 00 00 01 01 04 18 92 00 00 00
    03 06 ac 1f 12 a1 43 43 00 01 1c 52 18 21 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 fe 00 00
    received 7
    04 0e 04 01 4c fc 00
    writing
    
    ...
    
    writing
    01 4c fc 30 96 a1 21 00 00 18 08 0d 00 10 01 0f
    80 64 c8 01 00 b3 f0 dd bf 00 00 22 08 0d 00 10
    01 0f 81 50 b4 01 00 b5 f0 ee b9 00 00 30 08 0d
    00 fe 00 00
    received 7
    04 0e 04 01 4c fc 00
    writing
    01 4e fc 04 ff ff ff ff
    received 7
    04 0e 04 01 4e fc 00
    writing
    01 03 0c 00
    writing
    01 03 0c 00
    received 7
    04 0e 04 01 03 0c 00
    [  118.117411] Bluetooth: Core ver 2.22
    [  118.121228] NET: Registered protocol family 31
    [  118.125876] Bluetooth: HCI device and connection manager initialized
    [  118.132287] Bluetooth: HCI socket layer initialized
    [  118.137198] Bluetooth: L2CAP socket layer initialized
    [  118.142310] Bluetooth: SCO socket layer initialized
    [  118.158794] Bluetooth: HCI UART driver ver 2.3
    [  118.163392] Bluetooth: HCI UART protocol H4 registered
    Done setting line discpline
    
  • Check that the device was properly configured with the hciconfig command.

    Target (Linux)
    hciconfig
    
    Expected Output
    root@am65xx-phycore-kit:~# hciconfig
    hci0:   Type: Primary  Bus: UART
            BD Address: 00:25:CA:2F:EB:28  ACL MTU: 1021:8  SCO MTU: 64:1
            DOWN
            RX bytes:668 acl:0 sco:0 events:34 errors:0
            TX bytes:423 acl:0 sco:0 commands:34 errors:0
    

Connecting Device

  • Bring the Bluetooth interface up.

    Target (Linux)
    hciconfig hci0 up
    
  • Configure another Bluetooth device to scan for available Bluetooth devices, then run “hcitool scan” on the phyCORE-AM65x Development Kit to scan for your device.

    Target (Linux)
    hcitool scan
    

Example output when pairing with a Pixel 2 cell phone, where “40:4E:36:XX:XX:XX” is the MAC ID for the phone with the second half redacted:

Expected Output
root@am65xx-phycore-kit:~# hcitool scan
Scanning ...
        40:4E:36:XX:XX:XX       Pixel 2
  • Use the l2ping command to ping the device using the MAC ID that was printed from the previous command.

    Target (Linux)
    l2ping -i hci0 -c 10 XX:XX:XX:XX:XX:XX
    
    Expected Output
    root@am65xx-phycore-kit:~# l2ping -i hci0 -c 10 40:4E:36:XX:XX:XX
    Ping: 40:4E:36:A8:E2:21 from 00:25:CA:2F:EB:28 (data size 44) ...
    44 bytes from 40:4E:36:XX:XX:XX id 0 time 18.75ms
    44 bytes from 40:4E:36:XX:XX:XX id 1 time 18.61ms
    44 bytes from 40:4E:36:XX:XX:XX id 2 time 44.90ms
    44 bytes from 40:4E:36:XX:XX:XX id 3 time 44.86ms
    44 bytes from 40:4E:36:XX:XX:XX id 4 time 48.57ms
    44 bytes from 40:4E:36:XX:XX:XX id 5 time 44.86ms
    44 bytes from 40:4E:36:XX:XX:XX id 6 time 44.83ms
    44 bytes from 40:4E:36:XX:XX:XX id 7 time 44.88ms
    44 bytes from 40:4E:36:XX:XX:XX id 8 time 44.88ms
    44 bytes from 40:4E:36:XX:XX:XX id 9 time 18.62ms
    10 sent, 10 received, 0% loss
    

Note

Performing the above demonstration may not work as expected with Apple’s iPhone products. Apple sets stricter permissions on their Bluetooth interfaces and requires more backend configuration.