11 Replies Latest reply on Jun 19, 2020 11:54 AM by shabaz

    raspberry pi zero w

    frodoclies

      hi im using a generic lcd with the dpi24.dtbo for the way to run it. it runs find but i wnat to push sound out of gpio18 and i can manually switch it to output sound but when i reboot i have to enable the gpio to use sound. i was wondering is there a way to edit dpi24 overlay in order to have it set gpio 18 to output sound. the screen i have uses the rgb lcd hat and does not use gpio18 ive had no difference in image. if i get greedy and try to use gpio 13 as well or on its own it makes the screen get funny scanlines that come in on a angle. please help im super new to this and ive about made my eyes bleed trying to search for information on how to make this work. its for a portable project im doing. any help would be super awsome and i would be grateful

        • Re: raspberry pi zero w
          shabaz

          Hi Adam,

           

          It's really hard to follow this question, it is missing capital letters at the start of sentences, and paragraphs.

          The overlay that you're using can be edited, I've no idea if it will work, I've not tried modifying it.

          The way to do it is to locate the source file. which usually has a .dts suffix. It is here:

          https://github.com/raspberrypi/linux/blob/rpi-4.14.y/arch/arm/boot/dts/overlays/dpi24-overlay.dts

           

          Use the following link to see how to edit it: https://www.raspberrypi.org/documentation/configuration/pin-configuration.md

          Build a new device tree fragment file (.dtbo suffix) with preferably a new filename too, using the information here:

          https://www.raspberrypi.org/forums/viewtopic.php?t=218235

          It is quite an advanced task, not very user-friendly or well documented.

           

          Alternatively, it may be possible to just create a systemd service since you suggest that you already have a command that you type to correct the situation, i.e. without needing to create the modified fragment file. Information is here: https://www.raspberrypi.org/documentation/linux/usage/systemd.md and this could be much easier than messing with device tree source, if you can avoid it.

          5 of 5 people found this helpful
            • Re: raspberry pi zero w
              frodoclies

              Thank you very much. And im sorry about the grammar im not really good at it so im sorry i burned your eyes with my nonsense. Ty for all the info i will try to apply this info tonight and see where it gets me. I can follow most tutorials with ease so if i get this thing working as i intend i will update here with pictures and maybe video. again thank you i would have been lost without this info.

              • Re: raspberry pi zero w
                frodoclies

                This is the command im trying to get my service to run and it keeps telling me invalid argument.

                gpio_alt -p 18 -f 5

                https://learn.adafruit.com/assets/28866

                I am trying to get pin to produce sound without me having to enter that command every time i reboot

                  • Re: raspberry pi zero w
                    shabaz

                    Hi Adam,

                     

                    I understand that you wish some command to be persistent after reboot, but first that command needs to be understood.

                     

                    Regarding:

                    it keeps telling me invalid argument

                    and

                    I am trying to get pin to produce sound without me having to enter that command every time i reboot

                    Are you saying that despite seeing an invalid argument error, the audio works when you enter that command?

                    Or did you mean something else? What do you type, to get the audio to work?

                     

                    Once you have confirmed what you have to type to get the audio to work, you can get the Pi to make it persistent after reboot, i.e. by automatically executing that text on each reboot, using the 'systemd' capability. Even easier, it could be possible to do it in a .bashrc file. But first you need to confirm what command works for getting the sound.

                    3 of 3 people found this helpful
                      • Re: raspberry pi zero w
                        frodoclies

                        the command i use is "gpio_alt -p 18 -f 5". The invalid argument is from when i attempt to follow the guide you linked me to for using systemd. I am almost sure that i just plain am missing how exactly to use it. ty for all the replies so far I really can not thank you enough because i know you got me going in the right direction i just cant seem to stick the landing lol.

                          • Re: raspberry pi zero w
                            shabaz

                            Hi Adam,

                             

                            As an experiment, try this:

                            Edit your .bashrc file (it will be in your home folder, such as /home/pi) and place this at the end:

                             

                            if [ $(tty) == /dev/tty1 ]; then 
                              /usr/local/bin/gpio_alt -p 18 -f 5
                            fi
                            

                             

                            Note you may need to change the path /usr/local/bin if it is placed elsewhere; you can find out the path by typing on the command line: which gpio_alt  

                             

                            Then, reboot your Pi and see if your audio works.

                            If it doesn't work, try just this line, at the end of .bashrc, instead of the three lines:

                            /usr/local/bin/gpio_alt -p 18 -f 5
                            3 of 3 people found this helpful
                              • Re: raspberry pi zero w
                                frodoclies

                                The second option worked but only if i run the terminal after i boot up. Leads me to believe the .bashrc file only runs if you open terminal or i added it too far towards the end or something. Not entirely sure lol but we are so close i can taste it

                                  • Re: raspberry pi zero w
                                    shabaz

                                    Hi Adam,

                                     

                                    I wasn't sure of the status of the Pi, i.e. if your terminal automatically came up (that's a boot option). Since it doesn't, then that means probably a service is more suitable. Delete the content you added to .bashrc, reboot, and then try this procedure:

                                     

                                    As super-user, create a file called (say) gpio_audio.service in the folder /etc/systemd/system containing the following text (please click on 'view plain' at the top of the code block shown below, and copy-paste it, or it must be typed as shown, i.e. the upper-case and lower-case matters):

                                     

                                    [Unit]
                                    Description=Set GPIO for audio
                                    After=basic.target
                                    
                                    [Service]
                                    Type=oneshot
                                    ExecStart=/usr/bin/nohup /usr/local/bin/gpio_alt -p 18 -f 5 &
                                    StandardOutput=inherit
                                    StandardInput=inherit
                                    User=pi
                                    RemainAfterExit=true
                                    
                                    [Install]
                                    WantedBy=multi-user.target
                                    

                                     

                                    Then, on the command line type:

                                    systemctl start gpio_audio.service
                                    

                                     

                                    If that works and the audio begins to function, then you can make it persistent across reboots by typing:

                                    systemctl enable gpio_audio.service
                                    

                                     

                                    There may be errors in the script, I have not tested it.

                                    2 of 2 people found this helpful