add swap partition

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
Michel-FK
2020-11-02 16:49:47 +01:00
parent c5c4b15523
commit 79a7be9716
11 changed files with 113 additions and 107 deletions

View File

@@ -7,4 +7,4 @@ tmpfs /tmp tmpfs mode=1777 0 0
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
sysfs /sys sysfs defaults 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
/dev/mmcblk0p3 /mnt vfat rw,relatime,fmask=0022,dmask=0022,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
/dev/mmcblk0p4 /mnt vfat rw,relatime,fmask=0022,dmask=0022,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0

View File

@@ -17,7 +17,7 @@ menu_display () {
0)
# USB mount/unmount
mount | grep -q /dev/mmcblk0p3
mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then
message=" USB mount"
else
@@ -80,7 +80,7 @@ menu_run () {
0)
# USB mount/unmount
mount | grep -q /dev/mmcblk0p3
mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then
notif "${message}..."
share start
@@ -112,14 +112,14 @@ menu_run () {
1)
# USB check
mount | grep -q /dev/mmcblk0p3
mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then
notif "${message}..."
umount /mnt >/dev/null 2>&1
if [ $? -ne 0 ]; then
notif "${message}...^Cannot check USB!"
fi
fsck.fat -a -v -w /dev/mmcblk0p3
fsck.fat -a -v -w /dev/mmcblk0p4
if [ $? -ne 0 ]; then
notif "${message}...^Cannot check USB!"
fi
@@ -137,14 +137,14 @@ menu_run () {
2)
# USB format
mount | grep -q /dev/mmcblk0p3
mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then
notif "${message}...^Press A to confirm"
while true; do
case $(getkey) in
1e0001|1e0002)
umount /mnt &&
mkfs.vfat /dev/mmcblk0p3 &&
mkfs.vfat /dev/mmcblk0p4 &&
mount /mnt
if [ $? -ne 0 ]; then
notif "${message}...^Cannot format USB!"
@@ -171,7 +171,7 @@ menu_run () {
3)
# Network enable/disable
mount | grep -q /dev/mmcblk0p3
mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then
if [ -e /mnt/usbnet ]; then
rm -f /mnt/usbnet
@@ -196,7 +196,7 @@ menu_run () {
5)
# Factory tests enable/disable
mount | grep -q /dev/mmcblk0p3
mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then
if [ -e /mnt/.assembly_tests ]; then
rm -f /mnt/.assembly_tests

View File

@@ -13,7 +13,7 @@ source usb_gadget
USB_IF=/etc/network/interfaces.d/usb0
# The USB mass storage backing store file or partition
BACKING_STORE_FILE=/sys/kernel/config/usb_gadget/FunKey/functions/mass_storage.mmcblk0p3/lun.0/file
BACKING_STORE_FILE=/sys/kernel/config/usb_gadget/FunKey/functions/mass_storage.mmcblk0p4/lun.0/file
# Unmount a local share
unmount_share () {
@@ -25,11 +25,11 @@ unmount_share () {
# Mount a share locally
mount_share () {
mount | grep -q /dev/mmcblk0p3
mount | grep -q /dev/mmcblk0p4
if [ $? -ne 0 ]; then
# Check if the FAT32 partition has been unmounted cleanly
fsck.fat -n /dev/mmcblk0p3 2>/dev/null | egrep -q "Dirty bit"
fsck.fat -n /dev/mmcblk0p4 2>/dev/null | egrep -q "Dirty bit"
if [ $? -eq 0 ]; then
# The FAT32 partition was not cleanly unmounted, try to
@@ -86,7 +86,7 @@ start_share () {
# 1) Check if the backing store partition is already shared
if [ -e $BACKING_STORE_FILE ]; then
cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3 && die 12 "the backing store partition is already shared"
cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p4 && die 12 "the backing store partition is already shared"
fi
# 2) Check if USB data is connected
@@ -97,7 +97,7 @@ start_share () {
# 4) Everything is now clear to start sharing the backing store partition
info "start sharing the backing store partition"
echo /dev/mmcblk0p3 > $BACKING_STORE_FILE || die 14 "cannot share the backing store partition"
echo /dev/mmcblk0p4 > $BACKING_STORE_FILE || die 14 "cannot share the backing store partition"
}
# Return if currently sharing
@@ -107,7 +107,7 @@ is_share_started () {
echo "no"
return 1
fi
cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3
cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p4
local res=$?
if [ "$res" == "0" ]; then
echo "yes"

View File

@@ -52,7 +52,7 @@ init_usb_gadget() {
mkdir ${GADGET}/configs/FunKey.1
mkdir ${GADGET}/configs/FunKey.1/strings/0x409
test ${USBNET} -eq 1 && mkdir ${GADGET}/functions/rndis.usb0
mkdir ${GADGET}/functions/mass_storage.mmcblk0p3
mkdir ${GADGET}/functions/mass_storage.mmcblk0p4
# USB2
echo "0x0200" > ${GADGET}/bcdUSB
@@ -123,22 +123,22 @@ init_usb_gadget() {
# Mass Storage Function
# Backing Store file
#echo "/dev/mmcblk0p3" > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/file
#echo "/dev/mmcblk0p4" > ${GADGET}/functions/mass_storage.mmcblk0p4/lun.0/file
# Gadget is not allowed to halt bulk endpoints
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p3/stall
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p4/stall
# Do not simulate a CDROM
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/cdrom
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p4/lun.0/cdrom
# No SCSI Force Unit Access (FUA) to work in synchronous mode ?!?
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/nofua
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p4/lun.0/nofua
# LUN is removable
echo 1 > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/removable
echo 1 > ${GADGET}/functions/mass_storage.mmcblk0p4/lun.0/removable
# Inquiry String
echo "FunKey S Shared Disk" > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/inquiry_string
echo "FunKey S Shared Disk" > ${GADGET}/functions/mass_storage.mmcblk0p4/lun.0/inquiry_string
if [ ${USBNET} -eq 1 ]; then
@@ -157,7 +157,7 @@ init_usb_gadget() {
fi
# Add the Mass Storage function to the FunKey.1 configuration
ln -s ${GADGET}/functions/mass_storage.mmcblk0p3 ${GADGET}/configs/FunKey.1
ln -s ${GADGET}/functions/mass_storage.mmcblk0p4 ${GADGET}/configs/FunKey.1
# Each interface specifies its own class code
echo "0x00" > ${GADGET}/bDeviceClass