2021-06-26 15:03:25 +08:00
[![License ](https://img.shields.io/badge/License-Apache--2.0-brightgreen )](LICENSE)
2021-04-13 19:23:11 +08:00
2021-06-25 17:43:48 +08:00
[中文版 ](README_zh.md )
2021-04-13 19:23:11 +08:00
2021-06-25 17:43:48 +08:00
# Introduction
2023-02-24 21:33:12 +08:00
**BouffaloSDK** is an MCU software development kit provided by the Bouffalo Lab Team, supports all the series of Bouffalo chips.
2022-10-21 10:17:49 +08:00
2023-02-24 21:33:12 +08:00
# SDK Architecture
2022-10-21 10:17:49 +08:00
2023-02-24 21:33:12 +08:00
![SDK Architecture ](BouffaloSDK.png )
2022-10-21 10:17:49 +08:00
2023-02-24 21:33:12 +08:00
# Code Directoryies
2022-10-21 10:17:49 +08:00
2023-02-24 21:33:12 +08:00
| Name | Description |
|:---:|:------:|
| bsp/board | clock, pinmux, memoryheap and console init |
| bsp/common | bsp common driver|
| components| components|
|docs | quick start、 api、demo doc|
|drivers/lhal| bouffalo common peripherals drivers which support all the chips|
|drivers/soc| bouffalo non-generic peripherals drivers|
|drivers/rfparam| rf param |
|examples| official samples|
|tools| tools |
2022-10-21 10:17:49 +08:00
2023-02-24 21:33:12 +08:00
# LHAL Support
2022-10-21 10:17:49 +08:00
**LHAL** is a low level hal driver for common peripherals designed by Bouffalo Lab, in order to support all the Bouffalo chips with the same api . Also it is convenient for users to use and port to other platforms.
2022-12-07 10:19:27 +08:00
Note: **√** means supported ; ** × ** means not supported; ** ○** means supported but not tested ; ** -** means no such peripheral.
2022-10-21 11:42:28 +08:00
2022-11-18 16:47:16 +08:00
| Peripheral | BL602/BL604 | BL702/BL704/BL706 | BL616/BL618 | BL808 |
2022-10-21 11:42:28 +08:00
|:------------:|:--------------:|:--------------------:|:-----------:|:--------:|
| ADC | ○ | √ | √ | ○ |
2023-02-24 21:33:12 +08:00
| CAM | - | × | × | × |
2022-10-29 16:13:16 +08:00
| CKS | ○ | √ | √ | ○ |
2022-10-21 11:42:28 +08:00
| DAC | ○ | √ | √ | ○ |
| DMA | ○ | √ | √ | √ |
2023-02-24 21:33:12 +08:00
| EFUSE | × | × | × | × |
2022-10-21 11:42:28 +08:00
| EMAC | - | √ | √ | √ |
2022-11-18 16:47:16 +08:00
| FLASH | √ | √ | √ | √ |
2022-10-21 11:42:28 +08:00
| GPIO | ○ | √ | √ | √ |
2023-02-24 21:33:12 +08:00
| I2C | ○ | √ | √ | ○ |
| I2S | ○ | ○ | √ | ○ |
2022-10-21 11:42:28 +08:00
| IR | ○ | √ | √ | ○ |
2023-02-24 21:33:12 +08:00
| MJPEG | × | × | √ | √ |
2022-10-21 11:42:28 +08:00
| PWM_v1 | ○ | √ | - | - |
| PWM_v2 | - | - | √ | √ |
| RTC | ○ | √ | √ | √ |
| SEC_AES | ○ | √ | √ | √ |
| SEC_SHA | ○ | √ | √ | √ |
| SEC_TRNG | ○ | √ | √ | √ |
2022-10-29 16:13:16 +08:00
| SEC_PKA | ○ | √ | √ | √ |
2022-11-18 16:47:16 +08:00
| SPI | ○ | √ | √ | √ |
2022-10-21 11:42:28 +08:00
| TIMER | ○ | √ | √ | √ |
2022-10-24 19:15:50 +08:00
| UART | √ | √ | √ | √ |
2022-10-21 11:42:28 +08:00
| USB_v1 | - | √ | - | - |
| USB_v2 | - | - | √ | √ |
2022-11-18 16:47:16 +08:00
| WDG | ○ | √ | √ | ○ |
2021-06-25 17:43:48 +08:00
2022-10-21 10:17:49 +08:00
# Environment Setup
2021-04-13 19:23:11 +08:00
2022-10-21 10:17:49 +08:00
## Toolchain
2021-04-27 12:39:52 +08:00
2022-10-21 10:17:49 +08:00
- [riscv64-unknown-elf-gcc ](https://gitee.com/bouffalolab/toolchain_gcc_t-head_windows ) toolchain used in windows.
- [riscv64-unknown-elf-gcc ](https://gitee.com/bouffalolab/toolchain_gcc_t-head_linux ) toolchain used in linux.
- [linux-riscv64-linux-gcc ](https://gitee.com/bouffalolab/linuxtoolchain_gcc_t-head ) toolchain used for compiling linux code.
2021-04-27 12:39:52 +08:00
2022-10-21 10:17:49 +08:00
## Command Line Development
2021-04-27 12:39:52 +08:00
2023-02-24 21:33:12 +08:00
Before compiling with the command line, you need to select the corresponding toolchain according to your operating system, configure it to the system environment variables, and install the **make** or **ninja** , then you can do the following. For the details, you can visit [BouffaloSDK Environment Setup ](https://bl-mcu-sdk.readthedocs.io/zh_CN/latest/get_started/index.html ).
2021-04-27 12:39:52 +08:00
2022-10-21 10:17:49 +08:00
- Go to the demo directory where you want to compile and there are `main.c` and `Makefile` files in that directory
- Just execute the following command, take **BL616** as an example
2021-08-25 10:49:37 +08:00
2022-10-21 10:17:49 +08:00
```
cd examples/helloworld
make CHIP=bl616 BOARD=bl616dk
2021-08-25 10:49:37 +08:00
```
2022-10-21 10:17:49 +08:00
- If you use **BL808** or **BL606P** , you need to add **CPU_ID** with m0 or d0.
2021-08-25 10:49:37 +08:00
2022-12-07 10:19:27 +08:00
If you want to use **ninja** , you can try:
```
cd examples/helloworld
make ninja CHIP=bl616 BOARD=bl616dk
```
2023-02-24 21:33:12 +08:00
```
cd examples/helloworld
make CHIP=bl808 BOARD=bl808dk CPU_ID=m0
```
2022-10-21 10:17:49 +08:00
## CDK Development
2021-04-13 19:23:11 +08:00
2022-10-21 10:17:49 +08:00
TODO
2021-04-13 19:23:11 +08:00
2022-11-05 10:51:33 +08:00
## Debug
2023-02-24 21:33:12 +08:00
Only supports debug with CKLink currently. See [BouffaloSDK Debug Guide ](https://bl-mcu-sdk.readthedocs.io/zh_CN/latest/get_started/debug.html ).
2022-11-18 16:47:16 +08:00
## Firmware Download
2023-02-24 21:33:12 +08:00
Note that if you are using linux, linux will deny access to the serial device due to permission issues, so add your own username to `dialout` for easy to use, restart your linux and then take effect. Or add `sudo` before command.
```
usermod -aG dialout xxx # xxx is your own name
```
```
cd examples/helloworld
make flash CHIP=chip_name COMX=xxx # chip_name should be bl602/bl702/bl616/bl808/bl606p, COMX in Windows, /dev/ttyxxx in Linux
```
- If you use **BL808** or **BL606P** , you need to add **CPU_ID** with m0 or d0.
2022-11-18 16:47:16 +08:00
2023-02-24 21:33:12 +08:00
```
cd examples/helloworld
make flash CHIP=chip_name CPU_ID=m0 COMX=xxx # chip_name should be bl602/bl702/bl616/bl808/bl606p, COMX in Windows, /dev/ttyxxx in Linux
```
If flash using serial port rather than USB, different USB2TTL chips support different max baudrates, need to pay attention to when flashing.
| chip | baudrate|
|:---:|:------:|
| ch340 | < = 500K |
| cp2102 | < = 2M |
| ft232 | < = 2M |
| bl702 | < = 8M |
| bl616 | < = 10M |
2022-11-05 10:51:33 +08:00
2022-10-21 10:17:49 +08:00
# Resources
2021-08-25 10:49:37 +08:00
2022-10-21 10:17:49 +08:00
## Chip Manual
2021-08-25 10:49:37 +08:00
2023-02-24 21:33:12 +08:00
**Chip Reference Manual** and **Chip Data Manual** are listed on [document ](https://dev.bouffalolab.com/document )
2021-08-25 10:49:37 +08:00
2022-10-21 10:17:49 +08:00
## Documentation Tutorial
2021-08-25 10:49:37 +08:00
2023-02-24 21:33:12 +08:00
To get more BouffaloSDK documentation tutorial, like api manual or peripheral demo and so on, please visit:
2021-04-13 19:23:11 +08:00
2023-02-24 21:33:12 +08:00
- [BouffaloSDK documentation tutorial ](https://bl-mcu-sdk.readthedocs.io/zh_CN/latest/ )
2021-04-27 12:39:52 +08:00
2022-10-21 10:17:49 +08:00
## Video Tutorial
2021-04-27 12:39:52 +08:00
2023-02-24 21:33:12 +08:00
TODO
2021-04-27 12:39:52 +08:00
2021-06-25 17:43:48 +08:00
## Forum
2021-04-13 19:23:11 +08:00
2023-02-24 21:33:12 +08:00
Bouffalolab Developer Forum: [https://bbs.bouffalolab.com/ ](https://bbs.bouffalolab.com/ )