Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions boards/aithinker/ai_m62_12f/Kconfig.ai_m62_12f
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
#
# SPDX-License-Identifier: Apache-2.0

config BOARD_AI_M62_12F
select SOC_BL616C50Q2I
26 changes: 26 additions & 0 deletions boards/aithinker/ai_m62_12f/ai_m62_12f-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <dt-bindings/pinctrl/bl616x-pinctrl.h>

&pinctrl {
uart0_default: uart0_default {
group1 {
pinmux = <GPIO22_UART0_RX>,
<GPIO21_UART0_TX>;
bias-pull-up;
input-schmitt-enable;
};
};

uart0_sleep: uart0_sleep {
group1 {
pinmux = <GPIO22_UART0_RX>,
<GPIO21_UART0_TX>;
bias-high-impedance;
};
};
};
63 changes: 63 additions & 0 deletions boards/aithinker/ai_m62_12f/ai_m62_12f.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <bflb/bl616.dtsi>
#include "ai_m62_12f-pinctrl.dtsi"

/ {
model = "Ai-Thinker M62-12F development board";
compatible = "bflb,bl616";

chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
zephyr,itcm = &sram1;
zephyr,sram = &sram0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
};
};

&cpu0 {
clock-frequency = <DT_FREQ_M(320)>;
};

&flashctrl {
flash0: flash@A0000000 {
compatible = "soc-nv-flash", "gd,25lq32d";
reg = <0xA0000000 (0x400000 - 0x2000)>;
write-block-size = <256>;
erase-block-size = <DT_SIZE_K(4)>;

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

slot0_partition: partition@0 {
label = "image-0";
reg = <0x00000000 0x00100000>;
read-only;
};

storage_partition: partition@100000 {
label = "storage";
reg = <0x00100000 (0x300000 - 0x2000)>;
};
};
};
};

&uart0 {
status = "okay";
current-speed = <115200>;

pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
};
19 changes: 19 additions & 0 deletions boards/aithinker/ai_m62_12f/ai_m62_12f.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
#
# SPDX-License-Identifier: Apache-2.0

identifier: ai_m62_12f
name: Ai-Thinker M62-12F development board
type: mcu
arch: riscv
ram: 480
toolchain:
- zephyr
testing:
ignore_tags:
- net
- bluetooth
supported:
- pinctrl
- uart
vendor: bflb
8 changes: 8 additions & 0 deletions boards/aithinker/ai_m62_12f/ai_m62_12f_defconfig
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions boards/aithinker/ai_m62_12f/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2024-2025 MASSDRIVER EI (massdriver.space)
#
# SPDX-License-Identifier: Apache-2.0

board_runner_args(openocd --cmd-pre-init "source [find bl61x.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 0x22FC0000 0x23010000 rw")
board_runner_args(openocd --gdb-init "mem 0x62FC0000 0x63010000 rw")
board_runner_args(openocd --gdb-init "mem 0x90000000 0x90020000 ro")
board_runner_args(openocd --gdb-init "mem 0xA8000000 0xA8800000 rw")
board_runner_args(openocd --gdb-init "mem 0xA0000000 0xA0400000 ro")
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

board_runner_args(bflb_mcu_tool --chipname bl616)
include(${ZEPHYR_BASE}/boards/common/bflb_mcu_tool.board.cmake)

board_set_flasher(bflb_mcu_tool)
6 changes: 6 additions & 0 deletions boards/aithinker/ai_m62_12f/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
board:
name: ai_m62_12f
full_name: Ai-Thinker M62-12F development board
vendor: aithinker
socs:
- name: bl616c50q2i
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions boards/aithinker/ai_m62_12f/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
.. zephyr:board:: ai_m62_12f

Overview
********

Ai-M62-12F is a Wi-Fi 6 + BLE5.3 module developed by Shenzhen Ai-Thinker Technology
Co., Ltd. The module is equipped with BL616 chip as the core processor, supports Wi-Fi
802.11b/g/n/ax protocol and BLE protocol, and supports Thread protocol. The BL616 system
includes a low-power 32-bit RISC-V CPU with floating-point unit, DSP unit, cache and
memory, with a maximum dominant frequency of 320M.

Hardware
********

For more information about the Bouffalo Lab BL-60x MCU:

- `Bouffalo Lab BL61x MCU Datasheet`_
- `Bouffalo Lab Development Zone`_
- `ai_m62_12f Schematics`_

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_m62_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_m62_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.2.0 ***
Hello World! ai_m62_12f/bl616c50q2i

Congratulations, you have ``ai_m62_12f`` configured and running Zephyr.


.. _Bouffalo Lab BL61x MCU Datasheet:
https://github.com/bouffalolab/bl_docs/tree/main/BL616_DS/en

.. _Bouffalo Lab Development Zone:
https://dev.bouffalolab.com/home?id=guest

.. _ai_m62_12f Schematics:
https://docs.ai-thinker.com/en/ai_m62/
80 changes: 80 additions & 0 deletions boards/aithinker/ai_m62_12f/support/bl61x.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
#
# 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 0x40000000
}

if { [info exists CPUTAPID] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x10000b6f
}

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 0

echo "Ready for Remote Connections"

$_TARGETNAME.0 configure -event reset-assert-pre {
echo "reset-assert-pre"
adapter speed 400
}

$_TARGETNAME.0 configure -event reset-deassert-post {
echo "reset-deassert-post"

adapter speed 400

reg mstatus 0x7880
reg mie 0
}

$_TARGETNAME.0 configure -event reset-init {
echo "reset-init"

adapter speed 400
reg mstatus 0x1880
reg mie 0
reg pc 0xA0000000
}

$_TARGETNAME.0 configure -event gdb-attach {
echo "Debugger attaching: halting execution"
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
5 changes: 5 additions & 0 deletions boards/aithinker/ai_m62_12f/support/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# For WCH linkE in DAP mode

interface cmsis-dap

adapter speed 400
1 change: 1 addition & 0 deletions drivers/clock_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL clock_con
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_LFCLK clock_control_nrf_lfclk.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_AUXPLL clock_control_nrf_auxpll.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_BOUFFALOLAB_BL60X clock_control_bl60x.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_BOUFFALOLAB_BL61X clock_control_bl61x.c)

if(CONFIG_CLOCK_CONTROL_RENESAS_RZA2M_CPG)
zephyr_library_sources(clock_control_renesas_rza2m_cpg.c)
Expand Down
5 changes: 5 additions & 0 deletions drivers/clock_control/Kconfig.bflb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ config CLOCK_CONTROL_BOUFFALOLAB_BL60X
bool "Bouffalolab BL60x Clock Control"
default y
depends on DT_HAS_BFLB_BL60X_CLOCK_CONTROLLER_ENABLED

config CLOCK_CONTROL_BOUFFALOLAB_BL61X
bool "Bouffalolab BL61x Clock Control Driver"
default y
depends on DT_HAS_BFLB_BL61X_CLOCK_CONTROLLER_ENABLED
Loading