$ - 指定Ubuntu系统下命令
# - Openwrt下命令
openwrt中,make menuconfig
生成.config文件后,我们如何对.config中自定义的差异内容进行进行备份,方便移植到其它的系统中,这是一个问题。当然,有人说有很多简单的方法。但是这些都不是Openwrt开发着所希望看到的。对于Openwrt,开发团队创建了简单的工具scripts/diffconfig.sh
。我们可以采用这个工具进行配置保存工作。
有一个简单的方法,生成diff文件,然后通过git进行操作,这样我们可以对我们自己的openwrt进行定制备份了。
$./scripts/diffconfig.sh > config.diff # write the changes to diffconfig`
$cp config.diff .config # write changes to .config
$make defconfig # expand to full config
或者
$cat config.diff >> .config # append changes to bottom of .config
$make defconfig # apply changes
全新编译
$ make package/feeds/packages/madplay/{clean,compile,install} V=s
$ make package/feeds/packages/madplay/{compile,install} V=s
重新编译
$ make package/feeds/packages/madplay/compile V=s
复制ipk文件到openwrt系统,然后通过opkg进行安装。
$ scp bin/ramips/packages/packages/madplay-alsa_0.15.2b-4_ramips_24kec.ipk root@192.168.1.104:/tmp
安装madplay到openwrt
# root@mylinkit:/tmp# opkg install madplay-alsa_0.15.2b-4_ramips_24kec.ipk
Installing madplay-alsa (0.15.2b-4) to root...
Configuring madplay-alsa.
package的Makefile
PKG_CONFIG_DEPENDS - specifies which config options depend on this package being selected
SECTION - The type of package (currently unused) //包的类型
scp ~/.ssh/id_dsa.pub root@192.168.1.1:/tmp
环境变量的相关信息,参考linux鸟歌私房菜上,P304。
# iwinfo ra0 scan
# time iwlist wlan0 scan | grep ESSID
root@mylinkit:/tmp# iwinfo ra0 scan
Cell 01 - Address: 6C:E8:73:AB:0C:96
ESSID: "FAST_AB0C96"
Mode: Master Channel: 1
Signal: -256 dBm Quality: 10/100
Encryption: WPA2 PSK (AES-OCB)
Cell 02 - Address: C8:3A:35:29:F5:54
ESSID: "wanghf"
Mode: Master Channel: 1
Signal: -256 dBm Quality: 7/100
Encryption: WPA PSK (AES-OCB)
Cell 03 - Address: 00:06:25:00:6E:72
ESSID: "home"
Mode: Master Channel: 6
Signal: -256 dBm Quality: 81/100
Encryption: WPA2 PSK (TKIP, AES-OCB)
Cell 04 - Address: 8C:21:0A:41:D3:64
ESSID: "wf"
Mode: Master Channel: 11
Signal: -256 dBm Quality: 0/100
Encryption: WPA2 PSK (AES-OCB)
0 是 < 的默认值,因此 < 与 0<是一样的;同理,> 与 1> 是一样的
#ls /dev 1>filename //把命令的标准输出重新定向到一个文件filename
#ls /dev >>filename //把输出追加到filename文件的末尾
#ls -qw /dev 2>filename //把标准错误重新定向到文件
#ls /dev &>filename //把标准输出和错误都定向到文件
$find /home -name .basehrc 2> /dev/null
参考文档:Linux鸟歌的私房菜 P359
获得当前喇叭音量值
# amixer cget numid=11,iface=MIXER,name='Speaker Playback Volume' | grep ': values' |sed 's/^.*values=//g' | sed 's/,.*$//g'
获得耳机音量值
# amixer cget numid=9,iface=MIXER,name='Headphone Playback Volume' | grep ': values' |sed 's/^.*values=//g' | sed 's/,.*$//g'
获得播放音量值
# amixer cget numid=8,iface=MIXER,name='Playback Volume' | grep ': values' |sed 's/^.*values=//g' | sed 's/,.*$//g'
# du /
root@mylinkit:/etc/config# date -help
date: invalid option -- h
BusyBox v1.23.2 (2016-01-20 23:54:03 CST) multi-call binary.
Usage: date [OPTIONS] [+FMT] [TIME]
Display time (using +FMT), or set time
[-s,--set] TIME Set time to TIME
-u,--utc Work in UTC (don't convert to local time)
-R,--rfc-2822 Output RFC-2822 compliant date string
-I[SPEC] Output ISO-8601 compliant date string
SPEC='date' (default) for date only,
'hours', 'minutes', or 'seconds' for date and
time to the indicated precision
-r,--reference FILE Display last modification time of FILE
-d,--date TIME Display TIME, not 'now'
-D FMT Use FMT for -d TIME conversion
-k Set Kernel timezone from localtime and exit
Recognized TIME formats:
hh:mm[:ss]
[YYYY.]MM.DD-hh:mm[:ss]
YYYY-MM-DD hh:mm[:ss]
[[[[[YY]YY]MM]DD]hh]mm[.ss]
参考连接:https://wiki.openwrt.org/doc/techref/mtd
# cd /tmp
# wget http://www.example.org/original_firmware.bin
# mtd -r write /tmp/original_firmware.bin firmware
root@mylinkit:/tmp# cat /proc/mtd
dev: size erasesize name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "factory"
mtd3: 00fb0000 00010000 "firmware"
mtd4: 0011a791 00010000 "kernel"
mtd5: 00e9586f 00010000 "rootfs"
mtd6: 00100000 00010000 "rootfs_data"
参考文档:linkit-smart-7688-feed\mtk-linkit\files\etc\uci-defaults\51_linkit_config
Line30: MAC=$(dd bs=1 skip=7 count=3 if=/dev/mtd2 2>/dev/null | hexdump -v -n 3 -e ‘3/1 “%02X”’
可以读取mtd2内的数据内容,mac地址
# dd bs=1 skip=3 count=6 if=/dev/mtd2 2>/dev/null | hexdump
参考文档:linkit-smart-7688-feed\mtk-linkit\files\etc\init.d\linkit
Line15: SEQ=
fw_printenv -n wifi_seq
# dd if=/dev/mtd2 of=/tmp/factory.bin
# mtd2 write /tmp/factory.bin factory
注意:如果命令返回不能写入MTD2,可能是由于你的系统设定了禁止写该区域的权限。我们可以通过修改target/linux/ramips/dts/LINKIT7688.dts,注销禁止代码。这样就可以将数据写入到MTD2区域了。
$git clone https://github.com/MediaTek-Labs/linkit-smart-7688-uboot.git
$cd linkit-smart-7688-feed
$make
$git checkout -b moh
$make meuncofig
$make
修改文件linkit-smart-7688-uboot\board\rt2880\serial.h
line21: #define CFG_RT2880_CONSOLE RT2880_UART3
MT7628 # setenv ipaddr 192.168.1.120
MT7628 # setenv serverip 192.168.1.116
MT7628 # saveenv
$cat lks7688.cfg
wifi_ssid=moh_app
wifi_key=12345678
插入u盘,按下wifi按钮,复位板子。等待wifi指示灯亮后,松开wifi按钮。uboot烧录配置到uboot-env
插入u盘,按下wifi按钮,复位板子,等待大约5秒(wifi指示灯亮然后灭掉),松开wifi按钮,uboot开始烧录firmware
插入u盘,按下wifi按钮,复位板子,等待大约20秒,松开wifi按钮,uboot更新uboot。
参考文档:Linux鸟歌的私房菜 P301