View unanswered posts | View active topics It is currently Fri Nov 16, 2018 4:31 pm

Reply to topic  [ 8 posts ] 
 Wii - debug through wifi 
Author Message

Joined: Wed Apr 25, 2012 6:12 pm
Posts: 3
Since the new Wiis no longer have a gamecube port for gecko debugging, what is the feasability of wifi debugging?

It seems like you should be able to put a server into GDB and route the gecko routines to it.

I imagine if it was this simple, then it would have been done by now, so I am wondering what makes this not feasible? It should be able to be a least used for some printf debugging.


(my first post disappeared, so if this gets double posted, sorry.)

Wed Apr 25, 2012 6:55 pm
Site Admin

Joined: Tue Aug 09, 2005 3:21 am
Posts: 1300
Location: UK
Wifi on the Wii is handled entirely by starlet (including the tcp/ip layer) and the powerpc communicates with starlet using interrupts. This makes it rather difficult to implement a reliable gdb stub since it obviously can't communicate with the host gdb when interrupts are disabled. Enabling interrupts will obviously allow parts of your application to continue running which is then likely to cause the whole thing to fall apart when the stub is waiting for commands while halted.

I'm not saying it's impossible but all tests so far have failed quite badly - stepping and continuing between breakpoints just freezes after several iterations.

Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

Sun May 06, 2012 12:06 am
Profile ICQ WWW

Joined: Thu Dec 10, 2009 9:26 am
Posts: 40
Communication to starlet doesn't require interrupts, you can poll the IPC register to see if a response is ready. But there are also other issues that need to be fixed to make the debug stub more reliable overall (don't rely on the stack being usable in the default exception handler, don't use r2/r13 relative accesses inside the debug stub code, etc).

Sun May 06, 2012 5:17 am

Joined: Wed Apr 25, 2012 6:12 pm
Posts: 3
I have just been trying wifi code from elsewhere and it seems to work:

The section on "run the net_print server" does not work as is. The code supplied in wii_dev_debug\net_print\sockettest\source\net_print.c does not work as is with IP addresses.

Easily fixed with this code:
static int clientsocket(const char *rhost, unsigned short port)
  struct hostent *ptrh;  /* pointer to a host table entry     */
  struct sockaddr_in sad;/* structure to hold server's address*/
  int    fd;             /* socket descriptor                 */

  memset((char *)&sad, 0, sizeof(sad)); /* clear sockaddr structure */
  sad.sin_port = htons((u_short)port);

   struct in_addr myaddr;

   if (inet_aton(rhost, &myaddr))
      // setup 'sa' with binarified address and a couple other things
      sad.sin_family= PF_INET;
      sad.sin_len = sizeof (struct sockaddr_in);
      sad.sin_port= htons (port);
      memcpy ((char *) &sad.sin_addr, &myaddr.s_addr, sizeof(struct in_addr));
      /* Convert host name to equivalent IP address and copy sad */
      sad.sin_family = AF_INET;  /* set family to Internet */
      ptrh = net_gethostbyname(rhost);
      if (((char *)ptrh) == NULL)
         fprintf(stderr, "invalid host: %s\n", rhost);
         return (-1);
      memcpy(&sad.sin_addr, ptrh->h_addr, ptrh->h_length);
  /* Create a socket */
  fd = net_socket(PF_INET, SOCK_STREAM, 0);
  if (fd < 0) {
    fprintf(stderr, "socket creation failed\n");
    return (-1);;
  /* Connect the socket to the specified server */
  if (net_connect(fd, (struct sockaddr *)&sad, sizeof(sad)) < 0) {
    fprintf(stderr, "connect failed\n");
    return (-1);

  return fd;

But that code does not really matter, it is just a sample. All we care about is the debug library.

The library supplied overwrites the normal libdb.a. A better way world be to merge in the code and add it a DEBUG_Init device_type. Maybe called GDBSTUB_DEVICE_WII_TCP


Tue May 08, 2012 5:20 am

Joined: Wed Apr 25, 2012 6:12 pm
Posts: 3
Further testing of that code shows that it seems to work if the program is well behaved. Stack dumps cause problems for it. And it does seem to loose sync with the tcip on occasion. :(

Oh well, at least I might be able to use the net print stuff to do some printf debugging. Beats getting up, removing the SD card with my fprintf logs, putting it in the computer, ... :)

Tue May 08, 2012 6:38 am

Joined: Fri Nov 06, 2009 1:50 pm
Posts: 11
Would it be possible to run a ppc version of gdb on the wii itself? Or would that suffer from the same interrupt issues?



Fri Aug 10, 2012 5:56 pm

Joined: Mon Feb 24, 2014 2:57 pm
Posts: 1

Did you manage to actually get GDB client to communicate to the wii? My GDB is dumping a message, " unrecognized item "timeout" in "qsupported" fixed in linux ".

Mon Feb 24, 2014 3:23 pm

Joined: Wed Mar 23, 2011 2:54 am
Posts: 12
@DRS, you can't run your program and gdb at the same time on the Wii. The Wii "os" isn't designed to be multitasking.

Sun Dec 28, 2014 6:40 am
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at Fast, secure and Free Open Source software downloads