QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Nagging hardware related question? Post here!
martyn_hill
Aurora
Posts: 909
Joined: Sat Oct 25, 2014 9:53 am

QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by martyn_hill »

Hi everyone!

Question: Has anyone come across LBYTES consistently failing on a QL running Minerva + TK2 ?

I've found ways around it for my purposes, but think I've uncovered an incompatibility with this combination that I've never seen written before.

Curiously, aside from the above, I've found the N/W to run quite reliably...

Setup:
QL1 - Issue 7, custom SRAM memory expansion, plus NVRAM holding Tk2 plus other goodies.
QL2 - Issue 5, custom SRAM exp, shadowing internal DRAM and also made (partially) non-volatile to hold various goodies.

Background:
So, for some time now, I have been exploring the QLNET functionality, with the (ultimate) aim of building a small USB to QLNET interface to link QPC/laptop to a BBQL - with Tk2's fileserver capability. Before anyone gets too excited, the end-goal is still some way off...

After many hours pouring over the Minerva and SMSQ/E source code (that still has Tk2 source embedded in it for the N/W and MDV), with the Tk2 description of the QLNET protocol as a (vague) guide, I then moved to testing a pair of QLs (the second resurrected, with a custom-built memory expansion, shadowing the internal DRAM, which was flaky. Quite proud of that hardware project, actually...) and 'sniffing' the network by hooking-up a cheapo USB Digital Analyser between them.

To drive the test, I was using SBYTES/LBYTES of one display to the other.

After loads of permutations (really, loads...), I discovered that without Tk2 loaded on the destination (LBYTES) QL, the N/W worked flawlessly (within its limits).

The moment Tk2 was loaded on the destination QL, nothing would pass. Didn't matter which version of Tk2 (tried 2.13, 2.20, 2.23 and 2.26) and whether or not Tk2 was loaded on the source (SBYTES) QL.

Didn't matter which direction, either (QL1 to QL2 or vice-versa).

However, I could LOAD and OPEN 'neti_x' and pretty much everything else I've tried so far, and they would work. Only when LBYTES was used at the destination running Tk2 on Minerva would it fail.

I tried MGUK + Tk2 and that didn't seem to be a problem, even for LBYTES, so I'm guessing that there is some incompatibility specifically between Minerva and Tk2 whenever the LBYTES (ok, "fs.load" to be precise) is invoked.

The only fundamental difference I could find between Tk2 and Minerva's N/W source was the way the SCOUT is prepared (shouldn't matter as the timings are still very similar and the scout is skipped once detected) and how interrupts are disabled/re-enabled at set-up/close-down of the N/W activity.

As LBYTES/fs.load does something funky with that scatter-load idea (not especially relevant for a pure serial interface like the N/W), which I think involves disabling interrupts as well, I reckon its in there somewhere.

Or I could be wrong.

Just thought to share, anyways.


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by RWAP »

That is interesting - it might be worth checking the updates log on Minerva to see when anything was changed, and then see if you can test a different Minerva version.

Have you tried using one computer as a fileserver and using SBYTES direct to a file on that computer....


martyn_hill
Aurora
Posts: 909
Joined: Sat Oct 25, 2014 9:53 am

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by martyn_hill »

Hi Rich

Enabling FSERVE is my next step and, ultimately, what I want to monitor 'on the wire' towards my final goal (that USB-QLNET adapter) - the Tk2 sources in SMSQ/E are pretty obscure as to how those 'rpc' calls are handled...

Of course, its not clear which version of Tk2 is actually documented in the SMSQ/E sources, but the Tk2 'changes' document (only covers up to v2.13 ) don't indicate any relevant updates in the NW code over time.

Nor could I find anything relevant in the Minerva 'changes' document referring to the network driver. I'll stick with v1.98 until I find something to suggest that an earlier version handled the NW (or LBYTES) differently.

I'll keep you posted :-)

If any one is interested in the minutia of the things I've discovered (timings etc), I'll happily share them here - but its a bit dull and probably already known by those with any use of the info...


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by tofro »

Martyn,

can't help with the Minerva problem, unfortunately.

But you're doing interesting things ;)

I have started something similar. What hardware do you intend to use for the USB MCU?

I have one of these:
http://www.digikey.de/product-detail/en ... pmt=&pdv=c

Dead cheap at 5€, has an ARM core and UART/USB on board and a number of nice other goodies. 4kB RAM, 32KBytes ROM

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
martyn_hill
Aurora
Posts: 909
Joined: Sat Oct 25, 2014 9:53 am

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by martyn_hill »

Hi Tobias!

Well, I have an Arduino Uno (R3) clone that i intend to put in to action - when I finally get to that point.

The major challenge will be how to decouple the (usually dormant) Tk2 net drivers in SMSQ/E from the 'physical layer' and redirect via the virtual Serial port (connected to the Arduino). Got various ideas (and read the challenges in another thread around 'multi-layer' QDOS drivers), but still really at the 'discovery' stage of unraveling what the file-server protocol looks like on the wire, as compared to the basic NET protocol... Again, the Tk2 sources (in SMSQ/E at least) are somewhat opaque in this regard.

Meanwhile, prompted by Rich to try the file-server on the source QL, this DOES allow LBYTES to work (i.e. LBYTES 'Nx_file'...) under Minerva - but still, not the basic LBYTES 'NETi_x' approach - so there is still something incompatible with the way LBYTES is implemented in Minerva as compared to what Tk2 expects (the 'fault' could lie in either camp...)

I've got enough now to carry on my explorations, so will put the LBYTES problem down for now. Curious, none the less, but I guess the combination of Minerva + Tk2 _and_ regularly play with the N/W between two QLs is not so common as to have spotted this one before.

More to follow (and I'd love to hear about your ideas!)


Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by Derek_Stewart »

Hi Martyn,

Pre-Minerva networking via QNET was a little hit or miss, Minerva solved all the reliable issues.

Personally, I would not use anything less than Minerva, but saying that SMSQ/E is much better.


Regards,

Derek
User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by tofro »

Well, I have an Arduino Uno (R3) clone that i intend to put in to action - when I finally get to that point.

[/quote]

Aha. That's probably a bit low on RAM for the task - The extended TK2 file server protocol works with packets of 1k size - You'll probably have to provide at least one packet buffer for either side (to be able to receive at any point in time), that would mean your RAM is gone. Let's see how you are going to solve this.
martyn_hill wrote: The major challenge will be how to decouple the (usually dormant) Tk2 net drivers in SMSQ/E from the 'physical layer' and redirect via the virtual Serial port (connected to the Arduino)
My approach is actually targetting not to go into QPC2 at all, but rather have a "modern" host application act as a file server for QLAN. But that still implies serial connectivity over USB to the host. But I am by far not somewhere that I had something that could be shown (ah, that dreaded lack of time).

Even if the QLAN protocol is somewhat special, I have managed to receive (properly looking) bytes from the QLAN wire using a "normal" UART - It gets a bit confused with the scout, but once it's over that ;) , it will receive a packet just fine. This approach obviously does not work for sending, however. That is probably going to be buit-banged, just like the QL and the Spectrum do.

Tobias.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by Martin_Head »

martyn_hill wrote: However, I could LOAD and OPEN 'neti_x' and pretty much everything else I've tried so far, and they would work. Only when LBYTES was used at the destination running Tk2 on Minerva would it fail.

As LBYTES/fs.load does something funky with that scatter-load idea (not especially relevant for a pure serial interface like the N/W), which I think involves disabling interrupts as well, I reckon its in there somewhere.
Have you tried LBYTEing a small file rather than a screen display? Or LOADing a large file? (although wouldn't LOAD use io.fline rather than fs.load?)
I think that the scatter load is only used on files above a certain size.

Martin Head


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by RWAP »

martyn_hill wrote:
Nor could I find anything relevant in the Minerva 'changes' document referring to the network driver. I'll stick with v1.98 until I find something to suggest that an earlier version handled the NW (or LBYTES) differently.
Have you had a look at the SBASIC/SuperBASIC Reference Manual section on networking in case there is anything different in there (I forget).

I may have some older Minerva chips here (no carriers) if you want to try some different combinations... Might be worth trying a Minerva on both machines for example, in case it is anything to do with timing...


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: QLNET, Minerva, Tk2 and LBYTES - a curiosity...

Post by tofro »

The whole debugging should be much easier once you have a means to "sniff" QLAN packets off the wire using your Arduino - Once there you should easily be able to compare Minerva apples to MG oranges and find the differences. And I guess that sniffing stuff would be something you'll do anyhow. I wouldn't bother much atm.

Regards,
Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Post Reply