发帖
16 0 0

【首发?】Mac M1 编译原生toolchain以及配置烧录支持

oxromantic
注册会员

1

主题

4

回帖

118

积分

注册会员

积分
118
本帖最后由 oxromantic 于 2023-11-22 23:54 编辑

(说明:按流程Intel Mac应该同理,因为烧录的binary是x86架构)
前提:
你已经按Linux的新手教程准备好了AiPi-Open-Kits目录,步骤到 ". install.sh", 不要执行 ". export.sh",
游客,如果您要查看本帖隐藏内容请回复


首先按照Mac toolchain编译教程编译好toolchain,需要拉取7-8G的代码,编译比较快,总共耗时大概数小时,教程地址:

  1. https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md
复制代码
编译完成后,你将得到 /opt/riscv-toolchain/xuantie 下 890MB左右的toolchain,此时还不能直接编译,切换到 "AiPi-Open-Kits" 目录下

修改1:
  1. # 文件 aithinker_Ai-M6X_SDK/cmake/bflb_flash.cmake 替换ubuntu为macos
复制代码
if(MINGW OR CYGWIN OR WIN32)
set(TOOL_SUFFIX ".exe")
elseif(UNIX)
set(TOOL_SUFFIX "-macos")
endif()

修改2:
  1. # aithinker_Ai-M6X_SDK/export.sh 全部替换
复制代码
export PATH=$PATH:/opt/riscv-toolchain/xuantie/bin
export PATH=$(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

笑脸表情是 : $ 去掉空格
最后,执行 ". export.sh" 你的编译环境已经就绪,此时切换到helloworld, 执行下面命令即可编译&烧录
  1. make flash COMX=/dev/tty.usbserial-2130
复制代码

11.22 更新:
上传了预编译版本,因为整体超过100M不支持上传,拆分2个包,解压后自行合并,目录结构参考
bflb_flash.cmake  bin  export.sh  include  lib        libexec  riscv64-unknown-elf  share

需要额外编辑的2个文件(bflb_flash.cmake 、export.sh)也放在这个包里,自行替换AiPi-Open-Kits里的同名文件即可

这个toolchain默认需要放在 /opt/riscv-toolchain/xuantie 下(因为export.sh里是指向这个路径),理论也可以替换AiPi-Open-Kits/aithinker_Ai-M6X_SDK/toolchain 目录,这样export.sh 手工编辑时就不用修改PATH相关信息,自行决定

https://wwzb.lanzoue.com/b058nazcj
密码:
游客,如果您要查看本帖隐藏内容请回复




──── 0人觉得很赞 ────

使用道具 举报

学习
2024-12-29 09:17:10
我的是编译环境是刷了linux的小米手机,架构是aarch64,试试看看能不能用
2024-9-14 15:53:46
学习一下
export PATH=$(brew --prefix)/opt/coreutils/libexec/gnubinPATH
这个是安装什么?

在helloword 里执行报错:
CMake Error at /Users/master/Documents/Electronic_Fever/MCU/aipi/AiPi-Open-Kits/aithinker_Ai-M6X_SDK/cmake/bouffalo_sdk-config.cmake:31 (enable_language):
  The CMAKE_C_COMPILER:

    riscv64-unknown-elf-gcc

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)


CMake Error at /Users/master/Documents/Electronic_Fever/MCU/aipi/AiPi-Open-Kits/aithinker_Ai-M6X_SDK/cmake/bouffalo_sdk-config.cmake:31 (enable_language):
  The CMAKE_CXX_COMPILER:

    riscv64-unknown-elf-g++

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)
学习学习
2023-12-10 10:43:26
优秀
2023-11-22 23:44:33
爱思 发表于 2023-11-22 22:26
编译toolchain报错日志很长,我截取最后的几行,大佬看看:

/bin/sh: line 4: riscv64-unknown-elf-ar: co ...

你这个大概率代码没拉完整,我前面全新环境重新编译了一下,代码目录含.git共有9G多,或者你用我编译好的吧,我编辑到主贴里
2023-11-22 22:26:47
本帖最后由 爱思 于 2023-11-22 22:30 编辑

编译toolchain报错日志很长,我截取最后的几行,大佬看看:

/bin/sh: line 4: riscv64-unknown-elf-ar: command not found
make[6]: *** [Makefile:1034: libc.a] Error 127
make[6]: Leaving directory '/Users/zx/AiPi/xuantie-gnu-toolchain/build-newlib/riscv64-unknown-elf/newlib/libc'
make[5]: *** [Makefile:683: all-recursive] Error 1
make[5]: Leaving directory '/Users/zx/AiPi/xuantie-gnu-toolchain/build-newlib/riscv64-unknown-elf/newlib/libc'
make[4]: *** [Makefile:641: all-recursive] Error 1
make[4]: Leaving directory '/Users/zx/AiPi/xuantie-gnu-toolchain/build-newlib/riscv64-unknown-elf/newlib'
make[3]: *** [Makefile:452: all] Error 2
make[3]: Leaving directory '/Users/zx/AiPi/xuantie-gnu-toolchain/build-newlib/riscv64-unknown-elf/newlib'
make[2]: *** [Makefile:8521: all-target-newlib] Error 2
make[2]: Leaving directory '/Users/zx/AiPi/xuantie-gnu-toolchain/build-newlib'
make[1]: *** [Makefile:908: all] Error 2
make[1]: Leaving directory '/Users/zx/AiPi/xuantie-gnu-toolchain/build-newlib'
make: *** [Makefile:587: stamps/build-newlib] Error 2

2023-11-22 20:04:12
linyuuki 发表于 2023-11-22 16:00
秀儿,编译结果发蓝奏云,懒得编译

等我脱敏重新编译一份吧
您需要登录后才可以回帖 立即登录
高级模式
12下一页
统计信息
  • 会员数: 31059 个
  • 话题数: 44945 篇