From f2a05d7f7ea9085919e053689aa4e2a11a1ba88c Mon Sep 17 00:00:00 2001 From: Chris Lovett Date: Fri, 22 Dec 2023 18:29:08 -0800 Subject: [PATCH] new post --- docs/posts/nrf5340_pixel/index.md | 175 ++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 176 insertions(+) create mode 100644 docs/posts/nrf5340_pixel/index.md diff --git a/docs/posts/nrf5340_pixel/index.md b/docs/posts/nrf5340_pixel/index.md new file mode 100644 index 0000000..b1ffc5e --- /dev/null +++ b/docs/posts/nrf5340_pixel/index.md @@ -0,0 +1,175 @@ + +# Connecting nrf5340 audio devkit to Pixel 8 Android Phone + +I was able to stream audio from my Pixel 8 phone phone running Android 14 to my [nrf5340 audio devkit](https://www.nordicsemi.com/Products/Development-hardware/nRF5340-Audio-DK). + +First you build the firmware as a headset with CONFIG_AUDIO_DEV=1 flash the firmware and ensure +it is advertising. You should see this in the console output: + +```log +```log + nRF5340 Audio nRF5340 Audio DK cpuapp + NCS base version: 2.5.0 + Cmake run : Mon Dec 04 19:49:23 2023 +HL [00:00:00.256,408] fw_info: ------- DEBUG BUILD ------- +HL [00:00:00.256,408] fw_info: HEADSET left device +HL [00:00:00.267,059] board_version: Compatible board/HW version found: 1.0.0 +HL [00:00:00.300,750] sd_card: SD card volume size: 30543 MB +HL [00:00:00.336,730] bt_mgmt: Clearing all bonds +HL [00:00:00.337,066] bt_mgmt_ctlr_cfg: Controller: LL_ACS_NRF53: Version 5.2 (0x0b), Revision 3393 +HL [00:00:00.338,958] bt_mgmt: Local identity addr: E9:8C:6F:E2:D2:44 (random) +HL [00:00:00.370,025] bt_mgmt_adv: Local addr: 65:C3:C7:DE:D6:EA (random) +HL [00:00:00.370,513] bt_mgmt_adv: Advertising successfully started +``` + +Next on the Android phone you may need to enable developer mode, then make sure `Disable Bluetoioth LE audio` is not +enabled. Then Click `Pair new device` under settings -> Connected devices and look for the one named `NRF5340_AUDIO` +and click pair. You should see `streamctrl_unicast_server: Connected` appear in the log. + +```log +HL [00:00:57.231,292] streamctrl_unicast_server: Connected +HL [00:01:04.527,893] streamctrl_unicast_server: Security changed +HL [00:01:06.545,898] bt_content_ctrl_media: Discovery of MCS finished +HL [00:03:46.232,238] bt_rend_vol: Volume = 194, mute state = 0 +HL [00:03:55.593,017] unicast_server: LC3 codec config for sink: +HL [00:03:55.593,017] unicast_server: Frequency: 24000 Hz +HL [00:03:55.593,017] unicast_server: Frame Duration: 10000 us +HL [00:03:55.593,048] unicast_server: Channel allocation: 0x1 +HL [00:03:55.593,048] unicast_server: Octets per frame: 60 (48000 bps) +HL [00:03:55.593,078] unicast_server: Frames per SDU: 1 +HL [00:03:55.690,490] streamctrl_unicast_server: Presentation delay 10000 us is set by initiator +HL [00:03:56.498,077] unicast_server: Stream 0x20020e28 started +``` +Here you can see it has negotiated a 24 kHz channel 1 stream. This is because I configured the +nrf5340 devkit to run at 24kh because I was testing another device. I'm sure it would also work great +at 48 kHz. + +Click on the paired device settings icon and enable the switch titled `LE Audio`. Now open a youtube video and if the +audio is coming out of the phone speakers then click the volume button, and click settings, then change the `Play Chrome +on` button from This Phone to `NRF5340_AUDIO` device. + +Note that the nrf5340 chip acts as one channel, since normally you would have 2 chips for each earbud. So you will only +get the left channel in this case. You can use 2 nrf5340 audio devkits to get full stereo. + +THe log will show `Data received` and perhaps some under runs, but it is working fine and the audio sounds great through +some earbuds. + +```log +HL [00:03:56.576,782] audio_datapath: Drft comp state: CALIB +HL [00:03:56.577,758] audio_datapath: Data received, total underruns: 69 +HL [00:03:56.676,757] audio_datapath: Drft comp state: OFFSET +HL [00:03:57.094,177] audio_datapath: Data received, total underruns: 75 +HL [00:03:57.114,196] audio_datapath: Drft comp state: LOCKED +HL [00:03:57.120,025] audio_datapath: Pres comp state: MEAS +HL [00:03:57.168,182] audio_datapath: Data received, total underruns: 79 +HL [00:03:57.246,490] le_audio_rx: BLE ISO RX overrun +HL [00:03:57.256,469] le_audio_rx: BLE ISO RX overrun +HL [00:03:57.256,713] audio_datapath: sdu_ref_us not from consecutive frames (diff: 29999 us) +HL [00:03:57.256,744] audio_datapath: Pres comp state: WAIT +HL [00:03:57.257,171] audio_datapath: Data received, total underruns: 128 +HL [00:03:57.356,567] audio_datapath: Pres comp state: INIT +HL [00:03:57.366,577] audio_datapath: Pres comp state: MEAS +HL [00:03:57.476,562] audio_datapath: Pres comp state: WAIT +HL [00:03:57.616,577] audio_datapath: Pres comp state: INIT +HL [00:03:57.626,586] audio_datapath: Pres comp state: MEAS +HL [00:03:57.729,187] audio_datapath: Data received, total underruns: 141 +HL [00:03:57.736,572] audio_datapath: Pres comp state: WAIT +HL [00:03:57.876,586] audio_datapath: Pres comp state: INIT +HL [00:03:57.886,566] audio_datapath: Pres comp state: MEAS +HL [00:03:57.996,582] audio_datapath: Pres comp state: WAIT +HL [00:03:58.156,494] le_audio_rx: BLE ISO RX overrun +HL [00:03:58.166,503] le_audio_rx: BLE ISO RX overrun +HL [00:03:58.170,837] audio_datapath: sdu_ref_us not from consecutive frames (diff: 30000 us) +HL [00:03:58.171,203] audio_datapath: Data received, total underruns: 196 +HL [00:03:58.172,607] audio_datapath: Pres comp state: INIT +HL [00:03:58.178,497] audio_datapath: Pres comp state: MEAS +HL [00:03:58.276,855] audio_datapath: Pres comp state: WAIT +HL [00:03:58.416,595] audio_datapath: Pres comp state: INIT +HL [00:03:58.426,574] audio_datapath: Pres comp state: MEAS +HL [00:03:58.536,590] audio_datapath: Pres comp state: LOCKED +HL [00:03:59.586,578] audio_datapath: sdu_ref_us not from consecutive frames (diff: 20000 us) +HL [00:03:59.586,608] audio_datapath: Pres comp state: WAIT +HL [00:03:59.588,195] audio_datapath: Data received, total underruns: 198 +HL [00:03:59.610,778] bt_ascs: CCID 2 is unknown +HL [00:03:59.650,207] audio_datapath: Data received, total underruns: 200 +HL [00:03:59.726,501] le_audio_rx: BLE ISO RX overrun +HL [00:03:59.736,511] le_audio_rx: BLE ISO RX overrun +HL [00:03:59.746,490] le_audio_rx: BLE ISO RX overrun +HL [00:03:59.748,413] audio_datapath: sdu_ref_us not from consecutive frames (diff: 39999 us) +HL [00:03:59.749,206] audio_datapath: Data received, total underruns: 269 +HL [00:03:59.751,068] audio_datapath: Pres comp state: INIT +HL [00:03:59.756,835] audio_datapath: Pres comp state: MEAS +HL [00:03:59.866,577] audio_datapath: Pres comp state: WAIT +HL [00:04:00.006,591] audio_datapath: Pres comp state: INIT +HL [00:04:00.016,601] audio_datapath: Pres comp state: MEAS +HL [00:04:00.126,586] audio_datapath: Pres comp state: LOCKED +HL [00:04:01.306,518] le_audio_rx: BLE ISO RX overrun +HL [00:04:01.316,528] le_audio_rx: BLE ISO RX overrun +HL [00:04:01.326,538] le_audio_rx: BLE ISO RX overrun +HL [00:04:01.336,517] le_audio_rx: BLE ISO RX overrun +HL [00:04:01.346,527] le_audio_rx: BLE ISO RX overrun +HL [00:04:01.347,869] audio_datapath: sdu_ref_us not from consecutive frames (diff: 59996 us) +HL [00:04:01.347,900] audio_datapath: Pres comp state: WAIT +HL [00:04:01.348,205] audio_datapath: Data received, total underruns: 351 +HL [00:04:01.446,594] audio_datapath: Pres comp state: INIT +HL [00:04:01.456,604] audio_datapath: Pres comp state: MEAS +HL [00:04:01.566,619] audio_datapath: Pres comp state: WAIT +HL [00:04:01.706,604] audio_datapath: Pres comp state: INIT +HL [00:04:01.716,644] audio_datapath: Pres comp state: MEAS +HL [00:04:01.821,228] audio_datapath: Data received, total underruns: 356 +HL [00:04:01.829,223] audio_datapath: Pres comp state: WAIT +HL [00:04:01.829,193] audio_datapath: Saved 480000 bytes to wav file. +HL [00:04:01.966,613] audio_datapath: Pres comp state: INIT +HL [00:04:01.976,623] audio_datapath: Pres comp state: MEAS +HL [00:04:02.086,639] audio_datapath: Pres comp state: WAIT +HL [00:04:02.226,654] audio_datapath: Pres comp state: INIT +HL [00:04:02.236,602] audio_datapath: Pres comp state: MEAS +HL [00:04:02.346,618] audio_datapath: Pres comp state: LOCKED +HL [00:05:16.430,084] audio_datapath: Data received, total underruns: 0 +HL [00:05:16.483,154] audio_datapath: Pres comp state: MEAS +HL [00:05:16.484,100] audio_datapath: Data received, total underruns: 53 +HL [00:05:16.490,112] audio_datapath: Drft comp state: INIT +HL [00:05:16.491,088] audio_datapath: Drft comp state: CALIB +HL [00:05:16.493,133] audio_datapath: Pres comp state: INIT +HL [00:05:16.590,942] audio_datapath: Drft comp state: OFFSET +HL [00:05:16.634,948] audio_datapath: Data received, total underruns: 54 +HL [00:05:16.930,786] audio_datapath: Drft comp state: LOCKED +HL [00:05:16.933,166] audio_datapath: Pres comp state: MEAS +HL [00:05:17.043,151] audio_datapath: Pres comp state: WAIT +HL [00:05:17.183,166] audio_datapath: Pres comp state: INIT +HL [00:05:17.193,176] audio_datapath: Pres comp state: MEAS +HL [00:05:17.303,161] audio_datapath: Pres comp state: LOCKED +HL [00:06:43.983,703] audio_datapath: sdu_ref_us not from consecutive frames (diff: 389990 us) +HL [00:06:43.983,734] audio_datapath: Pres comp state: WAIT +HL [00:06:43.984,344] audio_datapath: Data received, total underruns: 425 +HL [00:06:44.085,357] audio_datapath: Data received, total underruns: 426 +HL [00:06:44.113,708] audio_datapath: Pres comp state: INIT +HL [00:06:44.123,718] audio_datapath: Pres comp state: MEAS +HL [00:06:44.233,734] audio_datapath: Pres comp state: WAIT +HL [00:06:44.373,718] audio_datapath: Pres comp state: INIT +HL [00:06:44.383,728] audio_datapath: Pres comp state: MEAS +HL [00:06:44.493,713] audio_datapath: Pres comp state: LOCKED +HL [00:06:47.333,740] audio_datapath: sdu_ref_us not from consecutive frames (diff: 159991 us) +HL [00:06:47.333,770] audio_datapath: Pres comp state: WAIT +HL [00:06:47.334,381] audio_datapath: Data received, total underruns: 567 +HL [00:06:47.435,394] audio_datapath: Data received, total underruns: 568 +HL [00:06:47.463,745] audio_datapath: Pres comp state: INIT +HL [00:06:47.473,754] audio_datapath: Pres comp state: MEAS +HL [00:06:47.583,740] audio_datapath: Pres comp state: WAIT +HL [00:06:47.723,754] audio_datapath: Pres comp state: INIT +HL [00:06:47.733,764] audio_datapath: Pres comp state: MEAS +HL [00:06:47.843,750] audio_datapath: Pres comp state: LOCKED +``` + +You can now go back to the bluetooth settings on the phone and tell it to forget this device +and it will disconnect and go back to advertising. + +```log +HL [00:06:53.385,406] bt_mgmt: Disconnected: 94:45:60:6F:5D:66 (public) (reason 0x13) +HL [00:06:53.385,437] streamctrl_unicast_server: Disconnected +HL [00:06:53.385,467] unicast_server: Stream 0x20020e28 released +HL [00:06:53.386,047] bt_mgmt_adv: Local addr: 65:C3:C7:DE:D6:EA (random) +HL [00:06:53.386,138] bt_mgmt_adv: Adv directed to: 94:45:60:6F:5D:66 (public). +HL [00:06:53.386,779] bt_mgmt_adv: Advertising successfully started +HL [00:06:53.389,434] audio_datapath: Pres comp state: INIT +``` diff --git a/mkdocs.yml b/mkdocs.yml index 8c89a07..c65f63a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -32,6 +32,7 @@ nav: - Videos: videos/index.md - Code: code/index.md - Blog: + - LE audio with the nrf5340 rocks: posts/nrf5340_pixel/index.md - Find better models!: posts/archai/index.md - Fun with Dart: posts/fun_with_dart/index.md - Lean Programming: posts/lean/index.md