BOARD/PKG: better LOGS in on OS scripts & add umtpr-debug (#169)

* firsboot/main - better LOGs
 - refactor a bit gmenu2x loop
 - add good logs for umtpr
* BOARD: options.cfg: add DEBUG options
 - use separate options for gmenu2x & umtpr debug
 - for default setup NO DEBUG
* PACKAGE: umtprd: add debug build
This commit is contained in:
Apaczer
2025-05-21 21:37:11 +02:00
committed by GitHub
parent a2929a4734
commit 5c0a711fd2
10 changed files with 283 additions and 146 deletions

View File

@@ -2,26 +2,38 @@
export TERM=linux
# expect to be run from /boot, where the boot partition is mounted (readonly)
export LOG=$(mktemp)
#LOG=/dev/null
LOG=${HOME}/log_firstboot.txt
LOG_TEMP=$(mktemp)
export LOG
export LOG_TEMP
restore_temp_log_func(){
cat ${LOG_TEMP} >> ${LOG}
sleep 2
LOG_TEMP=$(mktemp)
}
restore_dmesg_log_func(){
echo -en "\nNew DMESG log:\n" >> ${HOME}/dmesg.txt
sleep 2
dmesg >> ${HOME}/dmesg.txt
}
# high brightness
echo '10' > /sys/devices/platform/backlight/backlight/backlight/brightness
#echo -e "\e[?3c"
echo -e "\e[32m" # green
#echo -e "\e[32m" # green
echo "firstboot script running..." | tee -a ${LOG}
echo
echo -en "\e[32mfirstboot script running...\e[0m" | tee -a ${LOG}
# run a custom script if present - could be used to fix u-boot and such
if test -r "${BOOTDIR}/firstboot.custom.sh"; then
echo "Running a specific firstboot script..." | tee -a ${LOG}
(cd "${BOOTDIR}" && sh firstboot.custom.sh) | tee -a ${LOG}
(cd "${BOOTDIR}" && sh firstboot.custom.sh) 2>&1 | tee -a ${LOG}
echo "Finished running a specific firstboot script." | tee -a ${LOG}
fi
echo " "
sleep 1
@@ -41,7 +53,7 @@ consequences arising from the use or misuse of this software.
TEMP=$(mktemp)
## Access /boot directory
mount -o remount,rw "${BOOTDIR}" | tee -a ${LOG}
mount -o remount,rw "${BOOTDIR}" 2>&1 | tee -a ${LOG}
# list of available devices in u-boot Environment parameters' read from FORCE_VERSION
devices_ID="
@@ -122,13 +134,13 @@ detect_console_func(){
# write logs, sync & unmount MAIN before reboot/poweroff
safe_shutdown_func(){
echo "please wait a few seconds for a ${SHUTDOWN}...." | tee -a ${LOG}
dmesg > ${HOME}/dmesg.txt
mv ${LOG} ${HOME}/log_firstboot.txt
restore_dmesg_log_func
sync
sleep 1
mount -o remount,ro "${BOOTDIR}" | tee -a ${LOG}
umount /dev/mmcblk0p4 | tee -a ${LOG}
#umount /dev/mmcblk0p1 | tee -a ${LOG} # this fails
mount -o remount,ro "${BOOTDIR}" 2>&1 | tee -a ${LOG}
sleep 2
umount /dev/mmcblk0p4 2>&1 # | tee -a ${LOG} - logging here may brake unmouting
#umount /dev/mmcblk0p1 # this fails cuz we're running this script of /boot
sleep 4
}
@@ -145,13 +157,13 @@ safe_poweroff_func(){
}
console_unknown_func(){
echo "CONSOLE_VARIANT=unknown" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=unknown" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "##DO_NOT_REMOVE_THIS_LINE##" >> ${BOOTDIR}/console.cfg
}
## Default CONSOLE_VARIANT for st7789s screens
default_console_func(){
echo "CONSOLE_VARIANT=pocketgo" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=pocketgo" | tee ${BOOTDIR}/console.cfg >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
# No need to overwrite uboot FORCE version for default so continue procedure
CONSOLE_OVERWRITE=false
@@ -159,6 +171,7 @@ default_console_func(){
#Test-prompt dialogs fo various scenarios
test_image_func(){
echo "Performing Image Color Test" >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --defaultno --ok-label NO --cancel-label Inverted --stdout --title " Test Image" \
--colors --pause "\n\n \Z5Are your colors Inverted?\Zn\n\nSelect an option & press START" 12 34 10
@@ -169,16 +182,19 @@ test_image_func(){
## thus we have valid version and simply continue
if test $CHOICE -eq 0; then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 2 --msgbox "Colors are correct, proceed with flashing" 0 0
echo "Colors are correct" >> ${LOG}
# "INVERTED" choice for Test_Iamge msgbox DIALOG_CANCEL exit code and -1/255
## thus correct "invert" colors parameter on video driver
else
#TODO - make "invert" flag overwriting less dependent
echo "Colors are inverted, changing..." | tee -a ${LOG}
echo "INVERT=${INVERSION}" >> ${HOME}/options.cfg
safe_reboot_func
fi
}
test_video_func(){
echo "Performing Video Test" >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --defaultno --ok-label NO --cancel-label "Flipped!" --extra-button --extra-label YES --stdout --title " Test Video" \
--colors --pause "\n\n \Z5Can you see this message?\Zn\n\nSelect an option & press START" 12 34 10
@@ -189,7 +205,7 @@ test_video_func(){
# "YES" choice for Test_Video msgbox DIALOG_EXTRA exit code
if test $CHOICE -eq 3; then
# Correct variant for st7789s (non forced)
echo "CONSOLE_VARIANT=st7789s" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=st7789s" | tee ${BOOTDIR}/console.cfg >> ${LOG}
# "Flipped!" choice for Test_Video msgbox DIALOG_CANCEL exit code
elif test $CHOICE -eq 1; then
# Test_Flip-prompt double checks if user selected correct answer for 1'st video test
@@ -197,7 +213,7 @@ test_video_func(){
# "NO" or timeout choice for Test_Video msgbox thus DIALOG_OK exit code
elif test $CHOICE -eq 0; then
# Correct variant for bittboy2x_v1 (non forced)
echo "CONSOLE_VARIANT=bittboy" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=bittboy" | tee ${BOOTDIR}/console.cfg >> ${LOG}
safe_reboot_func
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
else
@@ -207,6 +223,7 @@ test_video_func(){
}
test_video2_func(){
echo "Performing Video Test-2 " >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --defaultno --ok-label NO --cancel-label YES --stdout --title " Test Video'2" \
--colors --pause "\n\n \Z5Can you see this message?\Zn\n\nSelect an option & press START" 12 34 10
@@ -216,7 +233,7 @@ test_video2_func(){
# "YES" choice for Test_Video'2 msgbox DIALOG_CANCEL exit code
## thus we have valid version, just update to FORCE_VERSION and continue
if test $CHOICE -eq 1; then
echo "CONSOLE_VARIANT=bittboy2x_v1" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=bittboy2x_v1" | tee ${BOOTDIR}/console.cfg >> ${LOG}
# "NO" or timeout choice for Test_Video msgbox thus DIALOG_OK exit code 0 (or ERROR/ESCAPE with -1/255)
## correct variant to unknown and redo whole flashing_prd again
else
@@ -226,6 +243,7 @@ test_video2_func(){
}
test_keyboard_func(){
echo "Performing Keyboard Test" >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --ok-label NO --cancel-label YES --stdout --title " Test Keyboard" \
--colors --pause "\n\n \Z5Does D-pad works correctly?\Zn\n\nSelect an option & press START" 12 34 10
@@ -237,28 +255,28 @@ test_keyboard_func(){
## thus we have valid version, just update to FORCE_VERSION and continue
if test $CHOICE -eq 1; then
if test "$CONSOLE_VARIANT" == "bittboy3"; then
echo "CONSOLE_VARIANT=bittboy3.5" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=bittboy3.5" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif test "$CONSOLE_VARIANT" == "bittboy2"; then
echo "CONSOLE_VARIANT=bittboy2x_v2" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=bittboy2x_v2" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif test "$CONSOLE_VARIANT" == "xyc"; then
echo "CONSOLE_VARIANT=xyc_gc9306" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=xyc_gc9306" | tee ${BOOTDIR}/console.cfg >> ${LOG}
# Test_Image-prompt if proper "invert" colors parameter was loaded:
INVERSION=1 #applied only if colors are inverted
test_image_func
elif test "$CONSOLE_VARIANT" == "m3"; then
echo "CONSOLE_VARIANT=m3_gc9306" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=m3_gc9306" | tee ${BOOTDIR}/console.cfg >> ${LOG}
fi
# "NO" or timeout choice for Test_Keyboard msgbox DIALOG_OK exit code
## thus correct Auto-Detection variant and reboot
elif test $CHOICE -eq 0; then
if test "$CONSOLE_VARIANT" == "bittboy3"; then
echo "CONSOLE_VARIANT=bittboy2" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=bittboy2" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif test "$CONSOLE_VARIANT" == "bittboy2"; then
console_unknown_func
elif test "$CONSOLE_VARIANT" == "xyc"; then
console_unknown_func
elif test "$CONSOLE_VARIANT" == "m3"; then
echo "CONSOLE_VARIANT=xyc" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=xyc" | tee ${BOOTDIR}/console.cfg >> ${LOG}
fi
safe_reboot_func
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
@@ -269,6 +287,7 @@ test_keyboard_func(){
}
test_variant_func(){
echo "Performing Device-Variant Test" >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --defaultno --ok-label NO --cancel-label YES --stdout --title " Test Variant" \
--colors --pause "Does this device match yours?" 0 0 15
@@ -284,9 +303,10 @@ test_variant_func(){
}
test_flip_func(){
echo "Performing Confirmation Flip Test" >> ${LOG}
if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --stdout --ok-label YES --cancel-label NO --title "Test Flip" --pause " \n Flipped? \n\nAre you sure?!" 12 15 10); then
# Correct variant for bittboy3.5 (non forced) and display info about flipped image
echo "CONSOLE_VARIANT=bittboy3" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=bittboy3" | tee ${BOOTDIR}/console.cfg >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 2 --msgbox "Image flipped! correct&reboot" 0 0
sleep 1.5
#TODO: use special Unicode characters to draw text upside-down e.g.:
@@ -305,9 +325,12 @@ if (grep -qE "${DETECTED_1}|${DETECTED_2}|${DETECTED_3}|${DETECTED_4}|${DETECTED
fi
# I - Test_Block
echo "Starting I Block - Test" >> ${LOG}
detect_console_func
if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
echo "Auto-Detected Console's variant from uEnv" >> ${LOG}
if (grep -q "$DETECTED_1" "${BOOTDIR}/uEnv.txt"); then
echo "Auto-Detected $DETECTED_1" >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_1" 0 0
# Test_Video-prompt if proper miyoo video's version driver was loaded:
## Loop Test_Video until correct selection has been performed (CHOICE=0/3)
@@ -320,10 +343,10 @@ if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
done
elif (grep -q "$DETECTED_2" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_2" 0 0
echo "CONSOLE_VARIANT=m3" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=m3" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif (grep -q "$DETECTED_3" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_3" 0 0
echo "CONSOLE_VARIANT=m3_r61520" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=m3_r61520" | tee ${BOOTDIR}/console.cfg >> ${LOG}
# Test_Image-prompt if proper "invert" colors parameter was loaded:
INVERSION=0 #applied only if colors are inverted
test_image_func
@@ -332,25 +355,27 @@ if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
## DETECTED_5 - bittboy3/2
elif (grep -q "$DETECTED_6" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_6" 0 0
echo "CONSOLE_VARIANT=m3_rm68090" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=m3_rm68090" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif (grep -q "$DETECTED_7" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_7" 0 0
#echo "CONSOLE_VARIANT=r61520" > ${BOOTDIR}/console.cfg
#echo "CONSOLE_VARIANT=r61520" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif (grep -q "$DETECTED_8" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_8" 0 0
#echo "CONSOLE_VARIANT=r61505w" > ${BOOTDIR}/console.cfg
#echo "CONSOLE_VARIANT=r61505w" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif (grep -q "$DETECTED_9" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_9" 0 0
echo "CONSOLE_VARIANT=m3_hx8347d" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=m3_hx8347d" | tee ${BOOTDIR}/console.cfg >> ${LOG}
elif (grep -q "$DETECTED_10" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_10" 0 0
#echo "CONSOLE_VARIANT=unknown-error" > ${BOOTDIR}/console.cfg
echo "Auto-Detected $DETECTED_10, so we have trouble finding correct drivers..." >> ${LOG}
#echo "CONSOLE_VARIANT=unknown-error" | tee ${BOOTDIR}/console.cfg >> ${LOG}
fi
# Overwrite CONSOLE_VARIANT from new entry
source "${BOOTDIR}/console.cfg"
fi
# II - Test_Block
echo "Starting II Block - Test" >> ${LOG}
## Defaulting to console overwriting inactive
CONSOLE_OVERWRITE=false
## Test if console have been found in devices_auto_ID
@@ -359,6 +384,7 @@ detect_console_func
if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
# show selection menu for ST7789S devices
if (test "$CONSOLE_VARIANT" == "st7789s" && grep -q "$DETECTED_1" "${BOOTDIR}/uEnv.txt"); then
echo "Selecting device by end-user choice." >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --timeout 60 --title "Select your device:" --menu " " 15 40 5 \
1 "Powkiddy Q20" \
2 "Powkiddy Q90" \
@@ -373,35 +399,39 @@ if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
## Perform actions based on the user's choice
case $CHOICE in
1)
echo "CONSOLE_VARIANT=q20" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=q20" | tee ${BOOTDIR}/console.cfg >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
;;
2)
echo "CONSOLE_VARIANT=q90" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=q90" | tee ${BOOTDIR}/console.cfg >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
;;
3)
echo "CONSOLE_VARIANT=v90" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=v90" | tee ${BOOTDIR}/console.cfg >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
;;
4)
default_console_func
;;
5)
echo "CONSOLE_VARIANT=pocketgo_TE" > ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=pocketgo_TE" | tee ${BOOTDIR}/console.cfg >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
;;
*)
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 4 --msgbox "Invalid choice. Exiting and selecting default device from autodetection." 0 0
echo "Selecting default device from autodetection..." >> ${LOG}
default_console_func
sleep 0.1
;;
esac
elif (((test "$CONSOLE_VARIANT" == "bittboy2" || test "$CONSOLE_VARIANT" == "bittboy3") && grep -q "$DETECTED_5" "${BOOTDIR}/uEnv.txt") || ((test "$CONSOLE_VARIANT" == "xyc" || test "$CONSOLE_VARIANT" == "m3") && grep -q "$DETECTED_2" "${BOOTDIR}/uEnv.txt")); then
echo "Extra Auto-Detected Console's variant from uEnv" >> ${LOG}
if (grep -q "$DETECTED_5" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_5" 0 0
echo "Auto-Detected $DETECTED_5" >> ${LOG}
elif (grep -q "$DETECTED_2" "${BOOTDIR}/uEnv.txt"); then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 4 --msgbox "Correcting $DETECTED_2 - wait for further instructions" 0 0
echo "Auto-Detected $DETECTED_2" >> ${LOG}
fi
# Test_Keyboard-prompt if proper miyoo.kbd version was loaded:
## Loop Test_Keyboard until correct selection has been performed (CHOICE=0/1)
@@ -413,16 +443,19 @@ if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
done
elif (test "$CONSOLE_VARIANT" == "bittboy" && grep -q "$DETECTED_4" "${BOOTDIR}/uEnv.txt") ; then
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 3 --msgbox "Auto-Detected $DETECTED_4" 0 0
echo "Auto-Detected $DETECTED_4" >> ${LOG}
# Test_Video'2-prompt if proper miyoo video's version driver was loaded:
test_video2_func
fi
fi
# III - Test_Block
echo "Starting III Block - Test" >> ${LOG}
detect_console_func
BITTBOY_CONFIG=false
MIYOO_CONFIG=false
if $FOUND_CONSOLE; then
echo "Found console ${CONSOLE_VARIANT}" >> ${LOG}
# Info_Box about selected/edited device in console.cfg
case $CONSOLE_VARIANT in
bittboy2x_v1)
@@ -483,28 +516,35 @@ if $FOUND_CONSOLE; then
# Test_Variant-prompt if correct CONSOLE_VARIANT has been written to console.cfg
test_variant_func
else
echo "Didn't find correct console" >> ${LOG}
dialog --backtitle "MiyooCFW 2.0" --no-shadow --colors --timeout 2 --ok-label " Your device " --msgbox "\Zb\Z1 Unknown\Zn" 5 18
console_unknown_func
fi
# License_agreement-prompt
echo "License agreement signing" >> ${LOG}
if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --ok-label NO --cancel-label YES --stdout --title " License agreement" \
--colors --pause "\n \ZbMiyooCFW\Zn\n$LICENSE" 22 60 30 || test $? -eq 255); then
echo -en " We understand. Have a nice day!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo -en " We understand. Have a nice day!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | tee -a ${LOG}
sleep 1
console_unknown_func
safe_poweroff_func
fi
# Format swap parition
/sbin/mkswap /dev/mmcblk0p3
/sbin/swapon /dev/mmcblk0p3
echo "Formatting swap P3 partition" | tee -a ${LOG}
sleep 1
/sbin/swapoff -a 2>&1 | tee -a ${LOG} # unplug SWAP, otherwise if present it won't be recreated via mkswap
/sbin/mkswap /dev/mmcblk0p3 2>&1 | tee -a ${LOG}
/sbin/swapon /dev/mmcblk0p3 2>&1 | tee -a ${LOG}
echo -en "\n Available memory:\n" >> ${LOG}
free -m >> ${LOG}
sync
sleep 1
mount -o remount,ro "${BOOTDIR}" | tee -a ${LOG}
mount -o remount,ro "${BOOTDIR}" 2>&1 | tee -a ${LOG}
#define priamry partitions FS types
#define primary partitions FS types
##TODO: detect FS type in script eg. grep `df -Th` cmd
P4_FS_TYPE="BTRFS"
P5_FS_TYPE="EXT4"
@@ -531,6 +571,7 @@ SD_MAX_AVAIL_SIZE="$((${SD_SIZE} - (${P1_SIZE} + ${P2_SIZE} + ${P3_SIZE} + ${P4_
SD_MAX_AVAIL_SIZE_IN_KiB=$((SD_MAX_AVAIL_SIZE * 512 / 1024))
# Change_MAIN_FileSystem-prompt for the p4 partition if requested
echo "Change MAIN FileSystem procedure" >> ${LOG}
CHANGE_FS_P4=false
if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --ok-label ${P4_FS_TYPE}\(default\) --cancel-label EXT4 --title " Change FileSystem" \
--colors --pause "\n\n\Z5Change default FileSystem of MAIN?\Zn\n\n BTRFS - safe & reliable\Zn\n\n EXT4 - fast & optimal\Zn\n\n Select an option & press START
@@ -541,29 +582,40 @@ if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --ok-label ${
else
P4_FS_TYPE="EXT4"
echo -en "\n\nConverting the MAIN partition filesystem to ${P4_FS_TYPE} type.\n\n" | tee -a ${LOG}
echo -en "This can take a few minutes, be patient!"
echo -en "\e[32mThis can take a few minutes, be patient!\e[0m"
sleep 3
mkdir "${ROMS}"/backup
mkdir "${ROMS}"/backup 2>&1 | tee -a ${LOG}
rsync -a --info=nonreg0 --info=progress2 "${HOME}" "${ROMS}"/backup
umount /dev/mmcblk0p4 | tee -a ${LOG}
echo $? > $TEMP && EXIT_CODE=$(cat $TEMP)
if test $EXIT_CODE -eq 0; then
echo "Archiving ${HOME} partition successful" | tee -a ${LOG_TEMP}
else
echo -en "\033[0;31mArchiving ${HOME} to ${ROMS}/backup failed with rsync exit code ${EXIT_CODE}\033[0m" | tee -a ${LOG_TEMP}
fi
sleep 2
umount /dev/mmcblk0p4 2>&1 | tee -a ${LOG_TEMP}
clear
echo -en "\n\n"
mkfs.ext4 -d "${ROMS}"/backup/"${HOME}" -L MAIN -v -F /dev/mmcblk0p4 | tee -a ${LOG}
mkfs.ext4 -d "${ROMS}"/backup/"${HOME}" -L MAIN -v -F /dev/mmcblk0p4 2>&1 | tee -a ${LOG_TEMP}
sleep 2
e2fsck -y /dev/mmcblk0p4 | tee -a ${LOG}
mount /dev/mmcblk0p4 "${HOME}" -o rw,sync,exec | tee -a ${LOG}
#cp -v -a "${ROMS}"/backup/"${HOME}" /
rm -r "${ROMS}"/backup
e2fsck -y /dev/mmcblk0p4 2>&1 | tee -a ${LOG_TEMP}
mount /dev/mmcblk0p4 "${HOME}" -o rw,sync,exec 2>&1 | tee -a ${LOG_TEMP}
restore_temp_log_func
rm -r "${ROMS}"/backup 2>&1 | tee -a ${LOG}
CHANGE_FS_P4=true
fi
## Correct inittab for new p4 filesystem type
if ( $CHANGE_FS_P4 ); then
if $CHANGE_FS_P4 && test "${P4_FS_TYPE}" == "EXT4" ; then
echo "Correcting inittab of p4 at ${HOME} procedure" >> ${LOG}
sleep 1
mount -o remount,rw / /
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p4\).*|\1 "${HOME}" -o rw,sync,exec|" /etc/inittab
mount -o remount,ro / /
cat /etc/inittab >> ${LOG}
fi
# Change_ROMS_FileSystem-prompt for the p5 partition if requested
echo "Change ROMS FileSystem procedure" >> ${LOG}
CHANGE_FS_P5=false
dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --ok-label "${P5_FS_TYPE}(def.)" --cancel-label BTRFS --extra-button --extra-label FAT32 --title " Change FileSystem" \
--colors --pause "\n\n\Z5Change default FileSystem for ROMS?\Zn\n\nEXT4 - fast write/read & UNIX compliant\Zn\n\nBTRFS - slow read but poweroff safe, UNIX compliant\Zn\n\nFAT32 - slow on-device write but Windows compatbile\Zn\n\n Select an option & press START
@@ -584,29 +636,44 @@ else
dialog --backtitle "MiyooCFW 2.0" --no-shadow --timeout 2 --msgbox "Invalid choice, continuing with default setup!" 0 0
sleep 1.5
fi
if ( $CHANGE_FS_P5 ); then
if $CHANGE_FS_P5; then
echo -en "\n\nConverting the ROMS partition filesystem to ${P5_FS_TYPE} type.\n\n" | tee -a ${LOG}
echo -en "This can take a few minutes, be patient!"
echo -en "\e[32mThis can take a few minutes, be patient!\e[0m"
sleep 3
mkdir "${HOME}"/backup
mkdir "${HOME}"/backup 2>&1 | tee -a ${LOG}
rsync -a --info=nonreg0 --info=progress2 "${ROMS}" "${HOME}"/backup
umount /dev/mmcblk0p5 | tee -a ${LOG}
echo $? > $TEMP && EXIT_CODE=$(cat $TEMP)
if test $EXIT_CODE -eq 0; then
echo "Archiving ${ROMS} partition successful" | tee -a ${LOG}
else
echo "\033[0;31mArchiving ${ROMS} to ${HOME}/backup failed with rsync exit code ${EXIT_CODE}\033[0m" | tee -a ${LOG}
fi
sleep 2
umount /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
clear
echo -en "\n\n"
if test "${P5_FS_TYPE}" == "FAT32"; then
mkfs.vfat -n ROMS -v -F32 /dev/mmcblk0p5 | tee -a ${LOG}
mkfs.vfat -n ROMS -v -F32 /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
sleep 2
fsck.fat -y /dev/mmcblk0p5 | tee -a ${LOG}
mount /dev/mmcblk0p5 "${ROMS}" -t vfat -o rw,utf8 | tee -a ${LOG}
fsck.fat -y /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
mount /dev/mmcblk0p5 "${ROMS}" -t vfat -o rw,utf8 2>&1 | tee -a ${LOG}
rsync -rvt --modify-window=1 --exclude "lost+found" --info=nonreg0 --info=progress2 "${HOME}"/backup"${ROMS}" /
echo $? > $TEMP && EXIT_CODE=$(cat $TEMP)
if test $EXIT_CODE -eq 0; then
echo "Extracting archive in ${ROMS} partition successful" | tee -a ${LOG}
else
echo "\033[0;31mExtracting archive ${ROMS} from ${HOME}/backup${ROMS} failed with rsync exit code ${EXIT_CODE}\033[0m" | tee -a ${LOG}
fi
elif test "${P5_FS_TYPE}" == "BTRFS"; then
mkfs.btrfs -r "${HOME}"/backup"${ROMS}" -v -f -L ROMS /dev/mmcblk0p5 | tee -a ${LOG}
mkfs.btrfs -r "${HOME}"/backup"${ROMS}" -v -f -L ROMS /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
sleep 2
btrfsck -y /dev/mmcblk0p5 | tee -a ${LOG}
mount /dev/mmcblk0p5 "${ROMS}" -o commit=5,flushoncommit,noatime,nodiratime | tee -a ${LOG}
btrfsck /dev/mmcblk0p5 2>&1 | tee -a ${LOG} # does not repair FS, just check integrity as it is dengarous to do so
mount /dev/mmcblk0p5 "${ROMS}" -o commit=5,flushoncommit,noatime,nodiratime 2>&1 | tee -a ${LOG}
fi
rm -r "${HOME}"/backup
## Correct inittab for new p5 filesystem type
echo "Correcting inittab of p5 at ${ROMS} procedure" >> ${LOG}
sleep 1
mount -o remount,rw / /
if test "${P5_FS_TYPE}" == "FAT32"; then
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p5\).*|\1 "${ROMS}" -t vfat -o rw,utf8|" /etc/inittab
@@ -614,9 +681,11 @@ if ( $CHANGE_FS_P5 ); then
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p5\).*|\1 "${ROMS}" -o commit=5,flushoncommit,noatime,nodiratime|" /etc/inittab
fi
mount -o remount,ro / /
cat /etc/inittab >> ${LOG}
fi
# Expand_ROMS_Partition-prompt for the p5 (ROMS) partition if requested
echo "Expand ROMS FileSystem procedure" >> ${LOG}
RESIZE_COMMENCED=false
if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --ok-label YES --cancel-label NO --title " AUTO-RESIZE" \
--colors --pause "\n\n \Z5Expand ROMS partition?\Zn\n\n Select an option & press START
@@ -642,42 +711,45 @@ if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --ok-label YE
\n\nWe could however expand it to 118GB. \n\n \ZuDo you AGREE?\Zn
\n\n\ZbINFO: For microSD >128GB big we\n recommend to use your PC!\Zn" 0 0 30 || test $? -eq 255); then
dialog --clear --colors --timeout 2 --msgbox " FAT resizing \ZuABORTED!\Zn" 5 27
echo "Your SD card exceeds max. 128G size for auto-resizing!" >> ${LOG}
clear
RESIZE_ABORT=true
else
SD_MAX_AVAIL_SIZE_IN_KiB=123731968
echo "Your SD card exceeds max. 128G so picked that value instead!" >> ${LOG}
fi
fi
fi
if ! $RESIZE_ABORT; then
echo "Performing resize on ${ROMS}" >> ${LOG}
echo "The full size of your SD is ${SD_SIZE_IN_MiB}MB large" | tee -a ${LOG}
echo "Unallocated space available for resizing equals ${SD_MAX_UNALL_SIZE_IN_GiB}GB," | tee -a ${LOG}
echo "and more precisely it's ${SD_MAX_UNALL_SIZE_IN_MiB}MB big" | tee -a ${LOG}
echo "Resizing the ROMS (${P5_FS_TYPE}) partition to ${SD_MAX_AVAIL_SIZE_IN_GiB}GB." | tee -a ${LOG}
umount /dev/mmcblk0p5 | tee -a ${LOG}
umount /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
if test "${P5_FS_TYPE}" == "FAT32"; then
echo "This can take a minute, so be patient!" | tee -a ${LOG}
echo -en "\e[32mThis can take a few minutes, be patient!\e[0m"
#TODO: fix outputting logs from fatresize stdout
fatresize --size="${SD_MAX_AVAIL_SIZE_IN_KiB}"ki -v -p /dev/mmcblk0p5 -n5 | tee -a ${LOG}
fsck.fat -y /dev/mmcblk0p5 | tee -a ${LOG}
fatresize --size="${SD_MAX_AVAIL_SIZE_IN_KiB}"ki -v -p /dev/mmcblk0p5 -n5 2>&1 | tee -a ${LOG}
fsck.fat -y /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
#echo -n -e \\xEB\\x58\\x90 > /dev/mmcblk0p5
sync
mount -t vfat -o rw,utf8 /dev/mmcblk0p5 "${ROMS}" | tee -a ${LOG}
mount -t vfat -o rw,utf8 /dev/mmcblk0p5 "${ROMS}" 2>&1 | tee -a ${LOG}
else
echo "This can take a few seconds." | tee -a ${LOG}
echo -en "\e[32mThis can take a few seconds!\e[0m"
P5_START_POINT=` parted --script /dev/mmcblk0 unit MB print | grep '5' | tail -n1 | awk '{print $2}'`
parted -a optimal /dev/mmcblk0 --script rm '5' | tee -a ${LOG}
parted -a optimal /dev/mmcblk0 --script mkpart roms $P5_START_POINT 100% | tee -a ${LOG}
partx -u /dev/mmcblk0 | tee -a ${LOG}
parted -a optimal /dev/mmcblk0 --script rm '5' 2>&1 | tee -a ${LOG}
parted -a optimal /dev/mmcblk0 --script mkpart roms $P5_START_POINT 100% 2>&1 | tee -a ${LOG}
partx -u /dev/mmcblk0 2>&1 | tee -a ${LOG}
if test "${P5_FS_TYPE}" == "BTRFS"; then
mount /dev/mmcblk0p5 "${ROMS}" -o rw,noatime | tee -a ${LOG}
btrfs filesystem resize max ${ROMS} | tee -a ${LOG}
mount /dev/mmcblk0p5 "${ROMS}" -o rw,noatime 2>&1 | tee -a ${LOG}
btrfs filesystem resize max ${ROMS} 2>&1 | tee -a ${LOG}
else #EXT4
resize2fs /dev/mmcblk0p5 | tee -a ${LOG}
e2fsck -y /dev/mmcblk0p5 | tee -a ${LOG}
mount /dev/mmcblk0p5 "${ROMS}" -o rw,noatime,nodiratime | tee -a ${LOG}
resize2fs /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
e2fsck -y /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
mount /dev/mmcblk0p5 "${ROMS}" -o rw,noatime,nodiratime 2>&1 | tee -a ${LOG}
fi
partprobe
partprobe 2>&1 | tee -a ${LOG}
fi
RESIZE_COMMENCED=true
else
@@ -686,20 +758,20 @@ if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --ok-label YE
fi
fi
if ! $RESIZE_COMMENCED && test "${P5_FS_TYPE}" == "FAT32" ; then
sgdisk --typecode=5:0700 /dev/mmcblk0 # Microsoft basic data - partition type
partprobe
sgdisk --typecode=5:0700 /dev/mmcblk0 2>&1 | tee -a ${LOG} # Microsoft basic data - partition type
partprobe 2>&1 | tee -a ${LOG}
fi
# output FS table with type
df -Th >> ${LOG}
df -Th >> ${LOG} 2>&1
# Cleanup - delete the temporary file storing variable value
rm $TEMP
# disable this script
mount -o remount,rw "${BOOTDIR}" | tee -a ${LOG}
mount -o remount,rw "${BOOTDIR}" 2>&1 | tee -a ${LOG}
echo "Disabling the firstboot script." | tee -a ${LOG}
mv "${BOOTDIR}/firstboot" "${BOOTDIR}/firstboot.done" | tee -a ${LOG}
mount -o remount,ro "${BOOTDIR}" | tee -a ${LOG}
mv "${BOOTDIR}/firstboot" "${BOOTDIR}/firstboot.done" 2>&1 | tee -a ${LOG}
mount -o remount,ro "${BOOTDIR}" 2>&1 | tee -a ${LOG}
# copy over the config files
echo "Copying default configuration files into place..." | tee -a ${LOG}
@@ -708,6 +780,8 @@ if $BITTBOY_CONFIG; then
elif $MIYOO_CONFIG; then
cp "${HOME}/gmenu2x/input_miyoo.conf" "${HOME}/gmenu2x/input.conf"
fi
echo -en "\nUsing following GMenu2X input configuration:\n" >> ${GMENU2X_LOGS}
cat "${HOME}/gmenu2x/input.conf" >> ${GMENU2X_LOGS}
sync
echo "firstboot script finished." | tee -a ${LOG}
@@ -716,13 +790,13 @@ echo
#install IPK packages
echo "starting ipk install manager..." | tee -a ${LOG}
${BOOTDIR}/ipk_install.sh | tee -a ${LOG}
${BOOTDIR}/ipk_install.sh 2>&1 | tee -a ${LOG}
# Reboot device if CONSOLE_VARIANT was overwritten from $CHOICE so that it could be applied in u-boot by readID
## or found firstboot custom script
if ($CONSOLE_OVERWRITE || test -r "${BOOTDIR}/firstboot.custom.sh"); then
safe_reboot_func
else
#just grep logs from temp directory before continuing
yes | mv ${LOG} ${HOME}/log_firstboot.txt
#just grep logs from temp directory before continuing just in case
restore_temp_log_func
fi

View File

@@ -67,11 +67,11 @@ if (dialog --backtitle "MiyooCFW 2.0" --no-shadow --clear --stdout --title "WARN
clear
for package in $selected_packages; do
ipk_package="${help_messages[$((2 * package + 1))]}"
echo "Installing $ipk_package..."
echo "Installing $ipk_package..." | tee -a ${LOG}
if opkg install "$ipk_package" 2>/dev/null; then
echo "$ipk_package installed successfully."
echo "$ipk_package installed successfully." | tee -a ${LOG}
else
echo "Failed to install $ipk_package."
echo "Failed to install $ipk_package." | tee -a ${LOG}
fi
done
echo "Installation complete."

View File

@@ -16,8 +16,8 @@ else
# Wait a few seconds before actual screen record, the X264 encoder needs resources before it will stabilize video ouput
st_exec_func "echo -e \"\n\n\n\n\n\n\t\t\tStarting VIDEO record...\n\t\t\tWait a few seconds to start.\"; read -t 10;\
if pgrep ffmpeg >/dev/null; then\
echo -e \"\n\n\t\t\tRecording VIDEO in background...\";\
echo -e \"\n\n\t\t Recording VIDEO in background...\n\n WARNING: Disable output logging or this\n\t\t will not continue any further.\";\
else\
echo -e \"\n\n\t\t\tFailed to launch ffmpeg for record...\";\
fi; read -t 2"
fi
fi

View File

@@ -6,7 +6,7 @@ st_exec_func(){
st -k -e "/bin/sh" "-c" "${1}"
}
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
killall umtprd
killall umtprd umtprd-debug
/mnt/apps/usb-mtd/remove.sh g2
modprobe -r g_serial
mount none /sys/kernel/config -t configfs

View File

@@ -2,7 +2,7 @@
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
modprobe -r g_serial
killall umtprd
killall umtprd umtprd-debug
/mnt/apps/usb-mtd/remove.sh g2
mount none /sys/kernel/config -t configfs
mkdir /sys/kernel/config/usb_gadget/g2
@@ -23,7 +23,11 @@ echo 120 > configs/c.1/MaxPower
ln -s functions/ffs.mtp configs/c.1
mkdir /dev/ffs-mtp
mount -t functionfs mtp /dev/ffs-mtp
if (grep -q DEBUG_UMTPR\=\1 "${HOME}/options.cfg"); then
umtprd-debug &
else
umtprd &
fi
sleep 1
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/g2/UDC

View File

@@ -6,7 +6,7 @@ MAC_DEV="12:34:56:78:9a:bc"
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
modprobe -r g_serial
killall umtprd
killall umtprd umtprd-debug
/mnt/apps/usb-mtd/remove.sh g2
sleep 1

View File

@@ -1,4 +1,4 @@
#!/bin/busybox sh
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
killall umtprd
killall umtprd umtprd-debug
modprobe g_serial

View File

@@ -1,4 +1,7 @@
MODULES_CUSTOM=0
DEBUG=0
DEBUG_GMENU2X=0
DEBUG_UMTPR=0
FS_CHECK=1
BOOT_LOGO=1
FLIP= (put 0 or 1 to overwrite)

View File

@@ -8,14 +8,33 @@ export SDL_NOMOUSE=1
START="${HOME}/autoexec.sh"
LOGS=/dev/null
LOGS_TEMP=/dev/null
UMTPR_LOGS=/dev/null
GMENU2X_LOGS=/dev/null
# check if it's first boot and turn on messages if yes
if ((test -r "${BOOTDIR}/firstboot") || (test -r "${HOME}/firstboot.completed")); then
if (grep -sq DEBUG\=\1 "${HOME}/options.cfg" || test -r "${BOOTDIR}/firstboot" || test -r "${HOME}/firstboot.completed"); then
DEBUG_MSG="yes"
LOGS=$(mktemp)
LOGS="${HOME}/log.txt"
GMENU2X_LOGS="${HOME}/log_gmenu2x.txt" # just standard stdout/stderr
#UMTPR_LOGS=/dev/null # see description at umtprd cmd
fi
if (grep -sq DEBUG_GMENU2X\=\1 "${HOME}/options.cfg"); then
DEBUG_GMENU2X="yes"
GMENU2X_LOGS="${HOME}/log_gmenu2x.txt"
fi
if (grep -sq DEBUG_UMTPR\=\1 "${HOME}/options.cfg"); then
DEBUG_UMTPR="yes"
UMTPR_LOGS="${HOME}/log_umtpr.txt"
fi
if test "x${DEBUG_MSG}" == "xyes" || test "x${DEBUG_GMENU2X}" == "xyes" || test "x${DEBUG_UMTPR}" == "xyes"; then
LOGS_TEMP=$(mktemp)
fi
export LOGS # so that subshells can use this as well
export LOGS_TEMP
export GMENU2X_LOGS
if test "x${DEBUG_MSG}" == "xyes"; then
echo -e "\e[0m" # normal foreground color
@@ -24,16 +43,29 @@ else
echo -e "\e[30m" # black foreground color
fi
restore_temp_log_func(){
if test "x${DEBUG_UMTPR}" == "xyes"; then
cat ${LOGS_TEMP} >> ${UMTPR_LOGS}
else
cat ${LOGS_TEMP} >> ${LOGS}
fi
LOGS_TEMP=$(mktemp)
}
! test -r "${HOME}/options.cfg"\
&& echo "Did not find valid ${HOME}/options.cfg file, using default configuration." >> ${LOGS}
# load kernel modules
# load usb gadget
mount none /sys/kernel/config -t configfs
mkdir /sys/kernel/config/usb_gadget/g2
cd /sys/kernel/config/usb_gadget/g2
mkdir configs/c.1
mkdir functions/ffs.mtp
mkdir strings/0x409
mkdir configs/c.1/strings/0x409
echo "Loading USB gadget" >> "${LOGS}"
mount none /sys/kernel/config -t configfs 2>&1 | tee -a "${LOGS}"
mkdir -p /sys/kernel/config/usb_gadget/g2 >> "${LOGS}" 2>&1
cd /sys/kernel/config/usb_gadget/g2 || echo "Failed to cd into /sys/kernel/config/usb_gadget/g2" >> "${LOGS}" 2>&1
mkdir -p configs/c.1 >> "${LOGS}" 2>&1
mkdir -p functions/ffs.mtp >> "${LOGS}" 2>&1
mkdir -p strings/0x409 >> "${LOGS}" 2>&1
mkdir -p configs/c.1/strings/0x409 >> "${LOGS}" 2>&1
echo 0x0100 > idProduct
echo 0x1D6B > idVendor
@@ -43,10 +75,15 @@ echo "Miyoo CFW 2.0" > strings/0x409/product
echo "Conf 1" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower
ln -s functions/ffs.mtp configs/c.1
mkdir /dev/ffs-mtp
mount -t functionfs mtp /dev/ffs-mtp
umtprd >> "${LOGS}" 2>&1 &
ln -s functions/ffs.mtp configs/c.1 2>&1 | tee -a "${LOGS}"
mkdir -p /dev/ffs-mtp >> "${LOGS}" 2>&1
mount -t functionfs mtp /dev/ffs-mtp 2>&1 | tee -a "${LOGS}"
if test "x${DEBUG_UMTPR}" == "xyes"; then
umtprd-debug >> "${LOGS_TEMP}" 2>&1 &
else
umtprd >> ${UMTPR_LOGS} 2>&1 & # since it's running in bg the stdout/stderr redirecction is constantly active, may brake unmounting so logging here to /dev/null
fi
sleep 1
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/g2/UDC
@@ -61,30 +98,34 @@ BACKLIGHT=$(cat ${HOME}/.backlight.conf)
# TVout scripting backend
if test -r "${HOME}/tvout"; then
echo "Starting TVout video." >> "${LOGS}"
echo 0 > /sys/class/backlight/backlight/brightness
echo 0 > /sys/class/vtconsole/vtcon1/bind
if test $BACKLIGHT -ne 0; then
cp ${HOME}/.backlight.conf ${HOME}/.backlight.bak
cp ${HOME}/.backlight.conf ${HOME}/.backlight.bak 2>&1 | tee -a "${LOGS}"
fi
echo 0 > ${HOME}/.backlight.conf
modprobe -r $video
modprobe -r $video 2>&1 | tee -a "${LOGS}"
#TVMODE options.cfg setting
export tvmode=$(grep -o TVMODE=[0-1] "${HOME}/options.cfg" | tr '[:upper:]' '[:lower:]')
modprobe miyoo-tvout $tvmode
tvmode=$(grep -o TVMODE=[0-1] "${HOME}/options.cfg" | tr '[:upper:]' '[:lower:]')
echo "Loding TV module miyoo-tvout with args tvmode=${tvmode}" >> "${LOGS}"
modprobe miyoo-tvout $tvmode 2>&1 | tee -a "${LOGS}"
echo 1 > /sys/class/vtconsole/vtcon1/bind
modprobe -r $video
modprobe -r $video 2>&1 | tee -a "${LOGS}"
else
if ((test -r "${HOME}/.backlight.bak")); then
mv ${HOME}/.backlight.bak ${HOME}/.backlight.conf
fi
# MODULES_CUSTOM scripting
if (!(test -r "${BOOTDIR}/modules.custom.sh") || !(grep -q MODULES_CUSTOM\=\1 "${HOME}/options.cfg")); then
if (!(test -r "${BOOTDIR}/modules.custom.sh") || !(grep -sq MODULES_CUSTOM\=\1 "${HOME}/options.cfg")); then
# Load video module read from uEnv.txt & defined by variant in console.cfg
#FLIP & INVERT options.cfg setting
export flip=$(grep -o FLIP=[0-1] "${HOME}/options.cfg" | tr '[:upper:]' '[:lower:]')
export invert=$(grep -o INVERT=[0-1] "${HOME}/options.cfg" | tr '[:upper:]' '[:lower:]')
modprobe $video $flip $invert
flip=$(grep -o FLIP=[0-1] "${HOME}/options.cfg" | tr '[:upper:]' '[:lower:]')
invert=$(grep -o INVERT=[0-1] "${HOME}/options.cfg" | tr '[:upper:]' '[:lower:]')
echo "Loding video module ${video} with args flip=${flip} invert=${invert}" >> "${LOGS}"
modprobe $video $flip $invert 2>&1 | tee -a "${LOGS}"
else
echo "Loding custom modules." >> "${LOGS}"
(cd "${BOOTDIR}" && sh modules.custom.sh ) >> "${LOGS}" 2>&1
fi
fi
@@ -96,38 +137,39 @@ elif test -r "${HOME}/firstboot.completed"; then
rm "${HOME}/firstboot.completed"
fi
if !(grep -q FS_CHECK\=\0 "${HOME}/options.cfg"); then
if !(grep -sq FS_CHECK\=\0 "${HOME}/options.cfg"); then
##Check if BOOT (FAT16) is flagged as "dirty", and if so unmount, repair, remount
if dmesg | grep "mmcblk0p1" > /dev/null; then
echo -e "\e[31mDirty sectors detected.\e[0m"
echo -e "\e[32mChecking&Repairing FAT16 BOOT partition...\e[0m"
umount /dev/mmcblk0p1
fsck.vfat -y /dev/mmcblk0p1 > /dev/null;
mount /dev/mmcblk0p1 "${BOOTDIR}" -t vfat -o ro,exec,utf8
echo -e "\e[32mCheck complete.\e[0m"
echo -e "\e[31mDirty sectors detected.\e[0m" | tee -a "${LOGS}"
echo -e "\e[32mChecking&Repairing FAT16 BOOT partition...\e[0m" | tee -a "${LOGS}"
umount /dev/mmcblk0p1 2>&1 | tee -a "${LOGS}"
fsck.vfat -y /dev/mmcblk0p1 >> "${LOGS}" 2>&1
mount /dev/mmcblk0p1 "${BOOTDIR}" -t vfat -o ro,exec,utf8 2>&1 | tee -a "${LOGS}"
echo -e "\e[32mCheck complete.\e[0m" | tee -a "${LOGS}"
fi
##Check if MAIN (EXT4) is flagged as "dirty", and if so unmount, repair, remount
if dmesg | grep "EXT4-fs (mmcblk0p4): warning: mounting fs with errors, running e2fsck is recommended" > /dev/null; then
echo -e "\e[31mUnclean shutdown detected.\e[0m"
echo -e "\e[32mChecking MAIN(EXT4) partition...\e[0m"
umount /dev/mmcblk0p4
e2fsck -y /dev/mmcblk0p4 > /dev/null;
mount /dev/mmcblk0p4 "${HOME}" -o rw,sync,exec
echo -e "\e[31mUnclean shutdown detected.\e[0m" | tee -a "${LOGS}"
echo -e "\e[32mChecking MAIN(EXT4) partition...\e[0m" | tee -a "${LOGS}"
umount /dev/mmcblk0p4 2>&1 | tee -a "${LOGS_TEMP}"
e2fsck -y /dev/mmcblk0p4 >> "${LOGS_TEMP}";
mount /dev/mmcblk0p4 "${HOME}" -o rw,sync,exec 2>&1 | tee -a "${LOGS_TEMP}"
restore_temp_log_func
fi
##Check if ROMS (EXT4 or FAT32) is flagged as "dirty", and if so unmount, repair, remount
if dmesg | grep "EXT4-fs (mmcblk0p5): warning: mounting fs with errors, running e2fsck is recommended" > /dev/null; then
echo -e "\e[31mUnclean shutdown detected.\e[0m"
echo -e "\e[32mChecking ROMS(EXT4) partition...\e[0m"
umount /dev/mmcblk0p5
e2fsck -y /dev/mmcblk0p5 > /dev/null;
mount /dev/mmcblk0p5 "${ROMS}" -o rw,noatime
echo -e "\e[31mUnclean shutdown detected.\e[0m" | tee -a "${LOGS}"
echo -e "\e[32mChecking ROMS(EXT4) partition...\e[0m" | tee -a "${LOGS}"
umount /dev/mmcblk0p5 2>&1 | tee -a "${LOGS}"
e2fsck -y /dev/mmcblk0p5 >> "${LOGS}" 2>&1;
mount /dev/mmcblk0p5 "${ROMS}" -o rw,noatime 2>&1 | tee -a "${LOGS}"
elif dmesg | grep "FAT-fs (mmcblk0p5): Volume was not properly unmounted. Some data may be corrupt. Please run fsck." > /dev/null; then
echo -e "\e[31mDirty sectors detected.\e[0m"
echo -e "\e[32mChecking&Repairing ROMS(FAT32) partition...\e[0m"
umount /dev/mmcblk0p5
fsck.vfat -y /dev/mmcblk0p5 > /dev/null;
mount /dev/mmcblk0p5 "${ROMS}" -t vfat -o rw,utf8
echo -e "\e[32mCheck complete.\e[0m"
echo -e "\e[31mDirty sectors detected.\e[0m" | tee -a "${LOGS}"
echo -e "\e[32mChecking&Repairing ROMS(FAT32) partition...\e[0m" | tee -a "${LOGS}"
umount /dev/mmcblk0p5 2>&1 | tee -a "${LOGS}"
fsck.vfat -y /dev/mmcblk0p5 >> "${LOGS}" 2>&1
mount /dev/mmcblk0p5 "${ROMS}" -t vfat -o rw,utf8 2>&1 | tee -a "${LOGS}"
echo -e "\e[32mCheck complete.\e[0m" | tee -a "${LOGS}"
fi
fi
@@ -151,19 +193,19 @@ else
fi
# run boot logo animation
if (!(grep -q BOOT_LOGO\=\0 "${HOME}/options.cfg")); then
if (!(grep -sq BOOT_LOGO\=\0 "${HOME}/options.cfg")); then
${BOOTLOGO} >> "${LOGS}" 2>&1
fi
# can't unmount boot because 'daemon' runs from it - but it's mounted read-only
# so it's fine
# we could unmount /boot here but since it's read-only it doesn't hurt to leave it running
## umount /dev/mmcblk0p1
# Writes dmesg after firstboot procedure or if DEBUG_MSG=yes
if test "x${DEBUG_MSG}" == "xyes"; then
sleep 1
dmesg > ${HOME}/dmesg.txt
yes | mv ${LOGS} ${HOME}/log.txt
echo -en "\n\nNew DMESG log:\n" >> ${HOME}/dmesg.txt
dmesg >> ${HOME}/dmesg.txt
restore_temp_log_func
fi
while [ 1 ]
@@ -171,8 +213,15 @@ do
if test -f "${START}"; then
source "${START}"
else
cd "${HOME}"/gmenu2x;
./gmenu2x >> /dev/null 2>&1;
echo "Starting GMenu2x" >> "${LOGS}"
cd "${HOME}"/gmenu2x || { echo "Failed to cd into ${HOME}/gmenu2x" >> "${LOGS}" ; exit; }
if test "x${DEBUG_GMENU2X}" == "xyes"; then
gdb -ex="set confirm off" -ex=run -ex="bt full" -ex=q ./gmenu2x-debug >> "${GMENU2X_LOGS}" 2>&1
else
./gmenu2x >> "${GMENU2X_LOGS}" 2>&1
fi
test "x${DEBUG_UMTPR}" == "xyes"\
&& restore_temp_log_func
fi
clear
done

View File

@@ -11,11 +11,18 @@ UMTPRD_LICENSE = GPL-3.0+
UMTPRD_LICENSE_FILES = LICENSE
define UMTPRD_BUILD_CMDS
# Compile umtprd-debug
CC=$(TARGET_CC) $(MAKE) -C $(@D) DEBUG=1 #USE_SYSLOG=1
mv -fn $(@D)/umtprd $(@D)/umtprd-debug
# Clean prv build
CC=$(TARGET_CC) $(MAKE) clean -C $(@D)
# Compile umtprd
CC=$(TARGET_CC) $(MAKE) -C $(@D)
endef
define UMTPRD_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/umtprd $(TARGET_DIR)/usr/sbin/umtprd
$(INSTALL) -D -m 0755 $(@D)/umtprd-debug $(TARGET_DIR)/usr/sbin/umtprd-debug
endef
$(eval $(generic-package))