Enable Persistent WiFi on NXP FRDM IMX93 Board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Enable Persistent WiFi on NXP FRDM IMX93 Board

899 Views
armwaheed
Contributor I

Here are instructions to configure the NXP board to connect to a specific WiFi network on boot.

  1. Log in to Linux on the board, as root

  2. Create a wpa_supplicant.conf:

    touch /etc/wpa_supplicant.conf
    nano /etc/wpa_supplicant.conf
     

    Enter your WiFi credentials into the wpa_supplicant.conf file:

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
        ssid="YOUR_SSID"
        psk="YOUR_PASSWORD"
        key_mgmt=WPA-PSK
    }
     
  3. Test the wpa_supplicant.conf file:

    modprobe moal mod_para=nxp/wifi_mod_para.conf
    ifconfig mlan0 up
    wpa_supplicant -B -i mlan0 -c /etc/wpa_supplicant.conf
    udhcpc -i mlan0
     
    • mlan0 is the WiFi interface on i.MX93
    • If this connects to WiFi, we’re ready for automation

  4. Configure DNS server IP addresses, so that the NXP board can resolve Internet addresses:

    touch /usr/share/udhcpc/default.script
    nano /usr/share/udhcpc/default.script
     

    and add in the following udhcpc script:

    #!/bin/sh
    # udhcpc script
    case "$1" in
        deconfig)
            ip addr flush dev $interface
            ;;
        bound|renew)
            ip addr add $ip/$subnet dev $interface
            ip route add default via $router
            echo "nameserver 8.8.8.8" > /etc/resolv.conf
            echo "nameserver 1.1.1.1" >> /etc/resolv.conf
            ;;
    esac
     

    Make the default.script executable:

    chmod +x /usr/share/udhcpc/default.script
     
  5. Create a nxp-wifi-setup.sh script:

    touch /usr/bin/nxp-wifi-setup.sh
    nano /usr/bin/nxp-wifi-setup.sh
     

    and add in the following lines:

    #!/bin/sh
    # Load WiFi driver
    /usr/sbin/modprobe moal mod_para=nxp/wifi_mod_para.conf
    
    # Bring interface up
    /usr/bin/ifconfig mlan0 up
    
    # Connect to WiFi
    /usr/sbin/wpa_supplicant -B -i mlan0 -c /etc/wpa_supplicant.conf
    
    # Obtain DHCP IP + DNS
    /usr/sbin/udhcpc -i mlan0 -s /usr/share/udhcpc/default.script
     

    Make the nxp-wifi-setup.sh executable:

    chmod +x /usr/bin/nxp-wifi-setup.sh
     
  6. Create a nxp-wifi-setup.service:

    touch /etc/systemd/system/nxp-wifi-setup.service
    nano /etc/systemd/system/nxp-wifi-setup.service
     

    Enter the following systemd commands into the nxp-wifi-setup.service file:

    [Unit]
    Description=WiFi Setup for NXP FRDM i.MX93
    After=network.target
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/nxp-wifi-setup.sh
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
     
  7. Create a wpa_supplicant.service:

    touch /etc/systemd/system/wpa_supplicant.service
    nano /etc/systemd/system/wpa_supplicant.service
     

    Enter the following systemd commands into the wpa_supplicant.service file:

    [Unit]
    Description=WPA Supplicant daemon
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/sbin/wpa_supplicant -i mlan0 -c /etc/wpa_supplicant.conf
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
     
  8. Enable and Start the nxp-wifi-setup.service:

    systemctl daemon-reload
    systemctl enable nxp-wifi-setup.service wpa_supplicant.service
    systemctl start nxp-wifi-setup.service wpa_supplicant.service
     
  9. Check status:

systemctl status nxp-wifi-setup.service
systemctl status wpa_supplicant.service
 

and confirm Internet connectivity:

curl -I http://www.example.com
0 Kudos
Reply
1 Reply

873 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @armwaheed 

Thanks for sharing !

Best Regards,
Zhiming

%3CLINGO-SUB%20id%3D%22lingo-sub-2170713%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EEnable%20Persistent%20WiFi%20on%20NXP%20FRDM%20IMX93%20Board%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2170713%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHere%20are%20instructions%20to%20configure%20the%20NXP%20board%20to%20connect%20to%20a%20specific%20WiFi%20network%20on%20boot.%3C%2FP%3E%3COL%3E%3CLI%3E%3CP%3ELog%20in%20to%20Linux%26nbsp%3Bon%20the%20board%2C%20as%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eroot%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECreate%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewpa_supplicant.conf%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Etouch%20%2Fetc%2Fwpa_supplicant.conf%0Anano%20%2Fetc%2Fwpa_supplicant.conf%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3EEnter%20your%20WiFi%20credentials%20into%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewpa_supplicant.conf%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efile%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Ectrl_interface%3DDIR%3D%2Fvar%2Frun%2Fwpa_supplicant%20GROUP%3Dnetdev%0Aupdate_config%3D1%0A%0Anetwork%3D%7B%0A%20%20%20%20ssid%3D%22YOUR_SSID%22%0A%20%20%20%20psk%3D%22YOUR_PASSWORD%22%0A%20%20%20%20key_mgmt%3DWPA-PSK%0A%7D%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3CLI%3E%3CP%3ETest%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewpa_supplicant.conf%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efile%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Emodprobe%20moal%20mod_para%3Dnxp%2Fwifi_mod_para.conf%0Aifconfig%20mlan0%20up%0Awpa_supplicant%20-B%20-i%20mlan0%20-c%20%2Fetc%2Fwpa_supplicant.conf%0Audhcpc%20-i%20mlan0%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CUL%3E%3CLI%3Emlan0%20is%20the%20WiFi%20interface%20on%20i.MX93%3C%2FLI%3E%3CLI%3EIf%20this%20connects%20to%20WiFi%2C%20we%E2%80%99re%20ready%20for%20automation%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3E%3CP%3EConfigure%20DNS%20server%20IP%20addresses%2C%20so%20that%20the%20NXP%20board%20can%20resolve%20Internet%20addresses%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Etouch%20%2Fusr%2Fshare%2Fudhcpc%2Fdefault.script%0Anano%20%2Fusr%2Fshare%2Fudhcpc%2Fdefault.script%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3Eand%20add%20in%20the%20following%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eudhcpc%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Escript%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3E%23!%2Fbin%2Fsh%0A%23%20udhcpc%20script%0Acase%20%22%241%22%20in%0A%20%20%20%20deconfig)%0A%20%20%20%20%20%20%20%20ip%20addr%20flush%20dev%20%24interface%0A%20%20%20%20%20%20%20%20%3B%3B%0A%20%20%20%20bound%7Crenew)%0A%20%20%20%20%20%20%20%20ip%20addr%20add%20%24ip%2F%24subnet%20dev%20%24interface%0A%20%20%20%20%20%20%20%20ip%20route%20add%20default%20via%20%24router%0A%20%20%20%20%20%20%20%20echo%20%22nameserver%208.8.8.8%22%20%26gt%3B%20%2Fetc%2Fresolv.conf%0A%20%20%20%20%20%20%20%20echo%20%22nameserver%201.1.1.1%22%20%26gt%3B%26gt%3B%20%2Fetc%2Fresolv.conf%0A%20%20%20%20%20%20%20%20%3B%3B%0Aesac%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3EMake%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Edefault.script%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eexecutable%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Echmod%20%2Bx%20%2Fusr%2Fshare%2Fudhcpc%2Fdefault.script%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECreate%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Enxp-wifi-setup.sh%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Escript%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Etouch%20%2Fusr%2Fbin%2Fnxp-wifi-setup.sh%0Anano%20%2Fusr%2Fbin%2Fnxp-wifi-setup.sh%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3Eand%20add%20in%20the%20following%20lines%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3E%23!%2Fbin%2Fsh%0A%23%20Load%20WiFi%20driver%0A%2Fusr%2Fsbin%2Fmodprobe%20moal%20mod_para%3Dnxp%2Fwifi_mod_para.conf%0A%0A%23%20Bring%20interface%20up%0A%2Fusr%2Fbin%2Fifconfig%20mlan0%20up%0A%0A%23%20Connect%20to%20WiFi%0A%2Fusr%2Fsbin%2Fwpa_supplicant%20-B%20-i%20mlan0%20-c%20%2Fetc%2Fwpa_supplicant.conf%0A%0A%23%20Obtain%20DHCP%20IP%20%2B%20DNS%0A%2Fusr%2Fsbin%2Fudhcpc%20-i%20mlan0%20-s%20%2Fusr%2Fshare%2Fudhcpc%2Fdefault.script%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3EMake%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Enxp-wifi-setup.sh%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eexecutable%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Echmod%20%2Bx%20%2Fusr%2Fbin%2Fnxp-wifi-setup.sh%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECreate%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Enxp-wifi-setup.service%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Etouch%20%2Fetc%2Fsystemd%2Fsystem%2Fnxp-wifi-setup.service%0Anano%20%2Fetc%2Fsystemd%2Fsystem%2Fnxp-wifi-setup.service%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3EEnter%20the%20following%20systemd%20commands%20into%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Enxp-wifi-setup.service%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efile%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3E%5BUnit%5D%0ADescription%3DWiFi%20Setup%20for%20NXP%20FRDM%20i.MX93%0AAfter%3Dnetwork.target%0A%0A%5BService%5D%0AType%3Doneshot%0AExecStart%3D%2Fusr%2Fbin%2Fnxp-wifi-setup.sh%0ARemainAfterExit%3Dyes%0A%0A%5BInstall%5D%0AWantedBy%3Dmulti-user.target%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECreate%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewpa_supplicant.service%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Etouch%20%2Fetc%2Fsystemd%2Fsystem%2Fwpa_supplicant.service%0Anano%20%2Fetc%2Fsystemd%2Fsystem%2Fwpa_supplicant.service%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3EEnter%20the%20following%20systemd%20commands%20into%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewpa_supplicant.service%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efile%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3E%5BUnit%5D%0ADescription%3DWPA%20Supplicant%20daemon%0AAfter%3Dnetwork.target%0A%0A%5BService%5D%0AType%3Dsimple%0AExecStart%3D%2Fusr%2Fsbin%2Fwpa_supplicant%20-i%20mlan0%20-c%20%2Fetc%2Fwpa_supplicant.conf%0ARestart%3Dalways%0A%0A%5BInstall%5D%0AWantedBy%3Dmulti-user.target%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3CLI%3E%3CP%3EEnable%20and%20Start%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Enxp-wifi-setup.service%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Esystemctl%20daemon-reload%0Asystemctl%20enable%20nxp-wifi-setup.service%20wpa_supplicant.service%0Asystemctl%20start%20nxp-wifi-setup.service%20wpa_supplicant.service%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECheck%20status%3A%3C%2FP%3E%3C%2FLI%3E%3C%2FOL%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Esystemctl%20status%20nxp-wifi-setup.service%0Asystemctl%20status%20wpa_supplicant.service%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3Eand%20confirm%20Internet%20connectivity%3A%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%3CPRE%3Ecurl%20-I%20http%3A%2F%2Fwww.example.com%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2170815%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Enable%20Persistent%20WiFi%20on%20NXP%20FRDM%20IMX93%20Board%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2170815%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F254072%22%20target%3D%22_blank%22%3E%40armwaheed%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20for%20sharing%20!%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20Regards%2C%3CBR%20%2F%3EZhiming%3C%2FP%3E%3C%2FLINGO-BODY%3E