5 Replies Latest reply on Dec 8, 2014 4:33 AM by mhahn

    Start wpa_supplicant on boot

    Precipice

      I am building a custom yocto image for Edison and need to be able to start and configure wpa_supplicant on boot.  There are a number of posts on here about starting scripts on boot but no seem to lead me to the correct solution.

       

      I am using systemd

      I have seen the docs in the BSP Users Guide and the example on using the watchdog-sample service.  I see it being deployed to my custom image and starting.  I can confirm with systemctl.  I see wpa_supplicant service being installed by it is not starting on boot.  I need it to start.  I cannot put my finger on what is the difference and how I would go about starting the wpa_supplicant service automatically.  I think I am missing something simple.

       

      Thanks

        • 1. Re: Start wpa_supplicant on boot
          CMata_Intel

          Hi Precipice

           

          You entered that you saw some other threads related to this, I'm not sure if you have already seen these ones:

          Related to how to enable a service by default

          This other one is to run a script at startup, take a look at the links in there, it could be helpful.

          Let me know if you tried this and if you not post your advances.

           

          Regards,

          CMata

          • 2. Re: Start wpa_supplicant on boot
            Precipice

            Hi

             

            Was out of the office yesterday - did not get a chance to work on the issue.  I saw the 2 posts you mentioned and tried them both.  Still missing something.

             

            I looked at the iokit-agent example and also the Edison BSP Guide.

             

            I did some more digging and have made some progress. I can get the service to start on the board if I edit the files manually.  Still have not made Yocto replicate this

             

            In wpa_supplicant-sane.conf I added my network block as below:

             

            ctrl_interface=/var/run/wpa_supplicant

            ctrl_interface_group=0

            update_config=1

            ap_scan=1

             

            network={

                    ssid="xxxxxx"

                    psk="xxxxxx"

            }

             

            I build and flash but cannot get the service to launch on boot unless I manually do a symbolic link in /etc/systemd/system/multi-user.target.wants.  I looks like this section of code is meant to make that link but does not trigger from (wpa-supplicant_2.1.bbappend)

             

                if ${@base_contains('DISTRO_FEATURES','systemd','true','false',d)}; then

             

                    install -d ${D}/${systemd_unitdir}/system
                    install -d ${D}${sysconfdir}/systemd/system/multi-user.target.wants

             

                    # Install the wpa_supplicant service
                    install -m 644 ${WORKDIR}/wpa_supplicant.service ${D}${systemd_unitdir}/system

             

                    # Install wpa_supplicant_event service for udhcp client start/stop based on wifi connection/disconnection
                    install -m 755 ${WORKDIR}/wpa_cli-actions.sh ${D}${sysconfdir}/wpa_supplicant
                    install -m 644 ${WORKDIR}/wpa_supplicant_event.service ${D}${systemd_unitdir}/system
               

            fi

             

            My poky.conf file contains the following:

            DISTRO_FEATURES = "systemd alsa argp bluetooth ext2 largefile usbgadget usbhost wifi xattr nfs zeroconf pci ${DISTRO_FEATURES_LIBC}"

             

            Not sure where to go from here just yet and how to make that link work -  any suggestions?

            • 3. Re: Start wpa_supplicant on boot
              Precipice

              Okay - got if figured out.  For anyone else who has this issue here is what I did.  I am not sure if this is the best way to do it - I will let the Yocto gurus comment on that

               

              I added 1 line to the if statement referenced below that made a symbolic link. 

               

                  if ${@base_contains('DISTRO_FEATURES','systemd','true','false',d)}; then

               

                      install -d ${D}/${systemd_unitdir}/system
                      install -d ${D}${sysconfdir}/systemd/system/multi-user.target.wants

               

                      # Install the wpa_supplicant service
                      install -m 644 ${WORKDIR}/wpa_supplicant.service ${D}${systemd_unitdir}/system

               

               

                      #install the symbolic link in multi-user.target.wants
                     
              ln -s  ${systemd_unitdir}/system/wpa_supplicant.service  ${D}${sysconfdir}/systemd/system/multi-user.target.wants/wpa_supplicant.service

               

               

                      # Install wpa_supplicant_event service for udhcp client start/stop based on wifi connection/disconnection
                      install -m 755 ${WORKDIR}/wpa_cli-actions.sh ${D}${sysconfdir}/wpa_supplicant
                      install -m 644 ${WORKDIR}/wpa_supplicant_event.service ${D}${systemd_unitdir}/system
                 fi


              • 4. Re: Start wpa_supplicant on boot
                CMata_Intel

                Great news Precipice!! I encourage you to keep posting your results in the communities and if you have more questions in the future don't hesitate in asking us.

                 

                Regards!

                CMata

                • 5. Re: Start wpa_supplicant on boot
                  mhahn

                  udhcp actually shouldn't be required: ConnMan already contains a DHCP client by itself. In addition, systemd-networkd v 215 also contains a DHCP client, rendering udhcpc quite obsolete.