当前位置: 首页 > article >正文

STM32F407移植OpenHarmony笔记4

上一篇写到make menuconfig报错,继续开整。

make menuconfig需要/device/soc/*下面有对应的Kconfig文件。
直接去gitee下载stm32的配置文件拿来参考用。
先提取Kconfig文件,后面再添加其它文件。https://gitee.com/openharmony/device_soc_st/tree/OpenHarmony-v3.2-Beta5/icon-default.png?t=N7T8https://gitee.com/openharmony/device_soc_st/tree/OpenHarmony-v3.2-Beta5/

soc下的目录结构如下: 

└── soc
    └── st
        ├── Kconfig.liteos_m.defconfig
        ├── Kconfig.liteos_m.series
        ├── Kconfig.liteos_m.soc
        └── stm32f4xx
            ├── Kconfig.liteos_m.defconfig.series
            ├── Kconfig.liteos_m.defconfig.stm32f4xx
            ├── Kconfig.liteos_m.series
            └── Kconfig.liteos_m.soc

Kconfig.liteos_m.soc会在菜单里添加st这个SOC_COMPANY
还会扫描子目录下的Kconfig.liteos_m.soc,
在stm32f4xx子目录下面的这个文件又向菜单添加SOC_STM32F407

Kconfig.liteos_m.series扫描子目录下的同名文件,
在stm32f4xx子目录里的这个文件又向菜单添加SOC_SERIES_STM32F4xx


再次测试make menuconfig还是会报错:

warning: <choice> (defined at arch/arm/Kconfig:34) defined with type unknown

根据错误提示并找不到问题在哪,
最后发现Makefile需要/vendor/demo/hello/kernel_configs/debug.config文件,空文件就行。

进入Platform选择 Soc和stm32f407。

Compat菜单下,选择newlibc 

配置完菜单后,配置保存在.config,并生成config.h文件,
同时还会向/vendor/demo/hello/kernel_configs/debug.config写入一部分配置内容。


再次编译看看报什么错:

[OHOS INFO] ERROR at //kernel/liteos_m/BUILD.gn:140:18: Unable to load "/home/openharmony/device/board/demo/BUILD.gn".

根据错误,添加BUILD.gn

# /device/board/demo/BUILD.gn
# https://kerndev.blog.csdn.net/

import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
module_group(module_name) {
    modules = [ "demo_board" ]
}

再次测试,继续根据错误提示,添加以下文件:

/home/openharmony/device/soc/st/BUILD.gn
/home/openharmony/device/soc/st/stm32f4xx/BUILD.gn
/home/openharmony/device/board/demo/demo_board/BUILD.gn
/home/openharmony/vendor/demo/hello/BUILD.gn
/home/openharmony/device/soc/st/stm32f4xx/sdk/BUILD.gn
/home/openharmony/device/soc/st/stm32f4xx/sdk/Drivers
/home/openharmony/device/soc/st/stm32f4xx/sdk/hals

然后再次编译错误是:

[OHOS ERROR] ../../../device/soc/st/stm32f4xx/sdk/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c:302:10: fatal error: stm32f4xx_hal.h: No such file or directory
[OHOS ERROR]   302 | #include "stm32f4xx_hal.h"
[OHOS ERROR]       |          ^~~~~~~~~~~~~~~~~
[OHOS ERROR] compilation terminated.

这个问题就是BUILD.gn里面没有正确配置include的路径。
打开bsp/BUILD.gn抄一段config():

config("public") {
  defines = [
    "STM32F407xx",
    "STM32F40_41xxx",
  ]
  include_dirs = [
    "include",
    "//device/soc/st/stm32f4xx/sdk/Core/Inc",
    "//device/soc/st/stm32f4xx/sdk/Drivers/STM32F4xx_HAL_Driver/Inc",
    "//device/soc/st/stm32f4xx/sdk/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
    "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr",
  ]
  ldflags = [
    "-Wl,-T" + rebase_path("ld/STM32F407IG_FLASH.ld"),
    "-Wl,-u_printf_float",
  ]
  libs = [
    "c",
    "m",
    "nosys",
  ]
}

这里面有defines预定义2个宏,include_dirs添加头文件路径,
ldflags定义链接脚本路径,libs添加要链接的基本库。


再次编译报错,还要添加/device/demo/demo_board/liteos_m/bsp/include/target_config.h文件。

[OHOS ERROR] ../../../kernel/liteos_m/kernel/include/los_config.h:40:10: fatal error: target_config.h: No such file or directory
[OHOS ERROR]    40 | #include "target_config.h"
[OHOS ERROR]       |          ^~~~~~~~~~~~~~~~~
[OHOS ERROR] compilation terminated.

再次编译报错:bool没定义,这个问题就不是我们的配置问题了,
把源码里的bool改为int,或者在源码内#include <stdbool.h>

[OHOS ERROR] ../../../kernel/liteos_m/components/fs/vfs/vfs_fs.c:214:43: error: unknown type name 'bool'
[OHOS ERROR]   214 | static int VfsPathCheck(const char *path, bool isFile)

再次编译找不到STM32F407IG_FLASH.ld文件,按提示添加这个文件。
最后再次编译通过:

[OHOS INFO] ---------------------------------------------
[OHOS INFO] ccache summary:
[OHOS INFO] cache hit (direct)  : 0
[OHOS INFO] cache hit (preprocessed)  : 0
[OHOS INFO] cache miss  : 0
[OHOS INFO] hit rate:  0.00% 
[OHOS INFO] mis rate: 0.00% 
[OHOS INFO] ---------------------------------------------
[OHOS INFO] c targets overlap rate statistics
[OHOS INFO] subsystem           files NO.       percentage      builds NO.      percentage      overlap rate
[OHOS INFO] kernel                    48        40.3%         48        40.3%   1.00
[OHOS INFO] securec                   39        32.8%         39        32.8%   1.00
[OHOS INFO] third_party               40        33.6%         40        33.6%   1.00
[OHOS INFO] thirdparty                40        33.6%         40        33.6%   1.00
[OHOS INFO] 
[OHOS INFO] c overall build overlap rate: 1.00
[OHOS INFO] 
[OHOS INFO] 
[OHOS INFO] hello build success
[OHOS INFO] cost time: 0:00:03
root@86cd4274494f:/home/openharmony# 

虽然编译通过,但产生的OHOS_Image.bin还不能运行,明天继续。


http://www.kler.cn/a/226429.html

相关文章:

  • [Python] 什么是PCA降维技术以及scikit-learn中PCA类使用案例(图文教程,含详细代码)
  • sudo用户添加/切换及授予权限
  • github上传代码遇到的问题
  • HTML 相关知识点记录
  • Datax3.0+DataX-Web部署分布式可视化ETL系统
  • 2021-10-14 51蛋骗鸡1秒变动0-9按键控制并蜂鸣器响
  • 【NLP冲吖~】一、朴素贝叶斯(Naive Bayes)
  • Android11+ 如何获得外部存储权限
  • QT播放gstreamer命令(三)---使用QMediaPlayer
  • 干旱绿洲农田无核白葡萄树蒸散发的分割研究_王尚涛_2021
  • 页面切换导致echarts不加载的问题
  • GmSSL - GmSSL的编译、安装和命令行基本指令
  • JavaScript-本地存储
  • 2024年美赛数学建模A题思路分析 - 资源可用性和性别比例
  • idea 中 tomcat 乱码问题修复
  • 新版MQL语言程序设计:装饰器模式的原理、应用及代码实现
  • interface转string输出打印
  • 【Vue】vue项目中使用tinymce富文本组件(@tinymce/tinymce-vue)
  • centos 7 部署若依前后端分离项目
  • 【手写数据库toadb】toadb表对象访问操作,存储管理抽象层软件架构设计思想应用