From 3416048779dfa165ed6a7f09dda9c72de1f9d6dc Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Mon, 22 Feb 2016 17:11:19 +0100 Subject: [PATCH 1/6] Fix failing reboot on H3 images through fex changes, prepare H3 autodetection --- config/boot.cmd | 4 ++-- config/orangepi2.fex | 3 --- config/orangepilite.fex | 3 --- config/orangepipc.fex | 3 --- scripts/firstrun | 4 ++-- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/config/boot.cmd b/config/boot.cmd index 85c02d484e..f661dc0525 100644 --- a/config/boot.cmd +++ b/config/boot.cmd @@ -1,5 +1,5 @@ # disp.screen0_output_mode=1920x1080p60 to set video mode -setenv bootargs "console=tty1 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup-enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 panic=10 consoleblank=0 enforcing=0 loglevel=1" +setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup-enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 panic=10 consoleblank=0 enforcing=0 loglevel=8" #-------------------------------------------------------------------------------------------------------------------------------- # Boot loader script to boot with different boot methods for old and new kernel #-------------------------------------------------------------------------------------------------------------------------------- @@ -21,4 +21,4 @@ bootz 0x48000000 #-------------------------------------------------------------------------------------------------------------------------------- fi # Recompile with: -# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr \ No newline at end of file +# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr diff --git a/config/orangepi2.fex b/config/orangepi2.fex index 2d93877cf3..bb25723a21 100644 --- a/config/orangepi2.fex +++ b/config/orangepi2.fex @@ -539,9 +539,6 @@ gmac_used = 2 ;gmac_mdio = port:PD17<2><3> gmac_power1 = -[gmac_phy_power] -gmac_phy_power_en = port:PL08<1><0> - ;-------------------------------------------------------------------------------- ;vip (video input port) configuration ;vip_used: 0:disable 1:enable diff --git a/config/orangepilite.fex b/config/orangepilite.fex index 95dee2c977..04b9d4d782 100644 --- a/config/orangepilite.fex +++ b/config/orangepilite.fex @@ -351,9 +351,6 @@ pwm_positive = port:PA05<3><0> gmac_used = 2 gmac_power1 = -[gmac_phy_power] -gmac_phy_power_en = port:PL08<1><0> - [csi0] vip_used = 1 vip_mode = 0 diff --git a/config/orangepipc.fex b/config/orangepipc.fex index 4cb2487a69..b11066f6de 100644 --- a/config/orangepipc.fex +++ b/config/orangepipc.fex @@ -353,9 +353,6 @@ pwm_positive = port:PA05<3><0> gmac_used = 2 gmac_power1 = -[gmac_phy_power] -gmac_phy_power_en = port:PL08<1><0> - [csi0] vip_used = 1 vip_mode = 0 diff --git a/scripts/firstrun b/scripts/firstrun index 468ff1a3ad..c441135494 100644 --- a/scripts/firstrun +++ b/scripts/firstrun @@ -89,14 +89,14 @@ display_alert() { autodetect_h3() { # This function adjusts script.bin and cpufreq settings based on /run/machine.id so - # that a single OS image built for Orange Pi Plus can be shipped. + # that a single OS image built for Orange Pi PC can be shipped. # wait for armhwinfo sleep 3 read MACHINE Date: Mon, 22 Feb 2016 17:53:13 +0100 Subject: [PATCH 2/6] Fix reboot issue also for Orange Pi One, revert boot.cmd settings --- config/boot.cmd | 2 +- config/orangepione.fex | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/config/boot.cmd b/config/boot.cmd index f661dc0525..b79de59c5a 100644 --- a/config/boot.cmd +++ b/config/boot.cmd @@ -1,5 +1,5 @@ # disp.screen0_output_mode=1920x1080p60 to set video mode -setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup-enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 panic=10 consoleblank=0 enforcing=0 loglevel=8" +setenv bootargs "console=tty1 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup-enable=memory swapaccount=1 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=16 hdmi.audio=EDID:0 panic=10 consoleblank=0 enforcing=0 loglevel=1" #-------------------------------------------------------------------------------------------------------------------------------- # Boot loader script to boot with different boot methods for old and new kernel #-------------------------------------------------------------------------------------------------------------------------------- diff --git a/config/orangepione.fex b/config/orangepione.fex index f81b1ebd6a..522ac61ca9 100644 --- a/config/orangepione.fex +++ b/config/orangepione.fex @@ -351,9 +351,6 @@ pwm_positive = port:PA05<3><0> gmac_used = 2 gmac_power1 = -[gmac_phy_power] -gmac_phy_power_en = port:PL08<1><0> - [csi0] vip_used = 1 vip_mode = 0 From ab8ab1cd2044a7da0e003e94dbfd5cd844b0dba9 Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Tue, 23 Feb 2016 13:10:14 +0100 Subject: [PATCH 3/6] Removed GPIO/1-Wire modules from H3 default modules, cleaned up firstrun, activated H3 autodetection --- config/interfaces.default | 4 +- configuration.sh | 10 ++-- scripts/firstrun | 99 ++++++++++++++++++++------------------- 3 files changed, 59 insertions(+), 54 deletions(-) diff --git a/config/interfaces.default b/config/interfaces.default index 5d0b4530cc..e9afc1daa5 100644 --- a/config/interfaces.default +++ b/config/interfaces.default @@ -1,5 +1,5 @@ # Wired adapter #1 -auto eth0 +allow-hotplug eth0 iface eth0 inet dhcp # hwaddress ether # if you want to set MAC manually # pre-up /sbin/ifconfig eth0 mtu 3838 # setting MTU for DHCP, static just: mtu 3838 @@ -19,4 +19,4 @@ auto eth0 # # Local loopback auto lo - iface lo inet loopback \ No newline at end of file + iface lo inet loopback diff --git a/configuration.sh b/configuration.sh index e51e096837..7a0f03cc97 100644 --- a/configuration.sh +++ b/configuration.sh @@ -217,7 +217,7 @@ #build 3wip LINUXFAMILY="sun8i" BOOTCONFIG="orangepi_plus_defconfig" - MODULES="8189es gpio_sunxi w1-sunxi w1-gpio w1-therm" + MODULES="8189es" MODULES_NEXT="" CPUMIN="480000" CPUMAX="1296000" @@ -229,7 +229,7 @@ #build 3wip LINUXFAMILY="sun8i" BOOTCONFIG="orangepi_pc_defconfig" - MODULES="8189es gpio_sunxi w1-sunxi w1-gpio w1-therm" + MODULES="8189es" MODULES_NEXT="" CPUMIN="480000" CPUMAX="1296000" @@ -241,7 +241,7 @@ #build 3wip LINUXFAMILY="sun8i" BOOTCONFIG="orangepi_pc_defconfig" - MODULES="gpio_sunxi w1-sunxi w1-gpio w1-therm" + MODULES="" MODULES_NEXT="" CPUMIN="480000" CPUMAX="1296000" @@ -253,7 +253,7 @@ #build 3wip LINUXFAMILY="sun8i" BOOTCONFIG="orangepi_one_defconfig" - MODULES="gpio_sunxi w1-sunxi w1-gpio w1-therm" + MODULES="" MODULES_NEXT="" CPUMIN="648000" CPUMAX="1200000" @@ -265,7 +265,7 @@ #build 3wip LINUXFAMILY="sun8i" BOOTCONFIG="orangepi_pc_defconfig" - MODULES="8189es gpio_sunxi w1-sunxi w1-gpio w1-therm" + MODULES="8189es" MODULES_NEXT="" CPUMIN="648000" CPUMAX="1200000" diff --git a/scripts/firstrun b/scripts/firstrun index c441135494..1f143d1b71 100644 --- a/scripts/firstrun +++ b/scripts/firstrun @@ -15,6 +15,15 @@ # # Create this file to speed up boot process # + +# Immediately exit if not called correctly +if [ "X$1" != "Xstart" ]; then + exit 1 +fi + +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +# create helper script to set swap settings cat > /tmp/create_swap.sh </dev/null 2>&1 fi -return 0 + return 0 } -case "$1" in - start) - display_alert "Force password change upon first login" - chage -d 0 root - - if [[ "$rootfstype" == "ext4" && ! -f "/root/.no_rootfs_resize" ]]; then - display_alert "Expand ext4 root filesystem" - do_expand_rootfs - fi - display_alert "Creating 128Mb emergency swap area" - display_alert "SSH keys recreation. One moment please" - display_alert "Updating packages" - #resize2fs $root_partition - /tmp/create_swap.sh & - update-rc.d -f firstrun remove >/dev/null 2>&1 - ;; - *) - exit 1 - ;; -esac +main() { + collect_informations + display_alert "Force password change upon first login" + chage -d 0 root + if [[ "$rootfstype" == "ext4" && ! -f "/root/.no_rootfs_resize" ]]; then + display_alert "Expand ext4 root filesystem" + do_expand_rootfs + fi + + display_alert "Creating 128Mb emergency swap area" + display_alert "SSH keys recreation. One moment please" + display_alert "Updating packages" + /tmp/create_swap.sh & + + if [ "X${HARDWARE}" = "Xsun8i" ]; then + autodetect_h3 + fi + + update-rc.d -f firstrun remove >/dev/null 2>&1 + sed -i 's/allow-hotplug\ eth0/auto eth0/' /etc/network/interfaces.default +} # main + +main exit 0 From 64ce453c812f0fa9582b285381f79eed2dd99276 Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Tue, 23 Feb 2016 18:12:38 +0100 Subject: [PATCH 4/6] Improved h3disp, now possible to specify resolution/DVI on command line --- scripts/h3disp | 126 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 115 insertions(+), 11 deletions(-) diff --git a/scripts/h3disp b/scripts/h3disp index 23b1e0517b..3b054ef222 100755 --- a/scripts/h3disp +++ b/scripts/h3disp @@ -14,6 +14,8 @@ # # Purpose of this script is to display the available reasonable settings and # let the user choose from them to adjust fex file accordingly afterwards. +# In the meantime it's also possible to specify available resolutions on the +# command line. To display possible values use the -h switch. # # If HDMI-to-DVI adapters are used another fix has to be applied to the fex # file: http://linux-sunxi.org/Orange_Pi_One#HDMI_to_DVI_converters -- so ask @@ -23,6 +25,11 @@ # # CHANGES: # +# v0.2: Added non-interactive mode. You can provide one or two arguments on +# the command line, eg. 'h3disp -m 1080p60 -d' (1920x1080@60Hz DVI) or +# 'h3disp -m 720i' (1280x720@30Hz HDMI). Complete list of modes via +# 'h3disp -h' +# # v0.1: Initial release to adjust display settings in script.bin on commonly # used Debian based OS images for H3 devices running Linux. # @@ -52,22 +59,119 @@ Main() { exit 1 fi - # Provide a list with possible HDMI display settings and store the chosen - # one in the HDMIMode variable - : - - # ask the user whether he uses a HDMI-to-DVI converter and if true then - # set DVIUsed=TRUE - : - - HDMIMode=4 - DVIUsed=TRUE + # interactive mode if no arguments are provided -- currently not implemented + # otherwise we try to parse the command line arguments and use these + if [ $# -eq 0 ]; then + DisplayUsage ; exit 0 + # Provide a list with possible HDMI display settings and store the chosen + # one in the HDMIMode variable + : + + # ask the user whether he uses a HDMI-to-DVI converter and if true then + # set DVIUsed=TRUE + : + else + ParseOptions "$@" + case ${VideoMode} in + 0|480i) # res + HDMIMode=0 + ;; + 1|576i) # res + HDMIMode=1 + ;; + 2|480p) # res + HDMIMode=2 + ;; + 3|576p) # res + HDMIMode=3 + ;; + 4|720p50|1280x720p50) # res + HDMIMode=4 + ;; + 5|720p60|720p|1280x720p60) # res + HDMIMode=5 + ;; + 6|1080i50|1920x1080i50) # res + HDMIMode=6 + ;; + 7|1080i60|1080i|1920x1080i60) # res + HDMIMode=7 + ;; + 8|1080p24|1920x1080p24) # res + HDMIMode=8 + ;; + 9|1080p50|1920x1080p50) # res + HDMIMode=9 + ;; + 10|1080p60|1080p|1920x1080p60) # res + HDMIMode=10 + ;; + *) + if [ "X${VideoMode}" = "X" ]; then + echo -e "$0: missing video mode. Try one of the following:\n" + else + echo -e "$0: illegal video mode \"-m ${VideoMode}\". Try one of the following:\n" + fi + ShowVideoModes + exit 0 + ;; + esac + fi echo -e "Now trying to patch script.bin with your settings. \c" PatchScriptBin ${HDMIMode} ${DVIUsed} echo "Successfully finished. Please reboot for changes to take effect" } # Main +ParseOptions() { + while getopts 'hvVdDm:M:' c ; do + case ${c} in + h) + DisplayUsage + exit 0 + ;; + v|V) + # debug switch set via toolclient. We'll be more verbose + export Debug=TRUE + set -x + ;; + d|D) + # use HDMI-to-DVI converter + export DVIUsed=TRUE + ;; + m|M) + # timeout for tool + export VideoMode=${OPTARG} + ;; + esac + done +} # ParseOptions + +DisplayUsage() { + echo -e "Usage: ${0##*/} -m [video mode] [-d]\n" + echo -e "############################################################################\n" + echo "Detailed Description:" + grep "^#" "$0" | grep -v "^#\!/bin/bash" | sed 's/^#//' + echo -e "\n Short summary: This is a tool to set the display resolution of your Orange" + echo -e " Pi by patching script.bin.\n\n In case you use an HDMI-to-DVI converter\c" + echo -e " please use the -d switch.\n\n The resolution can be set using the -m switch.\c" + echo -e " The following resolutions\n are currently supported:\n" + ShowVideoModes + echo -e "############################################################################\n" +} # DisplayUsage + +ShowVideoModes() { + OIFS=${IFS} + IFS="|" + awk -F" " '/ # res/ {print $1}' <"${0}" | tr -d ')' | grep -v 'awk' | while read ; do + set ${REPLY} + echo -e " ${2}\tuse \"-m ${2}\" or \"-m ${1}\"" + done + IFS=${OIFS} + echo -e "\n Two examples:\n\n ${0##*/} -m 1080p60 -d' (1920x1080@60Hz DVI)" + echo -e " ${0##*/} -m 720i' (1280x720@30Hz HDMI)\n" +} # ShowVideoModes + PatchScriptBin() { # This function will be called with 2 arguments: # $1 HDMI mode to set @@ -137,4 +241,4 @@ InstallSunxiTools() { make install } # InstallSunxiTools -Main +Main "$@" From eef7ebce52c4e7eba0ee2a0f45d57566ca49a0bb Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Tue, 23 Feb 2016 18:51:28 +0100 Subject: [PATCH 5/6] Improved h3disp bug reporting --- scripts/h3disp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/h3disp b/scripts/h3disp index 3b054ef222..eb636feafc 100755 --- a/scripts/h3disp +++ b/scripts/h3disp @@ -121,6 +121,15 @@ Main() { echo -e "Now trying to patch script.bin with your settings. \c" PatchScriptBin ${HDMIMode} ${DVIUsed} echo "Successfully finished. Please reboot for changes to take effect" + + # Let's see whether we have to collect debug output + case ${Debug} in + TRUE) + which curl >/dev/null 2>&1 || apt-get -f -qq -y install curl + echo -e "\nDebug output has been collected at the following URL: \c" + curl -F 'sprunge=<-' http://sprunge.us <"${DebugOutput}" + ;; + esac } # Main ParseOptions() { @@ -131,16 +140,21 @@ ParseOptions() { exit 0 ;; v|V) - # debug switch set via toolclient. We'll be more verbose + # Increase verbosity. Will try to upload debug output from script + # to ease reporting of bugs or strange behaviour. Use only when + # asked for. export Debug=TRUE + DebugOutput="$(mktemp /tmp/${0##*/}.XXXXXX)" + trap "rm \"${DebugOutput}\" ; exit 0" 0 1 2 3 15 set -x + exec 2>"${DebugOutput}" ;; d|D) # use HDMI-to-DVI converter export DVIUsed=TRUE ;; m|M) - # timeout for tool + # The HDMI mode in question export VideoMode=${OPTARG} ;; esac @@ -200,7 +214,6 @@ PatchScriptBin() { # create temp file MyTmpFile="$(mktemp /tmp/${0##*/}.XXXXXX)" - # trap "rm \"${MyTmpFile}\" ; exit 0" 0 1 2 3 15 # convert script.bin to temporary fex file bin2fex <"${ScriptBin}" 2>/dev/null | grep -v "^screen0_output" \ From ee1546908974063252abb8c4589eb7d9040e26bf Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Tue, 23 Feb 2016 19:25:49 +0100 Subject: [PATCH 6/6] Improved h3disp bug reporting again, also including fex contents --- scripts/h3disp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/h3disp b/scripts/h3disp index eb636feafc..58492cacad 100755 --- a/scripts/h3disp +++ b/scripts/h3disp @@ -127,7 +127,8 @@ Main() { TRUE) which curl >/dev/null 2>&1 || apt-get -f -qq -y install curl echo -e "\nDebug output has been collected at the following URL: \c" - curl -F 'sprunge=<-' http://sprunge.us <"${DebugOutput}" + (cat "${DebugOutput}"; echo -e "\n\n\nfex contents:\n" ; cat "${MyTmpFile}") \ + | curl -F 'sprunge=<-' http://sprunge.us ;; esac } # Main