How to get the WiFi adhoc mode on for iMX6 on bootup?

Hello Toradex Team,

I am trying to set up the WiFi adhoc mode between my Ubuntu PC and Apalis iMX6 board. I have successfully done this, by making the Apalis imx6 as the main Accesspoint and then connecting my Ubuntu PC to it. I followed the following steps :

on iMX6 board:

ifconfig wifi_interface down
iw wifi_interface set type ibss
iwconfig wifi_interface essid MY_ADHOC
ip link set wifi_interface up
ifconfig wifi_interface 10.2.1.1

on Ubuntu

ifconfig wifi_interface down
iw wifi_interface set type ibss
ifconfig wifi_interface up
iw wifi_interface ibss join MY_ADHOC 2432
ifconfig wifi_interface 10.2.1.2

Now this works completely fine. The problem is I want the iMX6 to do the above configuration automatically during after boot. So I wrote all the above commands in a file called config_wlan and copied it to the the path /usr/bin/

Later I wrote a service file in the path /lib/systemd/system, and try to call the config_wlan from ExecStart. Here is the service file : wlan.service

[Unit]
Description=get the wifi up
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=sleep 60 && /usr/bin/config_wlan start wifi_interface  iw
ExecStop=/usr/bin/config_wlan stop wifi_interface iw

[Install]
WantedBy=multi-user.target

I enabled the service file using systemctl enable wlan.service

Now after reboot, I expect the service to set up the adhoc mode at the iMX6 board, so that I can connect from my Ubuntu PC. But this does not happen. I also tried adding command sleep 60 in the ExecStart but that did not help.

Can you guys point out to where I am going wrong with this one? Or is there any other method to get the adhoc mode up and running?

hi @soc_learner

Could you provide the version of the hardware and software of your module?
Regarding your issue, please share the dmesg log and status of wlan.service in a file.

Thanks and best regards, Jaski

Apalis imx6 with the apalis evaluation board. imx6
Kernel 4.1.35v2 - Angstrom.

$dmesg | grep wlan
[    5.997748] rt2800usb 1-1.1.4:1.0 wlx70f11c0f6e0e: renamed from wlan0


$systemctl --state=failed
  UNIT               LOAD   ACTIVE SUB    DESCRIPTION                           
          
● wlan.service       loaded failed failed get the wifi up  

$systemctl status wlan.service
● wlan.service - get the wifi up
   Loaded: loaded (/lib/systemd/system/wlan.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2019-02-15 04:17:01 MST; 1min 13s ago
  Process: 624 ExecStart=/usr/bin/config_wlan start wlx70f11c0f6e0e iw (code=exited, status=203/EXEC)
 Main PID: 624 (code=exited, status=203/EXEC)

Thats all is available in the dmeg logs.

hi @soc_learner

Thanks for the log.

Concerning your Question, there are some points with your script.

So I wrote all the above commands in a file called config_wlan and copied it to the the path

If you want to launch the commands, then you need to add them in bashscript file (.sh) and make this file executable. Maybe you also need to add /bin/bash in front of the command for the bashscript file.

ExecStart=sleep 60 && /bin/bash /usr/bin/config_wlan

And your scripts has no input arguments? So why are you providing these to your script?

Best regards, Jaski