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

881 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

855 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @armwaheed 

Thanks for sharing !

Best Regards,
Zhiming