Skip to content

sprlightning/btstack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18,343 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTstack Port for ART-Pi Board with FreeRTOS

This port uses the ART-Pi Board with MDK Keil V5.23 based on the AMPAK AP6212A.

This Port is based on the bluekitchens' btstack and the FreeRTOS CMSIS V2.

ART-Pi is a DIY open source hardware with extended functions specially designed for embedded software engineers and open source makers after half a year of careful preparation by the RT-Thread team. Learn more via ART-Pi I

ART-Pi I

STCubeMX was used to provide the HAL, initialize the device, and create an initial PRJ for MDK Keil V5.23. The project can be built from the MDK, e.g. ARM Keil V5.23 or Microsoft's Visual Studio Code with the STM32CubeIDE Extension. In addition, bootloader project is used for boot the app.

Hardware

  • ART-Pi I

    ART-Pi

  • PCM5102 Module

    PCM5102 Module

  • 6-pin Female-to-Female Jumper Wires

  • USB-to-Type-C wire for Flash and USB Debug.

  • A pair of 3.5mm headphones.


Projects Status and Roadmaps

software modules status
bootloader: jump to W25Q64's app ✅ Done
app: boot from W25Q64 ✅ Done
app: run FreeRTOS ✅ Done
app: sai2_i2s module, write i2s form PCM via DMA ✅ Done
app: SAI2 I2S 动态配置(采样率/位深/通道/格式) ✅ Done
app: 32bit slot 标准 I2S 时序 ✅ Done
app: PLL3 分频框架 + 自动家族切换(44.1kHz/48kHz) ✅ Done
app: 预定义分频方案(22.5792/45.1584/90.3168/24.576/49.152/98.304) ✅ Done
app: SampleRates supprot 44.1kHz、48kHz、88.2kHz、96kHz、176.4kHz、192kHz ✅ Done
app: EMI 问题定位与 GPIO 速度优化 ✅ Done
app: 全部分频方案正弦波音源验证 ✅ Done
app: btstack port ✅ Done
app: A2DP Sink ✅ Done
app: PCM volume control ✅ Done
app: A2DP PCM wirte to I2S ✅ Done
app: AVRCP Lyric Function (based on AVRCP Title Function) ✅ Done
app: A2DP SBC decoder ✅ Done
app: A2DP Multiple Decoder Interface ⏰ Come soon...
app: A2DP LDAC decoder ⏰ Come soon...
app: A2DP LHDC V5 decoder ⏰ Come soon...
app: A2DP AAC decoder ⏰ Come soon...
app: A2DP Aptx decoder ⏰ Come soon...
app: A2DP LC3 decoder ⏰ Come soon...

Setup

  • Install ARM MDK Keil V5 on your PC, and install software package for STM32H750XXX.

  • Connect the ART-Pi board to your PC using USB-to-Type-C, must use the USB Debug.

  • Open bootloader PRJ, build and Flash to the ART-Pi.

  • Connect ART-Pi board with the PCM5102 Module using Female-to-Female Dupont Wires.

ART-Pi PIN PCM5102 Module PIN Comment
I2S_MCLK P1.37(PI4) SCK Left 1 主时钟,需要断开SCK接地焊盘
PCM_SCLK P1.12(PI5) BCK Left 2 串行位时钟
PCM_DOUT P1.40(PI6) DIN Left 3 串行数据
PCM_FS P1.35(PI7) LCK Left 4 帧同步信号
GND P1.6 GND Left 5 GND
5V P1.4 VIN Left 6 Need 5V
  • Open app PRJ, build and Flash to the ART-Pi.

Development on the MDK

The USB Debug of ART-Pi either supoort ST-LINK V2 and UART Adapter.

Git clone this repository

To start development, you need to git clone this repository form sprlightning/btstack by run CMD: git clone --recursive -b port-art-pi-stm32h750xbh6-freertos-ap6212a https://github.com/sprlightning/btstack.git

And change DIR to btstack by run CMD:cd btstack/.

Build and Flash the bootloader

  • Step 1. Change DIR to the bootloader PRJ by run CMD: cd projects/H750XBH6-bootloader/

  • Step2. Open H750XBH6-bootloader.uvprojx by MDK.
    Just change DIR to btstack/projects/H750XBH6-bootloader/MDK-ARM/ by run CMD: cd MDK-ARM/
    Then double click H750XBH6-bootloader.uvprojx.
    Or If your MDK is in path: C:\Keil_v5\UV4\UV4.exe, just run CMD: "C:\Keil_v5\UV4\UV4.exe" "H750XBH6-bootloader.uvprojx"

  • Step3. Trandlate.
    Just need to click Translate button, or press Ctrl+F7.

  • Step4. Build.
    Just need to click Build button, or press F7.

  • Step5. Download.
    Makesure you have connected ART-Pi's USB Debug with PC via an USB-2-Type-C wire, and click Download button, or press F8.

Now bootloader is Ready. If you have opened the console, you will see messages from the bootloader:

W25Q64 OK,flash ID:EF4017
W25Q64 was set to MemoryMappedMode(QSPI Clock: 120.00MHz)
Bootloader: jump to 0x90000000

Build and Flash the app

  • Step1. DIR back to btstack, and copy 3rd-party & chipset & platform & port & src files to the app PRJ by run CMDs:
xcopy "3rd-party\" "projects\H750XBH6-AP6212-app\lib_btstack\" /E /I /Y
xcopy "chipset\" "projects\H750XBH6-AP6212-app\lib_btstack\" /E /I /Y
xcopy "platform\" "projects\H750XBH6-AP6212-app\lib_btstack\" /E /I /Y
xcopy "port\" "projects\H750XBH6-AP6212-app\lib_btstack\" /E /I /Y
xcopy "src\" "projects\H750XBH6-AP6212-app\lib_btstack\" /E /I /Y
  • Step2. Open H750XBH6-AP6212-app.uvprojx by MDK.
    Just change DIR to btstack/projects/H750XBH6-AP6212-app/MDK-ARM/ by run CMD: cd projects/H750XBH6-AP6212-app/MDK-ARM/
    Then double click H750XBH6-AP6212-app.uvprojx.
    Or If your MDK is in path: C:\Keil_v5\UV4\UV4.exe, just run CMD: "C:\Keil_v5\UV4\UV4.exe" "H750XBH6-AP6212-app.uvprojx"

  • Step3. Trandlate.
    Just need to click Translate button, or press Ctrl+F7.

  • Step4. Build.
    Just need to click Build button, or press F7.

  • Step5. Download.
    Makesure you have connected ART-Pi's USB Debug with PC via an USB-2-Type-C wire, and click Download button, or press F8.

Now app is Ready. If you have opened the console, you will see messages from the bootloader and the app:

W25Q64 OK,flash ID:EF4017
W25Q64 was set to MemoryMappedMode(QSPI Clock: 120.00MHz)
Bootloader: jump to 0x90000000
This is PRJ: H750XBH6-AP6212-app
W25Q128JV ID: 0xEF4018
This is FreeRTOS TASK: StartLedFlashTask
BTstack up and running at 41:52:54:14:30:46

Finally, the btstack is running on the ART-Pi. You can use your cellphhone to pair ART-Pi.


Cellphone pair with ART-Pi

Open your cellphone's setting, and click the Bluetooth setting, discover and click ART-Pi A2DP Sink 41:52:54:14:30:46, cellphone will try to pair with ART-Pi. Your cellphone will pair with ART-Pi using SBC Codec.

If fail with no warning, it just means ART-Pi is not raedy, just pair again, no more than 3 times. This maybe a bug... If you are interested in it, open Info / Warning LOGs for btstack to see more details.

Insert a pair of 3.5mm headphones to the PCM5102 Module, just play musics on your cellphone, and enjoy it.

LDAC and LHDC V5 codecs will come soon...

If you have opened the console, you will see lyrics like:

HCI_EVENT_USER_CONFIRMATION_REQUEST 3C:38:24:5C:4A:CF
HCI_EVENT_LINK_KEY_NOTIFICATION 3C:38:24:5C:4A:CF, type 4
A2DP Sink: SBC config - fs=68, block=16, subbands=8, alloc=1, ch=4, bitpool[2,53]
A2DP Sink: stream established
AVRCP: connected to 3C:38:24:5C:4A:CF, cid 0x01
AVRCP: supported notifications by target:
   - [X] PLAYBACK_STATUS_CHANGED
   - [X] TRACK_CHANGED
   - [ ] TRACK_REACHED_END
   - [ ] TRACK_REACHED_START
   - [X] PLAYBACK_POS_CHANGED
   - [ ] BATT_STATUS_CHANGED
   - [ ] SYSTEM_STATUS_CHANGED
   - [X] PLAYER_APPLICATION_SETTING_CHANGED
   - [ ] NOW_PLAYING_CONTENT_CHANGED
   - [ ] AVAILABLE_PLAYERS_CHANGED
   - [ ] ADDRESSED_PLAYER_CHANGED
   - [ ] UIDS_CHANGED
   - [ ] VOLUME_CHANGED
AVRCP Target: volume changed to 6% (8/127)
AVRCP: notification registered: PLAYBACK_STATUS_CHANGED
AVRCP: playback status changed: PAUSED
AVRCP: notification registered: TRACK_CHANGED
AVRCP: track changed
AVRCP Title : 你说要我学着勇敢一点
AVRCP Artist: 周笔畅-笔记 (Live)
AVRCP Album : 唱歌去旅行 全国巡回演唱会 北京站
AVRCP Track : 1
AVRCP Total : 1
AVRCP Genre : Unavailable
AVRCP: playback status changed: PLAYING
A2DP Sink: stream started
AVRCP: track changed
AVRCP: track changed
AVRCP Title : 偶尔哭红双眼
AVRCP Artist: 周笔畅-笔记 (Live)
AVRCP Album : 唱歌去旅行 全国巡回演唱会 北京站
AVRCP Track : 1
AVRCP Total : 1
AVRCP Genre : Unavailable
AVRCP: track changed
AVRCP Title : 你一定会了解
AVRCP Artist: 周笔畅-笔记 (Live)
AVRCP Album : 唱歌去旅行 全国巡回演唱会 北京站
AVRCP Track : 1
AVRCP Total : 1
AVRCP Genre : Unavailable

Lyric function need Car-Play function by music app, like kugou/QQ Music, I put Lyrics in AVRCP Titles, if you are interested in Lyric Function, you can copy the AVRCP Titles to a array and print it only.

Does AVRCP support AVRCP Lyric ? No. However, Car-Play on music app will put lyrics in AVRCP Title, so we can use AVRCP Title to transport lyrics.


Configuration

Debug Console

All debug console can be via USB Debug. To get the console from UART4, connect USB Debug of the ART-Pi board to an USB-2-Type-C wire and open a terminal at 115200.

Automatic PatchRAM

The app embedded the BCM43430A1 firmware, and it will download PatchRAM for the AP6212(BCM43430A1) from the app image automatic when the app start.


Contributions and Cites

Thanks to bluekitchens' btstack, and thanks to RT-Thread-Studios' sdk-bsp-stm32h750-realthread-artpi, and thanks to supperthomas/RTT_PACKAGE_BTSTACK.

About

Dual-mode Bluetooth stack, with small memory footprint.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages