Jump to content

Weird DSWiFi connection Problem (and a partial solution)


Magin
 Share

Recommended Posts

lokicat: thanks - I'll look into it further.

Please note that the -O0 'trick' is just that, it's not changing anything except for how optimized the code is - if there are timing-specific problems, it has the potential to change them, but it is generally not fixing anything unless the compiler is broken... which it's not.

 

As somebody who's written a compiler or two, I understand what -O0 is doing. I'm stoked on -O0 because it takes me from being totally unable to connect to any access point, period, to having somewhat unstable wireless access, which is huge improvement.

 

Also as somebody who's written a compiler or two, I can't say I'm very confident the compiler's not broken, just maybe that its brokenness isn't the cause of this problem. All compilers tend to be broken in one way or another... :huh:

 

I still don't know what the problem is, but I'll do what I can to find out...

 

Awesome. If there's anything I can do to help just say the word.

Link to comment
Share on other sites

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

There are more people with the same problem as i see in the lasts topics.

Surelly a part of wifi_lib never worked and no one noticed because the older DS has already the correct sets by default and the very new ones does not have them correct. For much i look in the code i dont see anything suspicious, sgstair has do a awesome job and all registers are defined volatile as they must be, so find what is bad optimised will be very hard...

Link to comment
Share on other sites

There are more people with the same problem as i see in the lasts topics.

Surelly a part of wifi_lib never worked and no one noticed because the older DS has already the correct sets by default and the very new ones does not have them correct. For much i look in the code i dont see anything suspicious, sgstair has do a awesome job and all registers are defined volatile as they must be, so find what is bad optimised will be very hard...

 

LOOOOOOOOOOOOOOOOOOOOOOOL

I finally hunted down the BUG!!!!!!!!!!!!!!!!!!

 

in the function:

 

void Wifi_WakeUp() {

u32 i;

WIFI_REG(0x8036)=0;

for(i=0;i<100000;i++) i++;

WIFI_REG(0x8168)=0;

 

i=Wifi_BBRead(1);

Wifi_BBWrite(1,i&0x7f);

Wifi_BBWrite(1,i);

for(i=0;i<400000;i++) i++;

 

Wifi_RFInit();

}

 

must change the u32 i to volatile u32 i

so it remains

 

void Wifi_WakeUp() {

volatile u32 i;

WIFI_REG(0x8036)=0;

for(i=0;i<100000;i++) i++;

WIFI_REG(0x8168)=0;

 

i=Wifi_BBRead(1);

Wifi_BBWrite(1,i&0x7f);

Wifi_BBWrite(1,i);

for(i=0;i<400000;i++) i++;

 

Wifi_RFInit();

}

 

Explanation: being smart as is the compiler it has tought that the "for" only maked the i value 100000 and 400000 so it simplified it to a asignation, making it to not wait the time expected here to init the hardware.

The volatile makes no optimize the fors.

 

Surelly old DS comes with Wifi kinda activated on power on and the news ones not, and because of it no one noticed until now.

 

 

Please lokicat and moncul test the changes and post here the results

 

Now we have to make the change on the ofical wifi_lib and wait for the autors recompile their aps :clapping:

 

P.D.: If they put this change in the source, dont forget to put a litlle credit for me :clapping:

Link to comment
Share on other sites

Magin: Yes, that's exactly what the problem is. I suspected it was the other day, and mentioned it to crediar on IRC, but I haven't done anything about it yet. The better solution (and what the nintendo driver uses) is to call the swi delay function, rather than running around in a waitloop. I'll try to get this fix put in the lib soon, regardless of how it gets implemented.

 

-Stephen

Edited by sgstair
Link to comment
Share on other sites

Yes, the optimisation I believe would see those 2 for-loops as time-wasters (which they are) and would "optimise" the code - that is, remove the loops. Well done for spotting it. :clapping: I don't have a DS so I can't do any testing or whatnot for you.

Link to comment
Share on other sites

Please lokicat and moncul test the changes and post here the results

 

You're right Magin !!!

I made the change, recompiled (with original makefile : without -O0 of course) the dswifi lib then the wifilibtest and it works perfectly !

Very impressive !

i hope the dswifi lib will be released with taht change so many non open-source homebrews will work for everyone !

 

Congratualtions !

Edited by moncul
Link to comment
Share on other sites

  • 4 weeks later...

I have the following problem =

Normally homebrew with the wifilib dont works.

But the recompilled wifilib-text app with this fix works.

Now Iv tried to fix the wifilib by myself, but it dont works.

Iv downloaded the src, changed and compilled, then Iv pasted the 2 folders into the lib and compilled some test apps, but anythink works.

 

Can maybe someone upload the compilled files with this fix D: ?

Link to comment
Share on other sites

I have the following problem =

Normally homebrew with the wifilib dont works.

But the recompilled wifilib-text app with this fix works.

Now Iv tried to fix the wifilib by myself, but it dont works.

Iv downloaded the src, changed and compilled, then Iv pasted the 2 folders into the lib and compilled some test apps, but anythink works.

 

Can maybe someone upload the compilled files with this fix D: ?

 

I've been suffered from this problem too.

I couldn't make it by myself, so I asked a Japanese programmer named Rudolph.

Here's his blog.(Unfortunately, all the stuffs are Japanese)

http://blog.so-net.ne.jp/Rudolph/

 

I can translate it for you, but you should keep in mind that I'm not so good at English and Japanese because I'm Korean.

 

Below is the contents from the Rudolph's blog.

 

WiFiを使用するHomebrewなソフトについて、現在分かっていることを

まとめておきます。

I'm arranging what I know about bunch of problems of homebrew softwares which uses Wi-fi connection.

 

当然正規のゲームでは問題ないのですが、devkitProのlibdswifiに不具合が

あるため以下のDSではWiFiが動作しません。

It is natural that there's no problem with DS games, but because devikit pro and libds have problems, it is impossible to connect on the Wi-fi homebrew with DSs listed below.

 

①Firmware用に512KBのFlashが搭載されている機種(iQueDS、韓国向DS、台湾向DS...)

①DSs which are loaded with 512KB of Flash memory for the firmware.(iQueDS、Korean version of DS、Taiwan version of DS...)

 

②最近のDS(詳細不明)

②Newest DS(Don't know about detailed things)

 

①については、Flashのサイズが変わったことによりユーザの接続情報が格納されている

アドレスが変更になっているようです(0x03FA00から0x100*4が、0x07FA00からに変更)。

In the case of no.①, I think the address where the user connedtion settings are loaded is changed, according to the change of the size of flash memory.(The address from 0x03FA00 to 0x100*4、is changed to start from 0x07FA00)

 

②のタイプについては詳細は不明ですが、最近出荷されているDSでは搭載されている

RFユニットが変更されているのか電源ON時の初期状態でWiFiが無効(Shutdown)に

なっているようです。libdswifiのWifi_WakeUpが正常に動作していない為、動作しません。

I'm not sure about details but, in the case of no.②, the change on RF unit of the newest DSs is not enabled to use Wi-fi connection(the state of shutdown) when the power is switched on. Because Wifi_WakeUp of libdswifi is not working properly, Wi-fi connection is not working either.

 

wifi_arm7.c」 (上記2点を修正したlibdswifi 0.3.1のwifi_arm7.cのソース)

wifi_arm7.c」 (The source of wifi_arm7.c from libdswifi 0.3.1 that solved the problems of ① and ② mentioned above)

 

libdswifiを使って作成された、WiFiを使用するHomebrewなソフトを強制的に動かす為の

パッチも公開します。

I'm releasing the patch that forces to work the Wi-fi Homebrews which are based on libdswifi.

 

①に対応する為のパッチ(通常のFlashが256KBのDSでは当ててはいけません)

The patch to solve the problem ① (Attention: This patch should not be applied on old DSs which uses 256KB of flash memory)

 

   "FE 0B 80 E2 02 0C 80 E2" を検索して、そこを

  "7F 0A 80 E2 0A 0C 80 E2" に、8byte書き換える

   Find "FE 0B 80 E2 02 0C 80 E2" with your HEXCODE Editor(such as UltraEdit etc.,)

  Change into "7F 0A 80 E2 0A 0C 80 E2"

 

 

 

②に対応する為のパッチ(チョット強引だが、全てのDSで使用できる?)

The patch to solve the problem ① (It is somewhat compulsive but I wonder this might be used by all DSs)

 

   "81 1C 83 E2 02 39 83 E2 10 40 2D E9 B6 23 C3 E1" を検索して、そこを

   "01 1C 83 E2 10 40 2D E9 B6 23 C3 E1 0D 00 00 EB" に、16byte書き換える。

   Find "81 1C 83 E2 02 39 83 E2 10 40 2D E9 B6 23 C3 E1"

   and change into "01 1C 83 E2 10 40 2D E9 B6 23 C3 E1 0D 00 00 EB"

 

   そこから56(0x38)Byte後の

   56(0x38)Byte from that address, you could find these addresses

 

   "10 40 BD E8 XX FF FF EA 04 E0 2D E5 40 00 A0 E3" -

   "XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX" の部分を

   "01 00 00 EB 10 40 BD E8 1E FF 2F E1 06 28 A0 E3" -

   "02 28 82 E2 01 20 52 E2 FD FF FF 1A 1E FF 2F E1" に、32byte書き換える。

   (XはVerにより不定)

 

   Change the address "10 40 BD E8 XX FF FF EA 04 E0 2D E5 40 00 A0 E3" -

   "XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX"

   into "01 00 00 EB 10 40 BD E8 1E FF 2F E1 06 28 A0 E3" -

   "02 28 82 E2 01 20 52 E2 FD FF FF 1A 1E FF 2F E1"

   (XX varies with the version of libdswifi)

 

一応、DSLiveWeatherで動作を確認しましたが、いつもの通り責任は持てません。

特に②のパッチは強引で、Wifi_Shutdown()を潰していますのでソースが公開されている

場合は修正したwifi_arm7.cでリビルドした方がいいです。

I confirmed working with DSLiveWeather but, as usual, I don't have any responsibilities for applying this patch.

Especially, it is recommended to rebuild the source code with corrected wifi_arm7.c when you have the source of the Wi-fi homebrew because the patch no.② is quite compulsive that it is ignoring Wifi_Shutdown().

Edited by nin187
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...