Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
duo-buildroot-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
duo-buildroot-sdk
Commits
7186ede6
Commit
7186ede6
authored
Mar 11, 2023
by
sam.xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a script to package the SD card boot image
Change-Id: Ia9f31c72725a25abdd55fb1bd114e4f4dd466f4c
parent
f5796010
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
build/common_functions.sh
build/common_functions.sh
+5
-0
build/tools/common/sd_tools/sd_gen_burn_image.sh
build/tools/common/sd_tools/sd_gen_burn_image.sh
+84
-0
No files found.
build/common_functions.sh
View file @
7186ede6
...
@@ -244,6 +244,11 @@ function pack_upgrade
...
@@ -244,6 +244,11 @@ function pack_upgrade
command rm
-rf
"
$TMPDIR
"
command rm
-rf
"
$TMPDIR
"
)}
)}
function
pack_sd_image
{(
"
$COMMON_TOOLS_PATH
"
/sd_tools/sd_gen_burn_image.sh
"
$OUTPUT_DIR
"
)}
function
pack_prog_img
function
pack_prog_img
{(
{(
local
tmp_dir
local
tmp_dir
...
...
build/tools/common/sd_tools/sd_gen_burn_image.sh
0 → 100755
View file @
7186ede6
#!/bin/bash
# a sd image generator for sophpi
# usage
if
[
"$#"
-ne
"1"
]
then
echo
"usage: sudo ./sd_gen_burn_image.sh OUTPUT_DIR"
echo
""
echo
" The script is used to create a sdcard image with two partitions, "
echo
" one is fat32 with 128MB, the other is ext4 with 256MB."
echo
" You can modify the capacities in this script as you wish!"
echo
""
echo
"Note: Please backup you sdcard files before using this image!"
exit
fi
vfat_cap
=
128M
vfat_label
=
"boot"
ext4_cap
=
256M
ext4_label
=
"rootfs"
output_dir
=
$1
echo
${
output_dir
}
pushd
${
output_dir
}
# gen a empty image
image
=
sophpi-duo-
`
date
+%Y%m%d-%H%M
`
.img
echo
${
image
}
dd
if
=
/dev/zero
of
=
./
${
image
}
bs
=
1M
count
=
512
################################
# Note: do not change this flow
################################
sudo
fdisk ./
${
image
}
<<
EOF
n
p
1
+
${
vfat_cap
}
n
p
2
+
${
ext4_cap
}
w
EOF
# Note end
################################
dev_name
=
`
sudo
losetup
-f
`
echo
${
dev_name
}
echo
""
sudo
losetup
${
dev_name
}
./
${
image
}
sudo
partprobe
${
dev_name
}
sudo
mkfs.vfat
-F
32
-n
${
vfat_label
}
${
dev_name
}
p1
sudo
mkfs.ext4
-L
${
ext4_label
}
${
dev_name
}
p2
# mount partitions
rm
./tmp1 ./tmp2
-rf
mkdir
tmp1 tmp2
sudo
mount
-t
vfat
${
dev_name
}
p1 tmp1/
sudo
mount
-t
ext4
${
dev_name
}
p2 tmp2/
# copy boot file and rootfs
sudo cp
${
output_dir
}
/fip.bin ./tmp1/
sudo cp
${
output_dir
}
/rawimages/boot.sd ./tmp1/
sudo cp
-raf
${
output_dir
}
/rootfs/
*
./tmp2
sync
# umount
sudo
umount tmp1 tmp2
sudo
losetup
-d
${
dev_name
}
rmdir
tmp1 tmp2
# tar image
tar
zcvf
${
image
}
.tar.gz
${
image
}
echo
"Gen image successful:
${
image
}
"
echo
""
popd
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment