TWR-WIFI-G011M1 with TWR-60K and TWR-SER

cancel
Showing results for 
Search instead for 
Did you mean: 

TWR-WIFI-G011M1 with TWR-60K and TWR-SER

1,457 Views
GottiLuca
Contributor IV

 

It is possible to use the wifi tower ( i.e. TWR-WIFI-G011M1 ) with the Tower Kit for K60N512 ??

I've just get one TWR-WIFI-G011M1 and i need instructions on how to use it ..

 

 

Labels (1)
Tags (1)
19 Replies

257 Views
GottiLuca
Contributor IV

I've done some steps more .

Installed MQX_GAINSPAN_WIFI_PATCH.exe on MQX 3.6 . Pls Note my compiler is IAR 6.2 .

Following the suggestions of the document included in the "GainSpan WiFi patch for Freescale MQX™ RTOS
Release Notes" document i've been able to modify the BSP for TWRK60N . Then to test the module i've compiled the

project in MQX demo dir : Web_HVAC and tried to run on target .

What i get is always an error in the function gs_init() ( module gs_init.c ) at line  1063 : 

             priv->tx_buf = Gs_MemAlloc(GS_BUFFER_SIZE);

 

It seems that the GS_MemAlloc function (  or _mem_alloc_system_zero or _lwmem_alloc_system_zero ) which  always returns NULL ( unable to allocate memory) also if i reduce the GS_BUFFER_SIZE def to a very low value ( like 16 !! ).

 

There is any way to solve this problem ??

Any help would be appreciated ...

 

( Frescaleres , where have u gone ??? )

0 Kudos

257 Views
GottiLuca
Contributor IV

 

Finally I've been able to run the GS Wifi Module with my TWR-60K. The GS Wifi Module has been tested with UART connection and at different baud rate(s) of 115200 , 230400 , 460800 and 921600 .

 

Apart from the specific problem of the TWRK60 BSP ( mainly a problem in init of UART5 peripheral and a problem at high rates, see my posts https://community.freescale.com/thread/87166 and https://community.freescale.com/thread/87446 ) , there have not been particular problem .

The only problem i'm experiencing is when I increase the baud rate ( particularly at 460K and 921K ) , at such speed it seems that the module loose the connection with the AP in managed mode. But this problem has to be investigated better and can be due to the fact that I'm using the USB to power my Tower Kit.

I've tried to run the module in SPI too but no luck , here I suspect that there are again some BSP related problems . I'll inform the forum in case I'll succeed with the SPI implementation (for the moment the UART implementation would be enough to my project scope and it uses less I/O pin !! ).

 

0 Kudos

257 Views
ThomNet
Contributor III

Hi GottiLuca,

 

did you get your application with the TWR-WIFI-G1011MI finally to run in SPI- mode?

Did you try adhoc mode as well?

 

I working at the same problem.

 

Thanks for an answer

 

Thomas

0 Kudos

257 Views
hubje3
Contributor II

I don't know if you ever got your TWR-WIFI-G011MI up and raunning, but the first step for me was to use MQX 3.7 with the Gainspan patch.  The patch gave updated drivers, patched a couple of the MQX ethernet files, and gave some extra goodies.  After I got familiar with how it worked I have been able to use the driver with MQX version 3.8 and also 3.81.  FYI, the driver that comes with MQX 3.8 is outdated and doesn't work correctly.  I use the driver in SPI mode and with minor modifications to the driver I use it in Access Point mode.

 

Jeremy

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

 

thanks for your reply.

 

Can you tell me, what changes you made and did you ever try to run the application in adhoc mode?

 

All the best

 

 

Thomas

0 Kudos

257 Views
hubje3
Contributor II

Using the AT command set, I have put it into Adhoc mode and made sure the mode worked, but I never actually used that mode in my project.  However in the example project that is provided, the mode is very simple to change and is pretty much transparent to the application so I don't know why it shouldn't work.

 

In order to make the Access Point mode work I found that the define for ENET_MEDIACTL_MODE_MASTER was already in place in the enet_wifi.h file, but it wasn't used anywhere else, so anywhere there was a reference to ENET_MEDIACTL_MODE_INFRA or ENET_MEDIACTL_MODE_ADHOC I added a reference to ENET_MEDIACTL_MODE_MASTER.

 

In the gs_conn_mgt.c file in gs_connect_mge():

...}else if(priv->iw_mode == ENET_MEDIACTL_MODE_ADHOC) {   mode =1;}else if(priv->iw_mode == ENET_MEDIACTL_MODE_MASTER) {   mode =2;}else {...

 In the gs_init.c file, in gs_process_wps_conn():

...   priv->iw_mode = ENET_MEDIACTL_MODE_ADHOC;}else if(i == 2){   priv->iw_mode = ENET_MEDIACTL_MODE_MASTER;}else {...

and  in the gs_mediactl.c file in gs_set_mode():

...   if (mode != ENET_MEDIACTL_MODE_ADHOC && mode != ENET_MEDIACTL_MODE_INFRA && mode != ENET_MEDIACTL_MODE_MASTER)...

and then in the example project I for the mode I had to add support for the mode so in the httpdsrv.c file I added:

...   mode = ENET_MEDIACTL_MODE_ADHOC;}else if (strcmp(WIFICFG_NW_MODE,"master") == 0){   mode = ENET_MEDIACTL_MODE_MASTER;}...

I think these are all the changes I made to support the access point mode in addition to the other modes.  

 

I hope this helps,

 

Jeremy

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

 

many thanks for your answer again. By the way: what country are you from?

 

You're right. adhoc- mode ist easy to achive. I checked it with my iPad and I have direct access to the webserver now, but (and there are 2 "buts")

 

1.) at this time I have to use a fixed IP address in my iPad setup, because the "httpsrv_twrk60n512" testproject does not include a DHCP functionality or may be I just have to enable some flags? I don't know at his time. I will check.

 

2.) and (the second "but") I'm working in UART- mode not in SPI mode. In the SPI mode I got the same error message (ERROR: GS response buffer overflow ....... ) as CarlFST60L has, just have a look at:

 

https://community.freescale.com/thread/114732

 

In the end I followed the advices given later there and I was successful .... but in UART- mode not in SPI- mode.

SPI-mode is quicker and I like to have the speed, because I like to program an application, where I use the jquery mobile framework for the websides.

 

Do you have any idea, what could be wrong or what has to be changed to not get those messages?

 

You didn't have those massages, did you, when you tested your setup?

 

All the best

 

 

Thomas

 

0 Kudos

257 Views
hubje3
Contributor II

Thomas,

 

I am from the US.  When I added a DHCP server I was pleasantly surprised at how quickly it started working for me,  I added the following task and then it just started working for me.

 

/*TASK*----------------------------------------------------------------- * * Function Name  : dhcpserver_task * Returned Value : void * Comments       : * *END------------------------------------------------------------------*/void dhcpserver_task(uint_32 initial_data){ DHCPSRV_DATA_STRUCT dhcpsrv_data; uchar dhcpsrv_options[200]; _ip_address routers[3]; uchar_ptr optptr; uint_32 error; uint_32 optlen; error = DHCPSRV_init("DHCP server", 7, 2000); if(error != RTCS_OK) {  printf("\nDHCP server initialize returned : %08x\n",error);  printf("\nFailed to initialize the DHCP server\n");  _task_destroy(MQX_NULL_TASK_ID); } printf("\nDHCP Server running...\n"); /* Fill in the required parameters: */ /* 192.168.73.1: */ dhcpsrv_data.SERVERID = 0xC0A84901; /* 1 hour leases: */ dhcpsrv_data.LEASE    = 3600; // 1 hour /* 255.255.255.0: */ dhcpsrv_data.MASK  = 0xFFFFFF00; /* TFTP server address: */ dhcpsrv_data.SADDR = 0xC0A84902; _mem_zero(dhcpsrv_data.SNAME,sizeof(dhcpsrv_data.SNAME)); _mem_zero(dhcpsrv_data.FILE,sizeof(dhcpsrv_data.FILE)); /* Fill in the options: */ optptr = dhcpsrv_options; optlen = sizeof(dhcpsrv_options); /* Default IP TTL: */ DHCPSRV_option_int8(&optptr,&optlen,23,64); /* MTU: */ DHCPSRV_option_int16(&optptr,&optlen,26,1500); /* Renewal time: */ DHCPSRV_option_int32(&optptr,&optlen,58,3600); /* Rebinding time: */ DHCPSRV_option_int32(&optptr,&optlen,59,5400); /* Domain name: */ DHCPSRV_option_string(&optptr,&optlen,15,"arc.com"); /* Broadcast address: */ DHCPSRV_option_addr(&optptr,&optlen,28,0xC0A849FF); /* Router list: */ routers[0] = 0xC0A84904; routers[1] = 0xC0A84905; routers[2] = 0xC0A84906; DHCPSRV_option_addrlist( &optptr, &optlen, 3, routers, 3); DHCPSRV_ippool_add(0xC0A84981, 7, &dhcpsrv_data, dhcpsrv_options, optptr - dhcpsrv_options); _task_block();}

I used code from examples and from a couple different posts here in the forums, but I was able to implement the DHCP before I understood MQX (this was the first RTOS I've ever used, even though I have done quite a bit of coding).  You can see that I only have the server setting up 3 addresses to assign, so you'll probably want to change that, but this is working well for me.  I am having problems with this not assigning addresses correctly to mobile devices after I put the GS1011 into standby mode and then wake it up, but I'll probably just end up shutting it down and bringing it back up when I need it.

 

The SPI mode worked for me immediately, I think I just got really lucky, but here is a question though, do you have an SD card inserted into the socket?  The SD card write protect line is connected up to the reset line so the wifi dies when you have a card inserted with the standard jumper settings, I changed J11 and J12, on the Wifi tower board, to both connect pins 2-3 and then I adjusted the driver to use the GPIO instead of the reset line and it started working just fine with an SD card.  I have my web pages stored on the SD card now, it's very convenient for web page debugging now that I don't have to recompile my code to change a web page.  Thinking back, the symptoms of this problem were different from what you are describing, but it is still something you may want to address.

 

Jeremy

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

 

thanks again for your quick reply. I will check on the DHCP server asap.

 

On the SPI story I checked it with no SD-Card inserted. Same result.
The error message is created in the gs_int.c file, just have a look:

................................

 

if(priv->rxrsp_len >= (GS_RESP_BUFFER_SIZE-1))
{
priv->rxrsp_len = 0;
_mem_zero(priv->rxrsp_buf,GS_RESP_BUFFER_SIZE);
GS_PRINT(1, "\r\nERROR: GS response buffer overflow\n");
}

......................................

 

I have a question: Are you using the same hardware as me, i.e. TWR K60 N512 plus TWR-SER? or are you using a different CPU. And: Are you working with IAR WB or are you using CW?


All the best

 

 

 

Thomas

0 Kudos

257 Views
hubje3
Contributor II

Thomas,

 

I am using the same hardware as you, but I am using Codewarrior 10.2.  Have you tried to pause the program at that point and find out how big priv->rxrsp_len is when there is an overflow?  If it is only a couple bytes bigger than GS_RESP_BUFFER_SIZE and it is pretty consistent, personally, I would try increasing the buffer size to see if it makes the driver work.  It would increase the memory overhead of the driver but that may or may not be an issue for you.

 

It looks like in my gs_prv.h file GS_SPI_RX_BUF_MAX_SIZE is set to 2048 and GS_RESP_BUFFER_SIZE is 3000.  Are those set differently for you?  I can't remember if I have ever changed those.

 

Let me know what you find,

 

Jeremy

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

 

I checked it with GS_RESP_BUFFER_SIZE is 4000 (before 3000), no luck.

 

I think, I have to check the code against the driver description from GainSpan :-((

 

I will also ask  CarlFST60L whether he was successful in the end.

 

By the way: are you using MQX 3.8 or 3.7 with your application. I'm using 3.7.

 

All the best

 

 

Thomas

0 Kudos

257 Views
hubje3
Contributor II

Thomas,

 

That is too bad about the bigger buffer, did you check to see how much data came back when it was complaining about the overflow?  I am currently using MQX 3.8.1 but I started using 3.7, then I migrated it to 3.8 before I got to this point.

 

Good Luck,

 

Jeremy

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

 

another question: you mentioned in one of your earlier replies, that you also programm html files and use an SD card as the storage place for it. If have done this also and it works pretty good. But I do it manually, i.e I'm loading the html file from a PC onto the SD card and than place it it into the card holder of my MCU board.

 

More elegant would be, to load it via USB from a PC, as to say from the back and that use it with the webserver and a tablet from the front. I checked the USB examples, but I didn't find an "USB stick" example with a SD card. What way are you using?

 

All the best

 

 

Thomas

0 Kudos

257 Views
hubje3
Contributor II

Thomas,

 

Congratulations on getting it working, that is great to hear.  I updated my module as soon as I got it because the AP mode (which is the main reason we chose this module) isn't supported in the previous firmware versions.

 

Concerning the SD card question, I do it exactly how you do it, I load the html onto the SD card then manually place it into the tower board, if you wanted to make it so the tower board came up as a mass storage device, and the memory available was the SD card, that would be very convenient.  Looking in \Freescale MQX 3.8\usb\device\examples\msd\disk there is a readme which states "This demo is basically just a building block for communicating to a USB host via exchanging files, many applications can be built this way, like a removable media reader (SD card, or other)."  So with a little bit of implementation you can do exactly what you mentioned.

 

Jeremy

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

its me again, Thomas.

Could you do me a favour: DHCP- Server is running, thats the good news. The bad news is: It takes about 60 to 80 seconds, to get an IP- address, etc on my iPad or iPhone. I checked the IRQ_A line with an oscilloscope. A lot of activity is going on on that line, but as I said it takes that period of time. I checked it 15 to 20 times with a stop watch (apple based of course :-))

Could you check how long it takes on your application or do you have any idea, why it takes so long to get an IP adress on my devices. If I'm connecting to my internet  router, it's there, right away. Less than second.

All the best

Thomas

Ps: If you think, it's more convenient to use an e-mail address, just use th@thomnet.de. If you like to keep your privacy, this forum is also fine with me. Thanks anyway.

0 Kudos

257 Views
danielchai
Senior Contributor I

Hi Thomas,

I am facing the same problem now.

Did you solve the problem?

Thank you.

-Daniel

0 Kudos

257 Views
ThomNet
Contributor III

Hi Daniel,

I reduced the amount of routers down to 0. This creates a much more faster reaction time showing the IP address and the subnet mask on my iPhone / iPad. A router IP address of course than is not showing up. Try this:

……

routers[0] = 0xC0A80001;
// routers[1] = 0xC0A80005;
// routers[2] = 0xC0A80006;
DHCPSRV_option_addrlist( &optptr, &optlen, 3, routers, 0);
/* Serve addresses 192.168.0.129 to 192.168.0.135 inclusive: */
DHCPSRV_ippool_add(0xC0A80081, 7, &dhcpsrv_data, dhcpsrv_options,optptr - dhcpsrv_options);

…..


That should help.


Good luck


Thomas

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

 

I found the reason, why it was not working like yours. I thought: "The only difference between your application and my application is the GS board. So it could or must be a different  firmware??" I updated the firmware of my board, as it is described in the doc's. And ... it works! Great!

 

Thanks again for all your support!

 

Now I will try to make your DHCP- server to run.

 

Stay in touch

 

 

Thomas

0 Kudos

257 Views
ThomNet
Contributor III

Hi Jeremy,

it's Thomas again, a voice from the past. I hope, you doing fine!?

Are you planning to use the Gainspan application, we were discussing several times about, in MQX 4.0? Or are you already using MQX 4.0 successully with the Gaispan application.

All my best

Thomas

0 Kudos