Skip to content

Contributed by oxromantic, curated by Ai-Thinker

(Note: the process should be the same for Intel Macs, since the flashing binary is x86 architecture)

Prerequisites: You have already prepared the AiPi-Open-Kits directory following the Linux beginner tutorial, up to the ". install.sh" step. Do NOT run ". export.sh".

Hidden content of this post

If you already ran it, just reopen your terminal

First, follow the Mac toolchain compilation tutorial to build the toolchain. It requires pulling 7-8GB of code; compilation is relatively fast, and it takes about several hours in total. Tutorial link:

  1. https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md

After compilation, you will get a toolchain of about 890MB under /opt/riscv-toolchain/xuantie. It cannot be used to compile directly yet; switch to the "AiPi-Open-Kits" directory.

Modification 1:

text
# File aithinker_Ai-M6X_SDK/cmake/bflb_flash.cmake, replace ubuntu with macos

if(MINGW OR CYGWIN OR WIN32) set(TOOL_SUFFIX ".exe") elseif(UNIX) set(TOOL_SUFFIX "-macos") endif()

Modification 2:

text
# aithinker_Ai-M6X_SDK/export.sh, replace everything

export PATH=PATH:/opt/riscvtoolchain/xuantie/binexportPATH=(brew --prefix)/opt/coreutils/libexec/gnubinPATH

export PATH=$PATHPWD/toolchain/bin echo $PATH riscv64-unknown-elf-gcc -v chmod 755 $PWD/tools/cmake/bin/cmake chmod 755 $PWD/tools/bflb_tools/bouffalo_flash_cube/BLFlashCommand-macos chmod 755 $PWD/tools/bflb_tools/bflb_fw_post_proc/bflb_fw_post_proc-macos

The smiley face is : $ (remove the space) Finally, run ". export.sh" and your compilation environment is ready. Now switch to helloworld and run the following command to compile and flash:

bash
make flash COMX=/dev/tty.usbserial-2130

11.22 Update: I uploaded a precompiled version. Since the total size exceeds 100MB and cannot be uploaded, it is split into two packages; extract and merge them yourself. The directory structure for reference is:

bflb_flash.cmake bin export.sh include lib libexec riscv64-unknown-elf share

The two files that need extra editing (bflb_flash.cmake and export.sh) are also included in this package; just replace the files with the same names in AiPi-Open-Kits yourself.

This toolchain should be placed under /opt/riscv-toolchain/xuantie by default (because export.sh points to this path). Theoretically you can also replace the AiPi-Open-Kits/aithinker_Ai-M6X_SDK/toolchain directory, so that when editing export.sh manually you don't need to modify the PATH-related information. It's up to you.

https://wwzb.lanzoue.com/b058nazcj

Password:

Hidden content of this post

https://wwzb.lanzoue.com/b058nazcj

Password: 87fw

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