Enterprise Forever

:UK => Hardware => Topic started by: lgb on 2015.March.24. 11:03:13

Title: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 11:03:13
A new topic ... I have just had a quick peek into the documentation of the winzet 5300 chip. It seems, 8 and 16 bit bus is supported, of course we need 8 bit. The other thing: accessing the "registers" can be done in two ways: indirect access only needs some ports, basically some allocated I/O ports would be OK. The direct access is different it needs 10 bit addressing information (if I remember correctly now). We can say, that indirect access is OK too, and it's more simple, but at the other hand it can be slower, as accessing a register needs extra work first (specifying the register number or so). Though I am not sure it's worth, if a given socket is connected and using the same register anyway for most of the time ... Anyway, in case of direct access, we need 10 bits. I guess it can be done with I/O ports. We know, that 16 bit I/O addresses in EP cannot be used easily  as Dave's "MMU" functionality also modifies the address if it's an I/O request and not memory. However, the lower 14 bits remains the same anyway. By allocating a 16 I/O port range in the low byte address, we need 10-4=6 bits more address lines which exactly the number of bits we have in the high byte address not modified by Dave anyway. The only problem with this: I/O addresses will be somewhat complex, we need 16 "valuable" "normal" I/O port range, and also we need to do 16 bit I/O. Maybe the solution is to use an EP memory segment as I/O (like with the SD card) is a better solution. Originally I thought using the BASIC cartridge is a good "playground" to connect the 830MJ module to the ROM socket, and maybe it is, just it's now in conflict with the widespread solution of the SD card cartridge recently ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Zozosoft on 2015.March.24. 11:16:54
I also think the memory mapped I/I the better solution.

What do you think: make a adapterboard which can be used for connect the module to any standard EPROM socket?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 11:40:43
I am just not sure, what about this 5V and 3.3V logic voltage issue, to be honest. Maybe it would be nice to get information on the MSX network cartridge with 5100, to see how the problem solved, the situation must be the same (well, at least I guess 5100 also a 3.3V chip basically ...) also the target system somewhat (Z80 with 5V logic levels as with the EP). It would be nice to be able to see the schematics of the DenYoNet card for MSX, that is. If it's really true that 5300 is 5V tolerant on inputs, that's OK, now about the opposite signal direction: TTL 5V high logic level starts at 2V AFAIK. CMOS is about 2/3 of the Vdd, with 3.3V it's 2.2V, so at least CMOS-like high logic level of a 3.3V device seems to be enough for an 5V TTL level device. But I am really unsure about this topic. Moreover, there are people using CMOS Z80 instead of the original NMOS in their EP. I was always unsure it does not mean any problem in the original EP with slightly different logic voltage levels even at the same power voltage, and it can be even more complex topic if we try to compare parts with different power voltage needs. Maybe I worry too much and (if 5300 is really 5V tolerant on inputs) EP and the module can be wired together without any logic level shifter or a more complex solution.

Quote
What do you think: make a adapterboard which can be used for connect the module to any standard EPROM socket?

:) Maybe (especially for developing the stuff, it's a good idea), but we need a WR line as well, which is traditionally does not connected to a socket designed to accept ROM chips too much ... Also where would you connect that adaptor then? Plugging into the BASIC cartridge is OK, but what if someone has an SD-card cartridge already and he wants to use that too? I guess it would be nice (but quite unrealistic ...) to have an SD-card cartridge version with a socket to be able to accept another component like the adaptor board for the 830MJ module or such. Again it would require a re-design the SD card cartridge to have that 1K free of memory space used by the module. That's why I think it's a bit unrealistic and some other solution would be needed anyway ...

Also which EP segment should be used ...

Currently, I am planning to hook up the 830 module with Raspberry Pi's GPIO connectors (also 3.3V) so I can "play" with it, and learn how it can be programmed before try to do that on the EP/Z80 ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 11:53:17
Another (now software) idea: an EXOS device can be easily implemented for HTTP as http URLS begins with HTTP: anyway. Using the wiznet chips the bulk of the work is done by the chip itself, so the driver would be quite trivial, but then, simple EXOS function can be used to access the web, sounds cool in my opinion :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Zozosoft on 2015.March.24. 11:56:34
I think the FTP: will more useful as EXOS device :-)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.March.24. 11:59:06
lgb hold on to your wiz830mj I have just started working on an Enterprise network interface using one of these. I'm not sure of all the differences between the 5100 and 5300 but I think they are basically the same but with more RAM on the 5300. The 5100 should do the job fine for the Z80 but as they are the same price might as well use the better part which is also more readily available (here in the uk anyway). Don't hold your breath though, it will not be instant and I've only just seriously started looking into it. :)
Wow, that sounds very interesting! Bruce, what are your thoughts about the interface? Direct or indirect addressing?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 12:13:52
I think the FTP: will more useful as EXOS device :-)

:) Maybe, but you can place downloadable EP programs with both of HTTP and FTP accessible  anyway :) I am not sure of wiznet supports for FTP "by hardware", FTP is a quite old and brain-dead protocol (I know because of being administrator of firewalls) which opens new data connection and there is active/passive version, 7/8 bit transfer, etc, For example traditionally "listing" the content of a directory on an FTP server means remote executing the 'ls' program on the server and grabbing the output (the format is even not so standard ...) though modern FTP servers work differently because of security and performance reasons as well. I always try to avoid using FTP if possible. HTTP also allows to "download" files (not just web pages) so I prefer HTTP everywhere. But if wiznet chips supports FTP as well, why not, of course.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.March.24. 12:28:55
The other thing: accessing the "registers" can be done in two ways: indirect access only needs some ports, basically some allocated I/O ports would be OK. The direct access is different it needs 10 bit addressing information (if I remember correctly now). We can say, that indirect access is OK too, and it's more simple, but at the other hand it can be slower, as accessing a register needs extra work first (specifying the register number or so).

At least with the W5100 you have 4 ports, if you are using the indirect access mode:
- Port 1: accessing the MODE register directly; this is needed, as only with this register you activate the indirect access mode
- Port 2,3: set address (high, low); here you select the address (0-32767 for the W5100)
- Port 4: data read/write; after setting the address you can read or write to the W5100 by using this port; addresses are incremented automatically, so when reading a sequence of bytes you only need to set the address once

The W5300 seems to be a little bit different here due to its larger ram, but I guess in principle it's still something like this.
Anyway, if it's easier to develop the hardware for the EP by using indirect access mode (so only 4 ports are needed), I would go for it! On the CPC it will be implemented in this way, too (and I already did the routines for this way of interface :D ). The reason is, that it doesn't matter so much, if you loose a little bit CPU time when you access the registers in the indirect way. The code for the CPC indirect access interface is even smaller than the code for the MSX memory mapped interface, as here you have to take care about where your own code and your own data buffers are located and all these slot switching stuff.
The important thing is the data transfer. In indirect mode you use INIR/OTIR instead of LDIR (or the unrolled variant). This is only a little bit slower but in my opinion still fine - we are still speaking about loading some hundret KB of internet data to our Z80 system in seconds :D
At the end its the decission of the hardware developer, and I am no expert here at all. But I am already prepared for both solutions :P
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.March.24. 12:48:38
:) Maybe, but you can place downloadable EP programs with both of HTTP and FTP accessible  anyway :) I am not sure of wiznet supports for FTP "by hardware", FTP is a quite old and brain-dead protocol (I know because of being administrator of firewalls) which opens new data connection and there is active/passive version, 7/8 bit transfer, etc, For example traditionally "listing" the content of a directory on an FTP server means remote executing the 'ls' program on the server and grabbing the output (the format is even not so standard ...) though modern FTP servers work differently because of security and performance reasons as well. I always try to avoid using FTP if possible. HTTP also allows to "download" files (not just web pages) so I prefer HTTP everywhere. But if wiznet chips supports FTP as well, why not, of course.
Oh, I didn't know that FTP is sooo bad. Dr.Zed coded the SymFTP client in 2007 and it seemed to work fine, but maybe not for all servers. Soon I should be able to resurrect it again :)
The Wiznet doesn't include any implementations for the application layer. So you have to implement FTP, HTTP etc. (using TCP) but also DNS and DHCP (using UDP) by yourself.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 12:52:32
Oh, I didn't know that FTP is sooo bad. Dr.Zed coded the SymFTP client in 2007 and it seemed to work fine, but maybe not for all servers. Soon I should be able to resurrect it again :)
The Wiznet doesn't include any implementations for the application layer. So you have to implement FTP, HTTP etc. (using TCP) but also DNS and DHCP (using UDP) by yourself.

FTP is stone aged, and "bad" indeed, however it's still widespread especially if you need to upload, manage directory structures etc too. Not because it's not supported by some HTTP stuff as well, the (Web)DAV is invented to do similar things, however DAV is not so much known by many people and mainly used inside software for specific problems, like repository control (SVN  - Subversion for example).
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 12:55:24
At the end its the decission of the hardware developer, and I am no expert here at all. But I am already prepared for both solutions :P

Wow, you are faster than my thoughts :) I was just about to ask you what MSX uses, direct or indirect with that DenYoNet. I tried to find information about DenYoNet (schematics, detailed description, programming etc) but not so much success yet, can you help in that? I guess it would help a lot to see how MSX guys solved the problems (or even cared at all ...) I talked about like logic level shifting. Anyway, maybe you're right and indirect access is more simple with using some I/O ports only, and nothing more ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Zozosoft on 2015.March.24. 13:00:52
I think not needed to support all ftp servers in the world. Just enought ftp.enterpriseforever.com or ftp.ep128.hu or something similar where will upload all Enterprise programs. :-) And developers can easy add the new programs.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 13:16:21
I think not needed to support all ftp servers in the world. Just enought ftp.enterpriseforever.com or ftp.ep128.hu or something similar where will upload all Enterprise programs. :-) And developers can easy add the new programs.

Ok, but then you can use http as well from Enteprise to download softwares (well, download, but if it's an exos device, you can even directly load, using the URL of course). It's a totally different topic, that the same file space on the server can be accessed via FTP too (for both of download and upload via ftp). In fact,most bigger ftp sites makes it possible to access the file space via http and ftp too (I have no idea about the mentioned ep related sites though). I guess w5300 (and 5100) does not support http neither ftp directly but plain tcp connections, implementing http over it is trivial, ftp is not so much. But enough is enough, let's end my war against ftp, not so much interesting anyway :)

In fact, it's even possible to put an EP program online which can be loaded directly to EP, and it allows you to browse some popular EP software sites directly with fetched information from the Net! So other than directory listing there can be some screenshots (suitable for EP to show easily) etc, it would be kinda cool, like an "AppStore" for mobile devices but for the Enterprise! :) I guess something similar can be done for SymbOS as well, and it's true there too: probably it's not even needed to "download and install" software, if files can opened directly "from the Net", so basically it's "run from the network instead of a local storage device" situation ...

It's again another idea is to implement an EXDOS drive through the network, so a disk image can be "mounted" remotely, read-only access at least would be a good start point. Well, it's about the current technology now, when virtualization hypervisors can use disk images remotely, EP would seem to be a quite decent platform :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.March.24. 13:29:12
One of my priorities is to keep it simple, otherwise I will be in danger of "biting off more than I can chew", or more than I have time for. To this end I thought the indirect I/O mode would be better/simpler. I hoped OTIR etc would work and I am pleased to here confirmation that it does!

Physically I hope to develop a vertical-mounting board with edge connector fingers at the bottom but also a edge connector socket on the left side just above the fingers. This way it could either plug into an expansion motherboard or directly into the side of the Enterprise. Then I was hoping to be able to solder a long thin board with just fingers on so a disk unit (or anything else!) could then plug into the back of the network board.  But I am waiting for the bits to try this for dimensions so it might not work. There would be links/jumpers/switches to either use SA0-SA2 from the expansion board or to set the ROM and I/O address if it was being used directly. I like the idea of it's own RAM so I thought 12k ROM (well, FLASH) and 4k RAM.

Software wise I was thinking FTP initially again for simplicity but HTTP is a good idea I hadn't thought of. Another possibility is the old SMB protocol that was around at the time (or soon after) which would allow interoperability with Windows PCs (I'm not sure about Linux etc.) This has some appeal to me personally because I did a lot of work using that protocol in '87 onwards when I wrote a replacement for IBM's NET program for the IBM PC. Again for simplicity I was hoping the EXOS side of things could work synchronously without interrupts (I'm not sure what the effect of adding a new interrupt source would be on an EXOS system but difficult-to-find random crashes or other problems seem quite likely!) I will leave the possibility of interrupts though because SymbOS etc will need it, but they are in control of their own environment in that case.

Further down the line some integration with EXDOS would be nice eg. being able to map a drive letter to a network resource and DIR, COPY etc.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 13:50:10
Quote
Further down the line some integration with EXDOS would be nice eg. being able to map a drive letter to a network resource and DIR, COPY etc.

It would be interesting. Much I know about EXDOS is from Zozo, to be honest :) We have the SD card solution or even HDD interface, but both of these are allowed because of the modularity of the EXDOS, only a small, basically block I/O level collection of routines should be written for the specific hardware, and you're done (well, almost). But the key here, that basically EXDOS still expects the FAT12 filesystem (this is also a problem for bigger storage solutions - like SD card - where FAT16 would be nice). It would be nice to find an easy way to also "replace" (in a way that it's still usable of course for a given drives!) that, thus other filesystems can be implemented as well easily. I am not sure I could express my problem. I also thought (with my web based emulator JSep) to support a filesystem over HTTP but with actual files on the server, and not disk images. The problem was the same: I don't know at least an easy way to "hijack" EXDOS in a way to eg "force" EXDOS/FISH etc calls to use other fileystem implementation than FAT12 to be used, at least not with lots of work, I don't know too much about :( The final solution (which is not finished in JSep still) is to implemented "N" commands (N is for Network), like "NDIR" instead of "DIR" etc, and using EXOS device driver to implement the be able to read/write the given file at least. But it's kind of "hack" in its taste ...

Well, I try to express myself of a more easy way: how would you implement eg SMB on the EP, so regular EXDOS commands, and calls work? Or did you mean using an EP disk image just accessible via SMB and not individual files and directory structures on the SMB server?

Other stuff: there are even more simple ways to implement some kind of "network file system" especially if block level I/O is OK, and EXDOS would interpret a FAT12 then: like TFTP protocol using only UDP datagrams, quite simple and easy to implement, but it's more about accessing blocks for real than files, for the latter SMB or similar would be more useful, or even like "fuse" (file in user space) stuffs (used by Linux systems) eg to "mount" an FTP (hehe, the one I would hate) server as a local file system, something similar solution.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.March.24. 14:04:48
EXDOS doesn't currently have a way of using other file systems - it would probably need a new version of EXDOS with a patch on the function call entry points to see if the drive letter is a network drive etc. But the command line part and IS-DOS don't know anything about FATs etc (mostly, anyway) - they just do EXDOS calls so DIR and COPY etc should just work. SMB was created to basically map MS-DOS calls to the network so there is quite a close correlation between EX-DOS and SMB :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 14:18:03
EXDOS doesn't currently have a way of using other file systems - it would probably need a new version of EXDOS with a patch on the function call entry points to see if the drive letter is a network drive etc. But the command line part and IS-DOS don't know anything about FATs etc (mostly, anyway) - they just do EXDOS calls so DIR and COPY etc should just work. SMB was created to basically map MS-DOS calls to the network so there is quite a close correlation between EX-DOS and SMB :)

OK, thanks for the information, it was always a white spot for me. I always think about something like the VFS layer in Linux kernel, eg there are common functions "open file", "read file" etc, and any number (even network FS) can be done to implement those entry points by a given filesystem "driver". I always wanted to find something like this in EXDOS, but it's quite possible that EXDOS has totally different philosophy here :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 14:29:37
Next question: does 5100 and 5300 some kind of pre-allocated mac address per chip, or the user must provide "something"? According to the documentation of the w5300 it mentions a register named "SHAR" which is about to configure MAC address, so I guess we must provide a mac address. I don't know how MSX guys solved the problem, as it's a big problem if mac addresses collides, the situation is not so rare, if every wiz carts have the same MAC and eg in case of a 8 bit party :) people want to connect their machines on the same ethernet segment. Also, mac addresses should not be given just by random, as they are allocated by vendor at least at the "prefix" level. If someone does not hate Commodore too much (as some Z80 CPU believer does hehe), Commodore does have an allocated mac address space which is not so much used for obvious reasons , and often used by "retro computing" projects. But of course it still does not resolve the whole problem for the need to generate unique mac addresses for every cartridges.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.March.24. 15:22:59
I haven't looked into the MAC address yet but it seem likely the Wiz does not have its own - that would need some non-volatile storage which it probably does not have. The Enterprise network card ROM will be Flash, much of it unused, but the question is then whether just a small section can be written (I don't know the answer yet).

Each Enterprise has its own serial number so maybe the software can ask the user to type that in to make up a unique MAC address, if necessary "borrowing" a disused prefix as you suggest.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.March.24. 15:39:20
Wow, you are faster than my thoughts :) I was just about to ask you what MSX uses, direct or indirect with that DenYoNet. I tried to find information about DenYoNet (schematics, detailed description, programming etc) but not so much success yet, can you help in that? I guess it would help a lot to see how MSX guys solved the problems (or even cared at all ...) I talked about like logic level shifting. Anyway, maybe you're right and indirect access is more simple with using some I/O ports only, and nothing more ...
The DenYoNet card is using the memory of a full MSX slot/subslot (this is a 4x16K range which can be partially or fully mapped into the visible 64K area). The lower 32K are for the included flash ROM, in the upper 32K you can map the 32K of the W5100. This is separated into 2x16K, the lower are the registers, the higher are the transfer buffers. There are two additonal bits which select if and which part of the 32K is mapped to #8000 and if and which to #C000. Unfortunately I have no idea how this is done internally/wired, but it uses the memory-mapped based slot/subslot technology of the MSX standard.

@Bruce: SymbOS doesn't use the interrupt feature. It is polling the status of the 4 sockets on each Vblanc interrupt, which makes things easier for me.

Quote
"AppStore"
This is definitely planned!! :P

Quote
MAC address
Yes, you have to set the MAC address by yourself. On the MSX the producer of the card ("Sunrise") owns 4096 MAC addresses, which is enough :D (not sure about the exact range)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 15:41:26
Another possibility to also use some kind of RTC chip. RTC is nice to have, ZT (ZozoTools) ROM can even display a clock shown above the normal status line, and used to initialize EXOS time/date settings. Well, having a network solution would allow to set time with NTP, RDATE or similar network time protocol that's true. But what I mean with RTC: some RTC chips have NVRAM which is quite suitable to contain small amount of configuration data, as it does with ordinary PC BIOSes as well something like 56 bytes or such is free by the clock functions, if I remember correctly. Ok, it's not truely volatile, as battery can flat, but software can ask for EP serial number if the data seems to be invalid, and then it's re-set, and also MAC address is generated somehow from the serial number, as you pointed out, as it should be unique somehow at least :) But I am not sure it's worth to also build an RTC solution onto the card, even if it can be useful. The flash idea is not so bad, and usually it should be set once, so I guess it's not a big deal to re-flash a whole flash page because of that (as far as I know, flashes can be written only per page, not at byte  level though). EEPROM is another solution, but it's more expensive with capacity needed for the software, and a small EEPROM is a bit luxury to have just for the MAC address when you have flash too ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Zozosoft on 2015.March.24. 15:46:45
The flash idea is not so bad, and usually it should be set once, so I guess it's not a big deal to re-flash a whole flash page because of that (as far as I know, flashes can be written only per page, not at byte  level though).
No, only the erase works with pages. Then the erased bytes (FFh) can be written. (At the write you can overwrite 1 to 0, but can't 0 to 1)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 15:52:26
No, only the erase works with pages. Then the erased bytes (FFh) can be written. (At the write you can overwrite 1 to 0, but can't 0 to 1)

Ah, my fault, indeed. So, by creating cards there can be erased bytes (FFh) and it's OK to set some bytes for the serial number or whatever at once by the user at the very first time. Of course, it's important to warn the user that he should not make mistakes :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 17:22:22
Quote
So most work is just interfacing with the W5100, but also implementing DNS lookup (and DHCP)

DNS shouldn't be a big issue, it's just an UDP datagram sent to the recursive DNS server IP port 53, and waiting for the answer. Well, at least if no EDNS ... and you don't want to support DNSSEC :) Just kidding. I guess if message is truncated (on PC etc, client would retry the query over TCP then) then it can be ignored on an EP or similar system anyway, though there can be situations like a server has over 100 IP addresses for some kind of odd DNS based round-ribon load balancing idea, I've already seen things like this even with well defined DNS lookup type, not just with "ANY" lookup which is quite expensive nowdays (and used in DNS based DDoS attacks ...).

At the other hand DHCP is somewhat more complex at least. Especially if you need to receive routes as well, but I guess more home networks you want to use this wouldn't have too long routing table, just the default gateway maybe :) Or wait, that should be handled by the wiz chip as in non-MACRAW mode at least, you deal with IP addresses only, right? DHCP as I can imagine needs some MACRAW magic as well, since at the beginning you don't have IP address.

Since Enterprise's great OS (EXOS) is quite capable, I guess the best solution would be to let EXOS to do the intial work if you have such a network card (eg it can do DHCP like with the SD card detection before the Enterprise logo) SymbOS can query EXOS somehow (?) about it. But I am not sure, even not without SymbOS, eg user may want static IP configuration, and then anyway you need to store at least your own IP (not counting the MAC address now ... that's another story), DNS server ... But again, relaying for SymbOS on just EXOS may cause just even more complex situation among SymbOS platform, because at least I can imagine you want an own DHCP routine, network configuration dialog etc anyway, so Enterprise port would be a "special case" then. Speaking about the EP/EXOS only, some kind of non-volatile storage seems to be important again, not just because of MAC address but maybe in case static IP configuration too (or to avoid doing DHCP always even before the end of the lease time given by the DHCP server).

Anyway, what I would enjoy to have a fully usable network solution even with the base EP OS too, of course! :)

No, we need an IPv6 capable wiznet chip, btw :-D
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.March.24. 19:55:32
My first thought about the RTC was, that you don't need an RTC anymore if you have network, as you can get the time from the internet after startup and you are fine. The small included RAM is an interesting point. But especially because of the multi-platform way I would always store all settings in an INI file, which is loaded, when the network daemon is starting. This is probably different, when we speak about a ROM solution, which should be independant of mass storage devices.

Good to hear, that DNS is easy. It's what I am starting now to implement, since the UDP routines are finished. About DHCP, the way I am currently doing it on the MSX is exactly the way you described! I let the DenYoNet rom do the initialisation with DHCP in MSX-DOS, and after this I boot SymbOS. So the Wiznet already has all its basic network settings.
Didn't know that DHCP requires MacRaw. I thought that even without any network setting you are able to broadcast UDP packets. Anyway not so important now, I think this is one of the last items on the list! :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.March.24. 22:15:42
My first thought about the RTC was, that you don't need an RTC anymore if you have network,

Exactly my idea was this too, as I've mentioned. Not so easy to decide eg, ok-ok but time keeping in an interrupt handler always problematic (sometimes you need to disable interrupts and miss a tick, though on Ep the 1Hz interrupt source is a useful stuff), so the RTC is a quicker and more easy way, than always using eg ntp to get "time from the net", but I am still unsure which is the best :) In theory even SD card or _any_ storage is not needed as I would prefer using my router as "storage" even for the EP through the network, so what's the point of an SD card then in the EP? :) Now I talk about in general btw, not just SymbOS, EP/EXOS too.

Quote
Didn't know that DHCP requires MacRaw. I thought that even without any network setting you are able to broadcast UDP packets.

Hmm, maybe you're right :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.May.04. 14:26:36
As I read in the All-In-One thread there is currently some development going on with the Wiznet W5x00 hardware?
Any news about this or is it currently too far away from publishing details? :)
[attach=1]
I hope to get the network daemon for SymbOS finished soon, and TBH the low level drivers for the platform/hardware specific part is not much work compared to the management stuff around it.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.May.04. 15:53:57
Sorry but there is still no like button here to express feelings about some posts :) I don't know about the network project on the EP other than discussing various topics here. But as far as I remember, Bruce wrote something that he wants to create a solution. And about myself: I have only big mouth but quite lazy and lacking enough free time. Oh well, these excuses all the time ... Fortunately I am not the author of SymbOS otheriwse it would be never written :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Tuby128 on 2015.May.04. 15:56:27
(For EN version see bottom)
DE:
Ich denke gerade daran, ob ein ENC28J60 für diese Zweck ausreichend wäre. Das IC kann 10mbps, mehr brauchen wir sowieso nicht. Um das IC mit EP verbinden würde ich ein MAX2 CPLD nehmen. Kostet nicht viel, und somit kann man die SPI schnittstelle zum paraller EP anpassen. Das einzige Nachteil ist, dass man diese IC studieren muss, um das zu steuern.
 Ich bin der Meinung ein memory-mapped Zugriff wäre am beste Lösung, weil es beim Z80 schneller als IO Zugriff.

EN:
I am thinking right now, whether a ENC28J60 would be good for this purpose. This IC can 10mbps, we don't need more. To interface it to EP, I would take a MAX2 CPLD. It cost's not much, and thus the SPI can interface with paraller EP externsion. The only disdvantage is that we have to learn how to control the IC.
 In my oppinion a memory-mapped access would be the best solution, because at Z80 it is faster as IO access.

HU:
 Azon gondolkodom, hogy egy ENC28J60 talán megfelelne erre a célra. Ez az IC 10 mbps-t tud, többre nincs is szükségünk. Hogy összekapcsoljuk az EP-vel, én egy MAX2 CPLD-t használnék. Nem kerül sokba, és így az SPI összehozható a párhuzamos EP-vel. Az egyetlen hátránya, hogy meg kell tanulnuk vezérelni az IC-t.
 Szerintem egy memóriában leképzett hozzáférés lenne a legjobb megoldás, mert a Z80-nál ez gyorsabb mint az IO hozzáférés.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.May.04. 16:22:17
I am thinking right now, whether a ENC28J60 would be good for this purpose. This IC can 10mbps, we don't need more. To interface it to EP, I would take a MAX2 CPLD. It cost's not much, and thus the SPI can interface with paraller EP externsion. The only disdvantage is that we have to learn how to control the IC.
 In my oppinion a memory-mapped access would be the best solution, because at Z80 it is faster as IO access.

We have had some posts about that in the past, as far as I can remember. I suggested ENC28J60 too at first. However the problem, that you need create a full TCP/IP stack by yourself on the Enterprise, since ENC28J60 does not have higher level functionality. Well, first I thought it's not a problem, anyway it feels like cheating to use a "hardware" TCP/IP solution (actually an embedded MCU which is much more powerful than the Z80 itself in the EP), but after considering these facts I am not so sure anymore:

* SymbOS already (well, AFAIK, and only in development versions, I think) supports the wiznet chip (with "hardware" tcp/ip) for the MSX (wiznet w5100). Chance to implement the whole TCP/IP as well is much lower than adopt the MSX-like solution for the EP too, almost the same driver.
* Implementing a full TCP/IP stack for EP would require time (well maybe there are Z80 TCP/IP project already, but even just adopting)
* A software TCP/IP solution require some amount of resources (memory, CPU) again ... Then a stock EP would be not so much usable with 128K of RAM only (see the EXOS driver idea later)
* The mentioned wiznet chips has direct 8 bit CPU bus interface as well, basically you can just wire together without too much extra components or extra programmable logic devices, no need for even SPI
* wiznet chips are faster (ok, honestly it's not a point too much, 10mbit would be enough as well!!!!)
* You can even buy (I have) these wiznet chips in the form of modules (ok, it's true for the ENC28J60 too, I know) with integrated RJ45, etc, quite ready to be used even for someone like me (anti-SMD guy)

Btw, even before the SD card cartridge my dream was having a generic SPI bus implementation, and you can connect some SPI slaves, like ENC28J60, SD card, and even extra things SPI capable mpeg codec ICs just for fun.

After all, I think, it's much more realistic to have working ethernet solution (and softwares use it!) if it's easy to made (wiring a wiznet module to the EP etc) even if it's not "manufactured" unlike the SD card cartridge, and also it's much more easy to write software (not just SymbOS, think about the nice possibilities to have EXOS drivers for it, like LOAD "http://...." directly) for it. Even if it's a bit more expensive (not so much, even that module was something like 6000HUF) and feels "cheating" sometimes :)

Ah yes, and a bonus: these wiznet chips still allow low level programming if some wants to implement everything without the help of the chip itself beyond the ethernet layer at least ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: pear on 2015.May.04. 20:30:00
Something like this http://www.tme.eu/en/details/wiz811mj/moduly-wiznet/wiznet/ (http://www.tme.eu/en/details/wiz811mj/moduly-wiznet/wiznet/) ?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.May.04. 22:20:18
Something like this http://www.tme.eu/en/details/wiz811mj/moduly-wiznet/wiznet/ (http://www.tme.eu/en/details/wiz811mj/moduly-wiznet/wiznet/) ?

Yes, but I have wiz830mj it supports 8 and 16 bit parallel bus. Some of these modules seems to support only SPI, some of them parallel bus, some of them both :-P And also the chip type can counts, w5200 ior w5300. Wiz830mj has w5300, AFAIK SymbOS on MSX supports networking with w5100, but they are not so different, and w5300 can do more parallel connections and has bigger RAM buffer. As far as I can remember, I mean ...

http://www.wiznet.co.kr/sub_modules/en/product/Product_Line.asp?cate1=5&cate2=42 (http://www.wiznet.co.kr/sub_modules/en/product/Product_Line.asp?cate1=5&cate2=42)

But you can get some hints about the ideas here if you try read through the posts within this topic from the start. Well, maybe not, since I can write a lot :-/

Btw, comparsion of the used chips themselves:

http://www.wiznet.co.kr/sub_modules/en/product/Product_Line.asp?cate1=5&cate2=7 (http://www.wiznet.co.kr/sub_modules/en/product/Product_Line.asp?cate1=5&cate2=7)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.May.05. 02:34:11
As I read in the All-In-One thread there is currently some development going on with the Wiznet W5x00 hardware?
Any news about this or is it currently too far away from publishing details? :)

Yes I am working on it as and when I can, using the wiz830mj module (W5300) in 8-bit I/O mapped mode.

I have a schematic and nearly a completed PCB design.

It is a vertical board that plugs into either the side of the Enterprise or into an Enterprise expansion bus board. It has an extra 64k RAM and 64k FLASH space.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.May.05. 15:10:47
Glad to hear that it's going on! :) Time to have a closer look at the W5300 programming again...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.May.05. 15:16:43
Glad to hear that it's going on! :) Time to have a closer look at the W5300 programming again...

Well, if w5300 is compatible with w5100 with ignoring the new features of w5300 and possible with some extra initialization the same code can be used more or less, I guess. However I am not sure if it worth to use the extra features of w5300 (more buffer ram, more "sockets", probably, as far as I can remember). Which ports are used on MSX for this purpose? I have the faint memory that you told once: on MSX the memory mapped mode is not used only through for I/O ports. If the I/O ports would be the same, it would be even more easy for programming. Or SymbOS should introduce not only memory relocation of loaded programs but also for I/O ports :) I am not so serious now of course, as EP port of the SymbOS can have different I/O address for the wiznet stuff of course if the access method is similar at least ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.May.05. 16:43:30
Which ports are used on MSX for this purpose? I have the faint memory that you told once: on MSX the memory mapped mode is not used only through for I/O ports. If the I/O ports would be the same, it would be even more easy for programming.
You probably mixed it with a planned W5100 hardware for the CPC :) About the MSX hardware I wrote the following here:
The DenYoNet card is using the memory of a full MSX slot/subslot (this is a 4x16K range which can be partially or fully mapped into the visible 64K area). The lower 32K are for the included flash ROM, in the upper 32K you can map the 32K of the W5100. This is separated into 2x16K, the lower are the registers, the higher are the transfer buffers. There are two additonal bits which select if and which part of the 32K is mapped to #8000 and if and which to #C000. Unfortunately I have no idea how this is done internally/wired, but it uses the memory-mapped based slot/subslot technology of the MSX standard.

Well, if w5300 is compatible with w5100 with ignoring the new features of w5300 and possible with some extra initialization the same code can be used more or less, I guess. However I am not sure if it worth to use the extra features of w5300 (more buffer ram, more "sockets", probably, as far as I can remember).
No, AFAIK the W5300 doesn't provide a "compatibility mode".
I studied the datasheet again and figured out, that you can't access the 128KB transfer (TX/RX) buffer memory directly in any case. You have to use a special FIFO register for each of the 8 sockets for sending/receiving data, which means, that even memory mapped mode wouldn't allow simple LDIR commands. So one more argument for using I/O mode.
Everything else seems to be the same, just with the double amount of sockets, more buffer and maybe some other little improvements. It's not much work to rewrite the W5100 routines for the W5300.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.May.05. 16:48:12
You probably mixed it with a planned W5100 hardware for the CPC :) About the MSX hardware I wrote the following here:

Indeed :) The confusion because "DenYoNet" seems to use a wiznet chip and also we talk about that. However it seems the details are different.

Quote
Everything else seems to be the same, just with the double amount of sockets, more buffer and maybe some other little improvements. It's not much work to rewrite the W5100 routines for the W5300.

Even if it's done not in the memory mapped mode? I think it does not worth too much (or does it), if the "few I/O port" solution is much more easy to implement (in the hardware, I mean).
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.May.05. 17:10:56
Indeed :) The confusion because "DenYoNet" seems to use a wiznet chip and also we talk about that. However it seems the details are different.
Yes, it's using the W5100 :)

Even if it's done not in the memory mapped mode?
Yes, that doesn't matter. I developed the Wizenet code in a two-layer way. The lower layer is for writing/reading Wiznet registers and transfering data from/to the buffers. This layer is different for I/O and memory mapped, and has to be rewritten for different computer platforms. These are only a few and simple routines ("write byte to register memory", "write word to register memory", "read byte from register memory", "write data to buffer memory" etc.).
The higher layer code is handling the network activities like "open connection", "check connection status", "send data", "receive data", "close connection". It's still Wiznet W5x00 specific, but it doesn't know anything about how to access the registers and buffers, as this is done by the lower layer code. The higher layer code is platform independant when using the same Wiznet chip and it's probably even possible to use nearly the same higher layer code for both the W5100 and W5300 with small modifications for the register addresses.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.01. 12:40:54
[attach=2]

I have spoken to the WIZ 5300, and it has replied :) :) :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.01. 13:19:59
Nice work + good news! :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.01. 14:23:38
Congratulation Bruce! These are fantastic news!
I want to play battleship on my EP against another Z80, soon :P
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.01. 14:33:06
Congratulation Bruce! These are fantastic news!
I want to play battleship on my EP against another Z80, soon :P

That's boring :) It would be better to play ICMP war / SYN floods, etc between the network interfaces :-P But seriously, yes, it would be a very nice feature of SymbOS: multiple platforms are supported with SymbOS now it's time to connect these multiple platforms together on-line (or with the rest of the Net). :-)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: edoz on 2015.July.01. 14:34:13
(Attachment Link)

I have spoken to the WIZ 5300, and it has replied :) :) :)

Wow! That piece of hardware looks so nice!!!
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Zozosoft on 2015.July.01. 15:20:09
Wow, very nice!
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: geco on 2015.July.01. 19:08:03
:smt041 :smt041 :smt041
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 17:35:58
Dear All EPNET Fans! :)

I've exchanged some mails with Bruce meanwhile about the plans on project EPNET. I've already started to write a small "test program" which can be run (in theory ... without any hardware yet, I can't be sure, as I already write it by reading the specification from Wiznet) with the real EPNET and with my emulator Xep128 too (which will support _some_ features of the real hardware, the keyword here is "will", so it's in future tense).

The first problem of mine: where are the six I/O ports from viewpoint of EP. As Bruce told me, it's not a fixed I/O address, also Xep128 likely will use another - fixed - port. I proposed some kind of complicated way to find the I/O port (ie, scan segments to find EPNET ROM and then call a routine there which can tell). It's clear that Bruce has more experience with the Enterprise in general than me (hehe, no wonder ...) because he suggested to use an EXDOS-like method instead. That is: use an EXOS command with a probably impossible to type character in the command itself (like EXDOS\0xFD).

The idea basically: issue the EXOS command EPNET\0xFF (EXOS 26 call with DE set with that string, length of 6) and if command is returned with OK status (as far as I remember, A = 0), maybe register B contains the I/O port. Of course further functionalities can be provided by the EPNET ROM, ie, low level socket manipulation routines etc, and also EXOS integration, but the I/O port is the very basic thing to write the first apps which want to do all the I/O at their own and they only need the I/O address for this. I guess even SymbOS would use that, since - as far as I know - SymbOS loader uses some EXOS commands anyway, but does directly everything after that point by its own, when SymbOS is already running. Of course this "I/O port detection method" via EXOS will be supported by Xep128 too.

Any feedback, opinion, new ideas are welcome. Of course with proper EXOS integration (ie, devices like HTTP: etc) can make it possible later to even write network/internet capable software in IS-BASIC, now the I/O-port related problem is mainly about for the EP apps doing direct I/O anyway (probably including SymbOS!), because as far as I can see it can take more time to develop proper EP OS (EXOS) software support, but I can be wrong ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.04. 17:59:15
Isn't there a map of all known I/O ports for the EP? Or are I/O ports handled in a dynamic way all the time for additional hardware expansions?
On the CPC and even the MSX (but they usually use their memory mapped based slot system) I/O addresses of hardware expansions are always fixed, and we have this table (http://www.cpcwiki.eu/index.php/I/O_Port_Summary) to prevent conflicts between existing and new hardware.
But it's not a problem to detect the I/O port while booting SymbOS or to add them to the Network Daemon setup tab.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 18:03:17
Honestly, I don't know. You should ask Bruce, or Zozo. What I know that maybe with the bus bridge there was a nice idea to have some kind of "auto config" ability for cards, ie inserting even same type of cards but getting "private" resources (as for memory segments and I/O port ranges) based on (maybe) the card slot position. Or something like this ... The idea is quite "plug and play" like stuff, but ... I think it's not so well known method in Hungary for example and nobody cared on this later. Really, these are my best guesses, I am lame with this topic, just I tried to answer ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 18:08:10
Additionally: I think this not fixed I/O address idea has one big disadvantage: the code will be slower maybe. My idea would be to do some kind of self modification on start-up for the I/O ports used inside the code (after the detection when you know what they would be modified to ...). Well, at least at places where it is critical for the performance, eg in the loop of reading/writing TX/RX buffers of w5300, thus the real packet data exchange between the wiz chip and the EP. Most other parts are not so critical for performance, like set up a new connection etc. Just my ideas, of course. The best solution would be :) some kind of odd executable format which not only aware of memory address relocation but I/O port address relocation too. :-) Ok, maybe it's a too big idea without too much sense :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.04. 18:42:11
My idea would be to do some kind of self modification on start-up for the I/O ports used inside the code (after the detection when you know what they would be modified to ...).
This is what I would do in any case. At least my W5100 driver for the Amstrad CPC (which would use indirect I/O as well) only has two routines, which really have to deal with the base I/O port: setup the address and return the data port; one for register memory access, one for RX/TX buffer access. The W5300 shouldn't be much more complex. So such an I/O port "relocator" is not a problem at all.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 19:37:22
This is what I would do in any case. At least my W5100 driver for the Amstrad CPC (which would use indirect I/O as well) only has two routines, which really have to deal with the base I/O port: setup the address and return the data port; one for register memory access, one for RX/TX buffer access. The W5300 shouldn't be much more complex. So such an I/O port "relocator" is not a problem at all.

On w5300, indirect 8 bit mode (what we use) they are the same, RX/TX memories can be read/written through a FIFO register which maintains their (internal, cannot be accessed by the programmer) counters to be able to do that. FIFO register is just like another indirect access mode register for each of the 8 sockets. Only one interesting behaviour can be noticed with FIFO registers: according the specification there is need for very strict order to access IDM_DR0 and IDM_DR1, both of them, exactly in this order (probably because not to confuse the internal counters/pointers for RX/TX buffers). So - as far as I can understand - there are the following primitives (not mentioning accessing MR, which is "direct" even in indirect mode, but that is the only register that kind!):

Code: ZiLOG Z80 Assembler
  1. ; Input: DE = w5300 register number to select
  2. ; Output: C = points to IDM_DR0
  3. select_indirect_register:
  4.   LD C, IOB+2  ; C points to IOB+2 now, which is IDM_AR0, this is the only IOB dependent (IOB+2 ...) place we should modify
  5.   OUT (C), D    ; high byte of DE first!
  6.   INC C           ; C points to IOB+3 now, which is IDM_AR1
  7.   OUT (C), E    ; low byte next!
  8.   INC C           ; just let C points to IOB+4 (IDM_DR0) for the use by write_* and read_* routines
  9.   RET
  10.  
  11. ; Input: C = must point to IDM_DR0 (eg set by select routine)
  12. ;          HL = value to set
  13. write_selected_register:
  14.   OUT (C), H    ; high byte of HL first! output data to IDM_DR0
  15.   INC  C           ; C points to IDM_DR1 now
  16.   OUT  (C), L     ; outputs low byte of data into IDM_DR1
  17.   RET
  18.  
  19. ; Input: C = must point to IDM_DR0 (eg set by select routine)
  20. ; Output: HL = read data
  21. read_selected_register:
  22.   IN   H, (C)  ; high byte first!
  23.   INC  C
  24.   IN   L, (C)   ; low byte next
  25.   RET
  26.  

Sorry, this code above just written by me now for this post (so it can contain mistakes ...), this is not how I do for various reasons. Maybe not even this way it should be written, just the proof of the concept. Here, only one byte needed to be modified for IOB-related. The example not shows operations on MR, but it should be only init-time stuff probably!

Now, with the code above, you can read/write any indirect mode registers with select the register first, then read/write it:

Code: ZiLOG Z80 Assembler
  1. LD DE, 0x202 ; register number in w5300
  2. CALL select_indirect_register
  3. LD HL, 0x1234 ; the data ...
  4. CALL write_selected_register
  5. INC DE
  6. INC DE ; we want register now at 0x204 (do not forget that register address MUST BE even number!), so the next 16 bit register. two INCs!
  7. CALL select_indirect_register
  8. CALL read_selected_register
  9. ; now we have data from register 0x204 in HL
  10.  

Note, that it seems (there are some examples in the specification for that) there is way to read/write only ONE "half" of a 16 bit wide register, ie. setting address 0x202 in IDM_AR and then reading/writing IDM_DR0 will access the high byte of register at 0x202, while accessing IDM_DR1 will do with the low byte, so basically it would be 0x203, but IDM_AR ignores the lowest bit set, as the basic 16 bit construction of w5300. Hopefully you see. However FIFO registers MUST be accessed for IDM_DR0 and IDM_DR1 and exactly at this order. Specification even forbids accessing other register after IDM_DR0 than IDM_DR1 if IDM_AR specifies a FIFO register.

As for FIFO registers then, it can be used this way to, just it will be a bit slow. I think since IDM_AR is enough to set up once, and for eg reading RX buffer (received data), this can be something like this:

Code: ZiLOG Z80 Assembler
  1. LD DE, RX_fifo_register_number_for_the_given_socket_i_dont_know_by_heart_now ... ; :-)
  2. CALL select_indirect_register ; now C points to I/O port on EP for IDM_DR0
  3. IN A, (C) ; read IDM_DR0
  4. INC C
  5. IN A, (C) ; read IDM_DR1
  6. DEC C
  7. IN A, (C) ; read IDM_DR0
  8. INC C
  9. IN A, (C) ; read IDM_DR1
  10. DEC C
  11. ; etc etc etc, but you can only read (or write, if TX FIFO register) EVEN number of bytes!
  12.  

Surely, I was lazy, and I forgot to store the data which was read, after each IN opcodes, so it does not make too much sense if done exactly in this way, again, just for demonstration.

Note, that these are my best guesses now on w5300 in indirect+8 bit mode, I can't be sure if it really works this way.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 19:46:31
Of course in the case of RX/TX data transfer it's maybe slower to use OUT (0x??), A and similar constructs and self-modify code at init to set them at an altering reg, reg+1 numbers for ports, where reg = IOB + 4 is of course. And I meant about the unrolled loop to do data transfer for bigger data chunks, of course. Because IN/OUT with constant (rather than using register C) is faster (if I remember correctly) and then you can save the INC/DEC C opcodes as well.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.04. 21:29:46
lgb your description of the data transfer, and your code snippets,  agrees with my current understanding (perhaps not surprising as we have read the same datasheet!!) but I hope to be able to confirm for real very soon.

It's a bit disappointing: at first glance of the datasheet with its auto-incrementing register I thought we'd be able to use INIR etc but on closer inspection it seems not. :(
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 21:52:49
lgb your description of the data transfer, and your code snippets,  agrees with my current understanding (perhaps not surprising as we have read the same datasheet!!) but I hope to be able to confirm for real very soon.

Well, with my misunderstanding ability, it would be no wonder to think about a completely different thing even by reading the same spec as you :)

Quote
It's a bit disappointing: at first glance of the datasheet with its auto-incrementing register I thought we'd be able to use INIR etc but on closer inspection it seems not. :(

Hmm, maybe I missed something, but I have no knowledge about any auto-incrementing stuff, or do you mean about the internal counter of FIFO registers maybe? I wouldn't say that not having INIR is a so big problem. INIR is kinda slow, something like 21 cycles (well, about cycles I can be wrong!). At the other hand, a plain IN A,(nn) - let's say we use constant ports, and unrolled loops for big chunks - is 11. So it's faster this way, but for sure, you need _store_ data too then, so maybe not :) If we optimize this to have EP-memory buffer at fixed 256 byte boundary, it can be eg an LD (BC), A - 7 cycles? - and  a plain INC C (if no 256 byte boundary crossed) - 4 cycles, thus we have 11+7+4 ... well, one cycle slower than INIR and having just too much "good" conditions for being fast. Well, better than nothing ... The other possibility would be using memory mapped I/O, thus not real Z80-like I/O, but using a memory area for that, as SD card does it too. In that case, a bigger area (even 16K, etc, but for real it's even OK to decode a smaller part of the EPNET ROM area for that, of course) can be used to address basically IMD_DR0 or IMD_DR1 based on the lowest bit of the address. The other stuffs can be on I/O port. This sounds insane, but consider this: w5300 seems to be indirect for FIFO TX/RX transfer even in direct mode. Register addressing still indirect and needs IDM_AR on I/O ports (and MR too, of course). But when it is set up, IDM_DR0 and DR1 can be accessed via "normal RAM" thus you can use LDIR (as it increases the source address the toogling A0 line in our "DR segment" would read IDM_DR0, IDM_DR1 sequence as we should!), etc for the actual transfer than! Only some extra decoding should be used. I am not sure if it worth anyway :-| Sounds strange, but I've already started to like it :-P What I see here, that from view point of w5300 even in indirect mode, those are just signals, nothing says we can't map w5300 address pins in an "insane" way :)

One other thing I felt the void before, but I haven't realized: there is no way on the w5300 to detect the link status, speed, etc :( If EPNET ROM would support something like doing DHCP it would only wait for timing out when even no cable plugged in. I don't like this. But what I have is an idea: w5300 has outputs to drive LEDs about some attributes we are interested in. What would happen if we also interpret those as logic levels, routing them onto a buffer IC which is enabled in case of reading of an I/O port after the w5300 IDM's ones? Then we would be able to "read the status of LEDs" basically, or so :) But we can see the link status, speed, etc, from software too!
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.04. 22:26:29
I am a little bit confused as well. Currently I can't find any information about address-auto-incrementation. Wouldn't that mean, that even when reading/writing from/to the RX/TX buffer you have to update the address after each word? That would slow it down indeed. It's not a tragedy, but I wonder, why they should have leave this feature. The W5100 supports it, so I can't believe that they forgot it for the W5300.

Regarding fast data transfer:
That was my first thought if auto-incrementation would work:

LD C,dataport
LD HL,destination (256 byte aligned)
repeat {
INC L:INI:DEC L:DEC L:INC C:INI:INC L:DEC C  ;16microseconds/word = 8microseconds/byte (CPC; no idea about the exact EP timing)
}

Usually you only have 5 microseconds/byte (CPC way), but I think it would be still ok. Without auto-incrementation it would be indeed slower by a factor of maybe 4 or so?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.04. 22:54:20
All the code examples in the datasheet just have a loop which reads/writes the bytes from/to the data register.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.04. 23:01:26
prodatron there is a bit [8] in the Mode Register that byte swaps. So your loops would reduce to INI, INC C, INI, DEC C unless I have misunderstood it :) (very possible :oops: )

Edited to adjust punctuation to avoid accidental smiley face
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 23:08:24
All the code examples in the datasheet just have a loop which reads/writes the bytes from/to the data register.

Ah yes, those are the FIFO registers. Indeed they have auto-incremented (or decremented) _internal_ pointers pointing in the w5300's RAM, but only a "single" (*later on this) port from the viewpoint of the host. So that you need only read a single port to read RX buffer, and only write a single port to fill the TX buffer. Our problem is, that "the single port" is 16 bit wide, so for real (for a 8 bit system), it's reading/writing port, than port +1, then port, port +1, etc (if IDM_AR is set to the fifo register, it's IDM_DR0 and IDM_DR1 altering access then). Exactly that's why it came into my mind, to map _memory_ accesses for the w5300 as within a memory range any EP memory r/w op interpreted to access IDM_DR0 or IDM_DR1, based on the value of address bus bit0. Thus eg a simple LDIR would be able usable to read/write RX/TX memory, if IDM_AR is set up before, and you are very careful to start on even memory address (A0=0 -> accessing IDM_DR0 first) and doing even number of bytes strictly. You can question if it's sane then to use indirect mode, as we can use the direct one too with memory mapped I/O still using 8 bit. But as far as I can remember, the spec says that FIFO registers are some kind of similar and indirect stuff even in direct mode of w5300, so maybe it does not worth to do.

Unfortunately my proposal means some kind of tricky EP signal decoding can be "expensive" using discrete logic (eg with 74xx series of logic ICs) and would need some kind of GAL, PLD, and such. Then we can say that a given I/O port range for I/O request is forwarded towards the w5300, and a given _memory_ range op is forwarded as IDM bus address 4 or 5 based on the value of A0 from the EP. Then we would be able to use memory based ops to do the data transfer :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.04. 23:19:29
prodatron there is a bit (8) in the Mode Register that byte swaps. So your loops would reduce to INI, INC C, INI, DEC C unless I have misunderstood it :) (very possible :oops: )

Please don't do that. :) It's kinda useless, unless someone can test it on the real hardware, as the specification is quite confusing here (maybe at least for me, only!). The spec says that accessing of FIFO registers are _always_ should be done in DR0, DR1 order. So it seems even if you use the FIFO swap feature then? Because in this case, data bytes are swapped, so you will read 'hello!' as 'ehll!o' then. At least, in the 8 bit code example, the normal byte order of w5300 (which is the opposite of Z80 btw) results in the "natural" buffer order still from the view point of a 8 bit system. See the example on page 87. The 8 bit version still sends the text "abcde" in this order as you would read that string. If you swap byte order in MR "FS bit" then it will be quite odd pattern, _unless_ if the rule of "DR0 then DR1 for FIFO access" is not reversed as well, but it's not mentioned it seems. I more and more believe in, that these byte order changing stuffs has not so much sense in 8 bit mode because if the nature, it would be required for a 16 bit I/O capable system (but then you can use the DBS bit in MR which would swap 8 bit halves of the data bus for every registers not just for the FIFO registers). So, in nutshell: I feel a bit lost on this issue, but at this moment I would say, it won't work to well to utilize that feature ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.04. 23:38:02
Please don't do that. :)

ok, I won't, I hadn't read that example! :oops:
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 00:20:27
ok, I won't, I hadn't read that example! :oops:

Don't worry, I can't see clearly that specified strict read order of IDM_DR0 and IDM_DR1 does not change as well, or FS bit is usable at all in 8 bit mode (DBS is not, it seems). Just guessing ... But the example shows that it's quite OK even in the normal (non-FS) mode ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 09:45:06
Regarding fast data transfer:
That was my first thought if auto-incrementation would work:

Hmm, I guess you wanted to exchange every two bytes but it's not needed. So I guess, that's enough:

Code: ZiLOG Z80 Assembler
  1.   LD  C, IDM_AR0_EP_PORT_ADDRESS  ; *** EP I/O address of IDM_AR0 which is IOB + 2
  2.   LD  HL, register_number_of_the_fifo_register
  3.   OUT (C), H ; w5300 byte order: you need to specify the high byte of the register number first, so H of HL
  4.   INC C       ; C now for IDM_AR1 (IOB + 3)
  5.   OUT (C), L ; write low byte of regnum to IDM_AR1
  6.   INC C   ; now C for IDM_DR0, what we need in the loop exactly (IOB + 4)
  7.   LD  HL, buffer_to_store_RX_data_to    ; it is not needed to be 256 byte aligned
  8. THE_LOOP:     ; some unrolled loop for perforamce (just an example)
  9.   INI     ; C points to IDM_DR0 (@ IOB+4)
  10.   INC C
  11.   INI     ; C points to IDM_DR1 (@ IOB+5)
  12.   DEC C
  13.   INI     ; C points to IDM_DR0 (@ IOB+4)
  14.   INC C
  15.   INI     ; C points to IDM_DR1 (@ IOB+5)
  16.   DEC C
  17.   ... etc ... etc ...

As far as I can see (from code examples in datasheet) for 8 bit FIFO transfer, bytes are still in the "good order", eg, reading the network packet contain "abcde" would result in the following scheme:

Code: [Select]
IDM_DR0 reads as "a"   (always start with IDM_DR0!!)
IDM_DR1 reads as "b"
IDM_DR0 reads as "c"
IDM_DR1 reads as "d"
IDM_DR0 reads as "e"
IDM_DR0 reads as SOMETHING, since always _even_ number of transfer needed, but in our case you need to ignore this byte but you MUST read it!

This also means that you need always start with IDM_DR0 and end with IDM_DR1 and you must be careful to use this strict "altering" method of using I/O ports, so w5300's internal counter in buffer won't go mad (as it would use that for 16 bit ops, but we use w5300 in 8 bit mode!).

Actually, this can be surprising because of the opposite byte order of w5300 what we're used with Z80, but still, RX/TX FIFO stuffs seems to be "the right order". This is because (I think!) giving eg network port, it's a 16 bit value, so it's really high byte FIRST, then low byte, but TX/RX buffers DOES NOT contain 16 bit values, but 8 bit bytes! So maybe byte order simply does not apply here too much because of the nature of byte grained data. Still, the bus interface of w5300 is 16 bit oriented with "8 bit mode hack" so you need to access this altering order of ports and always even numbers (which would be natural in 16 bit I/O + bus mode).

What is also important still: if there is even number of bytes to be read/written, there is nothing special. If you need odd number of bytes, then you need to read one more bytes to be even number (and ignoring the last byte), or send a dummy byte if it's a write op for TX FIFO. That's natural, as w5300 expect word I/O, so for 8 bit I/O it's n * 2 ops of 8 bits (n would be the number of 16 bit I/O ops needed), thus it is always even number of 8 bit ops then as n * 2 for any n is always even!

Again, this is my understanding of the situation! It can be wrong ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 12:41:27
Ok, I've decided to try to be sure about the situation, and what I found:

Code: C
  1.   *((vuint8*)IDM_AR0) = Sn_TX_FIFOR0(s);
  2.   *((vuint8*)IDM_AR1) = Sn_TX_FIFOR1(s);
  3.   for (idx = 0; idx < len; idx+=2) {
  4.     *((vuint8*)IDM_DR0) = *((uint8*)(buf+idx));
  5.     *((vuint8*)IDM_DR1) = *((uint8*)(buf+idx+1));
  6.   }

This is code fragment from the "driver" of w5300 written by Wiznet (for AVR MCUs, but who cares what, if it's C). What is interesting here, that it seems the theory is OK, they do what we exactly want to do. This is writing TX buffer, you see, IDM_AR is set up for the FIFO TX register number ofr the given socket, then using only IDM_DR0 and IDM_DR1 to transfer. AVR is also 8 bit, so it's a good example for us, also since the driver is written by Wiznet, I assume they know it would work this way :) You see, "buf" is read "linearly" just outputting to TX FIFO registers with IDM_DR0, IDM_DR1, IDM_DR0, IDM_DR1 ... order. The example above is for writing (TX buffer) for sure for reading it is similar but for the RX FIFO and storing read data, of course. The C loop is written this way (with idx incremented by too, and then refer for idx and idx+1) I guess to automatically handle the situation of given odd number of bytes to be written, to always transfer even number of bytes even in that case.

Knowing this, I would say, the Z80 example - I wrote in my previous post - should be OK that way! So I can be proud that I could interpret the data sheet well ... haha.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.05. 13:34:52
Great, thanks LGB and Bruce for the clarification! These are good news, transfering data will be very fast!
I am currently working on the DHCP implementation, but as soon as it makes sense I can start with the W5300 driver for the Enterprise.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 14:15:19
Great, thanks LGB and Bruce for the clarification! These are good news, transfering data will be very fast!
I am currently working on the DHCP implementation, but as soon as it makes sense I can start with the W5300 driver for the Enterprise.

Hmm. I guess you mean a generic (not only SymbOS/EP but for any SymbOS platform) implementation. For EP, I think: if EPNET has decent EXOS support it would be more the task of the EXOS to set MAC, IP, etc.  Since anyway, maybe not only SymbOS want to utilize EPNET :) And because SymbOS would (?) use EXOS anyway in the loader to get IOB for example, a successful answer can mean that IP settings of the EPNET are already initialized? I am not sure about this, what Bruce think: should EPNET ROM set (or even DHCP) IP at "boot" time so EPNET is ready to be used for TCP/IP already, or it will be the job of the app, or at least the user (to issue some EXOS commands to do it even from IS-BASIC like :NET IP DHCP or whatever ...).  But I think SymbOS needs generic, SymbOS-platform-independent DHCP implementation anyway user can modify settings also other platforms may not have this job done already, etc etc ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.05. 14:27:32
But I think SymbOS needs generic, SymbOS-platform-independent DHCP implementation anyway user can modify settings also other platforms may not have this job done already, etc etc ...
Yes, exactly. As soon as there is EXOS support for EPNET it makes sense to set the IP and DNS config there (including DHCP usage).
On the MSX there is a tool for MSX-DOS for this task as well, but it is optional.
The Amstrad CPC probably won't have this (at the beginning).
So it's necessary to have it in SymbOS, too. DHCP is a nice "nice to have" feature :) but it makes the whole solution more completed.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 14:38:56
I already took a look on the DHCP protocol some weeks ago, hmm, it's multiple-time rounds between the client and the server, it sounded a bit complicated at the first glance. But it seems I have to "emulate" a DHCP server somehow, as for Xep128 will emulate w5300 using native TCP/IP by the host OS (the OS which runs the emulator, ie Linux or Windows for example). So from the point of the real LAN and host OS, it does not make any sense to send a real DHCP to the network as the host OS already has IP ... So what I thought is to check the sent packets by the emulated w5300 and if it is founded to be DHCP related, I fake an answer from Xep128. So apps in Xep128 would think it's a real ethernet network and it talks to the DHCP server and it can get an IP ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.05. 14:58:41
Nice find lgb - thanks for that, that clarifies it! INI, INC/DEC C is still one T faster than one INIR interation so maybe not *quite* as fast an an "unrolled" plain INIR but I can certainly live with that!

Yes I agree, I would hope DHCP could be done at startup by the EXOS device/code but there is probably a case for being able to set the subnet, ip etc manually too, even if just for testing (the w5300 really ought to doing the DHCP stuff!). I am now wondering whether the "use DHCP y/n" setting and the manually-set subnet & ip should be stored in flash along with the MAC address.

It might be a bit of pain as I'm not using interrupts - might have to have an EXOS timer interrupt and do it from there. The alternative is to do it synchronously on the first application EXOS call.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 15:10:42
Yes I agree, I would hope DHCP could be done at startup by the EXOS device/code but there is probably a case for being able to set the subnet, ip etc manually too, even if just for testing (the w5300 really ought to doing the DHCP stuff!). I am now wondering whether the "use DHCP y/n" setting and the manually-set subnet & ip should be stored in flash along with the MAC address.

Actually, storing IP settings and MAC in flash is a very nice idea! Just flash is not RAM, maybe you need to erase a whole flash page and rewrite then? It would be cool to put an RTC chip onboard, it can be used for clock source as well of course, and some RTC chips have some dozens of bytes of NVRAM which is cool to be used as config storage, as with the PCs + BIOSes. However as I've written one of my older posts in this topic: it seems w5300 has PHY interface running at its own, no connection with the app in any way. So you can't ask the link status etc, which would be nice to be solved, so it does not make sense to wait for DHCP answer, when there is even no link through the RJ45 connector eg without any cable connected. Other possibility: have a "sub command" of proposed command NET for DHCP and manual IP config (which is a good thing anyway too) and eg put in EXDOS.INI or something, and you can edit whatever you want to be set. Not as nice solution maybe, but more simple, that is the IP settings are stored on disk in some form!

Quote
It might be a bit of pain as I'm not using interrupts - might have to have an EXOS timer interrupt and do it from there. The alternative is to do it synchronously on the first application EXOS call.

Well, I also thought about the EXOS vs w5300 thing, that "events" on w5300 can cause interrupts or you need to wait inside a busy loop. But since EXOS is not a multitask OS, I guess apps should anyway wait ... What is interesting (and I don't know the details neither on EXOS nor with the w5300): if data is received and we can read RX FIFO I guess we must (?) read the whole byte stream (packet data?) received, but EXOS function may ask for a single byte to read only! What happens then? Should we have a buffer in EP too for EXOS to store received bytes, in case if EXOS app wants to read less bytes only? How the RAM needs of EPNET ROM is handled? It seems the designers of the SD card cartridge worried about allocating RAM from the system segment, as many apps are picky to have shortened amount of "base" RAM or at least system segment free space. So they built SRAM onto the cartridge not for general use, but mainly for usage by the SDEXT ROM code itself. If I understand the situation correctly, at least. So, with EPNET card, if I remember correctly you mentioned it will contain RAM too. Is it for this purpose exactly like with the SD stuff?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.05. 15:25:15
I already took a look on the DHCP protocol some weeks ago, hmm, it's multiple-time rounds between the client and the server, it sounded a bit complicated at the first glance. But it seems I have to "emulate" a DHCP server somehow

DHCP implementation had quite a low priority for me, as it is only a luxury feature for lazy users :D It is not important, as you can use a fixed IP/DNS configuration.
But the protocol seems to be quite easy. The reason for sending two packets on both sides (discover ->, offer <-, request ->, <- acknowledge) is probably the fact, that you can have more than one DHCP server in your local network, and the client has to make a choice after the discovery stage and tell its decission to all others.

if data is received and we can read RX FIFO I guess we must (?) read the whole byte stream (packet data?) received, but EXOS function may ask for a single byte to read only! What happens then? Should we have a buffer in EP too for EXOS to store received bytes, in case if EXOS app wants to read less bytes only?

No, that's not necessary. You can read less bytes than received from the RX buffer, you will just update the buffer pointer then in the correct way. The only thing I wonder is, if you always have to read and skip even number of bytes from the buffer because of the 16bit issue.

Regarding DHCP/DNS and interrupts: These operations work usually quite fast, so maybe you could stay in the routine until the process is finished. In SymbOS I poll the network hardware every 1/50second, which works fine as well.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.05. 16:03:32
Yes EPNET has separate RAM just like the SD card, and for the same reason. There is 64k flash in total and the top two 16k segments are "normal". The bottom two 16k segments each have their own 4k RAM area, so really 12k flash+4k RAM. I'm thinking EXDOS in the 32k, EPNET EXOS drivers etc in the first 12k+4k and the remaining 12k+4k spare/overflow or possibly for Compact Flash support code if that proves necessary (although it's pretty similar to IDE so EXDOS might just do it anyway with minor modification). Or could be for storage of addresses etc of all sorts...will see how it goes!

I'm aiming for EPNET to be useful without disks so if the IP address etc has to be set by user commands after each boot that will be a pain! Though that is how I will do "manual configuration".

I'm trying hard to resist "feature creep" so that I stand a chance of getting it finished! My thoughts were that with a network connection a RTC is less important because you can at least use NTP or something to get the date/time from somewhere else.

I assume you do not have to read the whole buffer immediately if you don't want to, but you'll probably have to read it a word at a time, so hold a byte "in hand" for the EXOS device - not too hard. But there should be enough RAM there to buffer it if that turns out to be necessary.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 17:16:31
DHCP implementation had quite a low priority for me, as it is only a luxury feature for lazy users :D It is not important, as you can use a fixed IP/DNS configuration.

Yes, but for not-so techy people, I guess this is a must. At the other hand, maybe not my mother will run SymbOS. Or use EP. Or EPNET :)

Quote
No, that's not necessary. You can read less bytes than received from the RX buffer, you will just update the buffer pointer then in the correct way. The only thing I wonder is, if you always have to read and skip even number of bytes from the buffer because of the 16bit issue.

16 bit is an issue, the specification says as something like "it is NOT allowed to access any other w5300 register than low byte of the FIFO if high byte is already accessed before" (that is, in indirect mode: IDM_DR1 must be accessed if IDM_DR0 has been  accessed before, and you can't even set another register to be selected with IDM_AR before you complete a 16 bit access. It seems this strict access method is only for the FIFO registers, others can be accessed for only a "8 bit half" of the register and continue with another register then!). So you must read (or writes) even number of bytes, always. Thus. if app wants odd number of bytes, you still need to buffer (ie in your network daemon, whatever) at least one byte! Of course if it was last byte in RX  buffer, you read two bytes from FIFO but ignore the other (and then not buffer).

Quoted from the specification (page 87):

"If  the host system  uses  8  bit  data  bus  width,  Sn_TX_FIFOR0  and  Sn_TX_FIFOR1  should  be accessed  in  a  pair.  When  copying  1 byte  data  into  internal  TX  memory, the host  writes  the  1 byte data in Sn_TX_FIFOR0 and dummy data in Sn_TX_FIFOR1. Sn_TX_FIFOR should be accessed with 2 byte size. Access the Sn_TX_FIFOR0 of low address register  first, and the Sn_TX_FIFOR1 of high address register. After accessing Sn_TX_FIFOR0, it is not allowed to access other W5300 registers except for Sn_TX_FIFOR1."

Of course, it translates a bit different for indirect mode, since there it means writing IDM_AR to be able to use other register, and IDM_DR1 for the already selected Sn_TX_FIFOR1 for example. Thus, if IDM_AR is set for the Sn_TX_FIFOR and then you accessed for write IDM_DR0 then you _must_ and _can only_ access IDM_DR1 not any other register. As far as I can see. The same for the other direction (RX FIFO reg).

For the RX direction (page 88):

"If  the host system uses  8  bit  data  bus  width,  Sn_RX_FIFOR0  and  Sn_RX_FIFOR1  should  be accessed  in  a  pair  as  like  Sn_TX_FIFOR.  It  is  not  allowed  to  access  Sn_RX_FIFOR0  and Sn_RX_FIFOR1  right  after  accessing  Sn_TX_FIFOR0  and  Sn_TX_FIFOR1.  Theseare  cause for the incorrect read.   In   order   to   prevent   this,   after   reading   Sn_TX_FIFOR0   and Sn_TX_FIFOR1, the host reads any register such as Sn_MR and then access Sn_RX_FIFOR. When the host reads the received DATA packet in internal RX memory through Sn_RX_FIFORby 2 bytes, the low and high data in internal RX memory can be readthrough Sn_RX_FIFOR0 and  Sn_RX_FIFOR1respectively.  The host  performs  RECV  command  after  processing the received DATA packet in internal RX memory. "

So about the same issue but for another direction. What seems to be odd for me, this RECV command ... If reading RX FIFO reg updates w5300 internal pointer stuff etc for the socket RX buffer, what exactly does. I had not so much time to try to analyze this part of the specification yet! Also for RX there seems to be more rules given by the spec, see what I've copied here above. Unfortunately I hadn't much time too much at the weekend, still I would need time to try to understand these. I guess ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 19:22:53
I'm aiming for EPNET to be useful without disks so if the IP address etc has to be set by user commands after each boot that will be a pain! Though that is how I will do "manual configuration".

Of course I agree, just I have no idea how "difficult" (or not) to modify the flash content from EP.

Quote
I'm trying hard to resist "feature creep" so that I stand a chance of getting it finished! My thoughts were that with a network connection a RTC is less important because you can at least use NTP or something to get the date/time from somewhere else.

Exactly :) I only miss the NVRAM feature of those chips more, if you have network, it's kinda easy otherwise to get the time from time servers ... Maybe it would be a great idea to have some larger NVRAM-like entity created for the EP, so every projects can use it, more like the BIOS settings storage on PCs. Or such ...

Quote
I assume you do not have to read the whole buffer immediately if you don't want to, but you'll probably have to read it a word at a time, so hold a byte "in hand" for the EXOS device - not too hard. But there should be enough RAM there to buffer it if that turns out to be necessary.

Honestly, I am a bit lost here with the specification (of w5300, I mean). Many things are not clear for me, ie it says packet-info word tell the size. But what happens, if multiple packet arrived before we could process? What I can imagine, that if you read FIFO RX you will get packet info which tells the number of bytes in the packet. After reading that, and still bytes in the RX buffer (according to fifo rx size) reading a word will find the next received packet's packet-info word with its length, so I know how many bytes should be read. Well, I think :) What I don't know, where and how RECV command is needed (fromt he spec it seems it is some kind of acknowledgement only that we really read X words, and it has no any other purposes?), and why, if internal counter of RX FIFO "knows" how much data is already transferred to the host (so: EP) from the RX buffer.

The problem here: I need to understand these also for creating my "test app" for EP, but also at a level that I can emulate a w5300 in Xep128, so things like these give me enough headache. And maybe my task is harder this way, compared to the situation that you need only understand w5300 to start to use it, but you don't need to reimplement it (as a form of software emulation ...).

"Of course" the "TCP aligned mode" should be forgotten, as it means that you _know_ always even number of bytes have in received packets? It sounds odd, that how you can be sure ever with that.

Haha, how "funny": it's _odd_ if you know that it's always _even_ :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.05. 20:29:31
Honestly, I am a bit lost here with the specification (of w5300, I mean). Many things are not clear for me, ie it says packet-info word tell the size. But what happens, if multiple packet arrived before we could process? What I can imagine, that if you read FIFO RX you will get packet info which tells the number of bytes in the packet. After reading that, and still bytes in the RX buffer (according to fifo rx size) reading a word will find the next received packet's packet-info word with its length, so I know how many bytes should be read. Well, I think :) What I don't know, where and how RECV command is needed (fromt he spec it seems it is some kind of acknowledgement only that we really read X words, and it has no any other purposes?), and why, if internal counter of RX FIFO "knows" how much data is already transferred to the host (so: EP) from the RX buffer.
You only have separated packets with own headers in the RX buffer in UDP mode. In TCP mode the whole data is one "stream" (no single packets). At least this is how it works for the W5100.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 20:46:42
You only have separated packets with own headers in the RX buffer in UDP mode. In TCP mode the whole data is one "stream" (no single packets). At least this is how it works for the W5100.

Hmm, that sounds odd for me. Because, what happens if you already read the packet info byte from RX buffer describing the data size, but meanwhile new packet arrives? The old packet info cannot be modified as it's already read ... That's why I thought, the new packet is stored then with its own packet-info word in the RX buffer. What I also suspected that the TCP aligned mode is just for that you mentioned: then it's one stream without any packet info in TCP mode.

Ah OK, I got your point now, but I'm afraid it's not so OK with the w5300! Just checked the "w5100 vs w5300" spec from Wiznet. It seems w5100 works like you mentioned, but w5300 does not, and it has (I already known that, that's why I lamented on that in my previous post you answered to) packet info even in TCP mode (not just in UDP, though it's much more simple, only a word for packet size in TCP mode). Unless if you set TCP aligned mode. I think the difference is because w5300 being so much 16 bit organized (and maybe w5100 is not? I don't know). Thus, if TCP data would be one stream with w5300 as you mentioned then there will be problem that an odd sized packet followed by a newer packet you wouldn't know that a byte should be skipped because it's just for the word alignment "dummy" byte. That is exactly what is TCP aligned mode is for: according the specification if you are SURE that only even sized packets received (that's something I find funny, because how you can be sure ...), you can set TCP align mode, and indeed, then it will work as you mentioned: a single stream without header in  TCP mode. Just because of the facts above, I doubt it's useful with that constraint we can't be sure about in a general TCP/IP solution at least (I can imagine that with a specific protocol a designer can make sure about this ...). Or it's also possible that I misunderstood something, of course.

It seems it's kinda handy to read that w5100 vs w5300 comparsion sheet from Wiznet. For me it does not mean too much (as I don't know w5100) but for you, it can be useful (as you are familiar with the w5100 because of the MSX net solution support already written using the w5100).

Anyway, I start to feel that w5100 is "better" for a 8 bit project: more simple. Only you have less sockets (4 instead of 8 ), and less on-chip TX/RX buffer RAM ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.05. 21:52:57
Hmm, that sounds odd for me. Because, what happens if you already read the packet info byte from RX buffer describing the data size, but meanwhile new packet arrives? The old packet info cannot be modified as it's already read ... That's why I thought, the new packet is stored then with its own packet-info word in the RX buffer. What I also suspected that the TCP aligned mode is just for that you mentioned: then it's one stream without any packet info in TCP mode.

Ah OK, I got your point now, but I'm afraid it's not so OK with the w5300! Just checked the "w5100 vs w5300" spec from Wiznet. It seems w5100 works like you mentioned, but w5300 does not, and it has packet info even in TCP mode (not just in UDP, though it's much more simple, only a word for packet size in TCP mode). Unless if you set TCP aligned mode. I think the difference is because w5300 being so much 16 bit organized (and maybe w5100 is not? I don't know). Thus, if TCP data would be one stream with w5300 as you mentioned then there will be problem that an odd sized packet followed by a newer packet you wouldn't know that a byte should be skipped because it's just for the word alignment "dummy" byte. That is exactly what is TCP aligned mode is for: according the specification if you are SURE that only even sized packets received (that's something I find funny, because how you can be sure ...), you can set TCP align mode, and indeed, then it will work as you mentioned: a single stream without header in  TCP mode. Just because of the facts above, I doubt it's useful with that constraint we can't be sure about in a general TCP/IP solution at least (I can imagine that with a specific protocol a designer can make sure about this ...). Or it's also possible that I misunderstood something, of course.

It seems it's kinda handy to read that w5100 vs w5300 comparsion sheet from Wiznet. For me it does not mean too much (as I don't know w5100) but for you, it can be useful.

Ops, ok, I also had a look in the W5300 manual again, and yes, there is this word in front of every package.
Ok, TCP aligned mode doesn't sound good, as it is always possible to receive packages with an odd number of bytes (best example: Telnet, where you sometimes send one single bytes in one whole package).
Because of the 16bit issue this length word in front of each package makes sense!
So my next idea is to store the word in front of the package in your socket handler. When the app only requests a smaller amount of bytes you update the remaining length in your handler. If you reach the end of the package you fetch the next length word and so on. This requires a little bit more code than the "stream" solution of the W5100 (yes, here everything is just completely byte-based!), but it should still work fine!
And now I also understand how they manage any odd package sizes without problems in the RX buffer when still having this 16bit stuff. That's really interesting!
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.05. 23:26:51
Yes. What I don't understand too much still, what exactly RECV command does, if internal (not transparent to the programmer) counters/pointers for buffers are maintained anyway on each FIFO reg access? According to spec, RECV command notifies that the host (we) received the data packet. Hmm.

"After memory copy, the host should inform the copy completion of data to W5300 by RECV command."

This sentence does not tell: after what kind of copy? A whole packet? Or every packets can be found in RX buffer? And why?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.05. 23:33:15
Yes. What I don't understand too much still, what exactly RECV command does, if internal (not transparent to the programmer) counters/pointers for buffers are maintained anyway on each FIFO reg access? According to spec, RECV command notifies that the host (we) received the data packet. Hmm.

"After memory copy, the host should inform the copy completion of data to W5300 by RECV command."

This sentence does not tell: after what kind of copy? A whole packet? Or every packets can be found in RX buffer? And why?
For the W5100 it only tells, that (after we copied a special amount of bytes from the buffer) we updated the pointers. It seems, that the W5100 doesn't poll the pointers but requires this command to know, that the pointers have been modified (which makes sense). I hope or guess, that it's the same for the W5300?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.05. 23:52:18
To the user at least it is not a circular buffer - incoming data just goes further and further up the buffer until it runs out. Maybe RECV resets the pointers back to the beginning. Or maybe I am being symplistic - if I was doing it I'd make the buffers circular so the pointers wrapped round the start and maybe that is what happens internally. I wonder what happens if a new packet comes in between you reading the last byte and issuing the RECV?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 00:13:41
To the user at least it is not a circular buffer - incoming data just goes further and further up the buffer until it runs out. Maybe RECV resets the pointers back to the beginning. Or maybe I am being symplistic - if I was doing it I'd make the buffers circular so the pointers wrapped round the start and maybe that is what happens internally.

I don't think RECV would "reset" the internal pointers. In the specification code examples uses RECV after "reading" one packet with size signaled by the packet-info. Thus there can be other packets in the RX buffer, I think in this case it wouldn't make any sense to reset. I would expect the buffers are some kind of ring buffers by the way as the specification does not write anything other just always things like "you can't receive more" or "transmit more" than the got/free size, and with the "moving further and further" statement it means some kind of circular/ring buffer works as an FIFO. So my best guess is like your, the internal FIFO pointer "wraps around" at the configured buffer size.

Quote
I wonder what happens if a new packet comes in between you reading the last byte and issuing the RECV?

Well yes, that is my question too :) In the examples, specification always show code fragments to read a packet than issuing a RECV command, but in this way, it seems like it would be not needed, because I can't see its purpose, if copying was already done anyway ... Hmm, maybe the memory inside the RX buffer is not freed without a RECV? I mean the RX data size is well modified after each FIFO RX access, but still there is a hidden counter inside to show the free RX size (for receiving new packet by w5300) and it's updated only by the RECV command with the counter value of number of access times of the FIFO RX. Or such. I have not so much better idea, what it is used for. What I mean here: if you have a small RX buffer configured and it's full with a packet, then w5300 can't receive (no free buffer). When reading RX FIFO register for the whole packet still won't allow for w5300 to receive, but at the time of a RECV command the internal counter is updated, thus w5300 can receive as seeing some free RX memory at last. Just guessing ... It would make sense too (for me) to update the internal counter stuff after each RX FIFO read as it would result in greater receiving raw performance (ie a smaller packet would already fit after reading some bytes but not the whole packet yet). But it's possible that it would make too complicated to try to receive after each FIFO access and not only after RECV.

Well even I have the idea (I can't say if it's true) that w5300 designers didn't want to do serious checks, and after the first access of RX FIFO register w5300 is forbidden to receive new packet till the host is done with the FIFO access, signalled by the RECV. So in this way there is no "concurrent" accesses (which always makes things more dangerous / complicated), ie reading by host, writing by w5300 receiver part. It does not mean that there can be only one packet in the RX buffer, I meant that _maybe_ receiving is not possible during copy, but it is possible for any amount of data/packets (till the size of RX buffer, of course) if host signalled the copy to be ready, and doing something different.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 08:59:50
That is important: if RECV command is really like that (blocking receiving between first RX FIFO reg access and RECV command) then it's problematic if we only fetch few bytes from w5300 on application's needs, as it blocks the receiving! So then we "should" fetch the whole packet and send RECV A.S.A.P. However if I think correctly, TCP on w5300 is also packet based (ie packet info on every packet) and since w5300 does not allow IP level fragmentation, the max packet size won't be bigger than something like the max MTU can be used on an ethernet network, well about 1500 bytes, minus the protocol overhead.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.06. 10:29:37
Yes and a bit of a pain if you are using all 8 sockets: I do not have the RAM to have 8x1500 byte buffers. I was planning on using just socket 0 for the EXOS device so that would be ok, but later with EXDOS integration I was thinking one socket per mapped network resource. I will do some experiments as soon as I can to see if this really is the case!
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 10:46:06
Yes and a bit of a pain if you are using all 8 sockets: I do not have the RAM to have 8x1500 byte buffers. I was planning on using just socket 0 for the EXOS device so that would be ok, but later with EXDOS integration I was thinking one socket per mapped network resource. I will do some experiments as soon as I can to see if this really is the case!

Yes, that's not a little amount of RAM :( Ok, you can say - in theory - that it's not problem that w5300 can't receive more packets on that socket, as the app is not interested in more bytes yet, so the reason not all bytes are read. However, if app is really slow, when it asks for, the window size tcp information is zero for the network peer and it's kinda slow to "recover" from the stalled connection (even when the app now NEEDs data!) at tcp/ip level then. The specification is a bit messy here, mentioning, that you can force the window size update with an empty packet sending. But things goes quite complicated then, at least at the first glance for me ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.06. 10:56:20
But things goes quite complicated then, at least at the first glance for me ...
Yes, I did not go beyond a brief glance at that point! :???:
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 11:01:10
But I have to admit that I am a bit lame with EXOS. Since the goal would be also having a proper EXOS integration of network resources (well, I hope so, at least). That is, for example, to able to open an EXOS channel which is a tcp connection for real, so even a BASIC program can do a POP3 connection then to check for mails, or whatever. But then here, I am a bit lost: what happens if app for an open channel like this wants to read X bytes, but only fewer is ready (in the RX buffer). Should we return with less byte read, or wait for further packets? Can EXOS provide the notion of "blocking" and "non blocking" I/O for example?

Also, without a hooked interrupt to check all sockets by EXOS, if a call is blocked because waiting for data, other connections are stalled, as not handled. Ok, EXOS is not multitasking, so you can say, it's not a problem, but then the connected peers through the network may have problem with interpreting the situation as stalled connections because of the receiving window size information is not so much updated and or no ACK is sent back (but hmm I guess ACK is sent by w5300, however I am not sure if it only happens after reading packet and issuing that RECV command!).
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.06. 12:18:54
My initial goal with EXOS integration is for network LOAD/SAVE in BASIC to work (and other applications of course) and I was thinking first of LOAD "ftp:blahblah" etc. (or LOAD "http:blahblah" as we have discussed before). Here the protocol on top of TCP/IP is FTP and the EXOS FTP: device will handle that.

What you are talking about is the EXOS app implementing a different protocol itself on top of TCP/IP, eg POP3 in your example, and I have not given much thought to that, but it needs to be possible. eg open a channel to "NET:192.168.0.20:1001" (can you have two : s and a filename that long?). But at least in this case the application is network-specific so it can work around whatever EXOS's blocking-or-not behaviour is. EXOS has a read status call which says whether a character is ready or not (shame it doesn't say how many are ready! :oops: ) and I would say block read should return whatever is available, possibly less than the user asked for. Surely protocols are designed so the "reader" knows how many bytes he is supposed to read? In the case of POP3 the responses from the server are single text lines which you could read character-by-character, or as a block returning however many are available, and then when a mail message itself is downloaded you already know how many to expect, so you loop doing block reads until you have the message, presumably with a timeout. Avoiding a waiting-for-network loop within EXOS seems like a good idea if at all possible!
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.06. 12:45:52
Yes, that's not a little amount of RAM :( Ok, you can say - in theory - that it's not problem that w5300 can't receive more packets on that socket, as the app is not interested in more bytes yet, so the reason not all bytes are read.
I still wonder what happens, if you read less bytes from the RX_FIFO than stated in the last PACKET_INFO and then send a RECEIVE command. Later you can still read the remaining bytes of the current packet (and send RECEIVE again), as you still know how much bytes are left. It would be strange, if this shouldn't work, as for the W5300 these are only bytes in its memory and nothing else. In this case you don't need these 8x1500 byte buffers on EP side. But who knows... :ds_icon_frown:

The specification is a bit messy here, mentioning, that you can force the window size update with an empty packet sending.
I just read that, and this seems to be a solution for such a problem that I sometimes have with the W5100 - the connection is sometimes stalled when receiving a lot of incoming data! But I think it's not possible to send an empty package? In the example the dummy data still has a size of 1 byte. Couldn't this cause issues with some protocols?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 13:08:10
My initial goal with EXOS integration is for network LOAD/SAVE in BASIC to work (and other applications of course) and I was thinking first of LOAD "ftp:blahblah" etc. (or LOAD "http:blahblah" as we have discussed before). Here the protocol on top of TCP/IP is FTP and the EXOS FTP: device will handle that.

I see, but I guess then you an even open a channel and use that for reading, if it's usuable with LOAD too. FTP is bit more problematic too, as also a firewall administrator (among many other things) I can say, that FTP is a stone aged horrible protocol, it needs another tcp connection for data, and it can be passive / active FTP which also means the "direction" (who is the listener, I mean). Not counting ASCII/BINARY transfer etc (but I guess binary is OK if you can do that only). I try to avoid FTP if it's possible, eg via HTTP you can download anything too (or even upload, but that's some kind of other stuff, namely the DAV protocol over HTTP). But I can understand of course that many people would be happy with FTP as many sites provides FTP download, which can be used with EP directly then.

Quote
What you are talking about is the EXOS app implementing a different protocol itself on top of TCP/IP, eg POP3 in your example, and I have not given much thought to that, but it needs to be possible. eg open a channel to "NET:192.168.0.20:1001" (can you have two : s and a filename that long?). But at least in this case the application is network-specific so it can work

Btw, this is what I've already talked about: that's EXOS filenames are limited in size, which can be problematic, maybe not here, but even with FTP and/or HTTP. That's why I've suggested the "network resource declaration" with an EXOS command and you can only refer it when opening a channel. Of course, if name is suitable (eg: short enough, and does not contain character(s) forbidden by EXOS) the direct naming (what you've wrote as an example with FTP) is more than OK.

Quote
whatever EXOS's blocking-or-not behaviour is. EXOS has a read status call which says whether a character is ready or not (shame it doesn't say how many are ready! :oops: ) and I would say block read should return whatever is available, possibly less than the user asked for. Surely protocols are designed so the "reader" knows how many bytes he is supposed to read? In the case of POP3 the responses from the server are single text lines which you could read character-by-character, or as a block returning however many are available, and then when a mail message itself is downloaded you already know how many to expect, so you loop doing block reads until you have the message, presumably with a timeout. Avoiding a waiting-for-network loop within EXOS seems like a good idea if at all possible!

I think POP3 is line oriented protocol more or less as iRC is too. What a simple app can do, is try to read "some bytes" and check if it's line terminated. If not, try to read more bytes, by appending the buffer. If line termination is found, then the line can be processed, and the possible left bytes are used again to try the first line terminator, or waiting for more bytes, etc.
Otherwise POP3 is not so hard, there can be an app over plain TCP/IP stream for basic mail client (IMAP at the other hand is more complicated, but it also gives the possibility of mail folders, with POP3 there is not such a thing). Also sending mail is not so complicated, if TLS etc stuff is not needed, the SMTP authentication with the PLAIN scheme can be done (but it requires base64 encoding).

Just, if you think about a simple app: it should poll the network for incoming data, but it has other tasks, ie user keyboard handling, screen updating etc. So what I would do, is checking if there is any data (so EXOS can do this) then I try to read data with size of the maximal possible (for our buffer in EP RAM, I mean). That's my problem, that an EXOS read function requested for n bytes can return with less bytes. Or if it can (it can, if I remember exactly) is it a good strategy, would it work with LOAD etc, or it should wait a bit for more data? Because the "common behaviour" with disk files that EXOS will return "n" bytes if "n" bytes are asked (unless if EOF is got of course ...). So I am not sure if applications are ready for this behaviour, that it will be much more common that read return with less bytes than eg with disk files. Of course a network-aware app (eg POP3 client ...) will know this, but we would like that existing software can be adopted easily just with opening let's say NET:1.2.3.4:110 instead of a name for a file on the disk. And it even includes eg BASIC's LOAD if it can handle this situation well enough, or if it gets less bytes than it requested then it's interpreted as end-of-file, since basically - AFAIK - this can be only the case if end of file is hit meanwhile if you work with disk files.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Zozosoft on 2015.July.06. 13:23:46
EXOS has a read status call which says whether a character is ready or not (shame it doesn't say how many are ready! :oops: )
What do you think about EXOS 10? It is can be used for network files?
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 13:33:57
What do you think about EXOS 10? It is can be used for network files?

Hmm, do you mean EXOS 9, or really 10? But the problem - I think - is not exactly this, but the fact that - as far as I can see - with disk files EXOS will return less bytes than asked on reading only in case of EOF (so no more bytes). Thus, maybe many EXOS apps can think that less bytes read than requested is the sign of end-of-file, so game over. With network channels the situation is not that (so not compatible) as EXOS call for a network channel can return less bytes than requested because of no data is sent by the network peer. But in this case this does not mean end-of-file, but the app should re-try later if more data is received meanwhile.

So basically me problem: EXOS apps maybe used to deal with "real files" behind the notion of "channels", but in our case network channel is a bit different as it's not an "already ready" stream of data on the disk, but received on reading, etc, in "real time". The problem that we can ask (maybe with EXOS 9) if there is any byte to read or not, but we don't know how much is that "any". Also, if EXOS 9 returned with "no characters" then what an app can think: "end of file" (closed connection like stuff) or just try to re-ask later. Maybe network channels are more like KEYBOARD: EXOS device than "real" files! And that is what EXOS apps are maybe not ready. For newly written apps it may be not a problem.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 14:02:42
I still wonder what happens, if you read less bytes from the RX_FIFO than stated in the last PACKET_INFO and then send a RECEIVE command. Later you can still read the remaining bytes of the current packet (and send RECEIVE again), as you still know how much bytes are left. It would be strange, if this shouldn't work, as for the W5300 these are only bytes in its memory and nothing else. In this case you don't need these 8x1500 byte buffers on EP side. But who knows... :ds_icon_frown:

Hmm, ok, but then you can say, you don't even read anything and send a RECV command. Or read all the packet then issuing the command. Or only a part of the packet and then. I don't see the difference, and then the question remains: what is the purpose of RECV command, if it is even not interesting when you send it to the w5300? That's why I think it has some important role, just we don't know what. Because if it wouldn't have importance at all, why would it be designed to be used? I am confused with this question a lot.

Quote
I just read that, and this seems to be a solution for such a problem that I sometimes have with the W5100 - the connection is sometimes stalled when receiving a lot of incoming data! But I think it's not possible to send an empty package? In the example the dummy data still has a size of 1 byte. Couldn't this cause issues with some protocols?

Well, a TCP packet can carry some informations (like ACK) even with no data payload at all. Then an OS should behave to deal with the information you got from the header, but since there is no application-level data, the application itself is not important here, just the TCP/IP stack of the OS. In our case the "OS" itself at the EP side is the w5300, since it does the TCP/IP "by hardware". I guess even w5300 processes incoming packets with data size zero, and it is not stored then in the RX buffer at all, since it's only connection-organization like information and not user data. Just consider the ACKs. TCP (unlike UDP) is "reliable", ie the receiver (now w5300 for example) should ACK the it for the sender. The ACK itself can be sent as a single packet with no data payload at all (as far as I know ...). It's another question that if the receiver has something to transmit, it's a better strategy to transmit, and use the ACK field of the TCP header to ack the previous receiving in one packet. But it can a case when receiver has nothing to send, but still the sender must be ACK'ed, thus then, a packet should be sent anyway to transmit the ACK without any application payload though. Well, it seems it was long time ago when I tried to write TCP/IP stack for C64 and I digged into TCP more deeply because of the project. Now I am not so sure anymore about the details :(
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: BruceTanner on 2015.July.06. 14:39:42
Hmm, do you mean EXOS 9, or really 10? But the problem - I think - is not exactly this, but the fact that - as far as I can see - with disk files EXOS will return less bytes than asked on reading only in case of EOF (so no more bytes). Thus, maybe many EXOS apps can think that less bytes read than requested is the sign of end-of-file, so game over. With network channels the situation is not that (so not compatible) as EXOS call for a network channel can return less bytes than requested because of no data is sent by the network peer. But in this case this does not mean end-of-file, but the app should re-try later if more data is received meanwhile.

So basically me problem: EXOS apps maybe used to deal with "real files" behind the notion of "channels", but in our case network channel is a bit different as it's not an "already ready" stream of data on the disk, but received on reading, etc, in "real time". The problem that we can ask (maybe with EXOS 9) if there is any byte to read or not, but we don't know how much is that "any". Also, if EXOS 9 returned with "no characters" then what an app can think: "end of file" (closed connection like stuff) or just try to re-ask later. Maybe network channels are more like KEYBOARD: EXOS device than "real" files! And that is what EXOS apps are maybe not ready. For newly written apps it may be not a problem.

A tcp/ip connection is just a stream of bytes with no meaning, it is not a file level protocol, and in that respect yes it is more like an EXOS keyboard channel than a disk channel. LOAD, SAVE etc need a file level protocol as they have filenames, file sizes etc. and I wouild think most EXOS apps will be like this. So I think FTP:, HTTP: etc will need to block for the reasons you say, but that's ok because they know how many bytes are arriving and EXOS is a synchronous system (and if the expected bytes don't arrive within a reasonable time the protocol has broken and an error will be returned). You will LOAD "FTP:..." or LOAD "HTTP:..." but you will not LOAD "NET:192.168...". So maybe NET: channels should be non-blocking but FTP: etc channels will block.

EXOS 10 might be able to work with the higher level (FTP: etc) protocol but I don't know them in enough detail to know for sure. I'm pretty sure it would with SMB though.

In your BASIC POP3 app example I guess you would use INPUT # to read and PRINT # to write to the POP3 server so if the TCP/IP channel behaves like the keyboard channel that won't be bad. Not the most efficient way to transfer a large email message though...

I know your dislike of FTP: and you undoubtedly know more than me about it. From a user's perspective though running an FTP server on a PC and being able to LOAD and SAVE to it might be the easiest way of getting files on and off the EP, which is my initial target. Other possibilities as we have discussed before are HTTP: (not sure of the ease of doing other file operations) and SMB: (designed to match MS-DOS functions and therefore EXDOS functions and the basis of Windows resource sharing, but not sure how much it has evolved to be difficult!).
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Prodatron on 2015.July.06. 14:49:31
what is the purpose of RECV command, if it is even not interesting when you send it to the w5300? That's why I think it has some important role, just we don't know what. Because if it wouldn't have importance at all, why would it be designed to be used? I am confused with this question a lot.
I think it's only to tell the W5300, that the buffer size changed. The buffer memory is the only place, which stores the information about the received packages (packet_info + data). But it's still only a FIFO buffer/data stream. So why should it be important to fetch the complete package?

Quote
Well, a TCP packet can carry some informations (like ACK) even with no data payload at all.
The example code on page 95 seem to send exactly 1 byte:

Code: [Select]
/* set RECV command */
Sn_CR = RECV;
/* Add the code that notifies the update of window size to the peer */
/* check the received data process to finish or not */
if(Sn_RX_RSR == 0) /* send the window-update packet when the window size is full */
{ /* Sn_RX_RSR can be compared with another value instead of ‘0’,
according to the host performance of receiving data */
    Sn_TX_WRSR = 0x00000001; /* set Dummy Data size to Sn_TX_WRSR */
    Sn_TX_FIFOR = 0x0000; /* Write Dummy Data into TX memory */
    Sn_CR = SEND; /* set SEND command */
    while(Sn_CR != 0x00); /* check SEND command completion */
    while(Sn_IR(SENDOK) == ‘0’); /* wait for SEND OK */
    Sn_IR(SENDOK) = ‘1’; /* Clear SENDOK bit */
}

When using a TCP connection with the W5300 there doesn't seem to be a possibility just to send an ACK package.
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 14:50:37
Well, something has just crossed my mind: EXOS 11, aka special functions. There are some "sub calls" there involves "the network". Of course it is _not_ that network we mean it now :) but anyway, the basic problems can be similar (block, should not block, special calls via EXOS 11 etc). I am not sure if it's useful, but maybe some can learn from the already ready EXOS parts dealing _a bit_ similar situations ... Eg, over SERIAL stuff, there are situations too that you have no ready data yet, etc.

http://ep.homeserver.hu/Dokumentacio/Konyvek/EXOS_2.1_technikal_information/exos/serial/

Regard to the original issue: I am quite interested what happens if an FTP: (or HTTP: whatever) like EXOS device would be ready and some use it to LOAD a program. It's quite possible that some of the calls can catch a time when 0 bytes are ready to read, or maybe not zero, but less than the requested size. It would be a great test to try, what happens then, would LOAD stopped as treating that end-of-file or what. I have no idea at all, I am not familiar with EXOS at this level ...
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 14:58:03
I think it's only to tell the W5300, that the buffer size changed. The buffer memory is the only place, which stores the information about the received packages (packet_info + data). But it's still only a FIFO buffer/data stream. So why should it be important to fetch the complete package?
The example code on page 95 seem to send exactly 1 byte:

Code: [Select]
/* set RECV command */
Sn_CR = RECV;
/* Add the code that notifies the update of window size to the peer */
/* check the received data process to finish or not */
if(Sn_RX_RSR == 0) /* send the window-update packet when the window size is full */
{ /* Sn_RX_RSR can be compared with another value instead of ‘0’,
according to the host performance of receiving data */
    Sn_TX_WRSR = 0x00000001; /* set Dummy Data size to Sn_TX_WRSR */
    Sn_TX_FIFOR = 0x0000; /* Write Dummy Data into TX memory */
    Sn_CR = SEND; /* set SEND command */
    while(Sn_CR != 0x00); /* check SEND command completion */
    while(Sn_IR(SENDOK) == ‘0’); /* wait for SEND OK */
    Sn_IR(SENDOK) = ‘1’; /* Clear SENDOK bit */
}

When using a TCP connection with the W5300 there doesn't seem to be a possibility just to send an ACK package.

ACK is a different thing, I just mentioned as an example, but this is only for window size update notification purpose. ACK can be transmitted without data, just it's internal to the w5300, a programmer can't do that (it's done by w5300 internally, it has even settings to delay ACKs or not, etc). This window size update is another thing, just I am surprised what happens now, as the code example transmits a byte! So you have an extra unwanted byte sent, and received by the peer. I am confused with this one, really.

Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: lgb on 2015.July.06. 15:24:34
Ah, I guess, I understand what happens. The specifications says that the problem can be noticed if w5300 is NOT used to transmit data, but only receiving, thus if buffer is full (we are not enough fast to process) the sender is not notified about the window size change too much. I guess later it will "recover" but it's up to the sender than it tries again and a longer time of "stalling" period can be noticed. The code example - as far as I can understand - is about the situation when w5300 only receives. So it can transmit a byte without too much problem for notification as the target won't use that as application data (eg not interested in it). But I am still not 100% sure how they mean that anyway :) But one thing is clear: for "normal" bi-directional tcp stream that code wouldn't work, or well let's say it would work, just it would corrupt the data communication with extra unwanted byte sent :)

Btw, that example is at page 98 ... Maybe we read not the very same spec :)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: edoz on 2015.July.10. 11:11:47
Hey Guys,

Prodatron created this movie! and it would be a big motivator to have the network ready for the Enterprise :D


https://www.youtube.com/watch?v=L3arrALdYcU (https://www.youtube.com/watch?v=L3arrALdYcU)
Title: Re: Wiznet 5100/5300 /etc and Enterprise
Post by: Zozosoft on 2015.July.10. 12:03:01
Wow! :ds_icon_cheesygrin: