WinterMute, maybe you want to move this thread to the bug reports forum?
melw, thanks for chiming in... that explains why the CVS seemed in repose.
I'm happy to say that I actually found the exact cause of my problems, and it makes total sense as to why no one else is having a problem.
I have MAC address filtering enabled on my wireless router. The bug I isolated in r26 incorrectly writes the bytes read from the firmware into the main WifiData structure. So with my MAC address wrong in this structure, my AP was rejecting the connection because the packet headers had an incorrect MAC that didn't correspond with the correct MAC I pulled from the DS WFC interface when setting my routers' ACL.
Thanks to diff, this wasn't horribly agonizing. Just a bit painful. For reference, I used:
- Code: Select all
diff -urNp -x '*svn*' dswifi-src-0.3.7 dswifi-src-0.3.8 > dswifi.patch
on the two directories to get the differences between the versions, excluding the svn nonsense. It didn't actually strike me at this time that I was looking in CVS previously and the latest source packages are full of SVN tags. Anyway, the important bits of the patch follow.
First in wifi_shared.h:
- Code: Select all
@@ -225,17 +225,18 @@ typedef struct WIFI_MAINSTRUCT {
u16 curChannel, reqChannel;
u16 curMode, reqMode;
u16 authlevel,authctr;
- u32 flags9, flags7, reqPacketFlags;
+ vu32 flags9, flags7;
+ u32 reqPacketFlags;
u16 curReqFlags, reqReqFlags;
u32 counter7,bootcounter7;
- char MacAddr[6];
+ u16 MacAddr[3];
u16 authtype;
u16 iptype,ipflags;
u32 ip,snmask,gateway;
// current AP data
char ssid7[34],ssid9[34];
- u8 bssid7[6], bssid9[6];
+ u16 bssid7[3], bssid9[3];
u8 apmac7[6], apmac9[6];
char wepmode7, wepmode9;
char wepkeyid7, wepkeyid9;
So the MacAddr member of the WIFI_MAINSTRUCT structure was changed to a u16 array from a char array.
Now the juicy part in wifi_arm7.c:
- Code: Select all
@@ -885,7 +861,7 @@ void Wifi_Init(u32 wifidata) {
// load in the WFC data.
GetWfcSettings();
- for(i=0;i<6;i++) WifiData->MacAddr[i]=ReadFlashByte(0x36+i);
+ for(i=0;i<3;i++) WifiData->MacAddr[i]= ReadFlashByte(0x36+i) + (ReadFlashByte(0x36+i+1)<<8);
W_IE=0;
Wifi_WakeUp();
This loop doesn't write the data to MacAddr as intended. After the loop, MacAddr is filled with the bytes from the following firmware addresses : 0x36, 0x37, 0x37, 0x38, 0x38, 0x39. The intention is obviously to write the bytes from 0x36, 0x37, 0x38, 0x39, 0x40, 0x41.
changing this line to:
- Code: Select all
for(i=0;i<6;i++) ((char*)WifiData->MacAddr)[i]=ReadFlashByte(0x36+i);
corrects the problem.
After changing this code, rebuilding dswifi and default_arm7, now I can connect to my AP without a problem using r26!
I also found another bug in the code while I was meandering about. In wifi_arm9.c, the function Wifi_GetData(...) is defined as:
- Code: Select all
int Wifi_GetData(int datatype, int bufferlen, unsigned char * buffer) {
int i;
if(datatype<0 || datatype>=MAX_WIFIGETDATA) return -1;
switch(datatype) {
case WIFIGETDATA_MACADDRESS:
if(bufferlen<6 || !buffer) return -1;
for(i=0;i<6;i++) {
buffer[i]=WifiData->MacAddr[i];
}
return 6;
case WIFIGETDATA_NUMWFCAPS:
for(i=0;i<3;i++) if(!(WifiData->wfc_enable[i]&0x80)) break;
return i;
}
return -1;
}
The line:
- Code: Select all
buffer[i]=WifiData->MacAddr[i];
should be:
- Code: Select all
buffer[i]=((unsigned char*)WifiData->MacAddr)[i];
I'm glad to have found the problem... I'm surprised that other issues in dswifi didn't arise because of this. At least now I know it wasn't just me, and plugged potential problems from this in the future. Glad to be able to give back to devkitPro.
Just wanted to take this opportunity to thank all you guys, WinterMute, Chishm, Sstair, Joat, et al. You've done a great service to the community by opening up all sorts of new possibilities for owners of the devices targeted by devkitPro.
Cheers.