share by hange
I tried to modify a sys-config (refer bpi-config) for BananaPro. The main menu: “1 Boot to Desktop/Console/Scratch” “Choose whether to boot to desktop, Scratch, or the command-line” “2 Internationalisation Options” “Set up language and regional settings to match your location” “3 Change User Password” “Change the password for the default user(lemaker)” “4 Expand Filesystem” “Ensures that all of the SD card storage is available to the OS” “5 Set Swap Space” “Enable/Disable the swap space” “6 Set Hostname” “Set the visible name for this board on a network” “7 Remote Access” “Enable/Disable remote command line access to your board using SSH” “8 Advance Options” “Configure advanced settings” “9 About sys-config” “Information about this configuration tool”
You can configure the display output from HDMI,LCD and AV(but need tools fex2bin and bin2fex). Choose boot desktop or command-line (lubuntu not work, don’t know how to do ;( ). The script is not perfect, please take a look at how to improve it.
#!/bin/sh
# Copyright (C) 2015 LeMaker Community <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DEFUSER=bananapi
UID=`id -u`
SCRIPTNAME=$(basename $0)
IS_PLATFORM=$(grep -i "hardware" /proc/cpuinfo | sed s/[[:space:]]//g | cut -d: -f2)
HEIGHT=20
WIDTH=108
DISKNAME=mmcblk0
REBOOT_FLAG=0
if [ $UID -ne 0 ];then
echo "Please run the $SCRIPTNAME with root."
exit
fi
enable_boot_to_scratch() {
if [ -e /etc/profile.d/boottoscratch.sh ]; then
printf "/etc/profile.d/boottoscratch.sh exists, so assuming boot to scratch enabled\n"
return 0;
fi
sed -i /etc/inittab -e "s|^\(1:2345.*getty.*tty1.*\)|\
#\1 # BTS_TO_ENABLE\n1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>\&1 # BTS_TO_DISABLE|"
cat <<-EOF > /etc/profile.d/boottoscratch.sh
#!/bin/sh
# Part of bpi-config http://github.com/LeMaker/bpi-config
#
# See LICENSE file for copyright and license details
# Should be installed to /etc/profile.d/boottoscratch.sh to force scratch to run upon boot
# You may also want to set automatic login in /etc/inittab on tty1 by adding a
# line such as the following (bpi-config does this for you):
# 1:2345:respawn:/bin/login -f bananapi tty1 </dev/tty1 >/dev/tty1 2>&1 # BTS_TO_DISABLE
if [ $(tty) = "/dev/tty1" ]; then
printf "openbox --config-file /home/pi/boottoscratch/openbox_rc.xml & scratch" | xinit /dev/stdin
printf "\n\n\nShutting down in 5 seconds, hit ctrl-C to cancel\n" && sleep 5 && sudo shutdown -h now
fi
EOF
mkdir -p /home/bananapi/boottoscratch
cat <<-EOF > /home/bananapi/boottoscratch/openbox_rc.xml
<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/3.4/rc"
xmlns:xi="http://www.w3.org/2001/XInclude">
<applications>
<application name="squeak" type="normal">
<focus>yes</focus>
<fullscreen>yes</fullscreen>
</application>
</applications>
</openbox_config>
EOF
telinit q
}
disable_boot_to_scratch() {
if [ -e /etc/profile.d/boottoscratch.sh ]; then
rm -f /etc/profile.d/boottoscratch.sh
sed -i /etc/inittab \
-e "s/^#\(.*\)#\s*BTS_TO_ENABLE\s*/\1/" \
-e "/#\s*BTS_TO_DISABLE/d"
telinit q
fi
}
set_boot_method()
{
BOOTOPTS=$(whiptail --title "Enable Boot to Desktop/Console/Scratch" --menu "Choose the method to boot" --ok-button "Select" --cancel-button "Exit" $HEIGHT $WIDTH 3 \
"<Desktop>" "Start the system with the X11 window" \
"<Console>" "Start the system with Console terminal" \
"<Scratch>" "Start the system with the Scratch Application" \
3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
case $BOOTOPTS in
"<Desktop>")
if [ -e /etc/init.d/lightdm ]; then
if id -u bananapi > /dev/null 2>&1; then
update-rc.d lightdm enable 2
sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=bananapi/"
disable_boot_to_scratch
else
whiptail --msgbox "The pi user has been removed, can't set up boot to desktop" 20 60 2
fi
else
whiptail --msgbox "Do sudo apt-get install lightdm to allow configuration of boot to desktop" 20 60 2
return 1
fi
;;
"<Console>")
[ -e /etc/init.d/lightdm ] && update-rc.d lightdm disable 2
disable_boot_to_scratch
;;
"<Scratch>")
if [ -e /usr/bin/scratch ]; then
if id -u bananapi > /dev/null 2>&1; then
[ -e /etc/init.d/lightdm ] && update-rc.d lightdm disable 2
enable_boot_to_scratch
else
whiptail --msgbox "The bananapi user has been removed, can't set up boot to scratch" 20 60 2
fi
else
whiptail --msgbox "Do sudo apt-get install scratch to allow configuration of boot to scratch" 20 60 2
fi
;;
*)
whiptail --msgbox "Programmer error, unrecognised boot option" 20 60 2
return 1
;;
esac
whiptail --title "Boot to the $BOOTOPTS" --msgbox "You have already set to boot system from the $BOOTOPTS, Choose Ok to continue" $HEIGHT $WIDTH
REBOOT_FLAG=1
fi
}
set_system_env()
{
if(whiptail --title "Internationalisation Options" --yesno "Change the Locale, Choose Ok to continue." --yes-button "Ok" --no-button "Cancel" $HEIGHT $WIDTH)then
dpkg-reconfigure locales
fi
if(whiptail --title "Internationalisation Options" --yesno "Change the TimeZone, Choose Ok to continue." --yes-button "Ok" --no-button "Cancel" $HEIGHT $WIDTH)then
dpkg-reconfigure tzdata
fi
if(whiptail --title "Internationalisation Options" --yesno "Change the Keyboard Layout, Choose Ok to continue." --yes-button "Ok" --no-button "Cancel" $HEIGHT $WIDTH)then
dpkg-reconfigure keyboard-configuration
#if [ $? -eq 0 ];then
# systemctl restart keyboard-setup.service > /dev/null 2>&1
#fi
fi
}
set_user_pwd()
{
if(whiptail --title "Change the user(bananapi) password" --yesno "Would you like to reset password for the default user ?" --yes-button "Ok" --no-button "Cancel" $HEIGHT $WIDTH)then
TMPOUT=`cat /etc/passwd | grep -i "$DEFUSER"`
if [ "$TMPOUT" != "" ];then
passwd $DEFUSER
if [ $? -eq 0 ];then
whiptail --title "Change the user(bananapi) password" --msgbox "Change the user password successful!" $HEIGHT $WIDTH
else
whiptail --title "Change the user(bananapi) password" --msgbox "Change the user password failed!" $HEIGHT $WIDTH
fi
else
whiptail --title "Change the user(bananapi) password" --msgbox "The default user is not exist!" $HEIGHT $WIDTH
fi
fi
}
expand_filesystem()
{
if(whiptail --title "Expand the filesystem" --yesno "Would you like to expand the filesystem ?" --yes-button "Ok" --no-button "Cancel" $HEIGHT $WIDTH)then
ls -l /dev/$DISKNAME > /dev/null 2>&1
if [ $? -eq 0 ];then
ENDPART=`ls -l /dev/${DISKNAME}* | wc -l` && ENDPART=$(($ENDPART-1))
STARTNUM=$(fdisk -l | grep /dev/${DISKNAME}p${ENDPART} | awk '{print $2}')
fdisk /dev/$DISKNAME <<-END
p
d
$ENDPART
n
p
$ENDPART
$STARTNUM
w
END
fi
fi
cat <<-EOF > /etc/init.d/resize2fs_once
resize2fs /dev/${DISKNAME}p${ENDPART}
sudo rm -f /etc/init.d/resize2fs_once
EOF
chmod +x /etc/init.d/resize2fs_once &&
cat <<-EOF > /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
if [ -e /etc/init.d/resize2fs_once ];then
sudo /etc/init.d/resize2fs_once
fi
exit 0
EOF
whiptail --title "Expand the filesystem" --msgbox "The filesystem has been expanded.\nThe filesystem will be enlarged upon the next reboot" $HEIGHT $WIDTH
REBOOT_FLAG=1
}
set_swap_space()
{
TMPOUT=`cat /etc/fstab | grep swap`
if(whiptail --title "Set swap space" --yesno "Please choose the button below to enable or disable the swap space." --yes-button "Enable" --no-button "Disable" $HEIGHT $WIDTH)then
if [ "$TMPOUT" != "" ];then
whiptail --title "Set swap space" --msgbox "The swap space has been enabled." $HEIGHT $WIDTH
else
dd if=/dev/zero of=/var/swap bs=1M count=256 &&
mkswap /var/swap &&
swapon /var/swap &&
echo "/var/swap\tswap\tswap\tdefault \t0\t0" >> /etc/fstab &&
whiptail --title "Set swap space" --msgbox "Enable the swap space successful. Choose the Ok to continue." $HEIGHT $WIDTH ||
whiptail --title "Set swap space" --msgbox "Enable the swap space failed. Choose the Ok to continue." $HEIGHT $WIDTH
fi
else
if [ "$TMPOUT" != "" ];then
sed -i "/swap/d" /etc/fstab &&
swapoff /var/swap &&
rm -rf /var/swap &&
whiptail --title "Set swap space" --msgbox "Disable the swap space successful.Choose the Ok to continue." $HEIGHT $WIDTH ||
whiptail --title "Set swap space" --msgbox "Disable the swap space failed. Choose the Ok to continue." $HEIGHT $WIDTH
else
whiptail --title "Set swap space" --msgbox "The swap space has been disabled." $HEIGHT $WIDTH
fi
fi
}
adjust_cpu_freq_sun7i()
{
COPTS=$(whiptail --title "OverClock" --menu "Choose the cpufreq below" --ok-button "Select" --cancel-button "Exit" $HEIGHT $WIDTH 3 \
"<Modest>" "800MHz ARM (Low preformance)" \
"<Medium>" "1000MHz ARM (Default value)" \
"<High>" "1200MHz ARM (Duty of care)" \
3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
case $COPTS in
"<Modest>")
cat <<-EOF > /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
exit 0
EOF
;;
"<Medium>")
cat <<-EOF > /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 1008000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
exit 0
EOF
;;
"<High>")
cat <<-EOF > /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 1200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
exit 0
EOF
;;
esac
chmod +x /etc/rc.local
whiptail --title "OverClock" --msgbox "You have already re-adjusted the CPU frequency, Choose Ok to continue." $HEIGHT $WIDTH
fi
}
set_display_output_sun7i()
{
DOPTS=$(whiptail --title "Set Display Output" --menu "Choose the display output type below" $HEIGHT $WIDTH 5 \
"<HDMI>" "Set the display output to the HDMI" \
"<AV>" "Set the display output to the AV" \
"<7-LCD>" "Set the display output to the 7 LCD" \
"<5-LCD>" "Set the display output to the 5 LCD" \
"<3.5-LCD>" "Set the display output to the 3.5 LCD" \
3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
mount /dev/mmcblk0p1 /boot &&
bin2fex /boot/script.bin /boot/script.fex > /dev/null 2>&1
if [ $? -ne 0 ];then
whiptail --title "Set Display Output" --msgbox "Failed to Convert the bin to fex file, Please check the reasons below: \
1.Repeat mounted partition /dev/mmcblk0p1 to /boot \
\n2.The bin2fex command doesn't exist." 20 85
return
fi
LCD0_AREA_START=$(grep -n "lcd0_para" /boot/script.fex | cut -d: -f1)
LCD0_AREA_END=$(grep -n "lcd1_para" /boot/script.fex | cut -d: -f1)
case $DOPTS in
"<HDMI>")
sed -i -e "s/lcd_used.*/lcd_used = 0/g" \
-e "s/screen0_output_type.*/screen0_output_type = 3/g" \
-e "s/screen0_output_mode.*/screen0_output_mode = 4/g" /boot/script.fex
;;
"<AV>")
sed -i -e "s/lcd_used.*/lcd_used = 0/g" \
-e "s/screen0_output_type.*/screen0_output_type = 2/g" \
-e "s/screen0_output_mode.*/screen0_output_mode = 11/g" /boot/script.fex
;;
"<7-LCD>")
sed -i -e "s/screen0_output_type.*/screen0_output_type = 1/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_used.*/lcd_used = 1/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_x.*/lcd_x = 1024/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_y.*/lcd_y = 600/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_pwm_freq.*/lcd_pwm_freq = 22000/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_dclk_freq.*/lcd_dclk_freq = 55/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_if.*/lcd_if = 3/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hbp.*/lcd_hbp = 150/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_ht.*/lcd_ht = 1344/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vbp.*/lcd_vbp = 20/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vt.*/lcd_vt = 1270/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vspw.*/lcd_vspw = 10/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hspw.*/lcd_hspw = 50/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_lvds_bitwidth.*/lcd_lvds_bitwidth = 0/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_bl_en[ =].*/lcd_bl_en = port:PH08<1><0><default><1>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_power[ =].*/lcd_power = port:PH12<1><0><default><1>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd0[ =].*/lcdd0 = port:PD00<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd1[ =].*/lcdd1 = port:PD01<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd2[ =].*/lcdd2 = port:PD02<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd3[ =].*/lcdd3 = port:PD03<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd4[ =].*/lcdd4 = port:PD04<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd5[ =].*/lcdd5 = port:PD05<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd6[ =].*/lcdd6 = port:PD06<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd7[ =].*/lcdd7 = port:PD07<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd8[ =].*/lcdd8 = port:PD08<3><0><default><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd9[ =].*/lcdd9 = port:PD09<3><0><default><default>/g" \
-e "s/ctp_used.*/ctp_used = 1/g" \
-e "s/ctp_name.*/ctp_name = \"ft5x_ts\"/g" \
-e "s/ctp_screen_max_x.*/ctp_screen_max_x = 1024/g" \
-e "s/ctp_screen_max_y.*/ctp_screen_max_y = 600/g" \
-e "s/ctp_det_used.*/ctp_det_used = 1/g" \
-e "s/^ft5x_ts.*/ft5x_ts = 1/g" /boot/script.fex
;;
"<5-LCD>")
sed -i -e "s/screen0_output_type.*/screen0_output_type = 1/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_used.*/lcd_used = 1/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_x.*/lcd_x = 800/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_y.*/lcd_y = 480/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_pwm_freq.*/lcd_pwm_freq = 22000/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_dclk_freq.*/lcd_dclk_freq = 30/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_if.*/lcd_if = 0/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hbp.*/lcd_hbp = 88/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_ht.*/lcd_ht = 928/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vbp.*/lcd_vbp = 32/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vt.*/lcd_vt = 1050/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vspw.*/lcd_vspw = 3/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hspw.*/lcd_hspw = 48/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hv_if.*/lcd_hv_if = 0/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_bl_en[ =].*/lcd_bl_en = port:PH08<1><0><default><1>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_power[ =].*/lcd_power = port:PH12<1><0><default><1>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd0[ =].*/lcdd0 = port:PD00<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd1[ =].*/lcdd1 = port:PD01<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd2[ =].*/lcdd2 = port:PD02<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd3[ =].*/lcdd3 = port:PD03<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd4[ =].*/lcdd4 = port:PD04<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd5[ =].*/lcdd5 = port:PD05<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd6[ =].*/lcdd6 = port:PD06<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd7[ =].*/lcdd7 = port:PD07<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd8[ =].*/lcdd8 = port:PD08<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd9[ =].*/lcdd9 = port:PD09<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd10[ =].*/lcdd10 = port:PD10<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd11[ =].*/lcdd11 = port:PD11<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd12[ =].*/lcdd12 = port:PD12<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd13[ =].*/lcdd13 = port:PD13<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd14[ =].*/lcdd14 = port:PD14<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd15[ =].*/lcdd15 = port:PD15<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd16[ =].*/lcdd16 = port:PD16<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd17[ =].*/lcdd17 = port:PD17<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd18[ =].*/lcdd18 = port:PD18<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd19[ =].*/lcdd19 = port:PD19<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd20[ =].*/lcdd20 = port:PD20<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd21[ =].*/lcdd21 = port:PD21<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd22[ =].*/lcdd22 = port:PD22<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd23[ =].*/lcdd23 = port:PD23<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdclk[ =].*/lcdclk = port:PD24<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdde[ =].*/lcdde = port:PD25<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdhsync[ =].*/lcdhsync = port:PD26<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdvsync[ =].*/lcdvsync = port:PD27<2><0><3><default>/g" \
-e "s/ctp_used.*/ctp_used = 1/g" \
-e "s/ctp_name.*/ctp_name = \"ft5x_ts\"/g" \
-e "s/ctp_screen_max_x.*/ctp_screen_max_x = 800/g" \
-e "s/ctp_screen_max_y.*/ctp_screen_max_y = 480/g" \
-e "s/ctp_det_used.*/ctp_det_used = 1/g" \
-e "s/^ft5x_ts.*/ft5x_ts = 1/g" /boot/script.fex
;;
"<3.5-LCD>")
sed -i -e "s/screen0_output_type.*/screen0_output_type = 1/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_used.*/lcd_used = 1/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_x.*/lcd_x = 320/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_y.*/lcd_y = 240/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_pwm_freq.*/lcd_pwm_freq = 22000/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_dclk_freq.*/lcd_dclk_freq = 7/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_if.*/lcd_if = 0/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hbp.*/lcd_hbp = 68/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_ht.*/lcd_ht = 408/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vbp.*/lcd_vbp = 18/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vt.*/lcd_vt = 524/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_vspw.*/lcd_vspw = 3/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hspw.*/lcd_hspw = 30/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_hv_if.*/lcd_hv_if = 0/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_bl_en[ =].*/lcd_bl_en = port:PH08<1><0><default><1>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcd_power[ =].*/lcd_power = port:PH12<1><0><default><1>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd0[ =].*/lcdd0 = port:PD00<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd1[ =].*/lcdd1 = port:PD01<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd2[ =].*/lcdd2 = port:PD02<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd3[ =].*/lcdd3 = port:PD03<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd4[ =].*/lcdd4 = port:PD04<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd5[ =].*/lcdd5 = port:PD05<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd6[ =].*/lcdd6 = port:PD06<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd7[ =].*/lcdd7 = port:PD07<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd8[ =].*/lcdd8 = port:PD08<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd9[ =].*/lcdd9 = port:PD09<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd10[ =].*/lcdd10 = port:PD10<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd11[ =].*/lcdd11 = port:PD11<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd12[ =].*/lcdd12 = port:PD12<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd13[ =].*/lcdd13 = port:PD13<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd14[ =].*/lcdd14 = port:PD14<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd15[ =].*/lcdd15 = port:PD15<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd16[ =].*/lcdd16 = port:PD16<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd17[ =].*/lcdd17 = port:PD17<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd18[ =].*/lcdd18 = port:PD18<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd19[ =].*/lcdd19 = port:PD19<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd20[ =].*/lcdd20 = port:PD20<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd21[ =].*/lcdd21 = port:PD21<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd22[ =].*/lcdd22 = port:PD22<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdd23[ =].*/lcdd23 = port:PD23<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdclk[ =].*/lcdclk = port:PD24<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdde[ =].*/lcdde = port:PD25<1><0><3><0>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdhsync[ =].*/lcdhsync = port:PD26<2><0><3><default>/g" \
-e "${LCD0_AREA_START},${LCD0_AREA_END}s/lcdvsync[ =].*/lcdvsync = port:PD27<2><0><3><default>/g" \
-e "s/ctp_used.*/ctp_used = 1/g" \
-e "s/ctp_name.*/ctp_name = \"ft5x_ts\"/g" \
-e "s/ctp_screen_max_x.*/ctp_screen_max_x = 320/g" \
-e "s/ctp_screen_max_y.*/ctp_screen_max_y = 240/g" \
-e "s/ctp_det_used.*/ctp_det_used = 1/g" \
-e "s/^ft5x_ts.*/ft5x_ts = 1/g" /boot/script.fex
;;
esac
fex2bin /boot/script.fex /boot/script.bin > /dev/null 2>&1
sync
umount /boot
whiptail --title "Set Display Output" --msgbox "Set Display output type to the $DOPTS, Choose the Ok to continue." $HEIGHT $WIDTH
fi
}
set_video_Acce_sunxi()
{
if(whiptail --title "Video Acceleration" --yesno "Please choose the button below to enable or disable the Video Acceleration" --yes-button "Enable" --no-button "Disable" $HEIGHT $WIDTH)then
if [ ! -f /usr/share/X11/xorg.conf.d/99-fbturbo-sunxi.conf ];then
touch /usr/share/X11/xorg.conf.d/99-fbturbo-sunxi.conf
fi
cat <<-END > /usr/share/X11/xorg.conf.d/99-fbturbo-sunxi.conf
Section "Screen"
Identifier "My Screen"
Device "Allwinner A10/A13 FBDEV"
Monitor "My Monitor"
EndSection
Section "Device"
Identifier "Allwinner A10/A13 FBDEV"
Driver "fbturbo"
Option "fbdev" "/dev/fb0"
Option "SwapbuffersWait" "true"
Option "AccelMethod" "G2D"
EndSection
Section "Monitor"
Identifier "My Monitor"
Option "DPMS" "false"
EndSection
END
if [ ! -f /etc/modules-load.d/mali-sunxi.conf ];then
touch /etc/modules-load.d/mali-sunxi.conf
fi
cat <<-END > /etc/modules-load.d/mali-sunxi.conf
ump
mali
mali_drm
END
else
if [ -f /usr/share/X11/xorg.conf.d/99-fbturbo-sunxi.conf ];then
rm -f /usr/share/X11/xorg.conf.d/99-fbturbo-sunxi.conf
fi
if [ -f /etc/modules-load.d/mali-sunxi.conf ];then
rm -f /etc/modules-load.d/mali-sunxi.conf
fi
fi
}
set_hostname()
{
whiptail --msgbox "Please note: RFCs mandate that a hostname's labels may contain only the
ASCII letters 'a' through 'z' (case-insensitive), the digits '0' through
'9',and the hyphen.Hostname labels cannot begin or end with a hyphen.
No other symbols, punctuation characters, or blank spaces are permitted." 20 80
CURRENT_HOSTNAME=`cat /etc/hostname | tr -d " \t\n\r"`
NEW_HOSTNAME=$(whiptail --inputbox "Please enter a hostname" 20 60 "$CURRENT_HOSTNAME" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
echo $NEW_HOSTNAME > /etc/hostname
sed -i "s/127.0.0.1.*${CURRENT_HOSTNAME}/127.0.0.1\t${NEW_HOSTNAME}/g" /etc/hosts
REBOOT_FLAG=1
fi
}
set_sshd()
{
if(whiptail --title "Set sshd service" --yesno "Please choose the button below to enable or disable the sshd service" --yes-button "Enable" --no-button "Disable" $HEIGHT $WIDTH)then
sed -i '/start on runlevel/s/^#//' /etc/init/ssh.conf
else
sed -i '/start on runlevel/s/^/#/' /etc/init/ssh.conf
fi
REBOOT_FLAG=1
}
set_adv_opts()
{
while true
do
AOPTS=$(whiptail --title "Advance Options" --menu "Setup Advance Options" --ok-button "Select" --cancel-button "Exit" $HEIGHT $WIDTH 4 \
"A1 Display Output" "Configure the display output from HDMI,LCD and AV" \
"A2 Video Acceleration" "Enable the Hardware Acceleration For X11, Improve the efficiency of decoding" \
"A3 Overclock" "Configure overclocking for your Board" \
3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
case $AOPTS in
A1\ *)
if [ "$IS_PLATFORM" = "sun7i" ];then
set_display_output_sun7i
else
:
fi
;;
A2\ *)
if [ "$IS_PLATFORM" = "sun7i" ];then
set_video_Acce_sunxi
else
:
fi
;;
A3\ *)
whiptail --title "OverClock" --msgbox "Be aware that overclocking may reduce the lifetime of your Board. If \
overclocking at a certain level causes system instability, try a more modest \
overclock. Hold down shift during boot to temporarily disable overclock." 20 80
if [ "$IS_PLATFORM" = "sun7i" ];then
adjust_cpu_freq_sun7i
else
:
fi
;;
esac
REBOOT_FLAG=1
else
break;
fi
done
}
readme_about_tool()
{
whiptail --title "About the sys-config" --msgbox "This tool provides a straight-forward way of doing initial configuration of the system. Although it can be run at any time, some of the options may have difficulties if you have heavily customised your installation. If you encounter a bug about using the sys-config, please report the bug to http://bugs.lemaker.org." 20 80
}
#=================================Start Run======================================
while true
do
MOPTS=$(whiptail --title "System Configuration Tool (sys-config)" --menu "Setup Options" --ok-button "Select" --cancel-button "Exit" $HEIGHT $WIDTH 9 \
"1 Boot to Desktop/Console/Scratch" "Choose whether to boot to desktop, Scratch, or the command-line" \
"2 Internationalisation Options" "Set up language and regional settings to match your location" \
"3 Change User Password" "Change the password for the default user(lemaker)" \
"4 Expand Filesystem" "Ensures that all of the SD card storage is available to the OS" \
"5 Set Swap Space" "Enable/Disable the swap space" \
"6 Set Hostname" "Set the visible name for this board on a network" \
"7 Remote Access" "Enable/Disable remote command line access to your board using SSH" \
"8 Advance Options" "Configure advanced settings" \
"9 About sys-config" "Information about this configuration tool" \
3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
case $MOPTS in
1\ *) set_boot_method ;;
2\ *) set_system_env ;;
3\ *) set_user_pwd ;;
4\ *) expand_filesystem ;;
5\ *) set_swap_space ;;
6\ *) set_hostname ;;
7\ *) set_sshd ;;
8\ *) set_adv_opts ;;
9\ *) readme_about_tool ;;
esac
else
if [ "$REBOOT_FLAG" -eq 1 ];then
if(whiptail --title "Reboot The System" --yesno "Would you like to reboot the system ?" $HEIGHT $WIDTH)then
sync
reboot
else
break;
fi
fi
break;
fi
done