Skip to content

Contributed by WangChong, curated by Ai-Thinker

Bouffalo Lab recently updated the MAC toolchain, so now you can use a Mac to compile and develop for the Xiao An Pai. Through my own exploration, I successfully configured it and flashed successfully. Next, I'll provide a detailed step-by-step tutorial.

Operation Steps

1
Clone the macOS toolchain
git clone https://github.com/bouffalolab/toolchain_gcc_t-head_macos.git
2
Modify the project Makefile

Modify the Makefile of the project you want to compile to point to your local SDK and toolchain:

SDK_DEMO_PATH ?= .
BL_SDK_BASE ?= /Users/aiden/bouffalo_sdk
export BL_SDK_BASE
CHIP ?= bl616
BOARD ?= bl616dk
CROSS_COMPILE ?= /Users/aiden/Documents/toolchain_gcc_t-head_macos/bin/riscv64-unknown-elf-
# add custom cmake definition
#cmake_definition+=-Dxxx=sss
include $(BL_SDK_BASE)/project.build
3
Modify bflb_flash.cmake to force the macOS tool

Modify the bflb_flash.cmake in the cmake directory of your toolchain to force bflb_fw_post_proc to use MACOS, otherwise the system will identify it as Ubuntu:

if(MINGW OR CYGWIN OR WIN32)
    set(TOOL_SUFFIX ".exe")
elseif(UNIX)
    set(TOOL_SUFFIX "-ubuntu")
elseif(APPLE)
    set(TOOL_SUFFIX "-macos")
endif()
# Modify this line of code to force the use of macos, instead of the system detection above. If not forced, it may be recognized as ubuntu.
set(BL_FW_POST_PROC ${BL_SDK_BASE}/tools/bflb_tools/bflb_fw_post_proc/bflb_fw_post_proc-macos)
set(BL_FW_POST_PROC_CONFIG --chipname=${CHIP} --imgfile=${BIN_FILE})
if(BOARD_DIR)
    list(APPEND BL_FW_POST_PROC_CONFIG --brdcfgdir=${BOARD_DIR}/${BOARD}/config)
else()
    list(APPEND BL_FW_POST_PROC_CONFIG --brdcfgdir=${BL_SDK_BASE}/bsp/board/${BOARD}/config)
endif()
if(CONFIG_AES_KEY)
    list(APPEND BL_FW_POST_PROC_CONFIG --key=${CONFIG_AES_KEY})
endif()
if(CONFIG_AES_IV)
    list(APPEND BL_FW_POST_PROC_CONFIG --iv=${CONFIG_AES_IV})
endif()
if(CONFIG_PUBLIC_KEY)
    list(APPEND BL_FW_POST_PROC_CONFIG --publickey=${CONFIG_PUBLIC_KEY})
endif()
if(CONFIG_PRIVATE_KEY)
    list(APPEND BL_FW_POST_PROC_CONFIG --privatekey=${CONFIG_PRIVATE_KEY})
endif()
if(CONFIG_FW_POST_PROC_CUSTOM)
    list(APPEND BL_FW_POST_PROC_CONFIG ${CONFIG_FW_POST_PROC_CUSTOM})
endif()
add_custom_target(combine
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMAND ${BL_FW_POST_PROC} ${BL_FW_POST_PROC_CONFIG})
4
Compile

Compile

5
Flash

Flash

6
Test

Test

Have questions?

For other questions, please visit the unified discussion area: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-09-11 14:52:23