Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    D1-H 开发板带 math.h 编译 Uboot 报错

    D1系列-RISC-V
    2
    6
    287
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      dongyuetu LV 3 last edited by zhoujunkai00000

      问题:

      • 在 Uboot 中的 cmd 文件夹下添加了一个 whetstone.c 文件,里面包含了 math.h ,调用了 sin、cos、atan 之类的函数。
      • 修改了 Makefile 使其会去编译这个 .c 文件。
      • 编译会报
      /brandy-2.0/u-boot-2018/cmd/sunxi_svudata.c:24: undefined reference to `sin'
      

      我做了什么:

      • 在 Uboot 的 cmd 文件夹下的 Makefile 中添加
      obj-y += benchmark/whetstone/whetstone.o
      
      • 删除 Makefile 里的 NOSTDINC_FLAGS 。
      • 在 CC 宏的 gcc 后面加了个 -lm
      • 修改了 Makefile 里的 CROSS_COMPILE ,修改为 prebuilt 中的那个编译链。
      • 删除了 /u-boot-2018/include/log.h 中的 log 宏

      我试了什么:

      • 在 Makefile 的 PLATFORM_LIBGCC 后面加了个 -lm 。
      • 在 Makefile 的 PLATFORM_LIBGCC 后面用 -L 指定了 libm.a 的目录
        • 尝试了 prebuild 目录中 sysroot 下, lib64/lib64vxthread/lib64xthread 目录下的 lib64 和 lib64d/v 。
        • 这种时候会报:
      /toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702/sysroot/usr/lib64/lp64d/libm.a: error adding symbols: bad value
      

      但是我直接自己写个 helloworld 带 math.h 用同一个工具链编译之后,丢到板子里在 linux 上跑,又完全没问题。

      编译报错的 sunxi_svudata.c 这个文件是全志自己的文件,而且我看了一下 24 行也没有 sin 这个函数的调用。

      有没有大佬知道这是个什么情况?

      YuzukiTsuru 1 Reply Last reply Reply Quote Share 0
      • YuzukiTsuru
        柚木 鉉 LV 9 @zhoujunkai00000 last edited by

        @zhoujunkai00000 是增加package吗

        Z 1 Reply Last reply Reply Quote Share 0
        • Z
          dongyuetu LV 3 @YuzukiTsuru last edited by

          @yuzukitsuru 在 D1-H 开发板带 math.h 编译 Uboot 报错 中说:

          增加packag

          不是的。
          math.h 是 gcc 自带的一个库,提供一些 sin、log、sqrt 之类的函数。

          我只是想在 Uboot 里调这些函数。但是编译会报错。

          YuzukiTsuru 1 Reply Last reply Reply Quote Share 0
          • YuzukiTsuru
            柚木 鉉 LV 9 @zhoujunkai00000 last edited by

            @zhoujunkai00000 Linux里可以运行但是Uboot无法运行吧

            Z 1 Reply Last reply Reply Quote Share 0
            • Z
              dongyuetu LV 3 @YuzukiTsuru last edited by

              @yuzukitsuru

              不是的,Uboot 是根本编译不过。

              { Uboot } 和 { Linux 里的 elf } 用的是同一套编译工具。

              1 Reply Last reply Reply Quote Share 0
              • YuzukiTsuru
                柚木 鉉 LV 9 last edited by

                了解了,现在先自己实现下用到的函数吧,之后我复现一下错误

                1 Reply Last reply Reply Quote Share 0
                • 1 / 1
                • First post
                  Last post

                Copyright © 2022 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

                行为准则 | 用户协议 | 隐私权政策