页次: 1
哦哦,谢谢啦
可以的, 但是flash写之前需要擦除, 如果用命令操作,步骤是这样的
1. 回读 /dev/mtdblock2 到文件 dd if=/dev/mtd2 of=f.bin
2. 修改文件f.bin, 加入id
3. 擦除/dev/mtdblock2 flash_eraseall /dev/mtd2
4. 写 /dev/mtdblock2 dd if=f.bin of=/dev/mtd2
5. 其实3,4步可以合并一起做 flashcp -v f.bin /dev/mtd2flash_eraseall, flashcp 都可以在busybox里面开启编译选项.
如果想自己整合, 那就去参考busybox的flash* 代码就好了。
哦哦!感谢指导!但是如果我想从新在 "factory"跟"firmware"增加一个分区呢?会有哪些步骤啊?难度大么?
root@OpenWrt:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "factory"
mtd3: 01fb0000 00010000 "firmware"
mtd4: 0011835d 00010000 "kernel"
mtd5: 01e97ca3 00010000 "rootfs"
mtd6: 01a00000 00010000 "rootfs_data"
我想要在"factory"分区内写入我自定义用途的id 我在openwrt做了如下操作:
root@OpenWrt:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "factory"
mtd3: 01fb0000 00010000 "firmware"
mtd4: 0011835d 00010000 "kernel"
mtd5: 01e97ca3 00010000 "rootfs"
mtd6: 01a00000 00010000 "rootfs_data"
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# dd if=/dev/mtdblock2 of=/dev/factory
128+0 records in
128+0 records out
root@OpenWrt:/# hexdump -C /dev/factory
00000000 20 76 05 01 0c ef af c3 14 5c ff ff ff ff ff ff | v.......\......|
00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000020 ff ff ff ff ff ff ff ff 0c ef af c3 14 5c 0c ef |.............\..|
00000030 af c3 14 5d 22 0c 00 00 ff ff 51 01 55 77 a8 aa |...]".....Q.Uw..|
00000040 8c 88 ff ff 0a 00 00 00 00 00 00 00 00 00 ff ff |................|
00000050 ff ff 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d |................|
00000060 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 80 ff |................|
00000070 ff ff 80 ff ff ff 00 00 ff ff ff ff ff ff ff ff |................|
00000080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
000000d0 20 ff ff ff ff ff ff ff ff ff ff ff ff ff 08 08 | ...............|
000000e0 08 08 04 00 07 07 04 00 08 08 04 00 07 07 04 00 |................|
000000f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00010000
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
我是不是可以在00000080---000000d0或000000f0---00010000之间(*号部分)写入我的id呢?
lzx1044364960 说:谢谢!指导!
搞定了吗?我过段时间也要弄7620了.
我说的是源码中的位置
请各位大神指导一下,我的openwrt系统启动以后打印出如下分区信息:
[ 0.760000] Creating 4 MTD partitions on "spi32766.0":
[ 0.770000] 0x000000000000-0x000000030000 : "u-boot"
[ 0.780000] 0x000000030000-0x000000040000 : "u-boot-env"
[ 0.800000] 0x000000040000-0x000000050000 : "factory"
[ 0.810000] 0x000000050000-0x000002000000 : "firmware"
[ 1.060000] 2 uimage-fw partitions found on MTD device firmware
[ 1.070000] 0x000000050000-0x00000016835d : "kernel"
[ 1.080000] 0x00000016835d-0x000002000000 : "rootfs"
[ 1.090000] mtd: device 5 (rootfs) set to be root filesystem
我怎么才能知道每一个分区中的具体内容在什么地方啊?比如说"factory"分区中的内容应该在哪查看呢?如果我要自定义一下内容加入"factory"分区,该怎么操作呢?
谢谢!指导!
在openwrt:/sys/class/leds/下可以看到7620a:blue:wifi
root@OpenWrt:/sys/class# cd leds/
root@OpenWrt:/sys/class/leds# ls
7620a:blue:wifi rt2800soc-phy0::quality
rt2800soc-phy0::assoc rt2800soc-phy0::radio
root@OpenWrt:/sys/class/leds#
我在代码中是不是应该在/openwrt/target/linux/ramips/base-files/etc/diag.sh这样添加啊?
MT7620a)
status_led="7620a:blue:wifi "
;;
看看widora neo MT7688开发板的配置:
https://github.com/openwrt/openwrt/search?utf8=%E2%9C%93&q=widora%3Aorange%3Awifi&type=
有没有配置 /etc/diag.sh 文件:
widora-neo)
status_led="widora:orange:wifi"
我的/openwrt/target/linux/ramips/base-files/etc/diag.sh文件内容如下,这里面什么以上啊,我网上没找到资料,该如何修改配置呢?
#!/bin/sh
# Copyright (C) 2010-2013 OpenWrt.org
. /lib/functions/leds.sh
. /lib/ramips.sh
get_status_led() {
case $(ramips_board_name) in
3g-6200n)
status_led="edimax:green:power"
;;
3g150b | 3g300m | w150m)
status_led="tenda:blue:ap"
;;
ai-br100)
status_led="aigale:blue:wlan"
;;
ar670w)
status_led="ar670w:green:power"
;;
ar725w)
status_led="ar725w:green:power"
;;
awapn2403)
status_led="asiarf:green:wps"
;;
argus-atp52b)
status_led="argus-atp52b:green:run"
;;
asl26555)
status_led="asl26555:green:power"
;;
br6524n)
status_led="edimax:blue:power"
;;
br6425 | br-6475nd)
status_led="edimax:green:power"
;;
cf-wr800n)
status_led="comfast:white:wps"
;;
cy-swr1100)
status_led="samsung:blue:wps"
;;
d105)
status_led="d105:red:power"
;;
dcs-930 | dir-300-b1 | dir-600-b1 | dir-600-b2 | dir-610-a1 | dir-615-h1 | dir-615-d | dir-620-a1| dir-620-d1| dir-300-b7| dir-320-b1)
status_led="d-link:green:status"
;;
dcs-930l-b1)
status_led="d-link:red:power"
;;
dir-645)
status_led="d-link:green:wps"
;;
dap-1350)
status_led="d-link:blue:power"
;;
e1700)
status_led="linksys:green:power"
;;
esr-9753)
status_led="esr-9753:orange:power"
;;
ex2700)
status_led="ex2700:red:power"
;;
f5d8235-v2)
status_led="f5d8235v2:blue:router"
;;
fonera20n)
status_led="fonera20n:green:power"
;;
ip2202)
status_led="ip2202:green:run"
;;
rt-n13u)
status_led="rt-n13u:power"
;;
hlk-rm04)
status_led="hlk-rm04:red:power"
;;
ht-tm02)
status_led="ht-tm02:blue:wlan"
;;
all0239-3g|\
hw550-3g)
status_led="hw550-3g:green:status"
;;
linkits7688| \
linkits7688d)
[ "$1" = "upgrade" ] && status_led="mediatek:orange:wifi"
;;
m2m)
status_led="m2m:blue:wifi"
;;
m3)
status_led="m3:blue:status"
;;
m4)
status_led="m4:blue:status"
;;
mlw221|\
mlwg2)
status_led="kingston:blue:system"
;;
mofi3500-3gn)
status_led="mofi3500-3gn:green:status"
;;
mpr-a1)
status_led="hame:red:power"
;;
mpr-a2)
status_led="hame:red:power"
;;
mr-102n)
status_led="mr-102n:amber:status"
;;
nbg-419n)
status_led="nbg-419n:green:power"
;;
nw718)
status_led="nw718:amber:cpu"
;;
omni-emb|\
omni-emb-hpm)
status_led="emb:green:status"
;;
pbr-m1)
status_led="pbr-m1:green:sys"
;;
psr-680w)
status_led="psr-680w:red:wan"
;;
pwh2004)
status_led="pwh2004:green:power"
;;
px4885)
status_led="7links:orange:wifi"
;;
re6500)
status_led="linksys:orange:wifi"
;;
rt-n15)
status_led="rt-n15:blue:power"
;;
rt-n10-plus)
status_led="asus:green:wps"
;;
rt-n14u | rt-n56u | wl-330n | wl-330n3g)
status_led="asus:blue:power"
;;
rut5xx)
status_led="rut5xx:green:status"
;;
sl-r7205)
status_led="sl-r7205:green:status"
;;
tew-691gr|\
tew-692gr)
status_led="trendnet:green:wps"
;;
v11st-fe)
status_led="v11st-fe:green:status"
;;
v22rw-2x2)
status_led="v22rw-2x2:green:security"
;;
vocore)
status_led="vocore:green:status"
;;
w306r-v20)
status_led="w306r-v20:green:sys"
;;
w502u)
status_led="alfa:blue:wps"
;;
wcr-150gn)
status_led="wcr150gn:amber:power"
;;
whr-g300n)
status_led="whr-g300n:green:router"
;;
wizfi630a)
status_led="wizfi630a::run"
;;
wmr300)
status_led="buffalo:green:status"
;;
wli-tx4-ag300n)
status_led="buffalo:blue:power"
;;
wzr-agl300nh)
status_led="buffalo:green:router"
;;
wl-351)
status_led="wl-351:amber:power"
;;
wr512-3gn)
status_led="wr512:green:wps"
;;
wr8305rt)
status_led="wr8305rt:sys"
;;
whr-300hp2 | \
whr-600d | \
whr-1166d | \
wsr-600 | \
wsr-1166)
status_led="buffalo:orange:diag"
;;
wnce2001)
status_led="netgear:green:power"
;;
nexx-wt1520)
status_led="nexx-wt1520:white:power"
;;
wt3020)
status_led="nexx:blue:power"
;;
mzk-w300nh2)
status_led="mzkw300nh2:green:power"
;;
ur-326n4g)
status_led="ur326:green:wps"
;;
ur-336un)
status_led="ur336:green:wps"
;;
x5)
status_led="x5:green:power"
;;
x8)
status_led="x8:green:power"
;;
xdxrn502j)
status_led="xdxrn502j:green:power"
;;
xiaomi-mini)
status_led="xiaomi:red:status"
;;
f7c027)
status_led="belkin:orange:status"
;;
na930)
status_led="na930:blue:power"
;;
y1 | \
y1s)
status_led="lenovo:blue:power"
;;
zbt-wg2626)
status_led="zbt-wg2626:green:status"
;;
zte-q7)
status_led="zte:red:status"
;;
esac
}
set_state() {
get_status_led $1
case "$1" in
preinit)
status_led_blink_preinit
;;
failsafe)
status_led_blink_failsafe
;;
upgrade | \
preinit_regular)
status_led_blink_preinit_regular
;;
done)
status_led_on
;;
esac
}
在/sys/class/leds/下也可以看到w856n:blue:wlan 我如下操作root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan# echo "1" > ./brightness 也能点亮led,但是我要如何才能让WiFi开启时点亮,关闭时熄灭呢?
root@OpenWrt:/sys/class# cd leds/
root@OpenWrt:/sys/class/leds# ls
rt2800soc-phy0::assoc rt2800soc-phy0::radio
rt2800soc-phy0::quality w856n:blue:wlan
root@OpenWrt:/sys/class/leds# cd w856n\:blue\:wlan/
root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan# ls
brightness max_brightness trigger
device subsystem uevent
root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan# echo "1" > ./brightness
root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan#
可以在用户空间操作io吗?
/sys/class/gpio里可以看到,但是我需要怎么配置才能让wifi打开是指示灯亮,关闭WiFi时指示灯灭呢?
root@OpenWrt:/sys/class/gpio#
root@OpenWrt:/sys/class/gpio# ls
export gpiochip0 gpiochip40 gpiochip72 unexport
root@OpenWrt:/sys/class/gpio#
以上是我的dts文件,代码部分为我增加的操作,最终不能实现功能,请各位大侠指导一下
openwrt下如何添加wifi指示灯和wan指示灯?
我用的MT7620a的开发板,wled-->gpio#72,wan-->gpio#49,我在openwrt/target/linux/ramips/dts/MT7620a.dts里做了如下操作(红色部分),可是编译出的固件指示灯还是不亮,各位大佬指导一下
/dts-v1/;
/include/ "mt7620a.dtsi"
/ {
compatible = "ralink,mt7620a-eval-board", "ralink,mt7620a-soc";
model = "Ralink MT7620a + MT7610e evaluation board";
palmbus@10000000 {
gpio2: gpio@660{
status = "okay";
};
gpio3: gpio@688{
status = "okay";
};
spi@b00 {
status = "okay";
m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "en25q64";
reg = <0 0>;
linux,modalias = "m25p80", "en25q64";
spi-max-frequency = <10000000>;
partition@0 {
label = "u-boot";
reg = <0x0 0x30000>;
read-only;
};
partition@30000 {
label = "u-boot-env";
reg = <0x30000 0x10000>;
read-only;
};
factory: partition@40000 {
label = "factory";
reg = <0x40000 0x10000>;
read-only;
};
partition@50000 {
label = "firmware";
reg = <0x50000 0x1fb0000>;
};
};
};
};
pinctrl {
state_default: pinctrl0 {
gpio {
ralink,group = "i2c", "uartf","wled";
ralink,function = "gpio";
};
};
};
ethernet@10100000 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
ralink,port-map = "llllw";
};
wmac@10180000{
ralink,mtd-eeprom = <&factory 0>;
};
gpio-leds {
compatible = "gpio-leds";
wan {
label = "w856n:blue:wan"; /*led灯的标识,会体现在/sys/class/leds目录中*/
gpios = <&gpio2 9 1>; /*led灯对应的gpio编号;表示是gpio2组中的第4个GPIO;这里的wan对应路由器面板外壳上的丝印*/
};
wlan {
label = "w856n:blue:wlan";
gpios = <&gpio3 0 1>;
};
};
gsw@10110000 {
ralink,port4 = "gmac";
};
sdhci@10130000 {
status = "okay";
};
pcie@10140000 {
status = "okay";
};
gpio-keys-polled {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <20>;
s2 {
label = "reset";
gpios = <&gpio0 1 1>;
linux,code = <0x198>;
};
s3 {
label = "power";
gpios = <&gpio0 2 1>;
linux,code = <116>;
};
};
ehci@101c0000 {
status = "okay";
};
ohci@101c1000 {
status = "okay";
};
};
到什么地方查看根文件系统呢?
我也不太清楚
最近准备通过UUID的方式挂载硬盘,但是我发现一个奇怪的现象:就是我在/etc/fstab里面写入硬盘UUID实现自动挂载,可是重启后/etc/fastab里的内容被清空
root@OpenWrt:/# cd /etc
root@OpenWrt:/etc# ls
TZ fstab ppp
banner group preinit
banner.failsafe hosts profile
board.d hotplug-preinit.json protocols
board.json hotplug.d rc.button
config hotplug.json rc.common
crontabs init.d rc.d
device_info inittab rc.local
diag.sh modules-boot.d resolv.conf
dnsmasq.conf modules.d services
dnsmasq.time mtab shadow
dropbear openwrt_release shells
e2fsck.conf openwrt_version sysctl.conf
ethers opkg sysupgrade.conf
filesystems opkg.conf uci-defaults
firewall.user passwd
root@OpenWrt:/etc# vi fstab
UUID="3E60240A6023C80B" /mnt/neizhi/sda1 ntfs defaults 0 2
保存退出后重启,再vi /etc/fstab 里面被清空了,也没有实现UUID自动挂载功能,这什么情况?
请问,
在Linux下如何识别硬盘和U盘?
我的意思是说经过我刚刚的改动 ,按之前的理解
hotplug.json中有描述, 如果 uevent 中含有BUTTON 字符串, 而且SUBSYSTEM 为 "button", 则执行/etc/rc.button/下的 %BUTTON%脚本来处理。
BUTTON赋值为“hello”了所以就去执行/etc/rc.button/下的hello脚本文件,但是/etc/rc.button/下没有hello这个文件,所以应该没有任何反应才对,但实际上板子却复位了
不对!好像不是这样的,我在DTS中改了 label = "hello";
gpio-keys-polled {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <20>;
s2 {
label = "hello";
gpios = <&gpio0 1 1>;
linux,code = <0x198>;
};
s3 {
label = "S3";
gpios = <&gpio0 2 1>;
linux,code = <0x101>;
};
};
编译后固件里/etc/rc.button/ 没有hello这个脚本文件还是reset ,an按下按键依然可以复位,所以好像不是上面描述那样的
failsafe power reset rfkill
我在DTS中定义了:
label = "reset";
gpio-keys-polled {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <20>;
s2 {
label = "reset";
gpios = <&gpio0 1 1>;
linux,code = <0x198>;
};
s3 {
label = "S3";
gpios = <&gpio0 2 1>;
linux,code = <0x101>;
};
};
就相当于给
hotplug.json中有描述, 如果 uevent 中含有BUTTON 字符串, 而且SUBSYSTEM 为 "button", 则执行/etc/rc.button/下的 %BUTTON%脚本来处理。
BUTTON赋值为“reset”所以就去执行/etc/rc.button/下的reset里的脚本文件?如果在DTS里改成
label = "hello";
是不是就去执行/etc/rc.button/下的hello(当然前提得有这个文件),你看我的理解对么?
大哥你在贴子上的回复我看到了,我非常感谢你的热心帮助,,不过有点没太明白,具体疑问如下:我在DTS中定义了
就相当于给
BUTTON赋值为“reset”所以就去执行/etc/rc.button/下的reset里的脚本文件?如果在DTS里改成
是不是就去执行/etc/rc.button/下的hello(当然前提得有这个文件),你看我的理解对么?
在/etc/rc.button目录下有如下文件:
failsafe power reset rfkill
我是要在/etc/rc.button目录下建一个文件调用umount.sh 呢?还是在上面的哪一个文件里调用umount.sh 按键按下系统是怎么找到这个脚本文件的呢?这点我一直没想明白
嗯嗯!对!我参考了一键复位来做的,一键复位中修改了DTS中MT7620a.dts文件来修改GPIO口:(下面的S2用来复位,准备用S3来做一键U盘弹出)
gpio-keys-polled {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <20>;
s2 {
label = "reset";
gpios = <&gpio0 1 1>;
linux,code = <0x198>;
};
s3 {
label = "S3";
gpios = <&gpio0 2 1>;
linux,code = <0x101>;
};
};
然后cd /etc/rc.button
vi reset 如下:
#!/bin/sh
[ "${ACTION}" = "released" ] || exit 0
. /lib/functions.sh
logger "$BUTTON pressed for $SEEN seconds"
if [ "$SEEN" -lt 1 ]
then
echo "REBOOT" > /dev/console
sync
reboot
elif [ "$SEEN" -gt 5 ]
then
echo "FACTORY RESET" > /dev/console
jffs2reset -y && reboot &
fi
return 0
这样就可以实现一键复位了,可是一键弹出U盘就不知该如何下手了
我现在想添加一个按键,当自动挂载上以后按下按键就umount,但是我现在不明白的是当按键按下触发异常以后是调用哪些路径下的脚本
这个脚本是什么情况下卸载呢?是拔掉U盘就自动卸载么?
openwrt在MT7620a中实现了自动挂载U盘或硬盘,
但是不能自动卸载,还得手动umount,
请问各大神如何实现一键umonut弹出u盘?
必须的
三个全改了,编译以后ok了!!感谢大神们指点迷津D
我find到三个文件改哪一个?还是都改?
./build_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/linux-3.18.75/drivers/mtd/devices/m25p80.c
./build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/linux-3.18.75/.pc/platform/0044-mtd-add-chunked-read-io-to-m25p80.patch/drivers/mtd/devices/m25p80.c
./build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/linux-3.18.75/drivers/mtd/devices/m25p80.c
我用的是MT7620a 32M 也是这么改么?
为什么我的源码根目录没有这个drivers啊 只有这些
bin Config.in feeds.conf.default LICENSE rules.mk tmp
BSDmakefile dl include Makefile scripts toolchain
build_dir docs key-build package staging_dir tools
config feeds key-build.pub README target
页次: 1