实例介绍
openwrt,Lede深入学习笔记v2.0.pdfopenwrt,Lede深入学习笔记v2.0.pdfopenwrt,Lede深入学习笔记v2.0.pdfopenwrt,Lede深入学习笔记v2.0.pdfopenwrt,Lede深入学习笔记v2.0.pdfopenwrt,Lede深入学习笔记v2.0.pdf
https://github.com/zhaojh329 Updatingfeed'packages'from'https://github.com/openwrtpackages.git;for-14.07 remote: Counting objects: 123, done. remote: Compressing objects: 100%(76/76), done remote: Total 123(delta 70), reused 92(delta 39) Receiving objects: 100%(123/123),13.89 kib o bytes/s, done Resolving deltas: 100%(70/70), completed with 19 local objects Fromhttps://github.com/openwrt/packages ad7c25a.71719eb for-14.07 -> origin/for-1407 Updating ad7c25a.71719eb 使下载的软件包可以出现在 make menuconfig配置菜单中 root@zjh-vm: /home/work/openwrt# /scripts/feeds install<PACKAGENAME> 或者 root@zjh-vm: /home/work/openwrt# /scripts/feeds install -a 注意:/ scripts/eds这个脚木只是使软件包可以出现在 make menuconfig配置菜单中,而并不是真止的安裝或者编译 软件。 配置 Openwrt默认不允许使用root用户操作,若要使用root用户操作可以修改 include/ prereq- build.mk这个文件 root@zjh-vm: /home/ work/openwrt/barrier breaker# vi include/prereq- build. mk define require non-root define require non-root [SS(shell whoami)"!="root"] ender s(eval $(call Require, non-root, l Please do not compile as root . 这里首先定义了一段检查rot用户的代码,然后迸过call函数调用这段代码。我们把调用部分屏蔽即可使用root用户 编译 define require /non-root ["SS(shell whoami)"[="root"] ende #S(eval S(call Require, non-root Please do not compile as root.\ 注:最新的 trunk版已经取消这个限制了。 执行 make menuconfig打开軋置菜单 root@zjh-vm: /home/work/openwrt/barrier breaker# make menuconfig https://github.com/zhaojh329 https:/github.com/zhaojh329 Target System (Ralink RT288X/RT3XXX)---> Subtarget (rT3X5X/RT5350 based boards) Target Profile (HAME MPR-A2) Target Images GLobal build settings Advanced configuration options (for developers) Build the OpenWrt Image Builder I Build the Openwrt SDK [ I Build the Openwrt based Toolchain I Image configuration---> 每个选项前面都有一个门]标签,我们可以选择y,m和n ·选择y设置为<*>,表示将软件包编译进固件 Image文件; 选择m设置为<M>,表示软件包会被编译,但不会编译进固件 Image文件。 Openwrt会把设置为M 选项的软件包编泽后再制作成一个以ipk为后缀(.jpk)的文件,然后在设备上通过opkg来安装到设 备上; ·选择n设置为<>,表示不编译该软件包。 配置主要包括4个部分 Target system(目标系统) Package selection(软件包选择) Build system settings(编译系统设置) Kernel modules(内核模块配置) 我们这里先简单配置一下,具体的以后再讲 首先配置目标系统,根据自u的设备选择SoC类型,我使用的设备使用是RT5350,是 Ralink公司的SoC,8MBF|ash, 32 MB SDRAM,从htt:// wiki.openwrt.org./toh/tat这个地址得知 openwrt支持的设备 HAME Model Version Status Target(s) Platform CPU Speed Flash RAM Wireless Wireless Wired VLAN (ME (MB) NI Standard Config trunk r305X RT6350 350 MHZ 11b/gn 1xEth None r38348 USB2 mpr- s trunk r305XRT5350360Mz SoC 17b/g 1xEth none r38348 USB2 因此 Target System配置如下 Target System (Ralink RT288X/RT3XXX) Subtarget (RT3X5X/RT5350 based boards Target Profile ( HAME MPR-A2)---> Target profi|e对应上面列表的mpra2 当配置完成并保存配置后, openwrt将根据你的配置创建一个配置文件 config root@zjh-vm: /home/ work/openwrt/barrier breaker# vi. config https://github.com/zhaojh329 https://github.com/zhaojh329 2 Automatically generated file: DO NOT EDIT 3# Openwrt Configuration 5 CONFIG MODULES=y 6 CONFIG HAVE DOT CONFIG=y 7# CONFIG TARGET ppc40x is not set 8# CONFIG TARGET realview is not set 9 CONFIG TARGET atheros is not set 10+ CONFIG TARGET ar/lxx is not set E CONFIG TaRGet atg1 is not set ONF ARGET 如果要配胃 busybox,可以进行如下操作 root@zjh-vm: /home/work/openwrt/barrier breaker# make menuconfig Base system <* busybox Core utilities for embedded linux---> 从 busybox这个菜单按回车就可以进入 busybox的配置界面了 如果要配置内核选项可以执行 make kernel menuconfig root@zjh-vm: /home/ work/openwrt/barrier breaker# make kernel_ menuconfig Machine selection--> Enable fpu emulation [*I openwrt specific image command line hack Endianness selection (Little endian)---> CPU selection 编译 可以直接执行make进行编译 root@zjh-vm: /home/work/openwrt/barrier breaker# make 添加make编详选项 root @zjh-vm: home/work/openwrt/barrier breaker# make -j3 V=S 多进程编译,这样编译快些。j指定的参数一般为你的CpU核数+1,比如双核CPU就指定为3 ∨=s:输出编译的详细信息,这样编译出错时,我们才知道错在哪里 编详成功后,会在bin目录下生成固件文件 root@zjh-vm: /home/work/openwrt/barrier breaker# ls bin/ramips/ md5sums openwrt-ramips-rt305X-vmLinux, bin cpenwrt-ramips-rt305x-mpr-a2-squashfs- sysupgrade bin openwrt-ramips-rt305x-vmLinux elf openwrt-ramips-rt305x-root squashfs packages cpenwrt-ramips-rt305x-uImage bin 其中的 openwrt-ramips-rt305 x-mpr-a2- squashfs- sysupgrade bin就是用来烧写到设备的固件。 清理工程 root@zjh-vm /home/work/openwrt/barrier breaker# make clean https://github.com/zhaojh329 https:/github.com/zhaojh329 删除/home/work/ openwrt/ barrier breaker/bin和/home/wok/ openwrt/ barrier breaker/ build_di这2个目录 root@zjh-vm: /home/ work/openwrt/barrier breaker# make dirclean W B/home/work/openwrt/barrier breaker/bin, /home/work/openwrt/barrier breaker/build dir home/work/openwrt/barrier breaker/staging_ dir /home/work/openwrt/barrier breaker/staging di r/toolchain A home/ work/openwrt/barrier breaker/staging_ dir root@zjh-vm /home/work/openwrt/barrier breaker# make distclean 删除所有编译的或者配置的和下载的feds内容以及下载的软件包源码,还有 config配置文件。 编译/清理单个软件包 以uci这个软件包为例 root@zjh-vm: /home/work/openwrt/barrier breaker# make package/system/uci/compile v=s yh e root@zjh-vm: /home/work/openwrt/barrier breaker# make package/system/uci/clean v=s 清理 烧写固件 打丌ttpd32,扣刚才编译生成的固件 openwrt- ramps-rt305×mpra2 squashfs- sysupgrade bin拷贝到ttpd32软件目录 A Tftpd32 by Ph Jounin Current Directory D: \Htpd32 400 旦r Server interface 192.168.0.104 Show di Tftp Server Tp Client DHCP server Syslog server Log viewer) start ime progre otaki Settings Help 下面的操作根据自己的设备的u-boot操作,不同的u-boot探作步骤和设置不同。 用网线连接设备和电脑,用串∏线连接设备和电脑,打开 Securecrt,波特率设置为57600。给设备上电启动设各, https://github.com/zhaojh329 https:/github.com/zhaojh329 #### The CPU freq 360 MHZ#### estimate memory size =32 Mbytes Please choose the operation 1: Load system code to SDRAM Via TFTP 2: Load system code then write to Flash via TFTP. 3: Boot system code via Flash (default) 4: Entr boot command line inter face 7: Load Boot loader code then write to flash via serial 9: Load Boot Loader code then write to flash via tftp You choosed 4 0 aspi_read: from: 40028 len: 6 4: System Enter Boot Command Line Inter face U-Boot1.1.3(Nov262013-22:36:55) RT5350# 在倒计吋时按4进入命令行界面 设置 tftpboot相关参数 RT5350# set ipaddr192168.0.100设置设备P地址 RT5350# set serveri1921680.104设置ttp服务器|P地址,即与你的设备相连的电脑的|P地址 RT5350# set bootfil| openwrt-ramips-rt305×mpr-a2 squashfs-sysupgrade.bin设置要下载的固件名称 RT5350#save将设置写入Fash 执行 reset車启设备,在倒计时时按2进入ttp烧写固件步骤 ####f The Cpu freq 360 MHZ #### estimate memory size =32 Mbytes Please choose the operation 1: Load system code to SDRAM via TFTP 2: Load system code then write to Flash via TFTP. 3: Boot system code via Flash (default) 4: Entr boot command line interface 7: Load boot loader code then write to flash via serial 9: Load boot loader code then write to flash via tftp You choosed 2 aspi_read: from: 40028 len:6 2: System Load Linux Kernel then write to Flash via TFTP Warning!! Erase Linux in Flash then burn new one. Are you sure? (Y/N) 选择γ进入设备P设置步骤,之前已经设置好了,这里就不用再设置了,直接一路回车 https://github.com/zhaojh329 https:/github.com/zhaojh329 oading: checksum bad Got ARP REQUEST, return our IP ArpTimeoutcheck TTTT Got ARP REPLY, set server/gtwy eth addr (44: 8a: 5b: ec:49: 27) Got It ##井######样##是#是是#是并并#并###并###井#########并########井井# checksum bad ########### ###甚井############# checksum bad ###########################################井######井#并########## #############并#########并#并##############并#升并升并####并##### ############################################################### 这就表示开始卜载固件了,等从电脑卜载固件完成,u-boot就会将卜载的固件烧写到 Flash,烧写完成后,u-boot自动 启动系统。 BusyBox v1. 22.1 (2015-01-18 18: 36: 51 CST) built-in shell (ash) Enter help for a list of built-in commands. W工 RELESS FREEDOM BARRIER BREAKER (Barrier Breaker, r43618) 1/2 oz Galliano Pour all ingredients into 实4 oz cold coffee an irish coffee mug filled 11/2 oz Dark Rum with crushed ice. stir 2 tsp. Creme de Cacao rootaopenwr t:/#囗 2UcI(统一配置接口) 概述 UC是 Openwrt中为实现所有系统配置的一个统一接口,英文名 Unified Configuration Interface,即统一配置接口。每 个程序的配置文件都保存在/etc/ config目录,可以通过文本编辑器、uci(一个可执行程序)以及各种APl(Shel!Lua和 C)来修改这些酩置文件。 Uc配置文件由个或多个 config语句组成,每个cong语句伴随着个或多个 option语句。这样的由个 config语 句以及伴随的几个 option语句组成的段落就叫做一个 section 在/etc/ong目录下创建一个配置文件 example,其内容如卜 root@ Openwrt:~井ⅵ/etc/ config/ example https://github.com/zhaojh329 https:/github.com/zhaojh329 config example 'test option name value list collection first item list collection second item config example test'中的 example表示这个 section的类型,test表示这个 section的名称 option name' value'定义了一个“名称-值”对name=vaue ist定义了一个列表,表示一个名称有多个值,比如这里的 collection就有2个值 first iten和 'second iten" 下面的例子都是正确的UC|语法 option example value option 'example value option example value option "example"value option ' examplevalue 下面的例子都是错误的UC|语法 option' example""vaue'(引号不对称) option example some value with space(缺少引号,引起歧义,不知道哪几个单词相结合) UC提供了一个命令行工具uci,它可以对配置文件中的内容进行修改、添加、删除和读取。 oot(openwrt:-# uc Usage: uci [<options]<command> [<ar guments>] Commands batch export L<config> import conf changes config> commIt <config> add <config> <section-type> add_list <config>. <section>. <option>x<string> del_list <config>. <section>, <option>=<string show [<config>[ <section>[ <option>]J] get <config>, <section>[ soption> set config>. <section>[ <option>=<value> delete config>[ <section>L. <option>][<id>]]] rename config>. <section>[ <option>]=<name> revert <config>[ <section>[ <option>J] reorder <config>. <section>=<position> options c <path> set the search path for config files (default: /etc/config) d est set the delimiter for list values in uci show f <file> use <file> as input instead of stdin when importing, merge data into an existing package name unnamed sections on export (default) don t name unnamed sections p <path> add a search path for config change files P <path> add a search path for config change files and use as default quiet mode (dont print error messages) force strict mode (stop on parser errors, default) disable strict made X do not use extended syntax on show 通过uc写配置文件后,整个配置会被重新写入配置文件,这意味着配置文件中仼何无关行都会被删除,包括注释(# 开头的内容)。因此如果你要保留自凵写的注释,就只能通过文木编辑器修改配置文件。 https://github.com/zhaojh329 https:/github.com/zhaojh329 下面列出详细用法 Command commit [<config> batch export <config> import[<config] changes [<config> <config> <section-type> section type add list<config>. <section>. option >=<string> show [<config>[ <section>[ <option>]] get <config>.<section>[ <option>] set <config>.<section>.<option>=<value> delete<config>[.section[. option>1] rename<config>.<section>.<option>]=<name> revert<config[ <section>[ <option>]] 实例操作 导出一个配置文件的内容,如果不指定配置文件则表小导出所有配置文件的内容 https://github.com/zhaojh329 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论