mirror of
https://github.com/MiyooCFW/buildroot.git
synced 2025-09-27 22:24:19 +03:00
[BOARD/README] Firstboot flashing_procedure-v2 (#42)
* [FIRSTBOOT] refactor code: -auto-detect all possible variants in firstboot - DRY script code - add $RESIZE_COMMENCED , $BITTBOY_CONFIG , $MIYOO_CONFIGvariable - add debug log before any shutdown - don't `export` env var if not needed - move and use $DETECTED auto_ID variants on II Test_Block - cleanup + add more descriptions - add Test_Flip prompt for double check on Test Video (only if enduser selected "Flipped!" at first test) - remove useless SWAP & MAIN part. mount - add safety read-only for /boot before shutdown * [BOARD] add gmenu2x inputs inputs with `manifest` - update genimage config with `input_bittboy.conf` and `input_miyoo.conf` * [README] Add flashing procedure schematic (made in draw.io)
This commit is contained in:
@@ -45,7 +45,11 @@ or buy a powerful PC for yourself.
|
|||||||
|
|
||||||
## Flashing firmware to target
|
## Flashing firmware to target
|
||||||
|
|
||||||
load output/images/miyoo-cfw-2.0.0.img on sdcard
|
load output/images/miyoo-cfw-*.img on sdcard
|
||||||
|
|
||||||
|
## First booting device
|
||||||
|
You will have to answer a few questions on first boot, represented on graphic below:
|
||||||
|

|
||||||
|
|
||||||
---
|
---
|
||||||
# _Buildroot 2022.02.9 (docs: https://github.com/MiyooCFW/buildroot/blob/master/docs/manual/manual.pdf)_
|
# _Buildroot 2022.02.9 (docs: https://github.com/MiyooCFW/buildroot/blob/master/docs/manual/manual.pdf)_
|
||||||
|
|||||||
17
board/miyoo/boot/configs/input_bittboy.conf
Normal file
17
board/miyoo/boot/configs/input_bittboy.conf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
up=keyboard,273
|
||||||
|
down=keyboard,274
|
||||||
|
left=keyboard,276
|
||||||
|
right=keyboard,275
|
||||||
|
modifier=keyboard,8
|
||||||
|
confirm=keyboard,308
|
||||||
|
cancel=keyboard,306
|
||||||
|
manual=keyboard,9
|
||||||
|
section_prev=keyboard,32
|
||||||
|
section_next=keyboard,304
|
||||||
|
pagedown=keyboard,32
|
||||||
|
pageup=keyboard,304
|
||||||
|
settings=keyboard,13
|
||||||
|
menu=keyboard,27
|
||||||
|
power=keyboard,305
|
||||||
|
dec=keyboard,280
|
||||||
|
inc=keyboard,281
|
||||||
17
board/miyoo/boot/configs/input_miyoo.conf
Normal file
17
board/miyoo/boot/configs/input_miyoo.conf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
up=keyboard,273
|
||||||
|
down=keyboard,274
|
||||||
|
left=keyboard,276
|
||||||
|
right=keyboard,275
|
||||||
|
modifier=keyboard,304
|
||||||
|
confirm=keyboard,308
|
||||||
|
cancel=keyboard,306
|
||||||
|
manual=keyboard,32
|
||||||
|
section_prev=keyboard,9
|
||||||
|
section_next=keyboard,8
|
||||||
|
pagedown=keyboard,8
|
||||||
|
pageup=keyboard,9
|
||||||
|
settings=keyboard,13
|
||||||
|
menu=keyboard,27
|
||||||
|
power=keyboard,305
|
||||||
|
dec=keyboard,280
|
||||||
|
inc=keyboard,281
|
||||||
@@ -3,10 +3,6 @@
|
|||||||
MOUNTDIR=/boot
|
MOUNTDIR=/boot
|
||||||
# expect to be run from /boot, where the boot partition is mounted (readonly)
|
# expect to be run from /boot, where the boot partition is mounted (readonly)
|
||||||
|
|
||||||
# create swap
|
|
||||||
mkswap /dev/mmcblk0p3 | tee -a ${LOG}
|
|
||||||
swapon /dev/mmcblk0p3 | tee -a ${LOG}
|
|
||||||
|
|
||||||
LOG=/dev/null
|
LOG=/dev/null
|
||||||
|
|
||||||
# high brightness
|
# high brightness
|
||||||
@@ -20,30 +16,6 @@ echo
|
|||||||
|
|
||||||
BASEDIR="${MOUNTDIR}"
|
BASEDIR="${MOUNTDIR}"
|
||||||
|
|
||||||
# action time
|
|
||||||
|
|
||||||
# copy over the config files
|
|
||||||
echo "Copying default configuration files into place..." | tee -a ${LOG}
|
|
||||||
mount -t vfat -o rw,sync,utf8 /dev/mmcblk0p4 /mnt | tee -a ${LOG}
|
|
||||||
if test -r "${BASEDIR}/configs/manifest"; then
|
|
||||||
cat "${BASEDIR}/configs/manifest" | while read -r LINE; do
|
|
||||||
if test "${LINE}" == "${LINE#!}" -a "${LINE}" != "" ; then
|
|
||||||
set -- ${LINE}
|
|
||||||
# 1 2
|
|
||||||
# source_filename target_filename/inside main/
|
|
||||||
if test -r "${BASEDIR}/configs/$1"; then
|
|
||||||
TO="$2"
|
|
||||||
if test "${TO}" == ""; then
|
|
||||||
TO="$1"
|
|
||||||
fi
|
|
||||||
echo "Copying $1 to /mnt/$TO..." | tee -a ${LOG}
|
|
||||||
cp -f "${BASEDIR}/configs/$1" "/mnt/$TO" | tee -a ${LOG}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
|
|
||||||
# run a custom script if present - could be used to fix u-boot and such
|
# run a custom script if present - could be used to fix u-boot and such
|
||||||
if test -r "${BASEDIR}/firstboot.custom.sh"; then
|
if test -r "${BASEDIR}/firstboot.custom.sh"; then
|
||||||
echo "Running a specific firstboot script..." | tee -a ${LOG}
|
echo "Running a specific firstboot script..." | tee -a ${LOG}
|
||||||
@@ -81,6 +53,31 @@ console_var_func(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# write logs, sync & unmount MAIN then reboot/poweroff
|
||||||
|
safe_reboot_func(){
|
||||||
|
echo "please wait a few seconds for a reboot...." | tee -a ${LOG}
|
||||||
|
dmesg > /mnt/dmesg.txt
|
||||||
|
sync
|
||||||
|
sleep 1
|
||||||
|
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
|
||||||
|
umount /dev/mmcblk0p4 | tee -a ${LOG}
|
||||||
|
#umount /dev/mmcblk0p1 | tee -a ${LOG} # this fails
|
||||||
|
sleep 2
|
||||||
|
reboot
|
||||||
|
}
|
||||||
|
|
||||||
|
safe_poweroff_func(){
|
||||||
|
echo "please wait a few seconds for a shutdown...." | tee -a ${LOG}
|
||||||
|
dmesg > /mnt/dmesg.txt
|
||||||
|
sync
|
||||||
|
sleep 1
|
||||||
|
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
|
||||||
|
umount /dev/mmcblk0p4 | tee -a ${LOG}
|
||||||
|
#umount /dev/mmcblk0p1 | tee -a ${LOG} # this fails
|
||||||
|
sleep 2
|
||||||
|
poweroff
|
||||||
|
}
|
||||||
|
|
||||||
# list of available devices in u-boot Environment parameters' read from FORCE_VERSION
|
# list of available devices in u-boot Environment parameters' read from FORCE_VERSION
|
||||||
devices_ID="
|
devices_ID="
|
||||||
bittboy2x_v1
|
bittboy2x_v1
|
||||||
@@ -114,20 +111,20 @@ DETECTED_2="GC9306/GC9305 controller from gc9306fb"
|
|||||||
DETECTED_3="SUP M3 unknown controller Works with R61520"
|
DETECTED_3="SUP M3 unknown controller Works with R61520"
|
||||||
DETECTED_4="bittboy2x_v1 r61520fb controller"
|
DETECTED_4="bittboy2x_v1 r61520fb controller"
|
||||||
DETECTED_5="bittboy3.5/bittboy2x_v2 ST7789S controller"
|
DETECTED_5="bittboy3.5/bittboy2x_v2 ST7789S controller"
|
||||||
#DETECTED_6="RM68090 controller"
|
DETECTED_6="RM68090 controller"
|
||||||
#DETECTED_7="R61520 controller"
|
DETECTED_7="R61520 controller"
|
||||||
#DETECTED_8="R61505W controller"
|
DETECTED_8="R61505W controller"
|
||||||
#DETECTED_9="HX8347-D controller"
|
DETECTED_9="HX8347-D controller"
|
||||||
#DETECTED_10="UNKNOWN"
|
DETECTED_10="UNKNOWN"
|
||||||
|
|
||||||
## Defaulting to "not found the console in string list"
|
## Defaulting to "not found the console in string list"
|
||||||
export FOUND_CONSOLE=false
|
FOUND_CONSOLE=false
|
||||||
export FOUND_CONSOLE_AUTO=false
|
FOUND_CONSOLE_AUTO=false
|
||||||
|
|
||||||
find_console_func(){
|
find_console_func(){
|
||||||
for i in $devices_ID; do
|
for i in $devices_ID; do
|
||||||
if test "$i" = "$CONSOLE_VARIANT"; then
|
if test "$i" = "$CONSOLE_VARIANT"; then
|
||||||
export FOUND_CONSOLE=true
|
FOUND_CONSOLE=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -136,7 +133,7 @@ done
|
|||||||
find_console_auto_func(){
|
find_console_auto_func(){
|
||||||
for i in $devices_auto_ID; do
|
for i in $devices_auto_ID; do
|
||||||
if test "$i" = "$CONSOLE_VARIANT"; then
|
if test "$i" = "$CONSOLE_VARIANT"; then
|
||||||
export FOUND_CONSOLE_AUTO=true
|
FOUND_CONSOLE_AUTO=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -148,16 +145,18 @@ detect_console_func(){
|
|||||||
find_console_auto_func
|
find_console_auto_func
|
||||||
}
|
}
|
||||||
|
|
||||||
export CONSOLE_DETECTED=false
|
CONSOLE_DETECTED=false
|
||||||
#Checking if device at hand is operational within flashing procedure
|
#Checking if device at hand is operational within flashing procedure
|
||||||
if (grep -qE "${DETECTED_1}|${DETECTED_2}|${DETECTED_3}|${DETECTED_4}|${DETECTED_5}" "${MOUNTDIR}/uEnv.txt"); then
|
if (grep -qE "${DETECTED_1}|${DETECTED_2}|${DETECTED_3}|${DETECTED_4}|${DETECTED_5}|${DETECTED_6}|${DETECTED_7}|${DETECTED_8}|${DETECTED_9}|${DETECTED_10}" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
CONSOLE_DETECTED=true
|
CONSOLE_DETECTED=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# I - Test_Block
|
||||||
detect_console_func
|
detect_console_func
|
||||||
if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
||||||
if (grep -q "$DETECTED_1" "${MOUNTDIR}/uEnv.txt"); then
|
if (grep -q "$DETECTED_1" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
# Test_Video if proper miyoo video's version driver was loaded:
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_1" 0 0
|
||||||
|
# Test_Video-prompt if proper miyoo video's version driver was loaded:
|
||||||
test_video_func(){
|
test_video_func(){
|
||||||
dialog --defaultno --ok-label NO --cancel-label "Flipped!" --extra-button --extra-label YES --stdout --title " Test Video" \
|
dialog --defaultno --ok-label NO --cancel-label "Flipped!" --extra-button --extra-label YES --stdout --title " Test Video" \
|
||||||
--colors --pause "\n\n \ZuCan you see this message?\Zn\n\nSelect an option & press START" 12 34 10
|
--colors --pause "\n\n \ZuCan you see this message?\Zn\n\nSelect an option & press START" 12 34 10
|
||||||
@@ -172,23 +171,24 @@ if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
echo "CONSOLE_VARIANT=st7789s" > ${MOUNTDIR}/console.cfg
|
echo "CONSOLE_VARIANT=st7789s" > ${MOUNTDIR}/console.cfg
|
||||||
# "Flipped!" choice for Test_Video msgbox DIALOG_CANCEL exit code
|
# "Flipped!" choice for Test_Video msgbox DIALOG_CANCEL exit code
|
||||||
elif test $CHOICE -eq 1; then
|
elif test $CHOICE -eq 1; then
|
||||||
# Correct variant for bittboy3.5 (non forced) and display info about flipped image
|
# Test_Flip-prompt double checks if user selected correct answer for 1'st video test
|
||||||
echo "CONSOLE_VARIANT=bittboy3" > ${MOUNTDIR}/console.cfg
|
if (dialog --stdout --ok-label YES --cancel-label NO --title "Test Flip" --pause " \n Flipped? \n\nAre you sure?!" 12 15 10); then
|
||||||
dialog --timeout 2 --msgbox "Image flipped! correct&reboot" 0 0
|
# Correct variant for bittboy3.5 (non forced) and display info about flipped image
|
||||||
#TODO: use special Unicode characters to draw text upside-down e.g.:
|
echo "CONSOLE_VARIANT=bittboy3" > ${MOUNTDIR}/console.cfg
|
||||||
## dialog --timeout 2 --msgbox "ƃuᴉʇooqǝɹ⅋uᴉʇɔǝɹɹoɔ 'pǝddᴉןɟ ǝƃɐɯᴉ \n\n image flipped, correcting&rebooting" 0 0
|
dialog --timeout 2 --msgbox "Image flipped! correct&reboot" 0 0
|
||||||
sync
|
sleep 1.5
|
||||||
sleep 0.1
|
#TODO: use special Unicode characters to draw text upside-down e.g.:
|
||||||
reboot
|
## dialog --timeout 2 --msgbox "ƃuᴉʇooqǝɹ⅋uᴉʇɔǝɹɹoɔ 'pǝddᴉןɟ ǝƃɐɯᴉ \n\n image flipped, correcting&rebooting" 0 0
|
||||||
sleep 2
|
safe_reboot_func
|
||||||
|
else
|
||||||
|
dialog --timeout 2 --msgbox "Invalid choice, please redo the test!" 0 0
|
||||||
|
sleep 1.5
|
||||||
|
fi
|
||||||
# "NO" or timeout choice for Test_Video msgbox thus DIALOG_OK exit code
|
# "NO" or timeout choice for Test_Video msgbox thus DIALOG_OK exit code
|
||||||
elif test $CHOICE -eq 0; then
|
elif test $CHOICE -eq 0; then
|
||||||
# Correct variant for bittboy2x_v1 (non forced)
|
# Correct variant for bittboy2x_v1 (non forced)
|
||||||
echo "CONSOLE_VARIANT=bittboy" > ${MOUNTDIR}/console.cfg
|
echo "CONSOLE_VARIANT=bittboy" > ${MOUNTDIR}/console.cfg
|
||||||
sync
|
safe_reboot_func
|
||||||
sleep 0.1
|
|
||||||
reboot
|
|
||||||
sleep 2
|
|
||||||
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
|
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
|
||||||
else
|
else
|
||||||
dialog --timeout 2 --msgbox "Invalid choice, please redo the test!" 0 0
|
dialog --timeout 2 --msgbox "Invalid choice, please redo the test!" 0 0
|
||||||
@@ -196,18 +196,17 @@ if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Loop Test_Video until correct selection has been performed (CHOICE=0/1/3)
|
# Loop Test_Video until correct selection has been performed (CHOICE=0/3)
|
||||||
|
## former CHOICE=1 meant safe_reboot if correct and shouldn't reach to this point
|
||||||
while true; do
|
while true; do
|
||||||
test_video_func
|
test_video_func
|
||||||
if !(test $CHOICE -eq -1 || test $CHOICE -eq 255); then
|
if !(test $CHOICE -eq -1 || test $CHOICE -eq 1 || test $CHOICE -eq 255); then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
elif (grep -q "$DETECTED_2" "${MOUNTDIR}/uEnv.txt"); then
|
|
||||||
echo "CONSOLE_VARIANT=m3" > ${MOUNTDIR}/console.cfg
|
|
||||||
|
|
||||||
elif (grep -q "$DETECTED_3" "${MOUNTDIR}/uEnv.txt"); then
|
elif (grep -q "$DETECTED_3" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
# Test_Image if proper "invert" colors parameter was loaded:
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_3" 0 0
|
||||||
|
# Test_Image-prompt if proper "invert" colors parameter was loaded:
|
||||||
dialog --defaultno --ok-label NO --cancel-label Inverted --stdout --title " Test Image" \
|
dialog --defaultno --ok-label NO --cancel-label Inverted --stdout --title " Test Image" \
|
||||||
--colors --pause "\n\n \ZuAre your colors Inverted?\Zn\n\nSelect an option & press START" 12 34 10
|
--colors --pause "\n\n \ZuAre your colors Inverted?\Zn\n\nSelect an option & press START" 12 34 10
|
||||||
|
|
||||||
@@ -222,13 +221,29 @@ if ! $FOUND_CONSOLE && ! $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
# "INVERTED" choice for Test_Iamge msgbox DIALOG_CANCEL exit code and -1/255
|
# "INVERTED" choice for Test_Iamge msgbox DIALOG_CANCEL exit code and -1/255
|
||||||
## thus correct "invert" colors parameter on video driver
|
## thus correct "invert" colors parameter on video driver
|
||||||
else
|
else
|
||||||
#TODO - make "invert" flag overwriting less dependent
|
#TODO - make "invert" flag overwriting less dependent
|
||||||
echo "INVERT=0" >> /mnt/options.cfg
|
echo "INVERT=0" >> /mnt/options.cfg
|
||||||
sync
|
safe_reboot_func
|
||||||
sleep 0.1
|
|
||||||
reboot
|
|
||||||
sleep 2
|
|
||||||
fi
|
fi
|
||||||
|
# look in II Test block for following DETECTED versions as these imply devices_auto_ID variants:
|
||||||
|
## DETECTED_2 - xyc/m3
|
||||||
|
## DETECTED_4 - bittboy
|
||||||
|
## DETECTED_5 - bittboy3/2
|
||||||
|
elif (grep -q "$DETECTED_6" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_6" 0 0
|
||||||
|
echo "CONSOLE_VARIANT=m3_rm68090" > ${MOUNTDIR}/console.cfg
|
||||||
|
elif (grep -q "$DETECTED_7" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_7" 0 0
|
||||||
|
#echo "CONSOLE_VARIANT=r61520" > ${MOUNTDIR}/console.cfg
|
||||||
|
elif (grep -q "$DETECTED_8" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_8" 0 0
|
||||||
|
#echo "CONSOLE_VARIANT=r61505w" > ${MOUNTDIR}/console.cfg
|
||||||
|
elif (grep -q "$DETECTED_9" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_9" 0 0
|
||||||
|
echo "CONSOLE_VARIANT=m3_hx8347d" > ${MOUNTDIR}/console.cfg
|
||||||
|
elif (grep -q "$DETECTED_10" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_10" 0 0
|
||||||
|
#echo "CONSOLE_VARIANT=unknown-error" > ${MOUNTDIR}/console.cfg
|
||||||
fi
|
fi
|
||||||
# Overwrite CONSOLE_VARIANT from new entry
|
# Overwrite CONSOLE_VARIANT from new entry
|
||||||
source "${MOUNTDIR}/console.cfg"
|
source "${MOUNTDIR}/console.cfg"
|
||||||
@@ -239,15 +254,15 @@ console_unknown_func(){
|
|||||||
echo "##DO_NOT_REMOVE_THIS_LINE##" >> ${MOUNTDIR}/console.cfg
|
echo "##DO_NOT_REMOVE_THIS_LINE##" >> ${MOUNTDIR}/console.cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
# Defaulting to console overwriting inactive
|
# II - Test_Block
|
||||||
export CONSOLE_OVERWRITE=false
|
## Defaulting to console overwriting inactive
|
||||||
# Test if console have been found in devices_auto_ID
|
CONSOLE_OVERWRITE=false
|
||||||
|
## Test if console have been found in devices_auto_ID
|
||||||
detect_console_func
|
detect_console_func
|
||||||
# test if no device specified in console.cfg
|
## test if no device specified in console.cfg
|
||||||
if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
||||||
## show selection menu for ST7789S devices
|
# show selection menu for ST7789S devices
|
||||||
### TODO: test also if "<DETECTED_VERSION>"="$DETECTED_?" depending on current CONSOLE_VARIANT
|
if (test "$CONSOLE_VARIANT" == "st7789s" && grep -q "$DETECTED_1" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
if test "$CONSOLE_VARIANT" == "st7789s"; then
|
|
||||||
dialog --clear --timeout 60 --title "Select your device:" --menu " " 15 40 5 \
|
dialog --clear --timeout 60 --title "Select your device:" --menu " " 15 40 5 \
|
||||||
1 "Powkiddy Q20" \
|
1 "Powkiddy Q20" \
|
||||||
2 "Powkiddy Q90" \
|
2 "Powkiddy Q90" \
|
||||||
@@ -256,13 +271,13 @@ if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
5 "PocketGO with TE pin" \
|
5 "PocketGO with TE pin" \
|
||||||
2> $TEMP
|
2> $TEMP
|
||||||
## Defaulting to console overwriting active
|
## Defaulting to console overwriting active
|
||||||
export CONSOLE_OVERWRITE=true
|
CONSOLE_OVERWRITE=true
|
||||||
|
|
||||||
## Default CONSOLE_VARIANT for st7789s screns
|
## Default CONSOLE_VARIANT for st7789s screns
|
||||||
default_console_func(){
|
default_console_func(){
|
||||||
echo "CONSOLE_VARIANT=pocketgo" > ${MOUNTDIR}/console.cfg
|
echo "CONSOLE_VARIANT=pocketgo" > ${MOUNTDIR}/console.cfg
|
||||||
# No need to overwrite uboot FORCE version for default so continue procedure
|
# No need to overwrite uboot FORCE version for default so continue procedure
|
||||||
export CONSOLE_OVERWRITE=false
|
CONSOLE_OVERWRITE=false
|
||||||
}
|
}
|
||||||
## Read the user's choice from the file
|
## Read the user's choice from the file
|
||||||
CHOICE=$(cat $TEMP)
|
CHOICE=$(cat $TEMP)
|
||||||
@@ -289,8 +304,13 @@ if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
sleep 0.1
|
sleep 0.1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# Test_Keyboard if proper miyoo.kbd version was loaded:
|
## Test_Keyboard-prompt if proper miyoo.kbd version was loaded:
|
||||||
elif test "$CONSOLE_VARIANT" == "bittboy3" || test "$CONSOLE_VARIANT" == "bittboy2" || test "$CONSOLE_VARIANT" == "xyc" || test "$CONSOLE_VARIANT" == "m3"; then
|
elif (((test "$CONSOLE_VARIANT" == "bittboy2" || test "$CONSOLE_VARIANT" == "bittboy3") && grep -q "$DETECTED_5" "${MOUNTDIR}/uEnv.txt") || ((test "$CONSOLE_VARIANT" == "xyc" || test "$CONSOLE_VARIANT" == "m3") && grep -q "$DETECTED_2" "${MOUNTDIR}/uEnv.txt")); then
|
||||||
|
if (grep -q "$DETECTED_5" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_5" 0 0
|
||||||
|
elif (grep -q "$DETECTED_2" "${MOUNTDIR}/uEnv.txt"); then
|
||||||
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_2" 0 0
|
||||||
|
fi
|
||||||
test_keyboard_func(){
|
test_keyboard_func(){
|
||||||
dialog --ok-label NO --cancel-label YES --stdout --title " Test Keyboard" \
|
dialog --ok-label NO --cancel-label YES --stdout --title " Test Keyboard" \
|
||||||
--colors --pause "\n\n \ZuDoes D-pad works correctly?\Zn\n\nSelect an option & press START" 12 34 10
|
--colors --pause "\n\n \ZuDoes D-pad works correctly?\Zn\n\nSelect an option & press START" 12 34 10
|
||||||
@@ -323,10 +343,7 @@ if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
elif test "$CONSOLE_VARIANT" == "m3"; then
|
elif test "$CONSOLE_VARIANT" == "m3"; then
|
||||||
echo "CONSOLE_VARIANT=xyc" > ${MOUNTDIR}/console.cfg
|
echo "CONSOLE_VARIANT=xyc" > ${MOUNTDIR}/console.cfg
|
||||||
fi
|
fi
|
||||||
sync
|
safe_reboot_func
|
||||||
sleep 0.1
|
|
||||||
reboot
|
|
||||||
sleep 2
|
|
||||||
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
|
# Error (DIALOG_ERROR) or ESCAPE button pressed (DIALOG_ESCAPE) thus exit code -1/255
|
||||||
else
|
else
|
||||||
dialog --timeout 2 --msgbox "Invalid choice, please redo the test!" 0 0
|
dialog --timeout 2 --msgbox "Invalid choice, please redo the test!" 0 0
|
||||||
@@ -340,8 +357,9 @@ if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
elif test "$CONSOLE_VARIANT" == "bittboy"; then
|
elif (test "$CONSOLE_VARIANT" == "bittboy" && grep -q "$DETECTED_4" "${MOUNTDIR}/uEnv.txt") ; then
|
||||||
# Test_Video'2 if proper miyoo video's version driver was loaded:
|
dialog --timeout 3 --msgbox "Auto-Detected $DETECTED_4" 0 0
|
||||||
|
# Test_Video'2-prompt if proper miyoo video's version driver was loaded:
|
||||||
dialog --defaultno --ok-label NO --cancel-label YES --stdout --title " Test Video'2" \
|
dialog --defaultno --ok-label NO --cancel-label YES --stdout --title " Test Video'2" \
|
||||||
--colors --pause "\n\n \ZuCan you see this message?\Zn\n\nSelect an option & press START" 12 34 10
|
--colors --pause "\n\n \ZuCan you see this message?\Zn\n\nSelect an option & press START" 12 34 10
|
||||||
|
|
||||||
@@ -356,61 +374,74 @@ if ! $FOUND_CONSOLE && $FOUND_CONSOLE_AUTO && $CONSOLE_DETECTED; then
|
|||||||
## correct variant to unknown and redo whole flashing_prd again
|
## correct variant to unknown and redo whole flashing_prd again
|
||||||
else
|
else
|
||||||
console_unknown_func
|
console_unknown_func
|
||||||
sync
|
safe_reboot_func
|
||||||
sleep 0.1
|
|
||||||
reboot
|
|
||||||
sleep 2
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# III - Test_Block
|
||||||
detect_console_func
|
detect_console_func
|
||||||
|
BITTBOY_CONFIG=false
|
||||||
|
MIYOO_CONFIG=false
|
||||||
if $FOUND_CONSOLE; then
|
if $FOUND_CONSOLE; then
|
||||||
# Info_Box about selected/edited device in console.cfg
|
# Info_Box about selected/edited device in console.cfg
|
||||||
case $CONSOLE_VARIANT in
|
case $CONSOLE_VARIANT in
|
||||||
bittboy2x_v1)
|
bittboy2x_v1)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " BittBoy2x v1" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " BittBoy2x v1" 5 18
|
||||||
|
BITTBOY_CONFIG=true
|
||||||
;;
|
;;
|
||||||
bittboy2x_v2)
|
bittboy2x_v2)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " BittBoy2x v2" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " BittBoy2x v2" 5 18
|
||||||
|
BITTBOY_CONFIG=true
|
||||||
;;
|
;;
|
||||||
bittboy3.5)
|
bittboy3.5)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " BittBoy3.5" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " BittBoy3.5" 5 18
|
||||||
|
BITTBOY_CONFIG=true
|
||||||
;;
|
;;
|
||||||
q20)
|
q20)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " Powkiddy Q20" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " Powkiddy Q20" 5 18
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
q90)
|
q90)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " Powkiddy Q90" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " Powkiddy Q90" 5 18
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
v90)
|
v90)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " Powkiddy V90" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " Powkiddy V90" 5 18
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
pocketgo)
|
pocketgo)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " PocketGo" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " PocketGo" 5 18
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
pocketgo_TE)
|
pocketgo_TE)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " PocketGo+TE" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " PocketGo+TE" 5 18
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
xyc_gc9306)
|
xyc_gc9306)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " XYC Q8" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " XYC Q8" 5 18
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
m3_r61520)
|
m3_r61520)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n (controller of r61520fb)" 6 29
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n (controller of r61520fb)" 6 29
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
m3_rm68090)
|
m3_rm68090)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n(RM68090 controller)" 6 24
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n(RM68090 controller)" 6 24
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
m3_hx8347d)
|
m3_hx8347d)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n(HX8347D controller)" 6 24
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n(HX8347D controller)" 6 24
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
m3_gc9306)
|
m3_gc9306)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n(GC9306 controller)" 6 24
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox " SUP M3\n(GC9306 controller)" 6 24
|
||||||
|
MIYOO_CONFIG=true
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox "\Zb\Z1 Unknown-Error\Zn" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox "\Zb\Z1 Unknown-Error\Zn" 5 18
|
||||||
esac
|
esac
|
||||||
# Test_Variant if correct CONSOLE_VARIANT has been written to console.cfg
|
# Test_Variant-prompt if correct CONSOLE_VARIANT has been written to console.cfg
|
||||||
dialog --defaultno --ok-label NO --cancel-label YES --stdout --title " Test Variant" \
|
dialog --defaultno --ok-label NO --cancel-label YES --stdout --title " Test Variant" \
|
||||||
--colors --pause "Does this device match yours?" 0 0 15
|
--colors --pause "Does this device match yours?" 0 0 15
|
||||||
|
|
||||||
@@ -421,29 +452,24 @@ if $FOUND_CONSOLE; then
|
|||||||
## correct variant to unknown and redo whole flashing_prd again
|
## correct variant to unknown and redo whole flashing_prd again
|
||||||
if !(test $CHOICE -eq 1); then
|
if !(test $CHOICE -eq 1); then
|
||||||
console_unknown_func
|
console_unknown_func
|
||||||
sync
|
safe_reboot_func
|
||||||
sleep 0.1
|
|
||||||
reboot
|
|
||||||
sleep 2
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
dialog --colors --timeout 2 --ok-label " Your device " --msgbox "\Zb\Z1 Unknown\Zn" 5 18
|
dialog --colors --timeout 2 --ok-label " Your device " --msgbox "\Zb\Z1 Unknown\Zn" 5 18
|
||||||
console_unknown_func
|
console_unknown_func
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#License prompt
|
# License_agreement-prompt
|
||||||
if (dialog --clear --ok-label NO --cancel-label YES --stdout --title " License agreement" \
|
if (dialog --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
|
--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"
|
||||||
sleep 1
|
sleep 1
|
||||||
console_unknown_func
|
console_unknown_func
|
||||||
sync
|
safe_poweroff_func
|
||||||
sleep 0.1
|
|
||||||
poweroff
|
|
||||||
sleep 2
|
|
||||||
fi
|
fi
|
||||||
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
|
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
|
||||||
|
|
||||||
|
RESIZE_COMMENCED=false
|
||||||
# resize the main partition if requested
|
# resize the main partition if requested
|
||||||
if ((test -e "${MOUNTDIR}/resize") && (dialog --clear --stdout --ok-label YES --cancel-label NO --title " AUTO-RESIZE" \
|
if ((test -e "${MOUNTDIR}/resize") && (dialog --clear --stdout --ok-label YES --cancel-label NO --title " AUTO-RESIZE" \
|
||||||
--colors --pause "\n\n \ZuExpand MAIN partition?\Zn\n\n Select an option & press START
|
--colors --pause "\n\n \ZuExpand MAIN partition?\Zn\n\n Select an option & press START
|
||||||
@@ -458,6 +484,7 @@ if ((test -e "${MOUNTDIR}/resize") && (dialog --clear --stdout --ok-label YES --
|
|||||||
echo -n -e \\xEB\\x58\\x90 > /dev/mmcblk0p4
|
echo -n -e \\xEB\\x58\\x90 > /dev/mmcblk0p4
|
||||||
sync
|
sync
|
||||||
mount -t vfat -o rw,sync,utf8 /dev/mmcblk0p4 /mnt | tee -a ${LOG}
|
mount -t vfat -o rw,sync,utf8 /dev/mmcblk0p4 /mnt | tee -a ${LOG}
|
||||||
|
RESIZE_COMMENCED=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup - delete the temporary file storing variable value
|
# Cleanup - delete the temporary file storing variable value
|
||||||
@@ -467,9 +494,35 @@ rm $TEMP
|
|||||||
mount -o remount,rw "${MOUNTDIR}" | tee -a ${LOG}
|
mount -o remount,rw "${MOUNTDIR}" | tee -a ${LOG}
|
||||||
echo "Disabling the firstboot script." | tee -a ${LOG}
|
echo "Disabling the firstboot script." | tee -a ${LOG}
|
||||||
mv "${MOUNTDIR}/firstboot" "${MOUNTDIR}/firstboot.done" | tee -a ${LOG}
|
mv "${MOUNTDIR}/firstboot" "${MOUNTDIR}/firstboot.done" | tee -a ${LOG}
|
||||||
if test -e "${MOUNTDIR}/resize"; then rm "${MOUNTDIR}/resize"; reboot; fi
|
if test -e "${MOUNTDIR}/resize"; then
|
||||||
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
|
rm "${MOUNTDIR}/resize"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# copy over the config files
|
||||||
|
echo "Copying default configuration files into place..." | tee -a ${LOG}
|
||||||
|
if $BITTBOY_CONFIG; then
|
||||||
|
cp "${MOUNTDIR}/configs/input_bittboy.conf" "${MOUNTDIR}/configs/input.conf"
|
||||||
|
elif $MIYOO_CONFIG; then
|
||||||
|
cp "${MOUNTDIR}/configs/input_miyoo.conf" "${MOUNTDIR}/configs/input.conf"
|
||||||
|
fi
|
||||||
|
mount -o remount,ro "${MOUNTDIR}" | tee -a ${LOG}
|
||||||
|
if test -r "${BASEDIR}/configs/manifest"; then
|
||||||
|
cat "${BASEDIR}/configs/manifest" | while read -r LINE; do
|
||||||
|
if test "${LINE}" == "${LINE#!}" -a "${LINE}" != "" ; then
|
||||||
|
set -- ${LINE}
|
||||||
|
# 1 2
|
||||||
|
# source_filename target_filename/inside main/
|
||||||
|
if test -r "${BASEDIR}/configs/$1"; then
|
||||||
|
TO="$2"
|
||||||
|
if test "${TO}" == ""; then
|
||||||
|
TO="$1"
|
||||||
|
fi
|
||||||
|
echo "Copying $1 to /mnt/$TO..." | tee -a ${LOG}
|
||||||
|
cp -f "${BASEDIR}/configs/$1" "/mnt/$TO" | tee -a ${LOG}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
sync
|
sync
|
||||||
@@ -477,17 +530,8 @@ echo "firstboot script finished." | tee -a ${LOG}
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if test -r "${BASEDIR}/firstboot.custom.sh"; then
|
# Reboot device if CONSOLE_VARIANT was overwritten from $CHOICE so that it could be applied in u-boot by readID
|
||||||
echo "please wait a few seconds for shutdown...." | tee -a ${LOG}
|
## or resizing FAT partition has completed / found firstboot custom script
|
||||||
umount /dev/mmcblk0p4 | tee -a ${LOG}
|
if ($CONSOLE_OVERWRITE || $RESIZE_COMMENCED || test -r "${BASEDIR}/firstboot.custom.sh"); then
|
||||||
#umount /dev/mmcblk0p1 | tee -a ${LOG} # this fails
|
safe_reboot_func
|
||||||
sleep 3
|
|
||||||
reboot
|
|
||||||
fi
|
|
||||||
|
|
||||||
# REBOOT device if CONSOLE_VARIANT was overwritten from $CHOICE
|
|
||||||
## so that it could be applied in u-boot by readID
|
|
||||||
if $CONSOLE_OVERWRITE; then
|
|
||||||
reboot
|
|
||||||
sleep 1
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ image bootfs.vfat {
|
|||||||
file configs/manifest {
|
file configs/manifest {
|
||||||
image = "boot/configs/manifest"
|
image = "boot/configs/manifest"
|
||||||
}
|
}
|
||||||
|
file configs/input_bittboy.conf {
|
||||||
|
image = "boot/configs/input_bittboy.conf"
|
||||||
|
}
|
||||||
|
file configs/input_miyoo.conf {
|
||||||
|
image = "boot/configs/input_miyoo.conf"
|
||||||
|
}
|
||||||
file configs/.volume.conf {
|
file configs/.volume.conf {
|
||||||
image = "boot/configs/.volume.conf"
|
image = "boot/configs/.volume.conf"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user