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编译时 提示固件太大编译不出

相关推荐
你住过的屋檐1 小时前
【SeaweedFS】Linux上搭建SeaweedFS文件存储服务完整教程
linux·运维·服务器
少司府1 小时前
嵌入式外设篇(三)GPIO·三:MCU系统结构、总线与统一编制
linux·python·stm32·单片机·嵌入式硬件·mcu·嵌入式软件
不积跬步无以至千里mmbb262 小时前
Rust三大核心:Trait Crate Mod详解
linux·rust
console.log('npc')3 小时前
Python 学习教程 · 第4课:数据结构
数据结构·python·学习
吃我一窝jio3 小时前
Docker+Jenkins+K8s全流程部署
java·开发语言·笔记·python
我超膨胀der.3 小时前
关于如何完整转移LABVIEW源码
笔记·labview
国科安芯4 小时前
FPGA上电偶发不启动:多轨电源时序、PGOOD与并联供电的FAE排查笔记——ASP4644S2B在星载智能处理板中的工程应用分析
笔记·单片机·嵌入式硬件·fpga开发·低轨卫星·抗辐射
星落梦生6 小时前
Docker学习(11)
学习·docker·容器
无忧.芙桃17 小时前
Linux系统编程(四):用户与权限管理
linux·运维·服务器