lcd_ov5640 demo编译出现link错误



    1. kendryte相关软件栈版本号

    kendryte-gnu-toolchain
    branch: develop
    latest commit: fbf55383711b68c00ecf67e23959822180010398
    Author: sunnycase sunnycase@live.cn
    Date: Tue Feb 12 21:01:14 2019 +0800
    Update newlib

    kendryte-freertos-sdk
    branch: develop
    latest commit: b6bcf59355c410daa8b4038cc1d0cb15b691e981
    Author: Huang Rui vowstar@gmail.com
    Date: Tue Mar 19 13:10:31 2019 +0800
    Add apache 2.0 license badge
    Signed-off-by: Huang Rui vowstar@gmail.com

    kendryte-freertos-demo
    branch: develop
    latest commit: e86330d5be27293d88f283952a88567aa2b767bb
    Author: jiangxiangbing jiangxiangbing@canaan-creative.com
    Date: Fri Mar 15 17:02:52 2019 +0800
    modify spi slave demo

    1. 出现的问题描述
      编译kendryte-freertos-demo/lcd_ov5640项目,出现编译错误:
    [100%] Linking C executable lcd_ov5640
    /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: CMakeFiles/lcd_ov5640.dir/kendryte-freertos-demo/lcd_ov5640/dvp_camera.c.obj: can't link hard-float modules with soft-float modules
    /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file CMakeFiles/lcd_ov5640.dir/kendryte-freertos-demo/lcd_ov5640/dvp_camera.c.obj
    /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: CMakeFiles/lcd_ov5640.dir/kendryte-freertos-demo/lcd_ov5640/jlt32009a.c.obj: can't link hard-float modules with soft-float modules
    /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file 
    ......
    collect2: error: ld returned 1 exit status
    CMakeFiles/lcd_ov5640.dir/build.make:151: recipe for target 'lcd_ov5640' failed
    make[2]: *** [lcd_ov5640] Error 1
    CMakeFiles/Makefile2:78: recipe for target 'CMakeFiles/lcd_ov5640.dir/all' failed
    make[1]: *** [CMakeFiles/lcd_ov5640.dir/all] Error 2
    Makefile:83: recipe for target 'all' failed
    make: *** [all] Error 2
    
    1. 复现方法

    (1) toolchain编译

    ./configure --prefix=/opt/kendryte-toolchain --with-cmodel=medany           
    make
    

    (2) lcd_ov5640编译

    cmake .. -DPROJ=kendryte-freertos-demo/lcd_ov5640 -DTOOLCHAIN=/opt/kendryte-toolchain/bin
    make
    


  • 😟 kendryte-tensorflow也有同样的问题。补丁:

    diff --git a/tensorflow/lite/tools/make/targets/kendryte_makefile.inc b/tensorflow/lite/tools/make/targets/kendryte_makefile.inc
    index 712e314..c84a58a 100644
    --- a/tensorflow/lite/tools/make/targets/kendryte_makefile.inc
    +++ b/tensorflow/lite/tools/make/targets/kendryte_makefile.inc
    @@ -1,19 +1,21 @@
     # Settings for Kendryte platforms.
     ifeq ($(TARGET), kendryte)
    -  TARGET_ARCH := rv64imafdc
    +  TARGET_ARCH := rv64imafc
       TARGET_TOOLCHAIN_PREFIX := riscv64-unknown-elf-
     
       CXXFLAGS += \
       -ffunction-sections \
       -fdata-sections \
       -mcmodel=medany \
    -  -march=rv64imafdc \
    +  -mabi=lp64f \
    +  -march=rv64imafc \
       -fno-common
       CCFLAGS += \
       -ffunction-sections \
       -fdata-sections \
       -mcmodel=medany \
    -  -march=rv64imafdc \
    +  -mabi=lp64f \
    +  -march=rv64imafc \
       -fno-common
            LIBS += -ldl
     endif
    
    


  • 已解决!

    原因分析:
    SDK编译选项含:
    march=rv64imafc mabi=lp64f
    gnu工具链的configure文件默认设定的选项:
    --with-arch=rv64imafdc --with-abi=lp64d
    二者不一致导致问题。

    解决方法:
    因为已经取消掉D扩展,所以配置gnu工具链:

    ./configure --prefix=/opt/kendryte-toolchain --with-cmodel=medany --with-arch=rv64imafc --with-abi=lp64f
    

    后续问题:

    1. march=rv64imafc mabi=lp64f组合不存在于kendryte-gnu-toolchain/riscv-gcc/gcc/config/riscv/t-elf-multilib文件中,有没有潜在问题?
    2. 将D扩展取消之后,为什么不直接用march=rv32imafc mabi=ilp32f组合?

    谢谢!