HostFS and microcontrollers?

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
User avatar
myelin
Posts: 202
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

HostFS and microcontrollers?

Postby myelin » Wed Jun 21, 2017 12:19 am

I'm still working on the firmware to get an ATMEGA32U4 working as a USB-serial bridge for UPURS, but once I get that working, I'm really looking forward to trying out HostFS:UPURS, and then seeing if I can implement the host side of it in the microcontroller itself. Has anyone else done something like this?

I'm excited about the possibility of putting ADFS and DFS floppy images, ADFS hard disk images, and tape images on an SD card and having the microcontroller serve them up (with PAGE=&E00) to a BBC or Electron.
SW/EE from New Zealand, now in San Francisco: http://myelin.nz/
Having fun making hardware projects for the Electron!
So far: 32k flash cart, USB cart interface, 3-cart expansion, Elk PiTubeDirect. Later: Dual ported ram cart.

User avatar
jgharston
Posts: 2756
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: HostFS and microcontrollers?

Postby jgharston » Wed Jun 21, 2017 12:38 am

I've written serial HostFS clients for various microcontrollers, but have only written hosts for full-blown computers. Sounds like an interesting project.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
sweh
Posts: 1847
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: HostFS and microcontrollers?

Postby sweh » Wed Jun 21, 2017 11:44 pm

myelin wrote:I'm still working on the firmware to get an ATMEGA32U4 working as a USB-serial bridge for UPURS, but once I get that working, I'm really looking forward to trying out HostFS:UPURS, and then seeing if I can implement the host side of it in the microcontroller itself. Has anyone else done something like this?

I thought about this, at one point, but never even started writing code. A related thought I had was that the communication needn't be _serial_. We have at least 8 I/O ports (potentially 9 or 10, depending) so we could do something slightly smarter; eg have 4 pins to transmit a nibble at a time and 4 pins for handshaking (CTS/RTS or whatever else). It'd require rewriting of the code but HostFS:UPURS has that segmented and keeps MartinB's routines mostly untouched. It's probably just two functions that'd need replacing.
Rgds
Stephen

User avatar
myelin
Posts: 202
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: HostFS and microcontrollers?

Postby myelin » Thu Jun 22, 2017 4:41 am

sweh wrote:I thought about this, at one point, but never even started writing code. A related thought I had was that the communication needn't be _serial_. We have at least 8 I/O ports (potentially 9 or 10, depending) so we could do something slightly smarter; eg have 4 pins to transmit a nibble at a time and 4 pins for handshaking (CTS/RTS or whatever else). It'd require rewriting of the code but HostFS:UPURS has that segmented and keeps MartinB's routines mostly untouched. It's probably just two functions that'd need replacing.


I'd be curious to see a timing analysis for something like this, for a BBC or Electron talking to, say, a 16MHz AVR. I've started thinking this through before, but none of my ideas turn out to be that much better (and are definitely less convenient) than straight serial, unless I can use a CPLD to time things exactly, in which case I may as well put it on the 1MHz Bus instead :) Hopefully it's just that my ideas aren't very good -- I would definitely implement such a thing if someone can come up with a relatively efficient handshaking protocol!
SW/EE from New Zealand, now in San Francisco: http://myelin.nz/
Having fun making hardware projects for the Electron!
So far: 32k flash cart, USB cart interface, 3-cart expansion, Elk PiTubeDirect. Later: Dual ported ram cart.

User avatar
jgharston
Posts: 2756
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: HostFS and microcontrollers?

Postby jgharston » Thu Jun 22, 2017 2:36 pm

sweh wrote:I thought about this, at one point, but never even started writing code. A related thought I had was that the communication needn't be _serial_. We have at least 8 I/O ports (potentially 9 or 10, depending) so we could do something slightly smarter;

The "serial"-ness of the Serial Host really just refers to the fact that it uses a single data transmission port, as opposed to the hardware Tube that uses four ports. I've used the same serial host/clients with a single data port via back-to-back parallel ports, Z80+8255 plugged into BBC+6522. In retrospect it's probably a confusing name, but it seemed the logical name back in 1993-ish.

I've written all the Serial Clients with the actual I/O code severly compartmentalised, the 'SendData' and 'ReadData' routines, so it can be chopped out and replaced to talk with other hardware. With most single-port communication it just requires the EQUates changing, to change the data port address and the status register bits.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
myelin
Posts: 202
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: HostFS and microcontrollers?

Postby myelin » Sun Jul 09, 2017 12:15 am

sweh wrote:We have at least 8 I/O ports (potentially 9 or 10, depending) so we could do something slightly smarter; eg have 4 pins to transmit a nibble at a time and 4 pins for handshaking (CTS/RTS or whatever else). It'd require rewriting of the code but HostFS:UPURS has that segmented and keeps MartinB's routines mostly untouched. It's probably just two functions that'd need replacing.


I got frustrated trying to make the microcontroller communicate perfectly with the UPURS routines, and hacked together my ideal communication system using a CPLD instead, with the microcontroller talking to the CPLD using SPI, and the CPLD connected as an Electron cartridge (and a BBC 1MHz bus device eventually, once I make a board for it). This lets me do proper handshaking; to HostFS it just appears as a very fast serial port, with well-behaved TxRDY and RxRDY signals, and bytes never go missing. Theoretical bandwidth is 1.2 MB/s from PC to AVR, a little under 500 kB/s from AVR to CPLD, and as fast as the Electron can read from its bus (still working out the timing on that one) from CPLD to RAM.

In an initial test without properly configuring the AVR's SPI port, it loads Codename: Droid (for comparison with MMFS/MGC) in 13 seconds. Adding some timing to TubeHost, it looks like it maxes out around 12400 bytes/s (~80 us/byte) in send_data_to_memory in MODE 6, and around 6000 bytes/s (~167 us/byte) in MODE 2.

Commenting out most of the flow control code in ReadData brings it up to 17760 bytes/s in MODE 6 and 8930 bytes/s in MODE 2.

Code/HDL: https://github.com/google/myelin-acorn- ... sd_adapter
SW/EE from New Zealand, now in San Francisco: http://myelin.nz/
Having fun making hardware projects for the Electron!
So far: 32k flash cart, USB cart interface, 3-cart expansion, Elk PiTubeDirect. Later: Dual ported ram cart.

User avatar
myelin
Posts: 202
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: HostFS and microcontrollers?

Postby myelin » Mon Jul 10, 2017 4:00 pm

I wrote a fast-path version of WaitLoadIO that ignores flow control (i.e. just polls RxStatus for RxRDY, then reads RxData) and only handles esc+esc and esc+&Bx, and with that I'm seeing around 29 kB/s in MODE 2 and 39 kB/s in MODE 6, on an Electron. Finally faster than MMFS with my memory-mapped SPI port :)

Without getting really specific (like handling the 'esc' combinations in the external micro) this is about as good as I can do. It's at the point where program load time is no longer dominated by reading data into memory, so I'm pretty happy with it.
SW/EE from New Zealand, now in San Francisco: http://myelin.nz/
Having fun making hardware projects for the Electron!
So far: 32k flash cart, USB cart interface, 3-cart expansion, Elk PiTubeDirect. Later: Dual ported ram cart.

User avatar
davidb
Posts: 1900
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: HostFS and microcontrollers?

Postby davidb » Mon Jul 10, 2017 4:07 pm

That's effectively instant loading, so well done! :)

User avatar
myelin
Posts: 202
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: HostFS and microcontrollers?

Postby myelin » Fri Nov 10, 2017 11:30 pm

BTW I finally made a circuit board for this -- thread here.
SW/EE from New Zealand, now in San Francisco: http://myelin.nz/
Having fun making hardware projects for the Electron!
So far: 32k flash cart, USB cart interface, 3-cart expansion, Elk PiTubeDirect. Later: Dual ported ram cart.


Return to “hardware”

Who is online

Users browsing this forum: No registered users and 11 guests