2-Openwrt directory structure

Openwrt directory structure

了解Openwrt的目录结构是学习一个新系统最基础也是最重要的部分。试想如果你想加一行代码进行修复bug,却花了半个小时才找到相应的位置,那是多么悲催啊,所以懂得系统框架可以让你在开发过程不会跑偏、快速定位,让工程项目规范化等。

目录结构
如图是Openwrt的基本的目录结构,其中白色部分是直接下载源码就有的源目录,蓝色部分则是通过make之后产生的目录(其中feeds目录则是通过命令./scripts/feeds update -a;./scripts/feeds install -a之后安装的扩展包目录,这个目录将所有的文件链接到package/feeds/中去了),下面就对各目录进行简要说明。

1.tool和toolchain目录

编译固件image/获取内核头文件/二进制编译器和调试器/c库文件,需要用到的通用工具。

2.include目录

编译时的头文件索引,源码包就有,包含一些编译用的通用脚本和include宏定义。比较重要的包括:package.mk文件(几乎每个package目录中的模块的makefile中都提到它)

3.scripts目录

对openwrt的包进行管理的perl脚本,源码包就有,存放各类脚本的目录。比如:feeds脚本,使用.scripts/feeds update -a或者.scripts/feeds install -a,就可以对feeds.conf.default中列举的文件进行处理了。

4.target目录

包含了特定平台的文件,固件镜像和内核构建过程的索引,以及生成编译器各编译工具。

  • linux目录下为各个平台相应的内核patches,配置文件等;
  • imagebuilder目录则扫描如何生成这个平台的固件,源码包就有的,用来指导如何编译firmware和内核以及sdk的。
5.package目录和feeds目录

在openwrt中,基础的软件包目录为package,扩展的软件包在feeds中。

feeds中的软件扩展了openwrt的基本功能,它将所有的软件链接到package/feeds中。里面存放的就是按照 feeds.conf.default文件中列举的要处理的文件,所展开得到的目录。目录中存放的东西,和package目录中大致相似。指导如何下载和编译对应模块的。

这些软件大多数都是编译成.ipk格式的,这里面有内核模块文件,有各种软件的源码,以及patch文件和Makefile用来下载源码的。

6.dl目录

编译工具、目标、package所需要的软件包将从网上下载放到dl目录中

7.build_dir目录

一个临时目录,用来将所有需要编译的软件源码放到这个目录中进行编译。它包括一下三个目录:

  • build_dir/host: 与编译目标无关的工具的临时文件夹
  • build_dir/*: 作为所有目标,package编译的临时目录
  • build_dir/toolchain-*:编译特定体系的交叉编译链的文件夹
8.staging_dir目录

用于存放构建目标系统镜像的工具软件,包括:

  • staging_dir/host: 宿主系统使用的工具
  • staging_dir/*: 目标系统使用的软件软件包
  • staging_dir/
9.bin目录

make之后的新增目录,用来存放make的结果。比如我是用来编译ramips的,则此目录中会有:ramips子目录,其中又包含:packages子目录(里面含有各种.ipk文件,以及一个Packages文件用来介绍此目录中的每个ipk文件)和可以烧入CPE的openwrt-ramips-mt7620-xiaomi-miwifi-mini-squashfs-sysupgrade.bin文件。

10.其他文件
  • Makefile文件:make命令的总入口
  • rules.mk文件:定义了一系列在make时使用的规则
  • .config隐藏文件:make menuconfig后的config结果的存放文件。
  • .config.old隐藏文件:老的.config文件

Openwrt directory structure的分析就到这边,有感悟时会持续会更新。

注:以上内容都是本人在学习过程积累的一些心得,难免会有参考到其他文章的一些知识,如有侵权,请及时通知我,我将及时删除或标注内容出处,如有错误之处也请指出,进行探讨学习。文章只是起一个引导作用,详细的数据解析内容还请查看Linux相关教程,感谢您的查阅。

d/include -I/home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/../public/include -I/home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/include -I/home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/ubus -I/home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/onvif/include -ltrace_alloc -ldl -fno-omit-frame-pointer -I/home/x/nm/nvr_2025/torchlight/staging_dir/target-arm-openwrt-linux-uclibcgnueabihf/usr/include -c -o chm_dbg.o chm_dbg.c In file included from chm_dbg.c:18: /home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/include/chm_default.h:138: warning: "MAX_VER_LEN" redefined 138 | #define MAX_VER_LEN 64 | /home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/include/chm_default.h:131: note: this is the location of the previous definition 131 | #define MAX_VER_LEN 4 | chm_dbg.c: In function 'chm_trigger_access_nullptr': chm_dbg.c:251:5: error: unknown type name 'TEST_STRUCT' 251 | TEST_STRUCT *ts = NULL; | ^~~~~~~~~~~ chm_dbg.c:252:7: error: request for member 'val' in something not a structure or union 252 | ts->val = 1; | ^~ chm_dbg.c:253:16: error: request for member 'val' in something not a structure or union 253 | int value = ts->val; | ^~ <builtin>: recipe for target 'chm_dbg.o' failed make[4]: *** [chm_dbg.o] Error 1 make[4]: Leaving directory '/home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm' Makefile:185: recipe for target '/home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/.built' failed make[3]: *** [/home/x/nm/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/chm/.built] Error 2 make[3]: Leaving directory '/home/x/nm/nvr_2025/tp_package/u_packages/chm' package/Makefile:105: recipe for target 'package/tp_package/u_packages/chm/compile' failed make[2]: *** [package/tp_package/u_packages/chm/compile] Error 2 make[2]: Leaving directory '/home/x/nm/nvr_2025/torchlight' package/Makefile:101: recipe for target '/home/x/nm/nvr_2025/torchlight/staging_dir/target-arm-openwrt-linux-uclibcgnueabihf/stamp/.package_compile' failed make[1]: *** [/home/x/nm/nvr_2025/torchlight/staging_dir/target-arm-openwrt-linux-uclibcgnueabihf/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/x/nm/nvr_2025/torchlight' /home/x/nm/nvr_2025/torchlight/include/toplevel.mk:172: recipe for target 'world' failed make: *** [world] Error 2 报错
09-07
make "make -C modules/hub_manage MODULE_NAME=hub_manage" make[5]: Entering directory '/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/modules/hub_manage' mips-linux-gnu-gcc -Os -pipe -march=mips32r2 -g -I/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/usr/lib/libiconv-full/include -I/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/usr/lib/libintl-full/include -DTAPO_USR_DEF_AUDIO_ALARM -DCONFIG_STATISTIC_REPORT_DOMAIN=n-da.tplinkcloud.com.cn -DTELEMETRY_SUPPORT -DPTZ_SUPPORT=gpio -DUPNPC_ENABLE -DOPTIONAL_ALARM_AUDIO -DMSG_PUSH_TO_ALEXA -DFACTORY_INFO_INTEGRITY_RESTORE_SUPPORT -DWLAN_MODULE_SUPPORT -DGZIP_SUPPORT -DBASE64_SUPPORT -DTELEMETRY_SUPPORT -DLOCAL_PROTOCOL_SECURE -DCLIENTS_CONN_MAX=4 -DHUB_MANAGE_SUPPORT -DCONFIG_MSG_PUSH_POST_URL=/api/v1 -DSENSITIVITY_INT -DMAKEROOM_BEFORE_UPGRADE -DAUDIO_ENABLE -DCONFIG_MOBILE_ACCESS_SET_SUPPORT -DCONFIG_SD_UPGRADE_FROM_MMCBLK0 -DSYSUPGRADE_CHECK_RSA -DCONFIG_TP_TAPO_SPMINIOS -DCONFIG_TP_TAPO_MAP_ROOTFS -DCDN_HTTPS_UPGRADE_SUPPORT -DAMAZON_FFS_SUPPORT -DTAPO_CARE_CDN_SUPPORT -DTP_TAPO -DCLOUD_IOT_SUPPORT -DCLOUD_IOT_SOUNDALARM_SUPPORT -DBIND_CODE_SUPPORT -DTP_TAPO_P2P_SHARE -DT43_CONFIG_CHECK_WHETHER_IS_CAL -DLENS_MASK_SUPPORT -DMULTI_MODEL -I/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/usr/include -I/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/include -I/home/wyl/NVMP/nvmp/../sdk/soc/t31x/uclibc-toolchain-0.9.33/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/uclibc/usr/include -I/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/usr/lib/libiconv-full/include -I/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/usr/lib/libintl-full/include -Wall -Werror -ffunction-sections -fdata-sections -DMODULE_LIST="\"tdpd tdpc tmpd mactool wirelesstool nifc dhcpc dhcps httpd sntpc onvif system miniupnpc upgrade telemetry cloud_iot remote_debugger hub_manage ffs\"" -I/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/include -I/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/modules -I/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/common -I/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/common/ds -I./libXml -I./libutils -I../../include -c -o hub_manage_http_client.o hub_manage_http_client.c hub_manage_http_client.c: In function 'set_hub_connect_handle': hub_manage_http_client.c:844:2: error: unknown type name 'SET_HUB_CONNECT_MSG' hub_manage_http_client.c:844:28: error: initialization makes integer from pointer without a cast [-Werror] hub_manage_http_client.c:862:14: error: request for member 'ip' in something not a structure or union hub_manage_http_client.c:862:33: error: request for member 'ip' in something not a structure or union hub_manage_http_client.c:863:6: error: request for member 'ip' in something not a structure or union hub_manage_http_client.c:863:20: error: request for member 'ip' in something not a structure or union hub_manage_http_client.c:864:6: error: request for member 'port' in something not a structure or union hub_manage_http_client.c:869:3: error: implicit declaration of function 'ONBOARDING_ERROR' [-Werror=implicit-function-declaration] hub_manage_http_client.c: At top level: hub_manage_http_client.c:842:11: error: 'set_hub_connect_handle' defined but not used [-Werror=unused-function] cc1: all warnings being treated as errors <builtin>: recipe for target 'hub_manage_http_client.o' failed make[5]: *** [hub_manage_http_client.o] Error 1 make[5]: Leaving directory '/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/modules/hub_manage' Makefile:30: recipe for target 'build_modules' failed make[4]: *** [build_modules] Error 2 make[4]: Leaving directory '/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd' Makefile:574: recipe for target '/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/.built' failed make[3]: *** [/home/wyl/NVMP/nvmp/build_dir/target-mips-openwrt-linux-uclibc-c510wv1/nsd/.built] Error 2 make[3]: Leaving directory '/home/wyl/NVMP/nvmp/tp_package/nsd' package/Makefile:105: recipe for target 'package/tp_package/nsd/compile' failed make[2]: *** [package/tp_package/nsd/compile] Error 2 make[2]: Leaving directory '/home/wyl/NVMP/nvmp' package/Makefile:101: recipe for target '/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/stamp/.package_compile' failed make[1]: *** [/home/wyl/NVMP/nvmp/staging_dir/target-mips-openwrt-linux-uclibc-c510wv1/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/wyl/NVMP/nvmp' /home/wyl/NVMP/nvmp/include/toplevel.mk:277: recipe for target 'world' failed make: *** [world] Error 2
最新发布
09-20
property.c: In function 'tp_header_data_model': /home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/usr/include/ds_cmodule_def.h:227:51: error: 'TP_HEAD_INFO' {aka 'struct _TP_HEAD_INFO'} has no member named 'firmware_crc' 227 | DSLL_OPT(option_name, option_type, option_flags, offsetof(structure, member), option_size, extend_desc) | ^~~~~~~~ /home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/usr/include/ds_cmodule_def.h:158:12: note: in definition of macro 'DSLL_OPT' 158 | .offset = option_offset, \ | ^~~~~~~~~~~~~ /home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/usr/include/ds_cmodule_def.h:241:60: note: in expansion of macro 'DS_STRUCT_OPT' 241 | #define DS_HEXSTRM_OPT(structure, member, option_flags) DS_STRUCT_OPT(#member, OPT_TYPE_HEXSTREAM, option_flags, structure, member, MEMBER_SIZE(structure, member), NULL) | ^~~~~~~~~~~~~ property.c:190:3: note: in expansion of macro 'DS_HEXSTRM_OPT' 190 | DS_HEXSTRM_OPT(TP_HEAD_INFO, firmware_crc, OPT_FLAG_NORM), | ^~~~~~~~~~~~~~ /home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/usr/include/nvmp_common.h:136:30: error: 'TP_HEAD_INFO' {aka 'struct _TP_HEAD_INFO'} has no member named 'firmware_crc' 136 | (sizeof (((structure *) 0) -> member)) | ^~ /home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/usr/include/ds_cmodule_def.h:159:10: note: in definition of macro 'DSLL_OPT' 159 | .size = option_size, \ | ^~~~~~~~~~~ /home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/usr/include/ds_cmodule_def.h:241:60: note: in expansion of macro 'DS_STRUCT_OPT' 241 | #define DS_HEXSTRM_OPT(structure, member, option_flags) DS_STRUCT_OPT(#member, OPT_TYPE_HEXSTREAM, option_flags, structure, member, MEMBER_SIZE(structure, member), NULL) | ^~~~~~~~~~~~~ /home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/usr/include/ds_cmodule_def.h:241:136: note: in expansion of macro 'MEMBER_SIZE' 241 | (#member, OPT_TYPE_HEXSTREAM, option_flags, structure, member, MEMBER_SIZE(structure, member), NULL) | ^~~~~~~~~~~ property.c:190:3: note: in expansion of macro 'DS_HEXSTRM_OPT' 190 | DS_HEXSTRM_OPT(TP_HEAD_INFO, firmware_crc, OPT_FLAG_NORM), | ^~~~~~~~~~~~~~ <builtin>: recipe for target 'property.o' failed make[4]: *** [property.o] Error 1 make[4]: Leaving directory '/home/duanchangxu1604/NVMP/nvmp/build_dir/target-arm-openwrt-linux-gnueabi-c212v3/libsdm' Makefile:223: recipe for target '/home/duanchangxu1604/NVMP/nvmp/build_dir/target-arm-openwrt-linux-gnueabi-c212v3/libsdm/.built' failed make[3]: *** [/home/duanchangxu1604/NVMP/nvmp/build_dir/target-arm-openwrt-linux-gnueabi-c212v3/libsdm/.built] Error 2 make[3]: Leaving directory '/home/duanchangxu1604/NVMP/nvmp/tp_package/lib/libsdm' package/Makefile:105: recipe for target 'package/tp_package/lib/libsdm/compile' failed make[2]: *** [package/tp_package/lib/libsdm/compile] Error 2 make[2]: Leaving directory '/home/duanchangxu1604/NVMP/nvmp' package/Makefile:101: recipe for target '/home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/stamp/.package_compile' failed make[1]: *** [/home/duanchangxu1604/NVMP/nvmp/staging_dir/target-arm-openwrt-linux-gnueabi-c212v3/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/duanchangxu1604/NVMP/nvmp' /home/duanchangxu1604/NVMP/nvmp/include/toplevel.mk:277: recipe for target 'world' failed make: *** [world] Error 2
09-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Creator_Ly

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值