• 【MACOS(M1)编译Risc-v版OpenOCD】


    准备1

    • Installing the Mac OSX Command Line Tools, 输入:
    xcode-select --install 
    
    • 1
    • Install autoconf, automake, pkg-config, libtool and texinfo.
    brew install autoconf automake pkg-config libtool texinfo 
    
    • 1

    下载代码:

    git clone --recursive https://github.com/riscv/riscv-openocd.git
    
    • 1

    执行顺序

    进入到riscv-openocd目录下,执行:

    ./bootstrap
    ./configure
    make
    make install
    
    • 1
    • 2
    • 3
    • 4

    常见问题

    问题1: AC_PROG_CC_C99 告警2

    在执行./bootstrap的时候可能会报warning

    + aclocal --warnings=all
    + glibtoolize --automake --copy
    + autoconf --warnings=all
    + autoheader --warnings=all
    + automake --warnings=all --gnu --add-missing --copy
    Setting up submodules
    Generating build system...
    configure.ac:38: warning: The macro `AC_PROG_CC_C99' is obsolete.
    configure.ac:38: You should run autoupdate.
    ./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
    configure.ac:38: the top level
    Bootstrap complete. Quick build instructions:
    ./configure ....
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    这里提示configure.ac第38行有告警。开始以为是当前目录下的configure.ac文件有不兼容的问题。其实注释掉openocd-code/src/jtag/drivers/libjaylink/configure.ac.文件的第38行就可以了。

    修改后重新执行,log显示不再有告警:

    + aclocal --warnings=all
    + glibtoolize --automake --copy
    + autoconf --warnings=all
    + autoheader --warnings=all
    + automake --warnings=all --gnu --add-missing --copy
    Setting up submodules
    Generating build system...
    Bootstrap complete. Quick build instructions:
    ./configure ....
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    问题2: texinfo 版本不匹配

    brew install texinfo 后执行
    export PATH=“/opt/homebrew/opt/texinfo/bin:$PATH”

    问题2: libtool版本不匹配

    系统目录下/usr/bin/libtool版本较旧,我的是2.4.6
    用brew install libtool后会安装新的libtool,版本2.4.7,需要用环境变量执行新安装的目录。

    执行下面命令可以看到安装后的信息。

    > brew info libtool
    ...
    If you need to use these commands with their normal names, you
    can add a "gnubin" directory to your PATH from your bashrc like:
      PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
    
    • 1
    • 2
    • 3
    • 4
    • 5

    注意添加path后立即执行make是不生效的。原因是在config阶段会copy libtool到当前目录下,后面make阶段调用的都是当前目录下的libtool。这时需要手动删除当前目录下的libtool,然后重新执行./configure

    问题3: 编译错误

    编译产生如下错误:

    src/flash/nor/dsp5680xx_flash.c:48:11: error: variable 'offset' set but not used [-Werror,-Wunused-but-set-variable]
            uint32_t offset = HFM_FLASH_BASE_ADDR;
                     ^
    1 error generated.
    
    • 1
    • 2
    • 3
    • 4

    看起来是可以waive掉的问题。打开configure.ac文件,找到Werror的地方,注释的这个选项。如下:

    AS_IF([test "x${gcc_werror}" = "xyes"], [
       #GCC_WARNINGS="${GCC_WARNINGS} -Werror"
       GCC_WARNINGS="${GCC_WARNINGS}"
     ])
    
    • 1
    • 2
    • 3
    • 4

    验证一下

    > openocd --version
    Open On-Chip Debugger 0.11.0+dev-02377-g911d68ef2-dirty (2022-09-15-09:24)
    Licensed under GNU GPL v2
    For bug reports, read
    	http://openocd.org/doc/doxygen/bugs.html
    
    • 1
    • 2
    • 3
    • 4
    • 5

    显示已经安装成功了。


    1. https://www.mail-archive.com/autoconf@gnu.org/msg24261.html ↩︎

    2. https://www.mobilefish.com/developer/riscv/riscv_quickguide_build_riscv_openocd.html#:~:text=%20How%20to%20build%20RISC-V%20OpenOCD%20on%20macOS.,The%20following%20tools%20are%20required%3A%0Aautoconf%2C%20automake%2C…%20More%20 ↩︎

  • 相关阅读:
    CDH大数据平台 Role not started due to unhealthy host(多种解决方法)
    四、综合——通信系统
    (硬件设计)老工程师的经验之道
    遥测终端机RTU助力城市内涝监测系统
    程序媛小姐姐直播讲解第七周PHP上机作业
    计算机毕业设计——基于html汽车商城网站页面设计与实现论文源码ppt(35页) HTML+CSS+JavaScript
    JUC并发编程(一):Java内存模型(JMM)及三大特性:可见性、有序性、原子性
    贷记来帐、借记来帐、贷记往账、借记往账的区别
    剑指offer 38:字符串的排列
    超标量处理器设计 姚永斌 第6章 指令解码 摘录
  • 原文地址:https://blog.csdn.net/poena/article/details/126862190