Skip to content
79 changes: 40 additions & 39 deletions board/miyoo/boot/firstboot
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ done

# try to read what handheld we're on when calling func
console_var_func(){
if (test -r "${BOOTDIR}/console.cfg"); then
source "${BOOTDIR}/console.cfg"
if (test -r "${CONSOLE_CFG}"); then
source "${CONSOLE_CFG}"
else
export CONSOLE_VARIANT="unknown"
CONSOLE_VARIANT="unknown"
fi
export CONSOLE_VARIANT
}

detect_console_func(){
Expand Down Expand Up @@ -163,13 +164,13 @@ safe_poweroff_func(){
}

console_unknown_func(){
echo "CONSOLE_VARIANT=unknown" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "##DO_NOT_REMOVE_THIS_LINE##" >> ${BOOTDIR}/console.cfg
echo "CONSOLE_VARIANT=unknown" | tee ${CONSOLE_CFG} >> ${LOG}
echo "##DO_NOT_REMOVE_THIS_LINE##" >> ${CONSOLE_CFG}
}

## Default CONSOLE_VARIANT for st7789s screens
default_console_func(){
echo "CONSOLE_VARIANT=pocketgo" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=pocketgo" | tee ${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
Expand All @@ -194,8 +195,8 @@ test_image_func(){
else
#TODO - make "invert" flag overwriting less dependent
echo "Colors are inverted, changing..." | tee -a ${LOG}
sed -i '/^INVERT=/d' ${HOME}/options.cfg | tee -a ${LOG}
echo "INVERT=${INVERSION}" >> ${HOME}/options.cfg
sed -i '/^INVERT=/d' ${OPTIONS_CFG} | tee -a ${LOG}
echo "INVERT=${INVERSION}" >> ${OPTIONS_CFG}
safe_reboot_func
fi
}
Expand All @@ -212,15 +213,15 @@ 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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=st7789s" | tee ${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
test_flip_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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=bittboy" | tee ${CONSOLE_CFG} >> ${LOG}
safe_reboot_func
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
else
Expand All @@ -240,7 +241,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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=bittboy2x_v1" | tee ${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
Expand All @@ -262,28 +263,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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=bittboy3.5" | tee ${CONSOLE_CFG} >> ${LOG}
elif test "$CONSOLE_VARIANT" == "bittboy2"; then
echo "CONSOLE_VARIANT=bittboy2x_v2" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=bittboy2x_v2" | tee ${CONSOLE_CFG} >> ${LOG}
elif test "$CONSOLE_VARIANT" == "xyc"; then
echo "CONSOLE_VARIANT=xyc_gc9306" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=xyc_gc9306" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=m3_gc9306" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=bittboy2" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=xyc" | tee ${CONSOLE_CFG} >> ${LOG}
fi
safe_reboot_func
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
Expand Down Expand Up @@ -313,7 +314,7 @@ 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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=bittboy3" | tee ${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.:
Expand Down Expand Up @@ -350,10 +351,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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=m3" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=m3_r61520" | tee ${CONSOLE_CFG} >> ${LOG}
# Test_Image-prompt if proper "invert" colors parameter was loaded:
INVERSION=0 #applied only if colors are inverted
test_image_func
Expand All @@ -362,23 +363,23 @@ 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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=m3_rm68090" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
#echo "CONSOLE_VARIANT=r61520" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
#echo "CONSOLE_VARIANT=r61505w" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=m3_hx8347d" | tee ${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 "Auto-Detected $DETECTED_10, so we have trouble finding correct drivers..." >> ${LOG}
#echo "CONSOLE_VARIANT=unknown-error" | tee ${BOOTDIR}/console.cfg >> ${LOG}
#echo "CONSOLE_VARIANT=unknown-error" | tee ${CONSOLE_CFG} >> ${LOG}
fi
# Overwrite CONSOLE_VARIANT from new entry
source "${BOOTDIR}/console.cfg"
source "${CONSOLE_CFG}"
fi

# II - Test_Block
Expand Down Expand Up @@ -406,22 +407,22 @@ 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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=q20" | tee ${CONSOLE_CFG} >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
;;
2)
echo "CONSOLE_VARIANT=q90" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=q90" | tee ${CONSOLE_CFG} >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
;;
3)
echo "CONSOLE_VARIANT=v90" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=v90" | tee ${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" | tee ${BOOTDIR}/console.cfg >> ${LOG}
echo "CONSOLE_VARIANT=pocketgo_TE" | tee ${CONSOLE_CFG} >> ${LOG}
cp ${BOOTDIR}/suniv-f1c100s-miyoo-4bit.dtb ${BOOTDIR}/suniv-f1c100s-miyoo.dtb
;;
*)
Expand Down Expand Up @@ -649,7 +650,7 @@ fi
if ${CHANGE_FS_P4}; then
echo "Correcting inittab of p4 at ${HOME} procedure" >> ${LOG}
sleep 1
mount -o remount,rw / /
mount -o remount,rw / / 2>&1 | tee -a ${LOG}
while (pgrep "mount"); do
sleep 1
done
Expand All @@ -658,7 +659,7 @@ if ${CHANGE_FS_P4}; then
elif test "${P4_FS_TYPE}" == "BTRFS" ; then
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p4\).*|\1 "${HOME}" -o commit=5,flushoncommit,noatime,nodiratime,exec|" /etc/inittab
fi
mount -o remount,ro / /
mount -o remount,ro / / 2>&1 | tee -a ${LOG}
cat /etc/inittab >> ${LOG}
fi

Expand Down Expand Up @@ -747,7 +748,7 @@ if $CHANGE_FS_P5; then
## Correct inittab for new p5 filesystem type
echo "Correcting inittab of p5 at ${ROMS} procedure" >> ${LOG}
sleep 1
mount -o remount,rw / /
mount -o remount,rw / / 2>&1 | tee -a ${LOG}
while (pgrep "mount"); do
sleep 1
done
Expand All @@ -758,22 +759,22 @@ if $CHANGE_FS_P5; then
elif test "${P5_FS_TYPE}" == "EXT4"; then
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p5\).*|\1 "${ROMS}" -o rw,noatime|" /etc/inittab
fi
mount -o remount,ro / /
mount -o remount,ro / / 2>&1 | tee -a ${LOG}
cat /etc/inittab >> ${LOG}
fi

## Correct inittab & check if btrfs module needed for p4/p5
if ($CHANGE_FS_P4 || $CHANGE_FS_P5); then
echo "Correcting inittab for btrfs module loading" >> ${LOG}
mount -o remount,rw / /
mount -o remount,rw / / 2>&1 | tee -a ${LOG}
if test "${P4_FS_TYPE}" != "BTRFS" && test "${P5_FS_TYPE}" != "BTRFS" ; then
sed -i 's|^::sysinit:/sbin/modprobe btrfs|#&|' /etc/inittab
modprobe -r btrfs 2>&1 | tee -a "${LOGS}"
else
sed -i 's|^#::sysinit:/sbin/modprobe btrfs|::sysinit:/sbin/modprobe btrfs|' /etc/inittab
modprobe btrfs 2>&1 | tee -a "${LOGS}"
fi
mount -o remount,ro / /
mount -o remount,ro / / 2>&1 | tee -a ${LOG}
cat /etc/inittab >> ${LOG}
fi

Expand Down Expand Up @@ -876,9 +877,9 @@ rm $TEMP
# disable this script
mount -o remount,rw "${BOOTDIR}" 2>&1 | tee -a ${LOG}
echo "Disabling the firstboot script." | tee -a ${LOG}
if grep -sq FIRSTBOOT\=\1 "${HOME}/options.cfg"; then
sed -i '/^FIRSTBOOT=/d' ${HOME}/options.cfg 2>&1 | tee -a ${LOG}
echo "FIRSTBOOT=0" >> ${HOME}/options.cfg
if grep -sq FIRSTBOOT\=\1 "${OPTIONS_CFG}"; then
sed -i '/^FIRSTBOOT=/d' ${OPTIONS_CFG} 2>&1 | tee -a ${LOG}
echo "FIRSTBOOT=0" >> ${OPTIONS_CFG}
else
mv "${BOOTDIR}/firstboot" "${BOOTDIR}/firstboot.done" 2>&1 | tee -a ${LOG}
fi
Expand Down
14 changes: 14 additions & 0 deletions board/miyoo/boot/options.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#In options only "0" and "1" are accepted values

MODULES_CUSTOM=0 #load custom drivers from /boot/modules_custom.sh
DEBUG=0 #debug whole OS & output logs to $HOME/log.txt
DEBUG_GMENU2X=0 #debug gmenu2x & output logs to $HOME/log_gmenu2x.txt
DEBUG_UMTPR=0 #debug USB storage protocol $HOME/log_umtpr.txt
FIRSTBOOT=0 #perform again firstboot setup (once after reboot)
FS_CHECK=1 #check FileSystems at startup (except BTRFS)
BOOT_LOGO=1 #display scrolling boot-logo at startup
HOTKEY_CUSTOM=1 #use hotkeys from $HOME/.buttons.conf if present
USB_OTG=1 #activate USB On-The-Go for plugging ext. devices (use $HOME/.usbmode FILE for mode change)
FLIP= #(put 0 or 1 to overwrite) flip display up/down
INVERT= #(put 0 or 1 to overwrite) change colors on display to normal/invert
TV_OUT= #(put 0 or 1 to overwrite) force TV-output OFF/ON (use $HOME/.tvmode FILE for PAL/NTSC change)
1 change: 1 addition & 0 deletions board/miyoo/genimage-sdcard.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ image bootfs.vfat {
"boot/autorun.inf",
"boot/boot.ico",
"boot/console.cfg",
"boot/options.cfg",
"boot/firstboot",
"boot/firstboot.custom.sh-OFF",
"boot/modules.custom.sh",
Expand Down
13 changes: 0 additions & 13 deletions board/miyoo/main/options.cfg

This file was deleted.

Loading