Gryphon Lv3

ip addr add 192.168.1.1/20 dev eth0

适配ubootenv:

需要将将CONFIG_SPI_NANDSPI_NAND注释掉,开启CONFIG_MMC

1.升级命令

function cmd
上层升级kernel mount /dev/mmcblk0p1 /mnt/;cd /mnt/;tftp -gr v3s.itb 192.168.1.10;
上层升级uboot tftp -gr u-boot-sunxi-with-spl-250825.bin 192.168.1.10;
上层升级rootfs mount /dev/mmcblk0p3 /mnt/;cd /mnt/;

2.启动命令

function cmd
从emmc ramfs启动镜像 setenv boot_ramfs “setenv bootargs console=ttyS0,115200 rdinit=/sbin/init panic=10 && fatload mmc 0:1 0x41F00000 v3s.itb && bootm 0x41F00000”
从emmc启动镜像 setenv boot_mmc “setenv bootargs console=ttyS0,115200 rdinit=/sbin/init panic=10 && fatload mmc 0:1 0x41F00000 v3s.itb && bootm 0x41F00000#config-ramfs”
从tftp启动fit镜像 setenv bootcmd “run boot_tftp”
使用测试dtb启动 setenv bootcmd “run boot_test”;

1.fit镜像制作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
=> fdt print
/ {
timestamp = <0x6846acbc>;
description = "Various kernels, ramdisks and FDT blobs";
#address-cells = <0x00000001>;
version = <0x00000001>;
images {
kernel-1 {
description = "Linux ARM kernel";
data = * 0x41f000ec [0x003d9048];
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0x40100000>;
entry = <0x40100000>;
hash-1 {
value = <0x28cd78ac>;
algo = "crc32";
};
hash-2 {
value = <0xf686bbda 0xcfeb22a3 0x656f975a 0x7fccb025 0xbda233ad>;
algo = "sha1";
};
};
fdt-lichee {
description = "ARM OpenWrt qcom_mixx device tree blob";
data = * 0x422d926c [0x00002dd0];
type = "flat_dt";
arch = "arm";
compression = "none";
load = <0x40700000>;
entry = <0x40700000>;
hash-1 {
value = <0x6c6ca1d5>;
algo = "crc32";
};
hash-2 {
value = <0x2143c02d 0xdf21a670 0x7f80a63d 0xc709f8ad 0x2e53e977>;
algo = "sha1";
};
};
ramdisk-1 {
description = "Buildroot Initramfs rootfs";
data = * 0x422dc154 [0x00c2b200];
type = "ramdisk";
arch = "arm";
os = "linux";
compression = "none";
load = <0x40800000>;
entry = <0x40800000>;
hash-1 {
value = <0x77a6f3f4>;
algo = "crc32";
};
hash-2 {
value = <0x64e28de4 0xfb8bab72 0xb66bd5a9 0x5e57105a 0x09c4a443>;
algo = "sha1";
};
};
};
configurations {
default = "lichee";
config-lichee {
description = "licheepi-zero-dock OS";
kernel = "kernel-1";
fdt = "fdt-lichee";
};
config-ramfs {
description = "licheepi-zero-dock OS";
kernel = "kernel-1";
fdt = "fdt-lichee";
ramdisk = "ramdisk-1";
};
};
};

2.genimage制作烧录精选

start addr end addr
Uboot 8K 512k
uboot env 512k 512k+256k

附录文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
image boot.vfat {
vfat {
files = {
"zImage",
"sun8i-v3s-licheepi-zero-dock.dtb",
"sun8i-v3s-licheepi-zero.dtb",
"boot.scr"
}
}

size = 8M
}

image sdcard.img {
hdimage {
}

partition u-boot {
in-partition-table = "no"
image = "u-boot-sunxi-with-spl.bin"
offset = 8K
size = 504K # 512KB - 8KB
}

partition boot {
partition-type = 0xC
bootable = "true"
image = "boot.vfat"
}

partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
size = 0
}
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#!/bin/sh
mkdir -p /tmp/ramroot /tmp/ramroot/tmp

# Step 2: 挂载 tmpfs 作为新根(RAM 文件系统)
mount -t tmpfs -o size=32M tmpfs /tmp/ramroot

# Step 3: 创建必要的目录结构
mkdir -p /tmp/ramroot/proc
mkdir -p /tmp/ramroot/sys
mkdir -p /tmp/ramroot/dev
mkdir -p /tmp/ramroot/tmp
mkdir -p /tmp/ramroot/oldroot

# Step 4: 拷贝基础文件(可选)
cp -a /bin /sbin /etc /lib* /usr /tmp/ramroot/

# Step 5: 挂载虚拟文件系统到新根
mount --bind /proc /tmp/ramroot/proc
mount --bind /sys /tmp/ramroot/sys
mount --bind /dev /tmp/ramroot/dev

# Step 6: 执行 pivot_root
cd /tmp/ramroot
pivot_root . ./oldroot

# Step 7: 清理旧根
exec chroot . sh <<EOF
umount -l /oldroot/proc
umount -l /oldroot/sys
umount -l /oldroot/dev
umount -l /oldroot
EOF

# Step 8: 启动新系统的 init
exec chroot . /sbin/init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
setenv serverip 192.168.1.10;
setenv ipaddr 192.168.1.1;

tftpboot 0x44000000 u-boot-sunxi-with-spl.bin;
mmc dev 0;
mmc write 0x44000000 0x10 1024;

###
setenv serverip 192.168.1.10;setenv ipaddr 192.168.1.1;
setenv bootargs console=ttyS0,115200 rdinit=/sbin/init panic=10 earlyprintk rw
tftpboot 0x41F00000 iboot.itb;
bootm 0x41F00000#config-lichee
bootm 0x41F00000#config-ramfs
###
setenv bootcmd boot_tftp
setenv boot_tftp "setenv bootargs console=ttyS0,115200 rdinit=/sbin/init panic=10 e && tftpboot 0x41F00000 iboot.itb; && bootm 0x41F00000#config-ramfs"

###
n e
2097152 +36M w


###
fdisk /dev/mmcblk0
mkfs.ext2 /dev/mmcblk0p4
mount /mnt/ /dev/mmcblk0p4
mount /dev/mmcblk0p4 /mnt/
cd /mnt/
ifconfig eth0 up
192.168.1.1
tftp -gr rootfs.ext2 192.168.1.10

#!/bin/sh
# /etc/init.d/S99overlay

mount -n -t ext4 /dev/mmcblk0p3 -o rw,noatime /overlay;
mkdir -p /overlay/upper /overlay/work /mnt/rom;
mount -n -t overlay overlayfs:/overlay -o rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work /mnt;
mount -n /proc -o noatime,--move /mnt/proc;
pivot_root /mnt /mnt/rom;
mount -n /rom/dev -o noatime,--move /dev;
mount -n /rom/dev/shm -o noatime,--move /dev/shm;
mount -n /rom/tmp -o noatime,--move /tmp;
mount -n /rom/sys -o noatime,--move /sys;
mount -n /rom/run -o noatime,--move /run ;
mount -n /rom/media -o noatime,--move /media;





### case 2
mount -n -t ext4 /dev/mmcblk0p3 -o rw,noatime /overlay;
mkdir -p /overlay/upper /overlay/work /overlay/lower;
mount --bind / /overlay/lower;
mount -n -t overlay overlay -o rw,noatime,lowerdir=/overlay/lower,upperdir=/overlay/upper,workdir=/overlay/work /mnt;
mkdir -p /mnt/oldroot /mnt/proc /mnt/dev /mnt/shm;
mount -n /proc -o noatime,--move /mnt/proc;
pivot_root /mnt /mnt/oldroot
mount -n /oldroot/dev -o noatime,--move /dev;
mount -n /oldroot/dev/shm -o noatime,--move /dev/shm;
mount -n /oldroot/tmp -o noatime,--move /tmp;
mount -n /oldroot/sys -o noatime,--move /sys;
mount -n /oldroot/run -o noatime,--move /run ;
mount -n /oldroot/media -o noatime,--move /media;

upgrade.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# cat upgrade.sh 
#!/bin/sh

input_file="/etc/config/aspen_upgrade.cfg"
server_ip="$1"
upgrade_img="$2"
# ALL_FLASH_PARTITION=/dev/mtd20
ALL_FLASH_PARTITION=/dev/mmcblk0


print_usage() {
echo "usage:"
echo "sc_upgrade.sh <serverip> <file>"
echo "EX: sc_upgrade.sh 192.168.1.10 wa7232-noecc.bin"
}

check_file_valid() {
if [ "$1" = "" ]; then
return 1
fi
if [ "$2" != "" ]; then
return 1
fi
if [ -f "$1" ] && [ -s "$1" ]; then
return 0
else
return 1
fi
}

is_number() {
regex='^[0-9]+$'
if [[ $1 =~ $regex ]]
then
return 0 #number
else
return -1 #Not a number
fi
}

split_images() {
local section=""
local img=""
local addr_s=""
local addr_e=""

while IFS= read -r line; do
line=$(echo "$line" | sed 's/^\s*//;s/\s*$//') # Trim leading/trailing whitespace

# Skip empty lines
[ -z "$line" ] && continue

# Detect section headers
if echo "$line" | grep -q '^\[img[0-9]*\]$'; then
section=$(echo "$line" | sed 's/[][]//g')
continue
fi

# Detect key-value pairs
if echo "$line" | grep -q '='; then
key=$(echo "$line" | cut -d '=' -f 1 | sed 's/^\s*//;s/\s*$//')
value=$(echo "$line" | cut -d '=' -f 2 | sed 's/^\s*//;s/\s*$//')

case $key in
img)
img="$value"
;;
addr_s)
addr_s="$value"
;;
addr_e)
addr_e="$value"
;;
esac
fi

if [ -n "$img" ] && [ -n "$addr_s" ] && [ -n "$addr_e" ]; then
start_addr=$(printf "%d" "$addr_s") # Convert hex to decimal
end_addr=$(printf "%d" "$addr_e") # Convert hex to decimal
size=$((end_addr - start_addr))

cmd="dd if=\"$upgrade_img\" of=\"$img\" bs=1k skip=$((start_addr / 1024)) count=$((size / 1024))"
echo "Excuting $cmd"
eval "$cmd"
if [ $? -ne 0 ]; then
echo "Error: Command failed to execute: $cmd"
exit 1
fi

img=""
addr_s=""
addr_e=""
fi
done < "$input_file"
}

do_mtd_flash() {
local part_offest=$1
local part_size=$2
local mtd_device=$3
local upgrade_file=$4

echo "================= $upgrade_file ================="


cmd="dd if=/dev/zero of=$mtd_device bs=1k seek=$(($part_offest/1024)) count=$(($part_size/1024))"
# cmd="sc_mtd -p \"$part_offest\" -P \"$part_size\" erase \"$mtd_device\""
echo "Excuting $cmd"
eval "$cmd"

if [ $? -ne 0 ]; then
echo "Erase flash failed!!!"
exit 1
fi

size=$(ls -l "$upgrade_file" | awk '{print $5}')
is_number $size
if [ $? -ne 0 ]; then
echo "$upgrade_file doesn't exist!!!"
exit 1
fi


#cmd="sc_mtd -p \"$part_offest\" -P \"$part_size\" write \"$upgrade_file\" \"$mtd_device\""
cmd="dd if=$img of=$mtd_device bs=1k seek=$(($part_offest/1024)) count=$(($part_size/1024))"
echo "Excuting $cmd"
eval "$cmd"
if [ $? -ne 0 ]; then
echo "Write img to flash failed!!!"
exit 1
fi


cmd="dd if=$mtd_device of=file_check bs=1k skip=$(($part_offest/1024)) count=$(($part_size/1024))"
# cmd="sc_mtd -o \"$part_offest\" -P \"$part_size\" -l \"$size\" read \"$mtd_device\" file_check"
echo "Excuting $cmd"
eval "$cmd"



orig_md5=$(md5sum "$upgrade_file" | cut -d ' ' -f1)
new_md5=$(md5sum file_check | cut -d ' ' -f1)
echo "Verify MD5:"
md5sum "$upgrade_file"
md5sum file_check
echo " "
if [ "$orig_md5" = "$new_md5" ]; then
echo "$upgrade_file write success!!!"
else
echo "$upgrade_file write fail!!!"
exit 1
fi
rm -f file_check

echo " "
echo "============================================================"

}

upgrade_flash() {

local section=""
local img=""
local addr_s=""
local addr_e=""
local type=""

while IFS= read -r line; do
line=$(echo "$line" | sed 's/^\s*//;s/\s*$//') # Trim leading/trailing whitespace

[ -z "$line" ] && continue

if echo "$line" | grep -q '^\[img[0-9]*\]$'; then
section=$(echo "$line" | sed 's/[][]//g')
continue
fi

if echo "$line" | grep -q '='; then
key=$(echo "$line" | cut -d '=' -f 1 | sed 's/^\s*//;s/\s*$//')
value=$(echo "$line" | cut -d '=' -f 2 | sed 's/^\s*//;s/\s*$//')

case $key in
img)
img="$value"
;;
addr_s)
addr_s="$value"
;;
addr_e)
addr_e="$value"
;;
type)
type="$value"
;;
esac
fi

if [ -n "$img" ] && [ -n "$addr_s" ] && [ -n "$addr_e" ]; then
start_addr=$(printf "%d" "$addr_s") # Convert hex to decimal
end_addr=$(printf "%d" "$addr_e") # Convert hex to decimal
size=$((end_addr - start_addr))

echo "Upgrading $img..."
cmd="do_mtd_flash \"$addr_s\" \"$size\" $ALL_FLASH_PARTITION \"$img\""
echo "$cmd"
eval "$cmd"

# if [ "$type" = "rootfs" ]; then
# echo "Upgrade rootfs."
# cmd="do_mtd_flash \"$addr_s\" \"$size\" $ALL_FLASH_PARTITION \"$img\""
# echo "$cmd"
# eval "$cmd"
# else
# echo "type: $type"
# fi

img=""
addr_s=""
addr_e=""
type=""
fi
done < "$input_file"
}


if [ -z "$1" ] || [ -z "$2" ]; then
echo "error: incorrect usage."
print_usage
exit 1
fi

if ! check_file_valid "$upgrade_img"; then
echo "File not exist: $upgrade_img"
ftpget $server_ip $upgrade_img
else
echo "Upgrade img $upgrade_img exist!!!"
fi

echo " "
echo "MD5 of upgrade img:"
md5sum "$upgrade_img"

split_images

upgrade_flash

echo "Upgrade sercomm FW: $upgrade_img"
echo "========================END=========================="

问题解决

case cmd reason
telnetd无法使用 mdev -s #扫描dev设备 1. /dev/ptmx 是“入口点”,不是动态设备
,/dev/pts/0, /dev/pts/1 等是动态生成的(由 devpts 文件系统自动创建)
,但 /dev/ptmx 是一个固定的入口点,内核通过它来分配新的 PTY
,它不会像 /dev/pts/* 那样由 devpts 自动创建
  • Title:
  • Author: Gryphon
  • Created at : 2025-10-13 08:46:43
  • Updated at : 2025-10-13 08:46:43
  • Link: https://phoenixs.gitlab.io/2025/10/13/youdaonote/V3S开发笔记/001.系统镜像制作/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments