Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- temp_dir="/tmp/screen"
- mmc_dir="/mnt/mmc"
- sunxi_tools_dir="/opt/sunxi-tools"
- bin_file="script.bin"
- fex_file="script.fex"
- tempfile1=/tmp/dialog_1_$$
- tempfile2=/tmp/dialog_2_$$
- tempfile3=/tmp/dialog_3_$$
- tempfile4=/tmp/dialog_4_$$
- # Define some functions
- SET_NONE() {
- #get line number
- line=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- dialog --title "Confirmation" --yesno "Disable screen ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 0/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- }
- SET_HDMI() {
- #get line number
- line=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- mode=$(grep -nr "screen0_output_mode" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- dialog --backtitle "OLimeXino-A20 screen configuration" \
- --menu "Select screen mode:" 12 55 8 \
- 0 "480i" \
- 1 "576i" \
- 2 "480p" \
- 3 "576p" \
- 4 "720p50" \
- 5 "720p60" \
- 6 "1080i50" \
- 7 "1080i60" \
- 8 "1080p24" \
- 9 "1080p50" \
- 10 "1080p60" \
- 11 "pal" \
- 14 "ntsc" 2> $tempfile3
- retv=$?
- choice=$(cat $tempfile3)
- # Check if ESC of CANCLE are pressed
- if [ $retv -eq 1 -o $retv -eq 255 ];
- then
- clear
- exit
- fi
- case $choice in
- 0)
- dialog --title "Confirmation" --yesno "Set HDMI to 480i ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 0/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 1)
- dialog --title "Confirmation" --yesno "Set HDMI to 576i ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 1/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 2)
- dialog --title "Confirmation" --yesno "Set HDMI to 480p ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 2/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 3)
- dialog --title "Confirmation" --yesno "Set HDMI to 576p ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 3/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 4)
- dialog --title "Confirmation" --yesno "Set HDMI to 720p50 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 4/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 5)
- dialog --title "Confirmation" --yesno "Set HDMI to 720p60 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 5/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 6)
- dialog --title "Confirmation" --yesno "Set HDMI to 1080i50 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 6/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 7)
- dialog --title "Confirmation" --yesno "Set HDMI to 1080i60 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 7/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 8)
- dialog --title "Confirmation" --yesno "Set HDMI to 1080p24 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 8/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 9)
- dialog --title "Confirmation" --yesno "Set HDMI to 1080p50 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 9/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 10)
- dialog --title "Confirmation" --yesno "Set HDMI to 1080p60 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 10/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 11)
- dialog --title "Confirmation" --yesno "Set HDMI to pal ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 11/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 14)
- dialog --title "Confirmation" --yesno "Set HDMI to ntsc ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 14/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- esac
- }
- SET_VGA() {
- #get line number
- line=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- mode=$(grep -nr "screen0_output_mode" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- dialog --backtitle "OLimeXino-A20 screen configuration" \
- --menu "Select screen mode:" 0 0 0 \
- 0 "1680x1050" \
- 1 "1440x900" \
- 2 "1360x768" \
- 3 "1280x1024" \
- 4 "1024x768" \
- 5 "800x600" \
- 6 "640x480" \
- 10 "1920x1080" \
- 11 "1280x720" 2> $tempfile4
- retv=$?
- choice=$(cat $tempfile4)
- # Check if ESC of CANCLE are pressed
- if [ $retv -eq 1 -o $retv -eq 255 ];
- then
- clear
- exit
- fi
- case $choice in
- 0)
- dialog --title "Confirmation" --yesno "Set VGA to 1680x1050 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 0/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 1)
- dialog --title "Confirmation" --yesno "Set VGA to 1440x900 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 1/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 2)
- dialog --title "Confirmation" --yesno "Set VGA to 1360x768 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 2/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 3)
- dialog --title "Confirmation" --yesno "Set VGA to 1280x1024 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 3/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 4)
- dialog --title "Confirmation" --yesno "Set VGA to 1024x768 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 4/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 5)
- dialog --title "Confirmation" --yesno "Set VGA to 800x600 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 5/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 6)
- dialog --title "Confirmation" --yesno "Set VGA to 640x480 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 6/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 10)
- dialog --title "Confirmation" --yesno "Set VGA to 1920x1080 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 10/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- 11)
- dialog --title "Confirmation" --yesno "Set VGA to 1280x720 ?" 0 0
- case $? in
- 0)
- #replace line
- sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
- sed -i $mode's/.*/screen0_output_mode = 11/' $temp_dir/$fex_file
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- ;;
- esac
- }
- SET_LCD() {
- dialog --backtitle "OLimeXino-A20 screen configuration" \
- --menu "Select screen mode:" 0 0 0 \
- "4.3" "480x272" \
- "7.0" "800x480" \
- "10.3" "1024x600" \
- "15.6" "1366x768" 2> $tempfile2
- retv=$?
- choice=$(cat $tempfile2)
- # Check if ESC of CANCLE are pressed
- if [ $retv -eq 1 -o $retv -eq 255 ];
- then
- clear
- exit
- fi
- case $choice in
- "4.3")
- x=480
- y=272
- freq=9
- hbp=40
- ht=525
- vbp=8
- vt=576
- vspw=5
- hspw=30
- #extra options
- lcd_if=0
- lcd_lvds_bitwidth=0
- lcd_io_cfg0=0
- lcd_bl_en_used=1
- fb0_scaler_mode_enable=0
- fb0_width=0
- fb0_height=0
- gpio_num=75
- ;;
- "7.0")
- x=800
- y=480
- freq=33
- hbp=46
- ht=1055
- vbp=23
- vt=1050
- vspw=1
- hspw=30
- #extra options
- lcd_if=0
- lcd_lvds_bitwidth=0
- lcd_io_cfg0=0
- lcd_bl_en_used=1
- fb0_scaler_mode_enable=0
- fb0_width=0
- fb0_height=0
- gpio_num=75
- ;;
- "10.3")
- x=1024
- y=600
- freq=45
- hbp=160
- ht=1200
- vbp=23
- vt=1250
- vspw=2
- hspw=10
- #extra options
- lcd_if=0
- lcd_lvds_bitwidth=0
- lcd_io_cfg0=0
- lcd_bl_en_used=1
- fb0_scaler_mode_enable=0
- fb0_width=0
- fb0_height=0
- gpio_num=75
- ;;
- "15.6")
- x=1366
- y=768
- freq=70
- hbp=54
- ht=1440
- vbp=23
- vt=1616
- vspw=0
- hspw=0
- #extra options
- lcd_if=3
- lcd_lvds_bitwidth=1
- lcd_io_cfg0="0x04000000"
- lcd_bl_en_used=0
- fb0_scaler_mode_enable=1
- fb0_width=1366
- fb0_height=768
- gpio_num=81
- ;;
- esac
- dialog --title "Confirmation" --yesno "Set LCD to '$x'x'$y' ?" 0 0
- case $? in
- 0)
- #Edit fex file
- line_x=$(grep -nr -m 1 "lcd_x" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_x ];
- then
- dialog --infobox "Cannot find lcd_x variable!" 0 0
- sleep 2
- exit
- fi
- line_y=$(grep -nr -m 1 "lcd_y" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_y ];
- then
- dialog --infobox "Cannot find lcd_y variable!" 0 0
- sleep 2
- exit
- fi
- line_freq=$(grep -nr -m 1 "lcd_dclk_freq" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_freq ];
- then
- dialog --infobox "Cannot find lcd_dclk_freq variable!" 0 0
- sleep 2
- exit
- fi
- line_hbp=$(grep -nr -m 1 "lcd_hbp" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_hbp ];
- then
- dialog --infobox "Cannot find lcd_hbp variable!" 0 0
- sleep 2
- exit
- fi
- line_ht=$(grep -nr -m 1 "lcd_ht" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_ht ];
- then
- dialog --infobox "Cannot find lcd_ht variable!" 0 0
- sleep 2
- exit
- fi
- line_vbp=$(grep -nr -m 1 "lcd_vbp" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_vbp ];
- then
- dialog --infobox "Cannot find lcd_vbp variable!" 0 0
- sleep 2
- exit
- fi
- line_vt=$(grep -nr -m 1 "lcd_vt" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_vt ];
- then
- dialog --infobox "Cannot find lcd_vt variable!" 0 0
- sleep 2
- exit
- fi
- line_vspw=$(grep -nr -m 1 "lcd_vspw" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_vspw ];
- then
- dialog --infobox "Cannot find lcd_vspw variable!" 0 0
- sleep 2
- exit
- fi
- line_hspw=$(grep -nr -m 1 "lcd_hspw" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_hspw ];
- then
- dialog --infobox "Cannot find lcd_hspw variable!" 0 0
- sleep 2
- exit
- fi
- line_screen0_output_type=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_screen0_output_type ];
- then
- dialog --infobox "Cannot find screen0_output_type variable!" 0 0
- sleep 2
- exit
- fi
- #EXTRA OPTIONS
- line_lcd_if=$(grep -nr -m 1 "lcd_if" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcd_if ];
- then
- dialog --infobox "Cannot find lcd_if variable!" 0 0
- sleep 2
- exit
- fi
- line_lcd_lvds_bitwidth=$(grep -nr -m 1 "lcd_lvds_bitwidth" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcd_lvds_bitwidth ];
- then
- dialog --infobox "Cannot find lcd_lvds_bitwidth variable!" 0 0
- sleep 2
- exit
- fi
- line_lcd_io_cfg0=$(grep -nr -m 1 "lcd_io_cfg0" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcd_io_cfg0 ];
- then
- dialog --infobox "Cannot find lcd_io_cfg0 variable!" 0 0
- sleep 2
- exit
- fi
- line_lcd_bl_en_used=$(grep -nr -m 1 "lcd_bl_en_used" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcd_bl_en_used ];
- then
- dialog --infobox "Cannot find lcd_bl_en_used variable!" 0 0
- sleep 2
- exit
- fi
- line_fb0_scaler_mode_enable=$(grep -nr -m 1 "fb0_scaler_mode_enable" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_fb0_scaler_mode_enable ];
- then
- dialog --infobox "Cannot find fb0_scaler_mode_enable variable!" 0 0
- sleep 2
- exit
- fi
- line_fb0_width=$(grep -nr -m 1 "fb0_width" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_fb0_width ];
- then
- dialog --infobox "Cannot find fb0_width variable!" 0 0
- sleep 2
- exit
- fi
- line_fb0_height=$(grep -nr -m 1 "fb0_height" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_fb0_height ];
- then
- dialog --infobox "Cannot find fb0_height variable!" 0 0
- sleep 2
- exit
- fi
- line_gpio_num=$(grep -nr -m 1 "gpio_num" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_num ];
- then
- dialog --infobox "Cannot find gpio_num variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_screen0_output_type's/.*/screen0_output_type = 1/' $temp_dir/$fex_file
- sed -i $line_x's/.*/lcd_x = '$x'/' $temp_dir/$fex_file
- sed -i $line_y's/.*/lcd_y = '$y'/' $temp_dir/$fex_file
- sed -i $line_freq's/.*/lcd_dclk_freq = '$freq'/' $temp_dir/$fex_file
- sed -i $line_hbp's/.*/lcd_hbp = '$hbp'/' $temp_dir/$fex_file
- sed -i $line_ht's/.*/lcd_ht = '$ht'/' $temp_dir/$fex_file
- sed -i $line_vbp's/.*/lcd_vbp = '$vbp'/' $temp_dir/$fex_file
- sed -i $line_vt's/.*/lcd_vt = '$vt'/' $temp_dir/$fex_file
- sed -i $line_vspw's/.*/lcd_vspw = '$vspw'/' $temp_dir/$fex_file
- sed -i $line_hspw's/.*/lcd_hspw = '$hspw'/' $temp_dir/$fex_file
- sed -i $line_lcd_if's/.*/lcd_if = '$lcd_if'/' $temp_dir/$fex_file
- sed -i $line_lcd_lvds_bitwidth's/.*/lcd_lvds_bitwidth = '$lcd_lvds_bitwidth'/' $temp_dir/$fex_file
- sed -i $line_lcd_io_cfg0's/.*/lcd_io_cfg0 = '$lcd_io_cfg0'/' $temp_dir/$fex_file
- sed -i $line_lcd_bl_en_used's/.*/lcd_bl_en_used = '$lcd_bl_en_used'/' $temp_dir/$fex_file
- sed -i $line_fb0_scaler_mode_enable's/.*/fb0_scaler_mode_enable = '$fb0_scaler_mode_enable'/' $temp_dir/$fex_file
- sed -i $line_fb0_width's/.*/fb0_width = '$fb0_width'/' $temp_dir/$fex_file
- sed -i $line_fb0_height's/.*/fb0_height = '$fb0_height'/' $temp_dir/$fex_file
- sed -i $line_gpio_num's/.*/gpio_num = '$gpio_num'/' $temp_dir/$fex_file
- # DO SOME EXTRA THINGS ONLY FOR 15.6 LCD
- choice=$(cat $tempfile2)
- if [ "$choice" = "15.6" ];
- then
- # ADD P113
- line_pll3=$(grep -nr -m 1 "pll3" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pll3 ];
- then
- #There is no p113 in the fex file
- line_clock=$(grep -nr -m 1 "\[clock\]" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_clock ];
- then
- dialog --infobox "Cannot find [clock] variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_clock'a\pll3 = 297' $temp_dir/$fex_file
- else
- #Tgere is p113
- sed -i $line_pll3's/.*/pll3 = 297/' $temp_dir/$fex_file
- fi
- # REMOVE LCDD22
- sed -i '/lcdd22/d' $temp_dir/$fex_file
- sed -i '/lcdd23/d' $temp_dir/$fex_file
- sed -i '/lcdclk/d' $temp_dir/$fex_file
- sed -i '/lcdde/d' $temp_dir/$fex_file
- sed -i '/lcdhsync/d' $temp_dir/$fex_file
- sed -i '/lcdvsync/d' $temp_dir/$fex_file
- # CHECK FOR PIN76
- line_gpio_pin_76=$(grep -nr -m 1 "gpio_pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_76 ];
- then
- line_gpio_pin_75=$(grep -nr -m 1 "gpio_pin_75" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_75 ];
- then
- dialog --infobox "Cannot find gpio_pin_75 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_gpio_pin_75'a\gpio_pin_76 = port:PD22<1><default><default><1>' $temp_dir/$fex_file
- else
- sed -i $line_gpio_pin_76's/.*/gpio_pin_76 = port:PD22<1><default><default><1>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN77
- line_gpio_pin_77=$(grep -nr -m 1 "gpio_pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_77 ];
- then
- line_gpio_pin_76=$(grep -nr -m 1 "gpio_pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_76 ];
- then
- dialog --infobox "Cannot find gpio_pin_76 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_gpio_pin_76'a\gpio_pin_77 = port:PD23<1><default><default><1>' $temp_dir/$fex_file
- else
- sed -i $line_gpio_pin_77's/.*/gpio_pin_77 = port:PD23<1><default><default><1>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN78
- line_gpio_pin_78=$(grep -nr -m 1 "gpio_pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_78 ];
- then
- line_gpio_pin_77=$(grep -nr -m 1 "gpio_pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_77 ];
- then
- dialog --infobox "Cannot find gpio_pin_77 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_gpio_pin_77'a\gpio_pin_78 = port:PD24<1><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_gpio_pin_78's/.*/gpio_pin_78 = port:PD24<1><default><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN79
- line_gpio_pin_79=$(grep -nr -m 1 "gpio_pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_79 ];
- then
- line_gpio_pin_78=$(grep -nr -m 1 "gpio_pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_78 ];
- then
- dialog --infobox "Cannot find gpio_pin_78 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_gpio_pin_78'a\gpio_pin_79 = port:PD25<1><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_gpio_pin_79's/.*/gpio_pin_79 = port:PD25<1><default><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN80
- line_gpio_pin_80=$(grep -nr -m 1 "gpio_pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_80 ];
- then
- line_gpio_pin_79=$(grep -nr -m 1 "gpio_pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_79 ];
- then
- dialog --infobox "Cannot find gpio_pin_79 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_gpio_pin_79'a\gpio_pin_80 = port:PD26<0><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_gpio_pin_80's/.*/gpio_pin_80 = port:PD26<0><default><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN81
- line_gpio_pin_81=$(grep -nr -m 1 "gpio_pin_81" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_81 ];
- then
- line_gpio_pin_80=$(grep -nr -m 1 "gpio_pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_gpio_pin_80 ];
- then
- dialog --infobox "Cannot find gpio_pin_80 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_gpio_pin_80'a\gpio_pin_81 = port:PD27<0><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_gpio_pin_81's/.*/gpio_pin_81 = port:PD27<0><default><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN76
- line_pin_76=$(grep -nr -m 1 "pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_76 ];
- then
- line_pin_75=$(grep -nr -m 1 "pin_75" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_75 ];
- then
- dialog --infobox "Cannot find pin_75 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_pin_75'a\pin_76 = port:PD22<1><default><default><1>' $temp_dir/$fex_file
- else
- sed -i $line_pin_76's/.*/pin_76 = port:PD22<1><default><default><1>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN77
- line_pin_77=$(grep -nr -m 1 "pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_77 ];
- then
- line_pin_76=$(grep -nr -m 1 "pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $gpio_pin_76 ];
- then
- dialog --infobox "Cannot find pin_76 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_pin_76'a\pin_77 = port:PD23<1><default><default><1>' $temp_dir/$fex_file
- else
- sed -i $line_pin_77's/.*/pin_77 = port:PD23<1><default><default><1>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN78
- line_pin_78=$(grep -nr -m 1 "pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_78 ];
- then
- line_pin_77=$(grep -nr -m 1 "pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_77 ];
- then
- dialog --infobox "Cannot find pin_77 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_pin_77'a\pin_78 = port:PD24<1><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_pin_78's/.*/pin_78 = port:PD24<1><default><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN79
- line_pin_79=$(grep -nr -m 1 "pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_79 ];
- then
- line_pin_78=$(grep -nr -m 1 "pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_78 ];
- then
- dialog --infobox "Cannot find pin_78 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_pin_78'a\pin_79 = port:PD25<1><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_pin_79's/.*/pin_79 = port:PD25<1><default><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN80
- line_pin_80=$(grep -nr -m 1 "pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_80 ];
- then
- line_pin_79=$(grep -nr -m 1 "pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_79 ];
- then
- dialog --infobox "Cannot find pin_79 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_pin_79'a\pin_80 = port:PD26<0><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_pin_80's/.*/pin_80 = port:PD26<0><default><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR PIN81
- line_pin_81=$(grep -nr -m 1 "pin_81" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_81 ];
- then
- line_pin_80=$(grep -nr -m 1 "pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_pin_80 ];
- then
- dialog --infobox "Cannot find pin_80 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_pin_80'a\pin_81 = port:PD27<0><default><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_pin_81's/.*/pin_81 = port:PD27<0><default><default><default>/' $temp_dir/$fex_file
- fi
- else
- #NOT 15.6
- # REMOVE p133
- sed -i '/pll3/d' $temp_dir/$fex_file
- # REMOVE SOME GPIO
- sed -i '/gpio_pin_76/d' $temp_dir/$fex_file
- sed -i '/gpio_pin_77/d' $temp_dir/$fex_file
- sed -i '/gpio_pin_78/d' $temp_dir/$fex_file
- sed -i '/gpio_pin_79/d' $temp_dir/$fex_file
- sed -i '/gpio_pin_80/d' $temp_dir/$fex_file
- sed -i '/gpio_pin_81/d' $temp_dir/$fex_file
- sed -i '/pin_76/d' $temp_dir/$fex_file
- sed -i '/pin_77/d' $temp_dir/$fex_file
- sed -i '/pin_78/d' $temp_dir/$fex_file
- sed -i '/pin_79/d' $temp_dir/$fex_file
- sed -i '/pin_80/d' $temp_dir/$fex_file
- sed -i '/pin_81/d' $temp_dir/$fex_file
- # CHECK FOR LCDD22
- line_lcdd22=$(grep -nr -m 1 "lcdd22" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdd22 ];
- then
- line_lcdd21=$(grep -nr -m 1 "lcdd21" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdd21 ];
- then
- dialog --infobox "Cannot find lcdd21 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_lcdd21'a\lcdd22 = port:PD22<2><0><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_lcdd22's/.*/lcdd22 = port:PD22<2><0><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR LCDD23
- line_lcdd23=$(grep -nr -m 1 "lcdd23" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdd23 ];
- then
- line_lcdd22=$(grep -nr -m 1 "lcdd22" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdd22 ];
- then
- dialog --infobox "Cannot find lcdd22 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_lcdd22'a\lcdd23 = port:PD23<2><0><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_lcdd23's/.*/lcdd23 = port:PD23<2><0><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR LCDCLK
- line_lcdclk=$(grep -nr -m 1 "lcdclk" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdd23 ];
- then
- line_lcdd23=$(grep -nr -m 1 "lcdd23" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdd22 ];
- then
- dialog --infobox "Cannot find lcdd23 variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_lcdd23'a\lcdclk = port:PD24<2><0><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_lcdclk's/.*/lcdclk = port:PD24<2><0><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR LCDDE dialog --infobox $choice 0 0
- line_lcdde=$(grep -nr -m 1 "lcdde" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdde ];
- then
- line_lcdclk=$(grep -nr -m 1 "lcdclk" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdclk ];
- then
- dialog --infobox "Cannot find lcdclk variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_lcdclk'a\lcdde = port:PD25<2><0><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_lcdde's/.*/lcdde = port:PD25<2><0><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR LCDHSYNC
- line_lcdhsync=$(grep -nr -m 1 "lcdhsync" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdhsync ];
- then
- line_lcdde=$(grep -nr -m 1 "lcdde" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdde ];
- then
- dialog --infobox "Cannot find lcdde variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_lcdde'a\lcdhsync = port:PD26<2><0><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_lcdhsync's/.*/lcdhsync = port:PD26<2><0><default><default>/' $temp_dir/$fex_file
- fi
- # CHECK FOR LCDVSYNC
- line_lcdvsync=$(grep -nr -m 1 "lcdvsync" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdvsync ];
- then
- line_lcdhsync=$(grep -nr -m 1 "lcdhsync" $temp_dir/$fex_file | awk '{print$1}' FS=":")
- if [ -z $line_lcdhsync ];
- then
- dialog --infobox "Cannot find lcdhsync variable!" 0 0
- sleep 2
- exit
- fi
- sed -i $line_lcdhsync'a\lcdvsync = port:PD27<2><0><default><default>' $temp_dir/$fex_file
- else
- sed -i $line_lcdvsync's/.*/lcdvsync = port:PD27<2><0><default><default>/' $temp_dir/$fex_file
- fi
- fi
- dialog --infobox "Changes saved" 3 17
- sleep 2
- ;;
- 1|255)
- dialog --infobox "No changes done" 3 19
- sleep 2
- ;;
- esac
- }
- MAIN() {
- # Now to some fancy stuff
- dialog --backtitle "OLimeXino-A20 screen configuration" \
- --menu "Select output type:" 12 55 8 \
- "None" "Disable all screens" \
- "LCD" "Set configuration for LCD" \
- "HDMI" "Set configuration for HDMI" \
- "VGA" "Set configuration for VGA" 2> $tempfile1
- retv=$?
- choice=$(cat $tempfile1)
- # Check if ESC of CANCLE are pressed
- if [ $retv -eq 1 -o $retv -eq 255 ];
- then
- clear
- exit
- fi
- # Check selected option
- case $choice in
- "None") SET_NONE;;
- "LCD") SET_LCD;;
- "HDMI") SET_HDMI;;
- "VGA") SET_VGA
- esac
- }
- trap "rm -f $tempfile1" 0 1 2 5 15
- umount /dev/mmcblk0p1 > /dev/null 2>&1
- #Export PATH
- #Check for /opt/sunxi-tools
- if [ ! -d $sunxi_tools_dir ];
- then
- dialog --infobox "No sunxi-tools found!" 3 26
- sleep 2
- clear
- exit
- fi
- export PATH=$PATH:$sunxi_tools_dir
- # Check for /mnt/mmc
- if [ ! -d $mmc_dir ];
- then
- mkdir -p $mmc_dir
- fi
- # Check for /mnt/mmc
- if [ ! -d $temp_dir ];
- then
- mkdir -p $temp_dir
- fi
- mount /dev/mmcblk0p1 $mmc_dir
- sleep 1
- if [ $? -ne 0 ];
- then
- dialog --infobox "Failed to mount sd-card" 0 0
- sleep 2
- exit
- fi
- # Copy current script
- cp $mmc_dir/$bin_file $temp_dir/
- # bin2fex
- bin2fex $temp_dir/$bin_file > $temp_dir/$fex_file
- # Remove binfile
- rm $temp_dir/$bin_file
- MAIN
- # Adding timestamp
- TIME=$(date)
- sed -i "\$a;LAST EDITED: $TIME" $temp_dir/$fex_file
- # make the bin file
- fex2bin $temp_dir/$fex_file > $temp_dir/$bin_file
- # Copy current script
- cp -vf $temp_dir/$bin_file $mmc_dir
- # Unmount
- umount /dev/mmcblk0p1
- rm -rf $temp_dir
- dialog --title "Reboot" --yesno "Reboot the board? " 0 0
- case $? in
- 0) reboot;;
- 1|255) clear;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement