Networking with the BBA

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Chilly Willy
DC Developer
DC Developer
Posts: 414
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Networking with the BBA

Post by Chilly Willy »

I'm still having trouble with the networking. I just made a clean compile of the toolchain (based on gcc 4.4.4/binutils 2.20.1/newlib 1.18.0) and kos (from the repo). When I boot PlanetWeb v3.0, I have no trouble surfing the net from the DC, but when I have the cable plugged in and boot Doom, it crashes before ever reaching main() that I can tell. When I unplug the ethernet, it boots fine, but of course the networking is disabled.

The flags are

Code: Select all

KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET);
but otherwise I don't do anything net related before the GUI shows other than

Code: Select all

void dc_net_init (void)
{
	netif_t *netdev = net_default_dev;

	if (netdev && netdev->ip_addr[0]) {
		dc_net_available = 1;
		sprintf(dc_net_ipaddr, "%d.%d.%d.%d", netdev->ip_addr[0], netdev->ip_addr[1], netdev->ip_addr[2], netdev->ip_addr[3]);
		dc_net_dnssrv.sin_family = AF_INET;
		dc_net_dnssrv.sin_port = htons(53);
		dc_net_dnssrv.sin_addr.s_addr = htonl(*(int *)&netdev->dns[0]);
	} else {
		dc_net_available = 0;
	}
}
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Networking with the BBA

Post by Chilly Willy »

Just a bump and a question - I use SBI to make my discs, and I notice they stick a splash in front of the game. Could that be why the BBA blows up before even running the game? Is there a better way to make a bootable disc image?
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Networking with the BBA

Post by PH3NOM »

http://rapidshare.com/files/408728272/DATA2CDi_kos.rar

Data2CDi is a script to make CDi image from plain files.
Just place 1st_read.bin and all data in \DATA\ then run the .bat script.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Networking with the BBA

Post by Chilly Willy »

Thanks! I'll try that and see if it makes a difference on the networking.

Okay, found the problem. It was my fault. Think this is good? Works on any system I've ever used.

Code: Select all

dc_net_dnssrv.sin_addr.s_addr = htonl(*(int *)&netdev->dns[0]);
Nope! There's a little problem with that... the arrays in the net_if struct aren't aligned properly to do that. So you have to do THIS instead:

Code: Select all

dc_net_dnssrv.sin_addr.s_addr = htonl(netdev->dns[0]|(netdev->dns[1]<<8)|(netdev->dns[2]<<16)|(netdev->dns[3]<<24));
On an x86 or similar, it's not an issue - those processors don't care about alignment. The SH family does. If a long isn't on a long boundary, it causes an exception... which basically means the DC crashes.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 315
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 5 times
Been thanked: 1 time

Re: Networking with the BBA

Post by Neoblast »

I'm glad you managed to figure it out.
If you need people with BBA to test anything networking related count on Indiket and me.
User avatar
BB Hood
DC Developer
DC Developer
Posts: 189
Joined: Fri Mar 30, 2007 12:09 am
Has thanked: 41 times
Been thanked: 10 times

Re: Networking with the BBA

Post by BB Hood »

I was just wondering. Did you get an unhandled exception when your DC crashed? In the future you could do what they did in this thread: viewtopic.php?f=29&t=47741&start=0&st=0 ... +exception
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Networking with the BBA

Post by Chilly Willy »

BB Hood wrote:I was just wondering. Did you get an unhandled exception when your DC crashed? In the future you could do what they did in this thread: viewtopic.php?f=29&t=47741&start=0&st=0 ... +exception
No, I don't. It just hangs with a blank screen. I haven't got the DC setup to run in the debugger in any case, but I would like to have a default exception handler that let me know when it blew up and why. Getting an unaligned memory access fault vs divide by zero makes tracking problems easier. :lol:

Having gotten into the program with networking active, now I ran into a weirder bug - this line gives an empty string.

Code: Select all

		sprintf(dc_net_ipaddr, "%u.%u.%u.%u", netdev->ip_addr[0], netdev->ip_addr[1], netdev->ip_addr[2], netdev->ip_addr[3]);
Yes, the char array dc_net_ipaddr is big enough. It's not being overwritten by anything either. I've never seen sprintf fail like that. :?

It originally used %d instead of %u, but I changed them to see if it made a difference... it didn't.

EDIT: Found that problem - when I was editing this for the DC (this is a DC port of a PSP port of an AROS port of my AmigaPPC port of ADoom), I somehow lost one level of indirection on the ipaddr string. My GUI uses pointers to pointers to strings. I'm a little surprised it didn't just crash like the last bug. :lol:
User avatar
BB Hood
DC Developer
DC Developer
Posts: 189
Joined: Fri Mar 30, 2007 12:09 am
Has thanked: 41 times
Been thanked: 10 times

Re: Networking with the BBA

Post by BB Hood »

edit: NVM you fixed problem
Post Reply