Openwrt开发汇总

来源:互联网 发布:平面美工 招聘 编辑:程序博客网 时间:2024/06/05 19:42

从17年3月开始到现在,基于Openwrt的WLAN开发也基本告一段落了,现在来梳理一下整个开发流程,以备不时之需。

Openwrt固件编译

 *:表示该模块直接编译到核心中  
  M:该模块以被核心支持,可以后再安装
  空白:不支持该模块

1.root用户下安装编译所需组件

sudo apt-get install gcc 
sudo apt-get install g++ 
sudo apt-get install binutils 
sudo apt-get install patch 
sudo apt-get install bzip2 
sudo apt-get install flex 
sudo apt-get install bison 
sudo apt-get install make 
sudo apt-get install autoconf 
sudo apt-get install gettext 
sudo apt-get install texinfo 
sudo apt-get install unzip 
sudo apt-get install sharutils 
sudo apt-get install libncurses5-dev 
sudo apt-get install ncurses-term 
sudo apt-get install zlib1g-dev 
sudo apt-get install subversion 
sudo apt-get install git-core
sudo apt-get install gawk
sudo apt-get install asciidoc
sudo apt-get install libz-dev
sudo apt-get install libssl-dev
sudo apt-get install libssl0.9.8
2.非root用户下,创建Openwrt文件夹并下载源码
3.添加feeds
更新最新源码
./scripts/feeds update -a
安装最新源码
./scripts/feeds install -a
(目前Openwrt Trunk源码的获取方式已改为Git)

git clone git://github.com/openwrt/openwrt.git
4.make defconfig
5.make menuconfig
factory版用于原厂升级到Openwrt,sysupgrade用于已经安装过Openwrt

交叉编译

想要编译出可运行在Openwrt上的程序,需要配置交叉编译器,arm-openwrt-linux-gcc
分别要修改以下配置文件 /etc/bash.bashrc 和 /etc/profile

/etc/bash.bashrc

export PATH=$PATH:/home/colin/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.3.0_musl-1.1.16_eabi/bin

export CC=arm-openwrt-linux-gcc

export GCC=arm-openwrt-linux-gcc

export GXX=arm-openwrt-linux-g++

export STAGING_DIR=/home/colin/openwrt-trunk/staging_dir

source /etc/bash.bashrc


/etc/profile

source /etc/profile

export PATH=$PATH:/home/colin/openwrt-trunk/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-5.3.0_musl-1.1.16_eabi/bin


上传文件至路由器


上传本地文件到服务器
scp /path/filename username@servername:/path   

例如scp /var/www/test.php  root@192.168.0.101:/var/www/  把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中


Luci中文

在固件编译前,修改Luci源码中的配置,进入 ~openwrt/trunk/feeds/luci/modules/luci-base/root/etc/config$目录,编辑luci文件

config core main           option lang zh_cn           ```           ```config internal languages           option zh_cn chinese           option en English

UBOOT 可用

修改目录 /openwrt/trunk/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c        
parts[0].mask_flags = MTD_WRITEABLE

GPIO资源查看和释放

/sys/bus/platform/drivers/leds-gpio

echo gpio-leds > unbind

/sys/bus/platform/drivers/gpio-keys

echo gpio-keys > unbind

cat /sys/kernel/debug/gpio //查看GPIO资源



原创粉丝点击