Wifi RS21 doesn't initialize

Hey guys!

I’ve got a problem with my wifirs21 module which doesn’t want to initialize on fez raptor.
I’m currently on firmware version 4.3.6.0 (both loader and firmware).

Whenever i try to debug my application in vs13 with WiFi connected to the board, vs13 isn’t able to find the board.
If i debug without WiFi connected, and reconnect it before initializing the board (during the reboot), it tries to initialize all modules but hangs at WiFi module.
It doesn’t even get to the “Program Started”, it just seems to do nothing.

There’s only the WiFi module connected, and i only made a new project without any code in it.
The problem also occurs on different gadgeteer sdk’s (I tested 2014 R5, and 2015 Beta 1-3).

Also, a few weeks back, the module worked partly, sometimes i was able to get it working somehow, and was able to communicate with the raptor over WiFi. But now, it doesn’t even initialize.

Any suggestions on things i could try to get it working again?

@ rumkuhgel - Do you get any exceptions? Do you see a green light come on on the WiFi module? Does https://www.ghielectronics.com/docs/30/networking#3121 work (make sure to set the proper pins)?

There are no Exceptions, the green LED does light up, but it still doesn’t get past initialization.

This is the code i’m currently using, the WiFi module is connected to Socket 1 on the Raptor board:

using GHI.Networking;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Net.NetworkInformation;
using System;
using System.Net;
using System.Threading;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Pins;

namespace GadgeteerApp2
{
    public partial class Program
    {
        private static WiFiRS9110 netif;
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            Debug.Print("Initializing WiFi...");
            netif = new WiFiRS9110(SPI.SPI_module.SPI2, G400.PB5, G400.PB0, G400.PA7);
            Debug.Print("Done");
            netif.Open();
            netif.EnableDhcp();
            netif.EnableDynamicDns();
            netif.Join("STROH", "************");

            while (netif.IPAddress == "0.0.0.0")
            {
                Debug.Print("Waiting for DHCP");
                Thread.Sleep(250);
            }
        }
        private static void NetworkChange_NetworkAddressChanged(object sender, Microsoft.SPOT.EventArgs e)
        {
            Debug.Print("Network address changed");
        }

        private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Debug.Print("Network availability: " + e.IsAvailable.ToString());
        }
    }
}

But it never gets to the

 below the initialization of the module.
There's also no exception in the visual studio debugger.

This is all i get:
[quote]Using mainboard GHI Electronics FEZ Raptor version 1.0
Program Started
Initializing WiFi...
[/quote]

Also, the used pins should be correct according to the images.

@ rumkuhgel - Have you tried a different socket?

Just tried Socket 3 and 11, same output in visual studio…

@ rumkuhgel - Do you have a different mainboard by any chance?

I don’t, but i have a colleague who also has a raptor, but he already tried and it didn’t work either.

For Gadgeteer apps, this is bad:

while (netif.IPAddress == "0.0.0.0")
            {
                Debug.Print("Waiting for DHCP");
                Thread.Sleep(250);
            }

Do not block the ProgramStarted from completing. Do not expect the framework to be consistent before ProgramStarted completes.

Just remove that block of code, and print out the IP address within the network address changed handler.

Well, that’s not my problem, as it doesn’t even get past the initialization here:


Otherwise i would see the message in the debugger, which i don't.

have you tried to use the graphics designer, and compared the generated code to yours?

have you tried another cable?

@ rumkuhgel - Do you have the wifi module connected in the designer? If so, it can conflict with your own declaration of GHI.Networking.WiFiRS9110.

I first tried it with the module connected in designer without my initialization code, but that didn’t work.
Then John suggested i could try the initialization code here https://www.ghielectronics.com/docs/30/networking#3121 without the module connected, but that didn’t work either.
I also tried three different cables, but nothing changed.

@ rumkuhgel - Do you by any chance have the ability to record the SPI communications between the module and mainboard?

I don’t think so, how would i do that?

@ rumkuhgel - Usually using a logic analyzer. In the code you posted in your second post, can you wrap everything in ProgramStarted in its own thread and pass 1000 as the clock to the other WiFiRS9110 constructor overload and see if that helps?

Something like that:

public partial class Program
    {
        private static WiFiRS9110 netif; 
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            Thread thread = new Thread(new ThreadStart(Initialize));
            thread.Start();
        }

        private void Initialize()
        {
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            Debug.Print("Initializing WiFi...");
            netif = new WiFiRS9110(SPI.SPI_module.SPI1, G400.PB4, G400.PC26, G400.PA5, 1000);
            Debug.Print("Done");
            netif.Open();
            netif.EnableDhcp();
            netif.EnableDynamicDns();
            netif.Join("STROH", "************");
        }

        private static void NetworkChange_NetworkAddressChanged(object sender, Microsoft.SPOT.EventArgs e)
        {
            Debug.Print("Network address changed to:" + netif.IPAddress);
        }

        private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Debug.Print("Network availability: " + e.IsAvailable.ToString());
        }
    }

Same output…

@ rumkuhgel - It doesn’t get past the constructor?

This is all i get in the debugger in visual studio:

[quote]Using mainboard GHI Electronics FEZ Raptor version 1.0
The module ‘wifiRS21’ was not connected in the designer and will be null.
Program Started
Initializing WiFi…
[/quote]To answer your question, no it does not.

@ rumkuhgel - When trying to initialize the module, do you see a green light come on on it? If so, does it turn off and come back on?

It does turn on, but there’s no on/off/on, just turns on once and stays that way.