USB 2.0 Support in Minix

381 views
Skip to first unread message

Daniel Morgan

unread,
Sep 23, 2023, 12:25:27 AM9/23/23
to minix3
I am sure this has been asked and debated before.  And maybe someone has a Pull Request already.

Has anyone added or looked into adding USB support to Minix 3?  I am sure they have, but I have not found it.

What would it take?

I think NetBSD is good to look at.   

There is an alternative which is to use rump kernels from NetBSD for hardware device drivers.

Anybody willing to help?

Yes, USB 3 and other USB standards would be great to have.  But at a minimum try to support USB 2.0.  

Start simple with HID devices like keyboards and mice.
Then work on mass storage devices.
At least get somewhere we can list (enumerate) USB devices attached.

I have a motivation for this so I can install Minix via a USB stick since I do not have a CD/DVD ROM drive.

But I also like to plug in a USB mouse, keyboard on my laptop.  

I know this is crazy, but HDMI support too so I can hook my laptop to a monitor.. But I know this has nothing to do with USB.

But I also like to play with a device called RTL-SDR which requires USB.

And of course, I think have the ability to use SCSI, SATA, AHCI (not sure of the technology names here) so I can use my internal hard disk drive from my laptop for Minix.  I also have a SSD that fits internally NVMe?  Of course, this has nothing to do with USB.

Jean-Loups

unread,
Sep 23, 2023, 12:42:00 AM9/23/23
to min...@googlegroups.com
Great idea 💡
Envoyé de mon iPhone

Daniel Morgan

unread,
Sep 23, 2023, 1:54:23 AM9/23/23
to minix3
Hello Jean-Loups,
Yep.

I am up for ideas of what can be done.  And what parts can be split up?  And what dependencies are needed in Minix?

Even if I put Minix in my own partition myself.  It won't run on SATA.   

If I did get SATA working before USB mass storage for SSD works, then i would need to manually copy Minix to the partition and set it up, but I guess that is another question for the group - not here.

I am going to be looking into NetBSD at its USB and SATA implementations.   Hopefully, multiple people can work on this for Minix.

I really think if we can get USB, SATA (ACHI), and SCSCI implementations from NetBSD to work on Minix, more people will be to install Minix on bare metal.  That is my goal.
Once more people are running it bare metal, we will have more people helping.   

NetBSD - USB
See HID (Human Interface Devices) for mouse, keyboard, etc.
See Mass Storage Devices for SSD, etc.

NetBSD - AHCI - SATA

NetBSD - PCI
Not sure if I need PCI support in order to support AHCI - SATA.

NetBSD - SCSI

Of course, there is FreeBSD and OpenBSD as well to look at.  

Thanks,
Daniel

Jean-Loups

unread,
Sep 23, 2023, 3:33:46 AM9/23/23
to min...@googlegroups.com

Envoyé de mon iPhone

Le 23 sept. 2023 à 07:54, Daniel Morgan <linqd...@gmail.com> a écrit :

Hello Jean-Loups,
Yep.

I am up for ideas of what can be done.  And what parts can be split up?  And what dependencies are needed in Minix?

Even if I put Minix in my own partition myself.  It won't run on SATA.   

If I did get SATA working before USB mass storage for SSD works, then i would need to manually copy Minix to the partition and set it up, but I guess that is another question for the group - not here.

I am going to be looking into NetBSD at its USB and SATA implementations.   Hopefully, multiple people can work on this for Minix.

I really think if we can get USB, SATA (ACHI), and SCSCI implementations from NetBSD to work on Minix, more people will be to install Minix on bare metal.  That is my goal.
Once more people are running it bare metal, we will have more people helping. 
On servers ?

NetBSD - USB
See HID (Human Interface Devices) for mouse, keyboard, etc.
See Mass Storage Devices for SSD, etc.

NetBSD - AHCI - SATA

NetBSD - PCI
Not sure if I need PCI support in order to support AHCI - SATA.

NetBSD - SCSI

Of course, there is FreeBSD and OpenBSD as well to look at.  

Thanks,
Daniel



On Saturday, September 23, 2023 at 12:42:00 AM UTC-4 Jean-Loups wrote:
Great idea 💡
Envoyé de mon iPhone

> Le 23 sept. 2023 à 06:25, Daniel Morgan <linqd...@gmail.com> a écrit :
>
> USB mouse, keyboard on my laptop.

--
You received this message because you are subscribed to the Google Groups "minix3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minix3+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/minix3/233ed3d0-56b3-4945-b93b-8f04a0651532n%40googlegroups.com.

Daniel Morgan

unread,
Sep 23, 2023, 8:43:11 PM9/23/23
to minix3

Hello Jean-Loups, 
No.  I am interested in desktops and laptops.  Well, I only have laptops here.  An old laptop with a CD/DVD drive, but the new laptop does not.  So, any bare metal Minix would have to be done on my old laptop.  But it has at least 3 USB 2.0 ports on the old laptop to connect various USB devices.   Again, get USB 2.0 devices to list first.  Then get USB 2.0 devices working.  Start with HID devices like mouse and keyboard.  Then work on Mass storage devices like a USB stick.  Then look at other USB stuff like USB 3 or other features added to the USB standards over the years  

However, getting these things to work for a laptop or desktop will help for a server and embedded as well.

I have other USB devices to test like a RTL-SDR device and a Digital Microscope (basically a web cam with a light and lens to see small things). 

I cannot do this all by myself.  Any others wish to help looking at what NetBSD does, taking notes, drawings, and/or porting the USB device drivers to Minix 3.4 ?
It helps to read the USB 2.0 specification.

And take a look at an user space library like libusb which is open source and is portable to various unix-like operating systems which can be used by user applications to list USB devices and get data.   I would not use any source code from this library because it is LGPL or GPL - only use it for research.  This libusb still requires an underlying usb driver framework - I think.

Thanks,
Daniel


On servers ?

Jean-Loups

unread,
Sep 24, 2023, 11:05:46 AM9/24/23
to min...@googlegroups.com
Ok
Envoyé de mon iPhone

> Le 24 sept. 2023 à 02:43, Daniel Morgan <linqd...@gmail.com> a écrit :
>
> specification.

Vishal Oza

unread,
Sep 24, 2023, 1:37:33 PM9/24/23
to min...@googlegroups.com
I think that Minix 3.4 has stagnated for the last 5 years. I believed it was for full compatibility with NetBSD. It is nice to know work is being done on Minix 3

--
You received this message because you are subscribed to the Google Groups "minix3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minix3+un...@googlegroups.com.

Daniel Morgan

unread,
Oct 21, 2023, 5:06:17 PM10/21/23
to minix3
I am expressing my thoughts on what I learned so far and where I want to go.    Long read here.  So, I doubt anybody will read it.  But at least this will serve as my notes for later.

The only mentors I have  - are on IRC on #minix - and they have been helpful.  The NetBSD and Hurd people are friendly as well.
I don't think the goal is full compatibility with NetBSD.  The user land came from NetBSD and other things.  But Minix will remain a microkernel OS and try to stay lightweight.  Minix 3 will still be a real world useful OS.  Minix and NetBSD have their own goals.  Minix user land should strive to be compatible with NetBSD but cannot be 100% compatible because NetBSD kernel is monolithic while Minix is a microkernal.  So Minix can have its user land updated from newer releases of NetBSD.  This should make it easier (still lot of work) to port user land libraries, commands, and other software found installed via pkgin/pkgsrc.

Instead of writing a new book (take too long), we should strive to create a new book as an addendum to the edition 3 Minix book based on what Minix 3.3 and 3.4+ are and what we want Minix to become.  What is found in the Minix 3 wiki.  And what the differences between the 3.1.0 book version and 3.4+.  And a little more about the changes between each version.  I know - I am asking a lot since it seems the project is in hibernation.  I say 3.4+ to include changes in git master and various PRs that have not been merged - yet.  What PRs are good to include that have not been merged into git master?  

I want to create a new release - just to do a release so people will have an up-to-date Minix 3 OS to play with - include the source code - even if we need to create a DVD image instead of a CD.  Otherwise, store the source code that matches the binaries on the CD or DVD as a tarball bzipped or tarball gzipped (depends on what compression tools are installed).  I have no power to do this so it would be my own download site and the images would be UNOFFICIAL.  Is there some service somewhere that can build and host things for us and do security audits and provide some kind of (not sure of the right words here) to authenticate who the ISO image files came from?  Of course, they would not be official but they could prove they came from me?

There are commits to Minix git master that are not in the latest 3.4rc6 that I find helpful, such as, booting from EFI instead of legacy BIOS. 

Yes, there is the Minix 3 wiki - a great resource, but it mainly focuses on the later versions of Minix 3 - not the Minix 3 book version 3.1.0.  Plus, when i say "new book", I am talking about an addendum to the original Minix 3 book that can have a PDF created or printed or single-page HTML page.  This is so you can read it offline when you have no internet connection.  Read it from your tablet or phone while waiting in a doctors office, etc...  or something to read in bed before you go to sleep...  The new book would be considered as an addendum to the wonderful Minix 3 book.  This way - everything does not have to be re-written because much of the knowledge in the Minix 3 book is still very valid.

I think Minix should strive to be a lightweight / minimal microkernel-based operating system for laptops and desktops and single-board computers like BeagleBone Black and the Raspberry Pi 1 thru 3.  I would not consider Minix as a server OS because that is what NetBSD and others can provide - plus they have the eyeballs to make the server OS secure on the internet; Minix does not.  Raspberry Pi 4 would require 64-bit support in Minix.  We are not ready for 64-bit.  I think it is far more important to have a good working port of i386 and ARM 32-bit - and the 32-bit ARM support will be for 32-bit Beagle boards and Raspberry Pi.   Have good preemptive multithreading support.   We have GNU pth and mthreads.  But we need better support than that including kernel threads.  I want to take a look at the clone( ) sys call used in Linux (just the documentation for inspiration) and see what NetBSD source code has for LWP (Lightweight Processes) that implement a 1:1 kernel and user mode thread.  I mainly need threading for USB support but it would allow more software to work on Minix.   When I say lightweight, I mean our goal is to not compete with well-established OSes like NetBSD or Linux.  Even a desktop would not be heavily loaded with a ton of applications - just your basic stuff.  Even some X and lightweight desktop/window manager would be OK.  I keep stressing lightweight because the OS should be a real-world OS but also keep it small so others can learn from it, build quicker, and take up less space on a CD/DVD but also less on their hard drive.  And quicker to download the ISO. 

Should we move to 64-bit?  Eventually.  But not today.  Not this year.  I will not debate about 64-bit.  It is a practical matter - resources - getting existing stuff to work first.

Of course, this is only my opinion - just my 2 cents - real Minix developers' view points probably differ.

I am going to continue to reply to this message as I learn more.   I am going to start writing little test programs in C to see what is going on.   Making changes to existing stuff in Minix.  Play with Linix, NetBSD, FreeBSD including Windows 10 to see how PCI and USB work there - probably via test programs written in C.  See USBView project on github from Microsoft for Windows to list USB devices. 

After doing some research, such as, looking on the Minix 3 wiki, I see that there is some PCI and USB support.  But the USB support is only working on the ARM - the Beagle boards - that i can tell. I have not tried it on ARM.  I just know some USB parts like USBD are not even built on the i386.

Minix 3 currently has USB Support via DDEKit

Here are 4 ways to get USB support working for i386 port of Minix 3.4+:
(1). Look into why the existing support of USB via DDEKit is not being built (USBD) on Minix 3.4+.   Supposedly, I read it works on the ARM 32-bit support for the Beagle boards, but how well?  And some things are hard-coded for the ARM / Beagle boards.
       However, PCI does look like it is working on i386 - try the lspci command on Minix 3.4 - i do not know how well.  Not sure about the other stuff like APIC and ACPI.
(2). or try to port USB support (this may include PCI, ACPI, APIC support as well) from NetBSD because it is the closest thing to Minix compared to FreeBSD or Linux or HelenOS.
(3). or write our own home made solution.
(4). or port rump kernels from NetBSD to Minix 3.4+.  The Hurd has done this and the Hurd is a microkernel OS as well.

Take a look at the man pages, documentation, books, and source code of other open source operating systems like NetBSD, FreeBSD, OpenBSD, Linux, HelenOS, Hurd, Windows, etc.  However, be careful about Linux and Hurd because it is GPL/LGPL licensed.

FreeBSD has good documentation on their USB support and other things like PCI and device drivers and how it boots.  Take a look at all their online books.   FreeBSD support initially came from NetBSD.

FreeBSD USB Support in the FreeBSD Architecture Handbook
See all of FreeBSD online books / documentation here:
I also bought a Kindle book from amazon named Design and Implementation of FreeBSD

Things to know about USB
Read up on USB, ACPI, PCI, PIC / APIC on the OSDev.org wiki
There is also specifications of a PCI bus called PCI-X and PCI Express.
Read up on protected mode, virtual memory vs. physical memory, GDT, paged memory.  And how to pass messages in Minix 3 between the device drivers, servers, and the micokernel.  And how does user mode libraries and applications use USB and PCI to do stuff?   How do user mode applications and libraries communicate with the servers in Minix?  Much of that is in the Minix 3 book I need to revisit.

Understand the various USB host controllers: UHCI, OHCI, EHCI, and xHCI.  UHCI and OHCI are USB 1.x host controllers.   EHCI is a USB host controller for USB 2.0 devices.  USB 2.0 must support USB 1.x which means there must be support for UHCI and OHCI controllers as well.   xHCI is a USB host controller for USB 3.0 devices and includes support for USB 1.x, 2.0, and 3.0 under the one xHCI controller.  Learn about the various classes of USB devices including host controllers, hubs, HID, mass storage, etc.

These days, there is USB 3.2 and USB 4.0.   See usb.org and click the developers tab to search for specifications to download.

And of course, studying Minix 3 in the The Minix Book - Operating System - Design and Implementation - 3rd edition.  And read Modern Operating Systems as well.  Sure, maybe not up-to-date but still very, very useful.
But playing with Minix 3 running in a VM or on bare metal.   If using Minix 3.4rc6, use pkgin to install git and other things to get the latest Minix source code from git.  Build Minix.  Studying its source code.  Read the book and look at the source code to see how Minix boots up.  Read about its device drivers and servers and the kernel.

You can try Minix and NetBSD in a VM like qemu, bochs, Virtual Box or VMWare, but it is best to see how real USB devices work on bare metal.

On Minix, you can use the lspci command to list pci devices.   On Linux, you can use lspci and lsusb commands to list pci and usb devices.
On NetBSD, they have a pcictl command.  And there is a library for usb named libusb to be used by applications I think?  but this libusb is not the same libusb I mention below.    So, there might be a clash with the share object filename - not sure how to deal with that situation... does anybody know?

USB Support in HelenOS
HelenOS source code in git

USB support in Linux
Synopsys DesignWare Core SuperSpeed USB 3.0 Controller in Linux

Here is some info as well about the DesignWare USB Controller...  Not sure if it applies to what Linux or NetBSD has...

What other open source OSes out there that have USB (and of course PCI, ACPI, APIC) support we can research?
Especially BSD or similar licensed.

You need to know C programming but helps to know a little C++ and assembly language for x86.
And helps to know how the OS boots and initializes devices including various buses like ISA, PCI, AGP, USB, etc.
brokenthorn.com OS Dev is a good place but it appears the site is down.  Here is the link at the Internet Archive:

If you get any USB book, get the 1st or 2nd book below.

Books on USB (Universal Serial Bus)
Get this Kindle book which is only US$10
USB: The Universal Serial Bus (FYSOS: Operating System Design Book 8) by Benjamin David Lunt

Another book on USB.  You will find other books by the same publisher/author about PCI, ISA, Protected Mode, 486, Pentium Pro/Pentium II as well.
Universal Serial Bus System Architecture by Anderson Mindshare

There are other books I have listed below on USB but I do not have them.  I only list them to make you aware of their existence.

USB Complete: The Developer's Guide (Complete Guides series) Fifth Edition by Jan Axelson

USB Embedded Hosts: The Developer's Guide by Jan Axelson

Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems (Complete Guides series) 2nd Edition by Jan Axelson

USB 3.0 Technology: Comprehensive Guide to SuperSpeed USB First Edition by Donovan Anderson

USB Design by Example: A Practical Guide to Building I/O Devices by John Hyde

I read a lot of Kindle books.  I can read them via the web brower logged into amazon.com web site, on my iPad via Kindle app I got from the App Store, on my Android phone via Kindle app i got via Google Play app store, and at one time I had a 10" Kindle Fire tablet.

libusb - USB Library for user-mode applications to call to list USB devices but also be able to write a user-mode device driver.  This library is cross-platform and written in C.   Libusb works on Windows, Linux, NetBSD, OpenBSD, and others.  It is LGPL licensed.  It is in the NetBSD pkgin/pkgsrc or you can get the source code tarball or from git yourself. You can actually build it now on Minix provided you include a pthreads implementation like GNU pth or mthreads and you pass the environment for the pthread.h to the configure script.  However, any OS such as Minix which does not have a back end will default to the null_usb back end which is just a stub.  But this does allow you to build it.  Once you can build it, then you can add an implementation for Minix there.  Just follow what NetBSD is doing.  The are many USB applications that use this library.  If you use a SDR device such as RTL-SDR, then it requires libusb.

Looks like rtl-sdr was ported to NetBSD as well.

I am continuing with my education in C programming, advanced programming in the UNIX environment, assembly language for x86, reading various tutorials like brokenthorn OS Dev, books on USB, PCI, ISA, Protected mode, the Minix book of course, learning about UNIX commands and its environment, bash shell programming, editors like vi, emacs, pico/nano, mc (and its mcedit and mcview), learning by using Minix and NetBSD and reading their source code, etc.

Any suggestions or comments?  Please be constructive though.  

Anybody else interested in helping?  Research?  Write test programs in C?  See what NetBSD is doing?   Help make changes to Minix to give us good thread and USB support?

Anybody else interested in pursuing this journey into Minix 3, NetBSD, threads and USB support?  

Some consider working on operating systems a black art.  I consider it fun, very technical which I like, and it gives me an understanding about the internals of an OS to help me be a better applications programmer on UNIX like systems.  Will I be a great Minix internals developer - probably not - but it will help me tremendously give me a better idea of what REALLY is happening in the system.  No more guesses, gaps in knowledge, or misunderstanding - I want to know for sure what really is happening so i can make better judgement calls writing applications or debugging them.  

Thank you,
Daniel Morgan

Vishal Oza

unread,
Oct 21, 2023, 10:16:13 PM10/21/23
to min...@googlegroups.com
Dear Daniel:

I find your idea as ambitious, however I disagree that Minix 3 should be only about desktop, laptops and bare boards systems. I think Minix should have the tools to work as a server if needed. It also needs RISC-V support for EPS32 board as a cheaper alternative to ARM. The USB support should be in user space rather than kernel space.

Sincerely
Vishal Oza

Daniel Morgan

unread,
Oct 22, 2023, 3:35:13 PM10/22/23
to minix3
Vishal,
Nobody is going to use Minix 3 as a serious server operating system unless there is ongoing participation from others in making sure it is secure.   NetBSD, OpenBSD, Linux all stay on top of making sure their server editions of their OSes are secure.

It is unrealistic to do a RISC-V port when the i386 and ARM ports need to be working well first.
But feel free to work on a RISC-V port though.   RISC-V is off-topic for my message.  My message is about adding USB support to Minix 3.4+ for the i386 port and related technologies to make USB work, such as, threading and pci.  There is already USB support for ARM but I read the USB support there is buggy.

USB support is already in user space via the DDEKit.  This will not change even if I (or someone else) replace the USB support with something else.   Best to keep drivers and servers in user mode like USB.  I still like the idea of Minix 3 being a microkernel.

Vishal Oza

unread,
Oct 22, 2023, 4:33:47 PM10/22/23
to min...@googlegroups.com
Dear Daniel:
I am not talking about creating a sophisticated service but simple servers with the idea of avoiding content switching to avoid latency. The idea is to update the packages. As to build support for RISC-V all we need to find assembly targets and add the RISC-V instructions there. Finally the rest is to build Minix with RISC-V as a target.

Sincerely,
Vishal Oza 

Daniel Morgan

unread,
Oct 22, 2023, 5:07:44 PM10/22/23
to minix3
Again, RISC-V is off-topic for this thread.

If you feel strongly about a RISC-V port, contribute a RISC-V port.  Fork the github mirror.  Commit your changes for the port of RISC-V of Minix to your fork of the github mirror.  Create a PR.  Then let others know about it.

Jean-Loups

unread,
Oct 23, 2023, 7:47:25 AM10/23/23
to min...@googlegroups.com
Read all,
Great work.

Witch BeagleBone needs by to test your codes ?
@jean-loups

Envoyé de mon iPhone

Jeremy Harden

unread,
Oct 29, 2023, 6:31:23 PM10/29/23
to minix3
Using USB from ARM to x86 is not a good idea due Intel uses EHCI code that is CPU centric to USB.  Best bet would be for certain to look into EHCI code if it is open source within the NetBSD USB drivers, then have the kernel and modules load that code while MINIX boots.

Jean-Loups

unread,
Oct 30, 2023, 7:09:55 AM10/30/23
to min...@googlegroups.com
Can boot MINIX from usb ?

Envoyé de mon iPhone

Le 29 oct. 2023 à 23:31, Jeremy Harden <jerremi...@gmail.com> a écrit :

Using USB from ARM to x86 is not a good idea due Intel uses EHCI code that is CPU centric to USB.  Best bet would be for certain to look into EHCI code if it is open source within the NetBSD USB drivers, then have the kernel and modules load that code while MINIX boots.
--
You received this message because you are subscribed to the Google Groups "minix3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minix3+un...@googlegroups.com.

Jeremy Harden

unread,
Oct 30, 2023, 9:54:47 AM10/30/23
to minix3
I do believe they have USB boot images on the minix3.org page.  They even pointed out that MINIX should be able to boot (albeit complicated due most BIOS on i386 computers that MINIX supports doesn't recognize USB on BIOS).

Daniel Morgan

unread,
Oct 30, 2023, 12:44:10 PM10/30/23
to minix3
Those are only old images.  The later releases do not support USB.  Minix 3.1.2a supported booting from a usb drive but this is probably due to help from the bios.

On the Downloads page, it says: Please note that on x86, MINIX3 does not support USB at all (yet!

This topic is about adding USB support to Minix 3.4+ for i386.  But, try to figure out how maintain support for ARM as well.  But the USB support that does exist for ARM (Beagle boards) is buggy.

Jean-Loups

unread,
Nov 1, 2023, 6:37:25 PM11/1/23
to min...@googlegroups.com
Ok,
I think I wait for try on my Dell Latitude…
Envoyé de mon iPhone

Le 30 oct. 2023 à 17:44, Daniel Morgan <linqd...@gmail.com> a écrit :


Reply all
Reply to author
Forward
0 new messages