RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Script to start ES or Desktop on boot

    Scheduled Pinned Locked Moved Help and Support
    boot config
    26 Posts 4 Posters 5.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • FrazattoF
      Frazatto @mitu
      last edited by

      @mitu now I'm just confused :D

      If I try what you asked, it works just fine.
      So I went ahead and tried just startx & in autostart.sh and I get the same error.
      This is the log you asked for when the desktop fails to start:
      (the line about xf86OpenConsole used to be an access error to tty1 that I "fixed")

      [    20.335] 
      X.Org X Server 1.20.4
      X Protocol Version 11, Revision 0
      [    20.342] Build Operating System: Linux 4.15.0-48-generic armv8l Raspbian
      [    20.345] Current Operating System: Linux BMO.local 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l
      [    20.345] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_headphones=1 bcm2708_fb.fbwidth=1280 bcm2708_fb.fbheight=720 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  dwc_otg.lpm_enable=0 console=tty1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo
      [    20.356] Build Date: 05 June 2019  12:49:54PM
      [    20.359] xorg-server 2:1.20.4-1+rpt1 (https://www.debian.org/support) 
      [    20.362] Current version of pixman: 0.36.0
      [    20.368] 	Before reporting problems, check http://wiki.x.org
      	to make sure that you have the latest version.
      [    20.368] Markers: (--) probed, (**) from config file, (==) default setting,
      	(++) from command line, (!!) notice, (II) informational,
      	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
      [    20.380] (==) Log file: "/home/pi/.local/share/xorg/Xorg.0.log", Time: Sat Jul  4 15:48:27 2020
      [    20.394] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
      [    20.406] (==) No Layout section.  Using the first Screen section.
      [    20.406] (==) No screen section available. Using defaults.
      [    20.406] (**) |-->Screen "Default Screen Section" (0)
      [    20.406] (**) |   |-->Monitor "<default monitor>"
      [    20.425] (==) No device specified for screen "Default Screen Section".
      	Using the first device section listed.
      [    20.425] (**) |   |-->Device "Allwinner A10/A13 FBDEV"
      [    20.425] (==) No monitor specified for screen "Default Screen Section".
      	Using a default monitor configuration.
      [    20.425] (==) Automatically adding devices
      [    20.425] (==) Automatically enabling devices
      [    20.425] (==) Automatically adding GPU devices
      [    20.426] (==) Max clients allowed: 256, resource mask: 0x1fffff
      [    20.482] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist.
      [    20.482] 	Entry deleted from font path.
      [    20.482] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist.
      [    20.482] 	Entry deleted from font path.
      [    20.482] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist.
      [    20.482] 	Entry deleted from font path.
      [    20.482] (WW) The directory "/usr/share/fonts/X11/Type1" does not exist.
      [    20.482] 	Entry deleted from font path.
      [    20.483] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist.
      [    20.483] 	Entry deleted from font path.
      [    20.483] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist.
      [    20.483] 	Entry deleted from font path.
      [    20.483] (==) FontPath set to:
      	/usr/share/fonts/X11/misc,
      	built-ins
      [    20.483] (==) ModulePath set to "/usr/lib/xorg/modules"
      [    20.483] (II) The server relies on udev to provide the list of input devices.
      	If no devices become available, reconfigure udev or disable AutoAddDevices.
      [    20.483] (II) Loader magic: 0x1fcf80
      [    20.483] (II) Module ABI versions:
      [    20.483] 	X.Org ANSI C Emulation: 0.4
      [    20.483] 	X.Org Video Driver: 24.0
      [    20.483] 	X.Org XInput driver : 24.1
      [    20.483] 	X.Org Server Extension : 10.0
      [    20.487] (--) using VT number 2
      
      [    20.487] (II) systemd-logind: logind integration requires -keeptty and -keeptty was not provided, disabling logind integration
      [    20.488] (II) no primary bus or device found
      [    20.488] (II) LoadModule: "glx"
      [    20.534] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
      [    20.712] (II) Module glx: vendor="X.Org Foundation"
      [    20.712] 	compiled for 1.20.4, module version = 1.0.0
      [    20.712] 	ABI class: X.Org Server Extension, version 10.0
      [    20.713] (II) LoadModule: "fbturbo"
      [    20.713] (II) Loading /usr/lib/xorg/modules/drivers/fbturbo_drv.so
      [    20.736] (II) Module fbturbo: vendor="X.Org Foundation"
      [    20.736] 	compiled for 1.20.3, module version = 0.5.1
      [    20.736] 	Module class: X.Org Video Driver
      [    20.736] 	ABI class: X.Org Video Driver, version 24.0
      [    20.737] (II) FBTURBO: driver for framebuffer: fbturbo
      [    20.737] (EE) 
      Fatal server error:
      [    20.751] (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied)
      [    20.758] (EE) 
      [    20.764] (EE) 
      Please consult the The X.Org Foundation support 
      	 at http://wiki.x.org
       for help. 
      [    20.791] (EE) Please also check the log file at "/home/pi/.local/share/xorg/Xorg.0.log" for additional information.
      [    20.799] (EE) 
      [    20.806] (WW) xf86CloseConsole: KDSETMODE failed: Bad file descriptor
      [    20.806] (WW) xf86CloseConsole: VT_GETMODE failed: Bad file descriptor
      [    20.806] (EE) Server terminated with error (1). Closing log file.
      
      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by

        @Frazatto said in Script to start ES or Desktop on boot:

        [ 20.751] (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied)

        The error shows you're trying to run X on the 2nd text console, not the first. When running on the 1st one, it should show something like

        [420164.968] (++) using VT number 1
        

        Do you have other configuration added to the default image ? Did you add something to /boot/cmdline.txt ?

        FrazattoF 1 Reply Last reply Reply Quote 0
        • FrazattoF
          Frazatto @mitu
          last edited by

          @mitu manually? Never touched this file before.
          This is it's content:

          dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo
          
          1 Reply Last reply Reply Quote 0
          • mituM
            mitu Global Moderator
            last edited by

            That's strange, doesn't look like a standard cmdline.ext. Did you install from a Raspbian Lite image or from a RetroPie image ?

            FrazattoF 1 Reply Last reply Reply Quote 0
            • FrazattoF
              Frazatto @mitu
              last edited by

              @mitu
              https://www.raspberrypi.org/downloads/raspberry-pi-os/
              "Raspberry Pi OS (32-bit) with desktop and recommended software"
              Than Retropie flowing the GIT guide.

              How does your look like?
              What does this file do?

              mituM 1 Reply Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @Frazatto
                last edited by

                @Frazatto Not sure if that file is the culprit, but I've seen configuration when the default tty was modified via that file. Sorry, I have no ideas why it's not working, I just tested on a stock RetroPie install and couldn't get any errors.

                FrazattoF 1 Reply Last reply Reply Quote 0
                • FrazattoF
                  Frazatto @mitu
                  last edited by

                  @mitu don't worry, you tried to the very end and I thank you!
                  On the Raspberry forum nobody even bothered to answer me :P

                  1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator
                    last edited by

                    @Frazatto said in Script to start ES or Desktop on boot:

                    On the Raspberry forum nobody even bothered to answer me :P

                    That's probably because your problem is specific to the RetroPie auto-start configuration and not something Raspbian/Raspberry Pi related.

                    1 Reply Last reply Reply Quote 0
                    • FrazattoF
                      Frazatto
                      last edited by

                      Just for future reference, I was messing around with this problem again and it just worked now........

                      So to recap, if you want to change between X and EmulationStation depending on what output is connected, change /opt/retropie/configs/all/autostart.sh to something like the code below and it should work.

                      #if HDMI connected, go to desktop
                      video="$(tvservice -s)"

                      if [[ $video =~ "HDMI" ]];
                      then
                      startx
                      else
                      emulationstation #auto
                      fi

                      I believe my Pi had some inconsistency in which user had ownership over the display, I manually set up ES and Rapibian to start on cmd, than in raspconfig set it to start X and lastly changed it back to ES to start by default. (yes, sounds complicated, but it was an accident really)

                      After that, the code snippet should work as intended.

                      1 Reply Last reply Reply Quote 1
                      • M
                        millanzarreta
                        last edited by millanzarreta

                        Sorry to resurrect this interesting topic so much later. I came to it after looking for a script that allows us to select in a menu at the start if we want to start emulationstation or the desktop. I know that it's not exactly the same as what was discussed in this thread but it's very related. I've ended up making a custom script modifying /opt/retropie/configs/all/autostart.sh, and since I think it might be useful to someone, I'll leave it here for reference (this is the new content of that autostart.sh file):

                        ## Get WT Sizes
                        WT_HEIGHT=18
                        WT_WIDTH=$(tput cols)
                        if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then
                          WT_WIDTH=80
                        fi
                        if [ "$WT_WIDTH" -gt 178 ]; then
                          WT_WIDTH=120
                        fi
                        WT_MENU_HEIGHT=$(($WT_HEIGHT-7))
                        
                        ## Get Architecture
                        ARCH=$(dpkg --print-architecture)
                        
                        ## Dialog Menu
                        if [ "$ARCH" = "armhf" ] || [ "$ARCH" = "arm64" ] ; then
                          sw=`DIALOG_ERROR=5 DIALOG_ESC=1 dialog --timeout 6 --no-cancel --title "Raspberry Pi Startup Selection Tool" --backtitle "$(cat /proc/device-tree/model)" \
                            --menu "Startup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \
                            "1 EmulationStation" "Front-end of RetroPie Project" \
                            "2 Desktop" "Raspbian PIXEL Desktop Enviroment" \
                            "3 Console" "Abort auto-start and remain in console" \
                            3>&1 1>&2 2>&3`
                        else
                          sw=`DIALOG_ERROR=5 DIALOG_ESC=1 dialog --timeout 6 --no-cancel --title "Raspberry Pi Startup Selection Tool" \
                            --menu "Startup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \
                            "1 EmulationStation" "Front-end of RetroPie Project" \
                            "2 Desktop" "Raspbian PIXEL Desktop Enviroment" \
                            "3 Console" "Abort auto-start and remain in console" \
                            3>&1 1>&2 2>&3`
                        fi
                        rc=$?
                        #reset  #no needed
                        clear
                        source $HOME/.bashrc
                        case $rc in
                          0)
                            case "$sw" in
                              "1 EmulationStation")
                                emulationstation ;;
                              "2 Desktop")
                                startx ;;
                              "3 Console")
                                echo "" ;;
                              *)
                                emulationstation ;;
                            esac;;
                          1)
                            emulationstation ;;
                          5)
                            emulationstation ;;
                          *)
                            emulationstation ;;
                        esac
                        
                        

                        This is what it looks like:

                        autostart_retropie_screenshot

                        It's set to run emulationstation by default. A timeout of 6 seconds is established, so if the user does not press any key for 6 seconds, the default option (emulationstation) is executed. I've used dialog for the menu instead of whiptailonly because this last doesn't have the --timeout option, and although you can achieve a similar effect with other tricks it's a bit more complicated, both should work fine either way.

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post

                        Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                        Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.