openwrt学习笔记

c 复制代码
OPENWRT学习笔记

1.最好使用16版本以下的ubuntn,好像说是18.4不支持

2.获取到源码后 将dl文件包放到源码目录顶层,编译的过程会出很多问题,将有问题的文件替换

**可能会面临另一个问题:**

cat: openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/base-files/ipkg-ramips_24kec/base-files/etc/sdk.version

/home/user/openwrt-sdk/bin/ramips/packages/base/base-files_156-unknown_ramips_24kec.ipk

就是缺少几个sdk.version的文件。没有怎么办?

\#vi (路径)/sdk.version

内容就写V1.0.0,保存退出!

3.我们自己要加程序的话,需要openwrt-sdk/package 文件夹下,可创建一个文件夹如:helloworld

在里添加Makefile 和 src ,src中是.c 文件和Makefile编译文件

以下是顶层Makefile文件

c 复制代码
  include $(TOPDIR)/rules.mk
 
# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1
 
 
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
include $(INCLUDE_DIR)/package.mk
 
define Package/helloworld                          
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=Helloworld -- prints a snarky message
endef
# Uncomment portion below for Kamikaze and delete DESCRIPTION variable above
define Package/helloworld/description
	If you can't figure out what this program does, you're probably
	brain-dead and need immediate medical attention.
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)    
	$(CP) ./src/* $(PKG_BUILD_DIR)/	#这句意思是将当前文件下的src文件夹拷贝到PKG_BUILD_DIR
	$(CP) ./bin/ $(PKG_BUILD_DIR)/   #这句意思是将当前文件下的bin文件夹拷贝到PKG_BUILD_DIR
endef
define Build/Configure
endef
define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		CC="$(TARGET_CC)" \
		CFLAGS="$(TARGET_CFLAGS) -Wall" \
		LDFLAGS="$(TARGET_LDFLAGS)"
endef

define Package/helloworld/install
	$(INSTALL_DIR) $(1)/bin								#$(1)/bin指网关文件夹
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
	$(INSTALL_DIR) $(1)/bin
	$(CP) $(PKG_BUILD_DIR)/bin/* $(1)/bin/
endef

$(eval $(call BuildPackage,helloworld))

在make menuconfig 在Utilities下找到helloworld目录勾选即可编译进固件中,如果想单独编译 可以使用

  • sudo make package/myapp_test/compile -j1 V=s

openwrt编译时 提示固件太大编译不出

相关推荐
二哈赛车手7 小时前
新人笔记---ApiFox的一些常见使用出错
java·笔记·spring
wj3055853788 小时前
课程 9:模型测试记录与 Prompt 策略
linux·人工智能·python·comfyui
吃好睡好便好8 小时前
在Matlab中绘制横直方图
开发语言·学习·算法·matlab
abigriver8 小时前
打造 Linux 离线大模型级语音输入法:Whisper.cpp + 3090 显卡加速与 Rime 中英混输终极调优指南
linux·运维·whisper
wangqiaowq8 小时前
windows下nginx的安装
linux·服务器·前端
nashane8 小时前
HarmonyOS 6学习:CapsLock键失效诊断与长截图完整实现指南
学习·华为·harmonyos
YYRAN_ZZU9 小时前
Petalinux新建自动脚本启动
linux
charlie1145141919 小时前
嵌入式Linux驱动开发pinctrl篇(1)——从寄存器到子系统:驱动演进之路
linux·运维·驱动开发
于小猿Sup10 小时前
VMware在Ubuntu22.04驱动Livox Mid360s
linux·c++·嵌入式硬件·自动驾驶
cen__y10 小时前
Linux12(Git01)
linux·运维·服务器·c语言·开发语言·git