Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
B
Burning_Tool
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AM335X
Burning_Tool
Commits
8424bd1c
Commit
8424bd1c
authored
Jul 02, 2018
by
wangjunqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加通用linux脚本
parent
0cfc620b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
0 deletions
+178
-0
README.md
README.md
+4
-0
common_linux.sh
common_linux.sh
+174
-0
No files found.
README.md
View file @
8424bd1c
...
...
@@ -47,6 +47,10 @@ linux目录
/rootfs
wt2416-rootfs.tar
wt2416-userfs.tar
或
/rootfs
rootfs.tar
userfs.tar
wince 目录
单层全部内容
common_linux.sh
0 → 100755
View file @
8424bd1c
#!/bin/sh
AMIROOT
=
`
whoami
|
awk
{
'print $1'
}
`
if
[
"
$AMIROOT
"
!=
"root"
]
;
then
echo
" **** Error *** must run script with sudo"
echo
""
exit
fi
check_for_sdcards
()
{
# find the avaible SD cards
ROOTDRIVE
=
`
mount |
grep
'on / '
|
awk
{
'print $1'
}
|
cut
-c6-8
`
PARTITION_TEST
=
`
cat
/proc/partitions |
grep
-v
$ROOTDRIVE
|
grep
'\<sd.\>\|\<mmcblk.\>'
|
grep
-n
''
`
if
[
"
$PARTITION_TEST
"
=
""
]
;
then
echo
-e
"Please insert a SD card to continue
\n
"
while
[
"
$PARTITION_TEST
"
=
""
]
;
do
read
-p
"Type 'y' to re-detect the SD card or 'n' to exit the script: "
REPLY
if
[
"
$REPLY
"
=
'n'
]
;
then
exit
1
fi
ROOTDRIVE
=
`
mount |
grep
'on / '
|
awk
{
'print $1'
}
|
cut
-c6-8
`
PARTITION_TEST
=
`
cat
/proc/partitions |
grep
-v
$ROOTDRIVE
|
grep
'\<sd.\>\|\<mmcblk.\>'
|
grep
-n
''
`
done
fi
}
check_for_sdcards
echo
-e
"
\n
Available Drives to write images to:
\n
"
DEVICEDRIVENAME
=
`
cat
/proc/partitions |
grep
-i
boot |
awk
{
'print $4'
}
|
cut
-c1-7
|
uniq
`
IMAGEDEVICE
=
`
cat
/proc/partitions|grep
-v
$DEVICEDRIVENAME
|awk
{
'print $4'
}
|grep mmc|
cut
-c1-7
|
uniq
`
DRIVE
=
/dev/
$DEVICEDRIVENAME
IMAGEDRIVE
=
/dev/
$IMAGEDEVICE
echo
$DRIVE
echo
$IMAGEDRIVE
if
[[
${
DEVICEDRIVENAME
}
=
^sd.
]]
;
then
echo
"
$DRIVE
is an sdx device"
P
=
''
NUM_ALL_DRIVES
=
`
cat
/proc/partitions |
grep
${
DEVICEDRIVENAME
}
|
wc
-l
`
else
echo
"
$DRIVE
is an mmcblkx device"
P
=
'p'
NUM_ALL_DRIVES
=
`
cat
/proc/partitions |
grep
${
DEVICEDRIVENAME
}
$P
|
wc
-l
`
fi
echo
$NUM_ALL_DRIVES
DEL_CMD
=
""
if
[
"
$NUM_ALL_DRIVES
"
==
"1"
]
;
then
DEL_CMD
=
"d
\n
"
elif
[
"
$NUM_ALL_DRIVES
"
==
"2"
]
;
then
DEL_CMD
=
"d
\n
2
\n
d
\n
"
elif
[
"
$NUM_ALL_DRIVES
"
==
"3"
]
;
then
DEL_CMD
=
"d
\n
3
\n
d
\n
2
\n
d
\n
"
elif
[
"
$NUM_ALL_DRIVES
"
==
"4"
]
;
then
DEL_CMD
=
"d
\n
4
\n
d
\n
3
\n
d
\n
2
\n
d
\n
"
else
DEL_CMD
=
""
fi
echo
"Format EMMC Start..."
>
/dev/tty1
echo
-e
"
${
DEL_CMD
}
n
\n
p
\n
1
\n\n
+100M
\n
n
\n
p
\n
2
\n\n
+2048M
\n
n
\n
p
\n
3
\n\n\n
t
\n
1
\n
c
\n
a
\n
1
\n
p
\n
w
\n
"
| fdisk
${
DRIVE
}
sleep
5
echo
"Format EMMC End..."
>
/dev/tty1
echo
"Format Disk Start..."
>
/dev/tty1
mkfs.vfat
-F
32
${
DRIVE
}
p1
until
[
"
$?
"
==
0
]
;
do
sleep
8
done
mkfs.ext4
-F
${
DRIVE
}
p2
until
[
"
$?
"
==
0
]
;
do
sleep
8
done
mkfs.ext4
-F
${
DRIVE
}
p3
until
[
"
$?
"
==
0
]
;
do
sleep
8
done
echo
"Format Disk End..."
>
/dev/tty1
sleep
8
mkdir
-p
/mnt/boot
mkdir
-p
/mnt/root
mkdir
-p
/mnt/home
mkdir
-p
/mnt/image
if
[
!
-d
"/mnt/boot"
]
;
then
mkdir
-p
/mnt/boot
echo
"mount
${
DRIVE
}
p1 on /mnt/boot"
>
/dev/tty1
mount
${
DRIVE
}
p1 /mnt/boot
else
echo
"mount
${
DRIVE
}
p1 on /mnt/boot"
>
/dev/tty1
mount
${
DRIVE
}
p1 /mnt/boot
fi
if
[
!
-d
"/mnt/root"
]
;
then
mkdir
-p
/mnt/root
echo
"mount
${
DRIVE
}
p2 on /mnt/root"
>
/dev/tty1
mount
${
DRIVE
}
p2 /mnt/root
else
echo
"mount
${
DRIVE
}
p2 on /mnt/root"
>
/dev/tty1
mount
${
DRIVE
}
p2 /mnt/root
fi
if
[
!
-d
"/mnt/home"
]
;
then
mkdir
-p
/mnt/home
echo
"mount
${
DRIVE
}
p3 on /mnt/home"
>
/dev/tty1
mount
${
DRIVE
}
p3 /mnt/home
else
echo
"mount
${
DRIVE
}
p3 on /mnt/home"
>
/dev/tty1
mount
${
DRIVE
}
p3 /mnt/home
fi
if
[
!
-d
"/mnt/image"
]
;
then
mkdir
-p
/mnt/image
echo
"mount
${
IMAGEDRIVE
}
p1 on /mnt/image"
>
/dev/tty1
mount
${
IMAGEDRIVE
}
p1 /mnt/image
else
echo
"mount
${
IMAGEDRIVE
}
p1 on /mnt/image"
>
/dev/tty1
mount
${
IMAGEDRIVE
}
p1 /mnt/image
fi
cd
/mnt/image
if
[
!
-d
"linux"
]
;
then
echo
"Linux Image Folder not found"
>
/dev/tty1
exit
1
else
echo
"Start Copy Linux Image..."
>
/dev/tty1
cd
linux/
if
[
-d
"boot"
]
;
then
echo
"Copy Boot..."
>
/dev/tty1
cp
boot/
*
/mnt/boot
else
echo
"Can Not Find Boot..."
>
/dev/tty1
exit
1
fi
if
[
-d
"rootfs"
]
;
then
echo
"Copy Rootfs..."
>
/dev/tty1
cd
rootfs
tar
-xf
rootfs.tar
--strip-components
1
-C
/mnt/root
tar
-xf
usrfs.tar
--strip-components
1
-C
/mnt/home
else
echo
"Copt Rootfs End..."
>
/dev/tty1
exit
1
fi
fi
echo
"Sync files..."
>
/dev/tty1
sync
sync
sync
cd
~
echo
"Image Done..."
>
/dev/tty1
umount /mnt/boot
umount /mnt/root
umount /mnt/home
umount /mnt/image
#buzzer
echo
0
>
/sys/class/pwm/pwmchip0/export
sleep
1
echo
1000000
>
/sys/class/pwm/pwmchip0/pwm0/period
echo
500000
>
/sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo
1
>
/sys/class/pwm/pwmchip0/pwm0/enable
sleep
10
echo
0
>
/sys/class/pwm/pwmchip0/pwm0/enable
echo
7
>
/sys/class/backlight/backlight/brightness
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