Ubuntu配置OPENWRT开发环境
2018-01-22 15:23
351 查看
Ubuntu下配置OPENWRT开发环境
1.环境配置
sudo apt-get install gcc sudo apt-get install g++ sudo apt-get install patch sudo apt-get install bzip2 sudo apt-get install make sudo apt-get install gettext sudo apt-get install textinfo sudo apt-get install unzip sudo apt-get install libz-dev sudo apt-get install binutils sudo apt-get install flex sudo apt-get install bison sudo apt-get install autoconf sudo apt-get install sharutils sudo apt-get install subversion sudo apt-get install libncurses5-dev sudo apt-get install ncurses-term sudo apt-get install zlib1g-dev sudo apt-get install git-core sudo apt-get install gawk sudo apt-get install libssl-dev sudo apt-get install asciidoc
最后一个安装时间较长,耐心等待。
2.下载openwrt
git clone git://git.openwrt.org/15.05/openwrt.git
3.添加软件扩展包
cd openwrt/ cp feeds.conf.default feeds.conf ./scripts/feeds update -a ./scripts/feeds install -a
4.编译
make defconfig
5.配置
make menuconfig
选择要编译的固件平台、型号,固件中要添加的功能和组件。
6.生成SDK
make menuconfig选上“Build the OpenWRT SDK”,保存,退出。make V=99
完成后,在bin/ar71xx/目录下会生成SDK的压缩文件:OpenWrt-SDK-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-i686.tar.bz2
7.安装SDK
把上步生成的压缩文件放在任意目录,解压。tar -zxvf OpenWrt-SDK-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-i686.tar.bz2
8.创建项目(例:helloworld)
mkdir helloword cd helloword touch helloword.c Makefile
helloworld.c文件的内容:
#include <stdio.h> int main() { printf(“hello my world!!!\n”); return 0; }
Makefile文件的内容:
helloworld:helloworld.o cc -o helloworld hoelloworld.o helloworld.o:helloworld.c cc -c helloworld.c clean: rm *.o helloworld
9.生成包
cd OpenWrt-SDK/package mkdir helloworld cd hello world
把第8步的helloworld文件夹整体放入OpenWrt-SDK/package/helloworld中并改为src
touch Makefile
Makefile文件的内容:
include $(TOPDIR)/rules.mk PKG_NAME:=helloworld PKG_VERSION:=5.0 PKG_RELEASE:=1.0 PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME) include $(INCLUDE_DIR)/package.mk define Package/$(PKG_NAME) SECTION:=utils CATEGORY:=Utilitie TITLE:=helloworld -- i2c general program MAINTAINER:=asyncM DEPENDS:=+libc.so +libgcc_s.so.1 +libc.so.6 endef define Package/$(PKG_NAME)/description general program endef define Build/Prepare mkdir -p $(PKG_BUILD_DIR) $(CP) ./src/* $(PKG_BUILD_DIR)/ endef define Package/helloworld/install $(INSTALL_DIR) $(< 4000 /span>1)/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/ $(CP) /usr/lib/x86_64-linux-gnu/libc.so $(1)/bin/ $(CP) /lib/x86_64-linux-gnu/libgcc_s.so.1 $(1)/bin/ $(CP) /lib/x86_64-linux-gnu/libc.so.6 $(1)/bin/ ended $(eval $(call BuildPackage,helloworld))
回到 OpenWrt-SDK 目录下,执行
make V=s
生成helloworld_1_ar71xx.ipk文件,可用find查看其位置
10.测试
将生成的helloworld_1_ar71xx.ipk文件用scp上传到目标路由器scp helloworld_1_ar71xx.ipk root@IPaddr:
ssh登陆路由器,安装helloworld_1_ar71xx.ipk包
ssh root@IPaddr root@OpenWrt:~# ls helloworld_1_ar71xx.ipk root@OpenWrt:~# opkg install helloworld_1_ar71xx.ipk Installing helloworld (1) to root... Configuring helloworld. root@OpenWrt:~# helloworld hello my world!!!
相关文章推荐
- Ubuntu16.04配置CUDA开发环境
- ubuntu+hadoop+eclipse开发环境安装与配置
- Android开发环境搭建(一) —Ubuntu虚拟机安装配置
- Ubuntu嵌入式开发环境配置问题集锦(不断更新)
- linux下配置opencv开发环境 opencv + ubuntu + clion
- Ubuntu下配置OpenCV开发环境
- Ubuntu系统配置android-studio开发环境
- ubuntu14.0.4配置javaweb开发环境第四步eclipse配置tomcatt
- ubuntu下配置c/c++开发环境
- 在Ubuntu下如何开发配置OpenGL环境?
- SecureCRT远程连接Ubuntu,SecureCRT开发环境配置
- ubuntu 16.04 VSCode 配置C++开发环境
- 【嵌入式开发技术之环境配置】Ubuntu下 TFTP服务的配置
- 安装ubuntu后 配置C开发环境
- 配置ubuntu下android开发环境
- ubuntu配置swoole开发环境
- Ubuntu 配置 Go 语言开发环境(Sublime Text+GoSublime)
- Ubuntu下配置舒服的Python开发环境
- ubuntu eclipse Python开发环境配置