Latest KOS network system

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
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Latest KOS network system

Post by SWAT » Mon May 23, 2011 8:09 am

Hi everyone!
I have a problem with KOS net. During BBA initialization, DC stopping (and dead), if use the latest revisions of KOS.
I can not understand why. At the same time dc-tool-ip works. But do not work, even the most simple examples from kos/examples/dreamcast/network.
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5469
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 3 times
Been liked: 24 times
Contact:

Re: Latest KOS network system

Post by BlueCrab » Mon May 23, 2011 10:18 am

The problem is most likely that the network hasn't been configured properly in the flashrom to match what dcload is expecting. Make sure the flashrom has been configured with the same static IP that you're using to upload with dcload-ip, otherwise when the KOS network system takes over, fs_dclsocket will not be able to connect to the PC.
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Mon May 23, 2011 10:42 am

I'm using "KOS Network Settings" saved to VMU and configured as dc-tool.
But I'll try putting settings and to flashrom, thank you.

Updated.
Oh, bba_set_ispcfg() in bba_init() IMHO this is bad idea... "KOS Network Settings" in this case not work.
Image
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Mon May 23, 2011 10:20 pm

There is information when expected TCP/IP stack? I would like to using kos net without lwip.
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5469
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 3 times
Been liked: 24 times
Contact:

Re: Latest KOS network system

Post by BlueCrab » Mon May 23, 2011 10:38 pm

Its somewhat complicated why bba_init() does the network init from the flashrom when it does.

Essentially, bba_init() has to take over all network communications, since it ends up hooking the interrupts and everything else. At that point, the underlying dcload code no longer has control of the network card and you cannot communicate with the host dc-tool. In order to minimize the amount of time that you cannot do any debug printfs and the like (and to make sure that dc-tool on the host doesn't start freaking out), the whole sockets layer and fs_dclsocket must be initialized as soon as possible. The only logical way to do this is to init from the flashrom as soon as possible... That's why I wrote it that way.

As for TCP support, my only answer is when I get the time and patience to do it. With any luck, it'll be sometime in the next few months, but I can't promise anything. I'm also trying to clean everything up in KOS for an actual release sometime in the window of this summer. I'm only one person though, and I have other projects and such that compete for my time as well.
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Tue May 24, 2011 12:45 am

Maybe replace it to netcfg_load? So i did.

You're doing a very good job, thank you for it. It is a pity that you are one doing it.
I'd be very happy about tcp/ip. At least you have started work on this?

And the last question. Can work kos net and lwip at same time without conflicts?
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5469
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 3 times
Been liked: 24 times
Contact:

Re: Latest KOS network system

Post by BlueCrab » Tue May 24, 2011 1:13 am

SWAT wrote:Maybe replace it to netcfg_load? So i did.
netcfg_load is in libkosutils, and not in the main kernel of KOS. That is part of the reason that replacing the way I do things with netcfg_load isn't a good idea. Doing so would force every KOS program to link with libkosutils, which is not something I'm going to do.
You're doing a very good job, thank you for it. It is a pity that you are one doing it.
I'd be very happy about tcp/ip. At least you have started work on this?
In short: no.

Longer version: I have a partial TCP implementation that is very buggy and basically needs to be rewritten from scratch.
And the last question. Can work kos net and lwip at same time without conflicts?
I wouldn't have any idea. I've not even tried to use lwip for a very long time. That said, its pretty pointless to be trying to use both of the network stacks at the same time. If KOS' built-in network stack doesn't provide what you need, just use lwip. You can always change your code later if you decide to switch over to the built-in network stack.
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Tue May 24, 2011 2:52 am

netcfg сould be moved in the kernel ;)
Ok, thanks for answers!
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5469
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 3 times
Been liked: 24 times
Contact:

Re: Latest KOS network system

Post by BlueCrab » Tue May 24, 2011 8:09 am

SWAT wrote:netcfg сould be moved in the kernel ;)
Ok, thanks for answers!
I'd prefer not to move pieces into the kernel like that. You can still use netcfg to actually configure things, its just that in order to use dcload support with it, the flashrom must have the right values stored in it.

For released versions that you wouldn't be using dcload with, netcfg will still work just fine as it is. The only time the information needs to be in the flashrom is for using dcload debugging over KOS' internal network stack.
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Wed May 25, 2011 12:53 am

Yes, but it not help me :(
I tried to run the program without dcload and it hung in the same place.
I tried to clean up ISP settings loading and replace them with netcfg.
I tried to setup ISP settings in the PW3.
But no results for all, the program hangs when initializing BBA.
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5469
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 3 times
Been liked: 24 times
Contact:

Re: Latest KOS network system

Post by BlueCrab » Wed May 25, 2011 1:05 am

Is there any way you can narrow down where its crashing a bit more? Its rather hard to suggest things when I don't know exactly which piece isn't working. You could try using the framebuffer (for instance, drawing a string of text to the screen with the biosfont stuff) to help you to narrow down where the problem is coming from.

I assure you that the last time I changed anything network related, everything worked fine for me... :?
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Wed May 25, 2011 2:50 am

Ok, today I'll try and tell you where its crashing.
Image
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Wed May 25, 2011 7:39 am

Code: Select all

net_init: Detect and potentially initialize devices
lan_adapter: no device detected (wrong type = 0)
bba: MAC Address is 00:d0:f1:03:6a:31
Enable receive and transmit functions
Set Rx FIFO threashold to 1K, Rx size to 8k, 1024 byte DMA burst
Set Tx 1024 byte DMA burst
Enable FIFO auto-clear
Switch back to normal operation mode
Setup RX/TX buffers
Reset RXMISSED counter
Enable receiving broadcast and physical match packets
Filter out all multicast packets
Disable all multi-interrupts
Enable G2 interrupts
Enable receive interrupts 
Enable RX/TX once more
Initialize status vars
bba_if_init ok
Start the BBA RX thread.
Spin until the link is stabilized
Then wait for link_stable up to infinity. Timeout not work.
bba_irq_hnd only works once and does not reach the end (do not blink vid_border, green only).

Update.
When I uncommented to test vid_border_color in irg_hnd then dc rebooted at this point.
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5469
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 3 times
Been liked: 24 times
Contact:

Re: Latest KOS network system

Post by BlueCrab » Wed May 25, 2011 9:52 am

SWAT wrote:Then wait for link_stable up to infinity. Timeout not work.
bba_irq_hnd only works once and does not reach the end (do not blink vid_border, green only).

Update.
When I uncommented to test vid_border_color in irg_hnd then dc rebooted at this point.
So, its dying in bba_irq_hnd()? Could you do some more testing to try to narrow down where in the IRQ handler its dying?
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Wed May 25, 2011 10:52 am

BlueCrab wrote:So, its dying in bba_irq_hnd()? Could you do some more testing to try to narrow down where in the IRQ handler its dying?
I tried to do it.
I did debug on SD card. Dbglog wrote at the beginning of the handler after vid_border, but no writing to log, and vid_border was green and not blinking. When I removed the dbglog, but left vid_border, the DC began to restart at this point.
I try to debug this place tomorow with fb dbglog. Maybe writing to SD card does not work in interrupt.
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5469
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 3 times
Been liked: 24 times
Contact:

Re: Latest KOS network system

Post by BlueCrab » Wed May 25, 2011 4:35 pm

I'm not sure how you have the SD stuff hooking into the system. Its quite possible that the problem is coming because of the fact that before it inits the network if dcload is in use it switches dbglog to use scif (raw serial port access).

Its quite possible that might be what's confusing things if you're trying to use the SD card.
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Wed May 25, 2011 8:58 pm

No, i'm created dbglog handler with using sd card and switch to it before net_init() called.
The whole log that I wrote above was written by SD dbglog handler, it works well.
Image
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: Latest KOS network system

Post by SWAT » Thu May 26, 2011 11:22 am

Unfortunately could not test everything today. But concluded that the error occurs at the start of data transmission. Initialization works successfully. Once a request comes in, everything freezes. In the next few days will try to learn more.
Image
Post Reply