Skip to content

Commit 2642a7b

Browse files
VynDragonkartben
authored andcommitted
boards: bflb: Introduce AI-WB2-12F
This introduces the Ai-Thinker BL602 WB2 development board Signed-off-by: Camille BAUD <[email protected]>
1 parent a97508c commit 2642a7b

File tree

12 files changed

+336
-0
lines changed

12 files changed

+336
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config BOARD_AI_WB2_12F
6+
select SOC_BL602C00Q2I
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <dt-bindings/pinctrl/bl602x-pinctrl.h>
8+
9+
&pinctrl {
10+
uart0_default: uart0_default {
11+
group1 {
12+
pinmux = <GPIO7_UART0_RX>,
13+
<GPIO16_UART0_TX>;
14+
bias-pull-up;
15+
input-schmitt-enable;
16+
};
17+
};
18+
19+
uart0_sleep: uart0_sleep {
20+
group1 {
21+
pinmux = <GPIO7_UART0_RX>,
22+
<GPIO16_UART0_TX>;
23+
bias-high-impedance;
24+
};
25+
};
26+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
9+
#include <bflb/bl60x.dtsi>
10+
#include "ai_wb2_12f-pinctrl.dtsi"
11+
12+
/ {
13+
model = "Ai-Thinker WB2-12F development board";
14+
compatible = "bflb,bl602";
15+
16+
chosen {
17+
zephyr,flash = &flash0;
18+
zephyr,itcm = &itcm;
19+
zephyr,dtcm = &dtcm;
20+
zephyr,sram = &sram0;
21+
zephyr,console = &uart0;
22+
zephyr,shell-uart = &uart0;
23+
};
24+
};
25+
26+
&cpu0 {
27+
clock-frequency = <DT_FREQ_M(192)>;
28+
};
29+
30+
&spi1 {
31+
#address-cells = <1>;
32+
#size-cells = <0>;
33+
reg = <0x4000b000 0x1000 0x23000000 0x400000>;
34+
35+
flash0: flash@0 {
36+
compatible = "zb,25vq32", "jedec,spi-nor";
37+
status = "disabled";
38+
size = <DT_SIZE_M(128)>;
39+
jedec-id = [5e 40 16];
40+
reg = <0>;
41+
spi-max-frequency = <DT_FREQ_M(133)>;
42+
};
43+
};
44+
45+
&uart0 {
46+
status = "okay";
47+
current-speed = <115200>;
48+
49+
pinctrl-0 = <&uart0_default>;
50+
pinctrl-1 = <&uart0_sleep>;
51+
pinctrl-names = "default", "sleep";
52+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
identifier: ai_wb2_12f
6+
name: Ai-Thinker WB2-12F development board
7+
type: mcu
8+
arch: riscv
9+
ram: 64
10+
toolchain:
11+
- zephyr
12+
testing:
13+
ignore_tags:
14+
- net
15+
- bluetooth
16+
supported:
17+
- pinctrl
18+
- uart
19+
vendor: bflb
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
CONFIG_CONSOLE=y
6+
CONFIG_SERIAL=y
7+
8+
CONFIG_UART_CONSOLE=y
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
board_runner_args(openocd --cmd-pre-init "source [find bl60x.cfg]")
6+
7+
board_runner_args(openocd --use-elf --no-load --no-init)
8+
board_runner_args(openocd --gdb-init "set mem inaccessible-by-default off")
9+
board_runner_args(openocd --gdb-init "set architecture riscv:rv32")
10+
board_runner_args(openocd --gdb-init "set remotetimeout 250")
11+
board_runner_args(openocd --gdb-init "set print asm-demangle on")
12+
board_runner_args(openocd --gdb-init "set backtrace limit 32")
13+
board_runner_args(openocd --gdb-init "mem 0x22008000 0x22014000 rw")
14+
board_runner_args(openocd --gdb-init "mem 0x42008000 0x42014000 rw")
15+
board_runner_args(openocd --gdb-init "mem 0x22014000 0x22020000 rw")
16+
board_runner_args(openocd --gdb-init "mem 0x42014000 0x42020000 rw")
17+
board_runner_args(openocd --gdb-init "mem 0x22020000 0x2203C000 rw")
18+
board_runner_args(openocd --gdb-init "mem 0x42020000 0x4203C000 rw")
19+
board_runner_args(openocd --gdb-init "mem 0x23000000 0x23400000 ro")
20+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

boards/aithinker/ai_wb2_12f/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: ai_wb2_12f
3+
full_name: Ai-Thinker WB2-12F development board
4+
vendor: bflb
5+
socs:
6+
- name: bl602c00q2i
Binary file not shown.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.. zephyr:board:: ai_wb2_12f
2+
3+
Overview
4+
********
5+
6+
BL602/BL604 is a Wi-Fi+BLE chipset introduced by Bouffalo Lab, which is used
7+
for low power consumption and high performance application development. The
8+
wireless subsystem includes 2.4G radio, Wi-Fi 802.11b/g/n and BLE 5.0
9+
baseband/MAC design. The microcontroller subsystem includes a 32-bit RISC CPU
10+
with low power consumption, cache and memory. The power management unit
11+
controls the low power consumption mode. In addition, it also supports
12+
various security features. The external interfaces include SDIO, SPI, UART,
13+
I2C, IR remote, PWM, ADC, DAC, PIR and GPIO.
14+
15+
This WB2 (BL602) 12F format Module Development Board features a SiFive E24 32 bit
16+
RISC-V CPU with FPU, it supports High Frequency clock up to 192Mhz, have 128k ROM, 276kB RAM,
17+
2.4 GHz WIFI 1T1R mode, support 20 MHz, data rate up to 72.2 Mbps, BLE 5.0
18+
with 2MB phy. It is a secure MCU which supports Secure boot, ECC-256 signed
19+
image, QSPI/SPI Flash On-The-Fly AES Decryption and PKA (Public Key
20+
Accelerator).
21+
22+
Hardware
23+
********
24+
25+
For more information about the Bouffalo Lab BL-60x MCU:
26+
27+
- `Bouffalo Lab BL60x MCU Website`_
28+
- `Bouffalo Lab BL60x MCU Datasheet`_
29+
- `Bouffalo Lab Development Zone`_
30+
- `ai_wb2_12f Schematics`_
31+
- `The RISC-V BL602 Book`_
32+
33+
Supported Features
34+
==================
35+
36+
.. zephyr:board-supported-hw::
37+
38+
System Clock
39+
============
40+
41+
The WB2 (BL602) Development Board is configured to run at max speed (192MHz).
42+
43+
Serial Port
44+
===========
45+
46+
The ``ai_wb2_12f`` board uses UART0 as default serial port. It is connected
47+
to USB Serial converter and port is used for both program and console.
48+
49+
50+
Programming and Debugging
51+
*************************
52+
53+
Samples
54+
=======
55+
56+
#. Build the Zephyr kernel and the :zephyr:code-sample:`hello_world` sample
57+
application:
58+
59+
.. zephyr-app-commands::
60+
:zephyr-app: samples/hello_world
61+
:board: ai_wb2_12f
62+
:goals: build flash
63+
64+
#. Run your favorite terminal program to listen for output. Under Linux the
65+
terminal should be :code:`/dev/ttyUSB0`. For example:
66+
67+
.. code-block:: console
68+
69+
$ screen /dev/ttyUSB0 115200
70+
71+
The -o option tells minicom not to send the modem initialization
72+
string. Connection should be configured as follows:
73+
74+
- Speed: 115200
75+
- Data: 8 bits
76+
- Parity: None
77+
- Stop bits: 1
78+
79+
Then, press and release RST button
80+
81+
.. code-block:: console
82+
83+
*** Booting Zephyr OS build v4.1.0 ***
84+
Hello World! ai_wb2_12f/bl602c00q2i
85+
86+
Congratulations, you have ``ai_wb2_12f`` configured and running Zephyr.
87+
88+
89+
.. _Bouffalo Lab BL60x MCU Website:
90+
https://en.bouffalolab.com/product/?type=detail&id=6
91+
92+
.. _Bouffalo Lab BL60x MCU Datasheet:
93+
https://github.com/bouffalolab/bl_docs/tree/main/BL602_DS/en
94+
95+
.. _Bouffalo Lab Development Zone:
96+
https://dev.bouffalolab.com/home?id=guest
97+
98+
.. _ai_wb2_12f Schematics:
99+
https://docs.ai-thinker.com/en/wb2
100+
101+
.. _The RISC-V BL602 Book:
102+
https://lupyuen.github.io/articles/book
103+
104+
.. _Flashing Firmware to BL602:
105+
https://lupyuen.github.io/articles/book#flashing-firmware-to-bl602
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright (c) 2022-2025 ATL Electronics
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
if { [info exists CHIPNAME] } {
6+
set _CHIPNAME $CHIPNAME
7+
} else {
8+
set _CHIPNAME riscv
9+
}
10+
11+
if { [info exists WORKAREASIZE] } {
12+
set _WORKAREASIZE $WORKAREASIZE
13+
} else {
14+
set _WORKAREASIZE 0x10000
15+
}
16+
17+
if { [info exists WORKAREAADDR] } {
18+
set _WORKAREAADDR $WORKAREAADDR
19+
} else {
20+
set _WORKAREAADDR 0x22020000
21+
}
22+
23+
if { [info exists CPUTAPID] } {
24+
set _CPUTAPID $CPUTAPID
25+
} else {
26+
set _CPUTAPID 0x20000c05
27+
}
28+
29+
transport select jtag
30+
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $_CPUTAPID
31+
32+
set _TARGETNAME $_CHIPNAME.cpu
33+
target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME
34+
35+
$_TARGETNAME.0 configure -work-area-phys $_WORKAREAADDR -work-area-size $_WORKAREASIZE -work-area-backup 1
36+
37+
echo "Ready for Remote Connections"
38+
39+
$_TARGETNAME.0 configure -event reset-assert-pre {
40+
echo "reset-assert-pre"
41+
adapter speed 100
42+
}
43+
44+
$_TARGETNAME.0 configure -event reset-deassert-post {
45+
echo "reset-deassert-post"
46+
47+
adapter speed 100
48+
49+
reg mstatus 0x7800
50+
reg mie 0x0
51+
# reg pc 0x23000000
52+
}
53+
54+
$_TARGETNAME.0 configure -event reset-init {
55+
echo "reset-init"
56+
57+
adapter speed 3000
58+
}
59+
60+
$_TARGETNAME.0 configure -event gdb-attach {
61+
echo "Debugger attaching: halting execution"
62+
reset halt
63+
gdb_breakpoint_override hard
64+
}
65+
66+
$_TARGETNAME.0 configure -event gdb-detach {
67+
echo "Debugger detaching: resuming execution"
68+
resume
69+
}
70+
71+
gdb_memory_map enable
72+
gdb_flash_program enable
73+
74+
# 'progbuf', 'sysbus' or 'abstract'
75+
riscv set_mem_access sysbus
76+
riscv set_command_timeout_sec 1
77+
78+
init
79+
reset init

0 commit comments

Comments
 (0)