diff --git a/boards/aithinker/ai_wb2_12f/Kconfig.ai_wb2_12f b/boards/aithinker/ai_wb2_12f/Kconfig.ai_wb2_12f new file mode 100644 index 00000000000..9c4fa2f57d7 --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/Kconfig.ai_wb2_12f @@ -0,0 +1,6 @@ +# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space) +# +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_AI_WB2_12F + select SOC_BL602C00Q2I diff --git a/boards/aithinker/ai_wb2_12f/ai_wb2_12f-pinctrl.dtsi b/boards/aithinker/ai_wb2_12f/ai_wb2_12f-pinctrl.dtsi new file mode 100644 index 00000000000..2ca49209287 --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/ai_wb2_12f-pinctrl.dtsi @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +&pinctrl { + uart0_default: uart0_default { + group1 { + pinmux = , + ; + bias-pull-up; + input-schmitt-enable; + }; + }; + + uart0_sleep: uart0_sleep { + group1 { + pinmux = , + ; + bias-high-impedance; + }; + }; +}; diff --git a/boards/aithinker/ai_wb2_12f/ai_wb2_12f.dts b/boards/aithinker/ai_wb2_12f/ai_wb2_12f.dts new file mode 100644 index 00000000000..d3e99d7a45f --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/ai_wb2_12f.dts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include "ai_wb2_12f-pinctrl.dtsi" + +/ { + model = "Ai-Thinker WB2-12F development board"; + compatible = "bflb,bl602"; + + chosen { + zephyr,flash = &flash0; + zephyr,itcm = &itcm; + zephyr,dtcm = &dtcm; + zephyr,sram = &sram0; + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + }; +}; + +&cpu0 { + clock-frequency = ; +}; + +&spi1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0x4000b000 0x1000 0x23000000 0x400000>; + + flash0: flash@0 { + compatible = "zb,25vq32", "jedec,spi-nor"; + status = "disabled"; + size = ; + jedec-id = [5e 40 16]; + reg = <0>; + spi-max-frequency = ; + }; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + + pinctrl-0 = <&uart0_default>; + pinctrl-1 = <&uart0_sleep>; + pinctrl-names = "default", "sleep"; +}; diff --git a/boards/aithinker/ai_wb2_12f/ai_wb2_12f.yaml b/boards/aithinker/ai_wb2_12f/ai_wb2_12f.yaml new file mode 100644 index 00000000000..e7c5a4dc59e --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/ai_wb2_12f.yaml @@ -0,0 +1,19 @@ +# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space) +# +# SPDX-License-Identifier: Apache-2.0 + +identifier: ai_wb2_12f +name: Ai-Thinker WB2-12F development board +type: mcu +arch: riscv +ram: 64 +toolchain: + - zephyr +testing: + ignore_tags: + - net + - bluetooth +supported: + - pinctrl + - uart +vendor: bflb diff --git a/boards/aithinker/ai_wb2_12f/ai_wb2_12f_defconfig b/boards/aithinker/ai_wb2_12f/ai_wb2_12f_defconfig new file mode 100644 index 00000000000..7836442f7c4 --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/ai_wb2_12f_defconfig @@ -0,0 +1,8 @@ +# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space) +# +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_CONSOLE=y +CONFIG_SERIAL=y + +CONFIG_UART_CONSOLE=y diff --git a/boards/aithinker/ai_wb2_12f/board.cmake b/boards/aithinker/ai_wb2_12f/board.cmake new file mode 100644 index 00000000000..1a2a98c777e --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/board.cmake @@ -0,0 +1,20 @@ +# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space) +# +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(openocd --cmd-pre-init "source [find bl60x.cfg]") + +board_runner_args(openocd --use-elf --no-load --no-init) +board_runner_args(openocd --gdb-init "set mem inaccessible-by-default off") +board_runner_args(openocd --gdb-init "set architecture riscv:rv32") +board_runner_args(openocd --gdb-init "set remotetimeout 250") +board_runner_args(openocd --gdb-init "set print asm-demangle on") +board_runner_args(openocd --gdb-init "set backtrace limit 32") +board_runner_args(openocd --gdb-init "mem 0x22008000 0x22014000 rw") +board_runner_args(openocd --gdb-init "mem 0x42008000 0x42014000 rw") +board_runner_args(openocd --gdb-init "mem 0x22014000 0x22020000 rw") +board_runner_args(openocd --gdb-init "mem 0x42014000 0x42020000 rw") +board_runner_args(openocd --gdb-init "mem 0x22020000 0x2203C000 rw") +board_runner_args(openocd --gdb-init "mem 0x42020000 0x4203C000 rw") +board_runner_args(openocd --gdb-init "mem 0x23000000 0x23400000 ro") +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/aithinker/ai_wb2_12f/board.yml b/boards/aithinker/ai_wb2_12f/board.yml new file mode 100644 index 00000000000..071ebf95f87 --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/board.yml @@ -0,0 +1,6 @@ +board: + name: ai_wb2_12f + full_name: Ai-Thinker WB2-12F development board + vendor: bflb + socs: + - name: bl602c00q2i diff --git a/boards/aithinker/ai_wb2_12f/doc/img/ai_wb2_12f.webp b/boards/aithinker/ai_wb2_12f/doc/img/ai_wb2_12f.webp new file mode 100644 index 00000000000..ae6ef3f02dc Binary files /dev/null and b/boards/aithinker/ai_wb2_12f/doc/img/ai_wb2_12f.webp differ diff --git a/boards/aithinker/ai_wb2_12f/doc/index.rst b/boards/aithinker/ai_wb2_12f/doc/index.rst new file mode 100644 index 00000000000..b68fc820bbc --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/doc/index.rst @@ -0,0 +1,105 @@ +.. zephyr:board:: ai_wb2_12f + +Overview +******** + +BL602/BL604 is a Wi-Fi+BLE chipset introduced by Bouffalo Lab, which is used +for low power consumption and high performance application development. The +wireless subsystem includes 2.4G radio, Wi-Fi 802.11b/g/n and BLE 5.0 +baseband/MAC design. The microcontroller subsystem includes a 32-bit RISC CPU +with low power consumption, cache and memory. The power management unit +controls the low power consumption mode. In addition, it also supports +various security features. The external interfaces include SDIO, SPI, UART, +I2C, IR remote, PWM, ADC, DAC, PIR and GPIO. + +This WB2 (BL602) 12F format Module Development Board features a SiFive E24 32 bit +RISC-V CPU with FPU, it supports High Frequency clock up to 192Mhz, have 128k ROM, 276kB RAM, +2.4 GHz WIFI 1T1R mode, support 20 MHz, data rate up to 72.2 Mbps, BLE 5.0 +with 2MB phy. It is a secure MCU which supports Secure boot, ECC-256 signed +image, QSPI/SPI Flash On-The-Fly AES Decryption and PKA (Public Key +Accelerator). + +Hardware +******** + +For more information about the Bouffalo Lab BL-60x MCU: + +- `Bouffalo Lab BL60x MCU Website`_ +- `Bouffalo Lab BL60x MCU Datasheet`_ +- `Bouffalo Lab Development Zone`_ +- `ai_wb2_12f Schematics`_ +- `The RISC-V BL602 Book`_ + +Supported Features +================== + +.. zephyr:board-supported-hw:: + +System Clock +============ + +The WB2 (BL602) Development Board is configured to run at max speed (192MHz). + +Serial Port +=========== + +The ``ai_wb2_12f`` board uses UART0 as default serial port. It is connected +to USB Serial converter and port is used for both program and console. + + +Programming and Debugging +************************* + +Samples +======= + +#. Build the Zephyr kernel and the :zephyr:code-sample:`hello_world` sample +application: + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: ai_wb2_12f + :goals: build flash + +#. Run your favorite terminal program to listen for output. Under Linux the + terminal should be :code:`/dev/ttyUSB0`. For example: + + .. code-block:: console + + $ screen /dev/ttyUSB0 115200 + + The -o option tells minicom not to send the modem initialization + string. Connection should be configured as follows: + + - Speed: 115200 + - Data: 8 bits + - Parity: None + - Stop bits: 1 + + Then, press and release RST button + + .. code-block:: console + + *** Booting Zephyr OS build v4.1.0 *** + Hello World! ai_wb2_12f/bl602c00q2i + +Congratulations, you have ``ai_wb2_12f`` configured and running Zephyr. + + +.. _Bouffalo Lab BL60x MCU Website: + https://en.bouffalolab.com/product/?type=detail&id=6 + +.. _Bouffalo Lab BL60x MCU Datasheet: + https://github.com/bouffalolab/bl_docs/tree/main/BL602_DS/en + +.. _Bouffalo Lab Development Zone: + https://dev.bouffalolab.com/home?id=guest + +.. _ai_wb2_12f Schematics: + https://docs.ai-thinker.com/en/wb2 + +.. _The RISC-V BL602 Book: + https://lupyuen.github.io/articles/book + +.. _Flashing Firmware to BL602: + https://lupyuen.github.io/articles/book#flashing-firmware-to-bl602 diff --git a/boards/aithinker/ai_wb2_12f/support/bl60x.cfg b/boards/aithinker/ai_wb2_12f/support/bl60x.cfg new file mode 100644 index 00000000000..fcabb2c4e7c --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/support/bl60x.cfg @@ -0,0 +1,79 @@ +# Copyright (c) 2022-2025 ATL Electronics +# +# SPDX-License-Identifier: Apache-2.0 + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME riscv +} + +if { [info exists WORKAREASIZE] } { + set _WORKAREASIZE $WORKAREASIZE +} else { + set _WORKAREASIZE 0x10000 +} + +if { [info exists WORKAREAADDR] } { + set _WORKAREAADDR $WORKAREAADDR +} else { + set _WORKAREAADDR 0x22020000 +} + +if { [info exists CPUTAPID] } { + set _CPUTAPID $CPUTAPID +} else { + set _CPUTAPID 0x20000c05 +} + +transport select jtag +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $_CPUTAPID + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME + +$_TARGETNAME.0 configure -work-area-phys $_WORKAREAADDR -work-area-size $_WORKAREASIZE -work-area-backup 1 + +echo "Ready for Remote Connections" + +$_TARGETNAME.0 configure -event reset-assert-pre { + echo "reset-assert-pre" + adapter speed 100 +} + +$_TARGETNAME.0 configure -event reset-deassert-post { + echo "reset-deassert-post" + + adapter speed 100 + + reg mstatus 0x7800 + reg mie 0x0 +# reg pc 0x23000000 +} + +$_TARGETNAME.0 configure -event reset-init { + echo "reset-init" + + adapter speed 3000 +} + +$_TARGETNAME.0 configure -event gdb-attach { + echo "Debugger attaching: halting execution" + reset halt + gdb_breakpoint_override hard +} + +$_TARGETNAME.0 configure -event gdb-detach { + echo "Debugger detaching: resuming execution" + resume +} + +gdb_memory_map enable +gdb_flash_program enable + +# 'progbuf', 'sysbus' or 'abstract' +riscv set_mem_access sysbus +riscv set_command_timeout_sec 1 + +init +reset init diff --git a/boards/aithinker/ai_wb2_12f/support/openocd.cfg b/boards/aithinker/ai_wb2_12f/support/openocd.cfg new file mode 100644 index 00000000000..9a3b1644e96 --- /dev/null +++ b/boards/aithinker/ai_wb2_12f/support/openocd.cfg @@ -0,0 +1,5 @@ +# For WCH linkE in DAP mode + +interface cmsis-dap + +adapter speed 1000 diff --git a/boards/aithinker/index.rst b/boards/aithinker/index.rst new file mode 100644 index 00000000000..cdefd628132 --- /dev/null +++ b/boards/aithinker/index.rst @@ -0,0 +1,10 @@ +.. _boards-aithinker: + +Ai-Thinker Co. +############## + +.. toctree:: + :maxdepth: 1 + :glob: + + **/*