BushSTB serial0 ppp link <-> unix success
Matt Evans
bush-hacking@earth.li
Thu, 8 Aug 2002 18:24:28 +0100 (BST)
Dear Ladies & Gents,
Further to our last discussion on the first (unused) serial port on
the Bush STB, I have moved forwards a little.
I managed to get the STB talking PPP at 115200bps to my BSD box, under
RISC OS/NC OS, such that the desktop/NCFresco work transparently over
the serial link as if it were a modem link.
*phew*
The problem last time was that devices:$.Serial1 exists and you can
open it, but it does nothing. On closer examination (read: "getting
stung in the arse trying to find why serial IRQs in linux wouldn't
work) it is an IRQ problem. The SMSC 37C669 SuperIO chip goes through
a configuration mode when the OS boots, and is told what IO addresses
and IRQs it should respond to & generate. The NCOS sets up the
SuperIO chip so that UART0 IRQs go out of pin IRQ_D, and UART1 IRQs go
through IRQ_C. But, IRQ_D isn't connected to anything (!) whereas
IRQ_C goes through an inverter(ish) to nIRQ6 of the 7500FE... as the
serial IRQ that works.
The solution's simple - you reconfigure the SuperIO so that it
generates IRQs from both UARTs sharing the same pin IRQ_C.
The following BASIC program performs this (it's a little longer than
needs be, I can't remember where the config registers are; they aren't
arbitrary on the STB).
-------8<------8<------ izipfs:$.SIO --------8<----------
10 REM>SIO
15 REM Re-configure the STB's superio so both serial ports share 1 IRQ
17 REM (*not* as the NCOS ROM configures it!) 8/8/02 Matt Evans
20 DIM c% 2048
30 FOR p%=0 TO 2 STEP 2
40 P%=c%
50 [opt p%
60 .start
70 SWI "OS_EnterOS"
80 ; in SVC mode now, should be able to access SuperIO
90 .probe
100 ldr r10,superiobase
110 add r1,r10,#&3f0<<2
120 mov r0,#&55
130 strb r0,[r1]
140 strb r0,[r1]
150 mov r0,#&d
160 strb r0,[r1]
170 ldrb r0,[r1,#4]
180 cmp r0,#3
190 beq smsc_config
200 ;else try 370
210 add r1,r10,#&370<<2
220 mov r0,#&55
230 strb r0,[r1]
240 strb r0,[r1]
250 mov r0,#&d
260 strb r0,[r1]
270 ldrb r0,[r1,#4]
280 cmp r0,#3
290 beq smsc_config
300 ; else not found =( return -1
310 mvn r0,#0
320 movs pc,r14
330 .smsc_config
340 ; Chip config is at [r1]
350 mov r0,#&28
360 strb r0,[r1]
370 mov r0,#&3f ; serial0 out IRQ_C, serial1 shares serial0
380 strb r0,[r1,#4]
390 mov r0,#&aa
400 strb r0,[r1] ; end config
410 mov R1,PC
420 teqp R1,#3
430 mov R0,R0
440 mov r0,#0
450 mov pc,r14
460 .superiobase EQUD &03010000
470 ]:NEXT
480 PRINT "Reprogramming superio...";
490 A%=USR(start)
500 PRINT "..done, result = ";A%;"."
-----------------------
(sorry, no binary yet; paste it into BASIC in a task window?)
OK, so having built your MAX232 cable onto the UART0 pins, you can now
do:
*pppconnect devices:serial1 115200 defaultroute
and the box will connect to a unix box that you've done something like
this on:
/usr/sbin/pppd /dev/ttyS1 115200 10.10.10.1:10.10.10.2 noauth nocrtscts
(where 10.10.10.1 is the unix box's IP (or another network) and 10.10.10.2
is the STB)
I put this on my Zip disc, together with the 'SIO' program above:
------8<-------- izipfs:$.Auto ---------
izipfs:$.SIO
pppconnect devices:serial1 115200 defaultroute
set inet$resolvers 10.10.10.10
resolverconfig
----------------------------------------
(10.10.10.10 is my box running named)
Unfortunately a Zip disc is still needed, but hey. You can turn it
off when it boots. The only probs I've found so far is that my
FreeBSD kernel can't cope with >1 ppp interface.
I hope this helps people avoid stringing two modems together with a
PABX or something -- viva digitale all the way!
Cheers,
Matt
ps: now that I actually have a use for the thing... does anyone have a
spare they'd sell me? Mine's a bit too hacked-about-with to live under
the TV now. :)