gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > dswifi packet capture

#175690 - Wuschmaster - Mon Jan 17, 2011 4:10 pm

I'm trying to capture some frames and while it does work fine with broadcast frames (target ff:ff:ff:ff:ff:ff), it does not for any other frames. I simply don't receive anything else.

This is how I initialize dswifi:
Code:
   Wifi_EnableWifi();
   Wifi_SetChannel(1);
   Wifi_SetPromiscuousMode(1);
   Wifi_RawSetPacketHandler(PacketCaptureHandler);

From what I understand, Wifi_SetPromiscuousMode(1); should enable capturing even frames being sent to other devices, but it doesn't work.

While searching through Google for a few hours, I noticed some other people stumbled upon the same problem.
I also heard that changing some register might help, like so: WIFI_REG(0x80D0)=8095;
However, I have absolutely no idea how to do this from arm9 source...

Can anyone please help me? My project is currently arm9 cpp only.
Thanks!

#175691 - elhobbs - Mon Jan 17, 2011 6:18 pm

wifi registers cannot be set from arm9. there are currently no APIs in dswifi to set arbitrary wifi registers from the arm9. so this cannot be accomplished without arm7 code. one solution would be to create a custom fifo handler to send the register location and value from the arm9 to the arm7 where it can be set.

#175692 - Wuschmaster - Mon Jan 17, 2011 8:28 pm

Since I'm not really experienced with arm7/arm9 IPC yet, I tried putting them into arm7's VblankHandler() function:
Code:
#define WIFI_REG(ofs) (*((volatile u16 *)(0x04800000+(ofs))))
Code:
void VblankHandler(void) {
   Wifi_Update();
   WIFI_REG(0x80d0)=8095;
}

But it doesn't seem to change anything. :(

I also tried these which I found somewhere else:
Code:
   WIFI_REG(0x80D0) = 8095; // filter nothing important... ?
   WIFI_REG(0x8194) = 0x05; // true raw tx enable? (allows duration field on data packets to TX as specified)
   WIFI_REG(0x81A0) = 0x91D; // makes DS actually receive stuff!

Changing 0x81A0 to 0x91D results in receiving NO frames at all. The other two registers don't seem to change anything.
And these:
Code:
   WIFI_REG(0x8012)=0x703f;
   WIFI_REG(0x81ae)=0x1fff;
   WIFI_REG(0x80d0)=0x0301;
   WIFI_REG(0x80e0)=0x000d;
   WIFI_REG(0x8008)=0xe000;
   WIFI_REG(0x8004)=0x0001;

But nothing changed.

Would this method of changing the registers (in VblankHandler) even work?

#175693 - Wuschmaster - Tue Jan 18, 2011 12:19 pm

I tried something else (waiting 120 frames and then change the registers in arm7), and it has the same effect (changing 0x81A0 to 0x91D resulting in receiving NO frames at all).
So I'm positive I do change registers successfully.

But this also means that this does not fix the issue at all.

Does anyone know of another solution to receive ALL frames and not just broadcast ones? Any idea is much appreciated.

#175695 - elhobbs - Tue Jan 18, 2011 1:22 pm

80D0 and 80E0 are known to be receive related. But I am not sure anyone knows what 81A0 does. gbatek speculates that it is power related. Have you verified with a packet sniffer that there are packets to receive? Also one the articles points out that they could not get privacy enabled packets to be received without being connected to an AP.

Though to directly answer your question - no, I do not think anyone knows. The question has been asked quite a few times and no one has ever come up with a solution.

#175697 - ritz - Tue Jan 18, 2011 2:55 pm

I don't know anything about ds wifi stuff, but there's some new information about it in the newer gbatek (v2.6a). You can download it here: http://forum.gbadev.org/viewtopic.php?t=16867

Here's some of the new/changed info:

Quote:
- nds/wifi/help: added port 24Ch/24Eh/250h, 264h/270h, 2A4h/2C4h, 2C8h/2CCh info
- nds/wifi/help: added W_TX_HDR_CNT port 194h bit0,1,2 info (thanks Tim Seidel)
- nds/wifi/help: added 1D0h..1DFh info, added notes on body[2] instead txhdr[2]
- nds/wifi/help: confirmed 0B4h.Bit6, added 030h.Bit7, added info on 094h/098h
- nds/wifi/help: removed incorrect/unconfirmed rxbuf_begin/end-latching-info
- nds/wifi/help: added txhdr[2], port[0C0h], port[0C4h], renamed EXTRA to CMD
- nds/wifi/help: renamed W_RXUNITS to W_RXTX_ADDR and moved it to status chapter
- nds/wifi/help: added notes on registers affected by powerforce (and by irq13)
- nds/wifi/help: added RF2958 (aka RF9008) datasheet info (thanks Tim Seidel)

Hopefully it'll help.

#175699 - Wuschmaster - Tue Jan 18, 2011 4:00 pm

Ah, just found out something! For testing purposes, my arm9 code temporarily filtered to store only the 03:09:bf:00:00:10 frames. (The ones from DS Download Play transfers.)

With "WIFI_REG(0x80d0) = 8095;", it DOES capture frames other than broadcast just fine, for example those targeted to 03:09:bf:00:00:00 and 03:09:bf:00:00:03 -- but for some reason not ones for 03:09:bf:00:00:10.

Not sure why, but I can get at least everything else (I think). So thanks for your help and sorry for the stupid error on my side.

#175703 - elhobbs - Tue Jan 18, 2011 6:03 pm

I think the frame you are getting have the toDS bit set meaning they are meant for an AP. But if you are getting all you need then I guess it does not matter.

#175713 - wintermute - Thu Jan 20, 2011 1:07 pm

The DS wifi hardware is limited to 2mbit, anything transmitted faster than that will not be captured.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog