Wednesday, December 1, 2010
Debugging through Falcon’s serial port
Article posted in the FreeMiNT wiki by myself.
1) The first thing you need is a debug kernel which has all the debug info included in the binary.
By default the debug kernel built is only valid for 040 and 060 CPUs, so if you don’t have an accelerator with one of those CPUs you will need to edit the file KERNELDEFS to get the right kernel for you.
2) Deactivate the module scc.xdd from your system directory. SCC is the chip responsible for serial communication in the Falcon. Computers with a MFP chip can use direct MFP debug output (see section “6.1.4 New debug facilities” in this link).
3) Install HSMODEM. Falcon BIOS ROM serial functions are very buggy, if you use these functions your system will crash sooner or later after some debug messages are sent to the serial port. HSMODEM replaces those buggy functions by more reliable ones.
4) Default settings are 19200 and 8N1, those have to be configured in the terminal program in the computer that is attached to your Falcon. You can increase speed later from HSMODEM control panel (CPX) and readjust it in the terminal program.
5) When booting the kernel will show version and identification, then you can press shift key to access the boot built-in menu. There you can select the debug output device (key 8), choose “AUX:, modem” for Falcon serial port. Also the debug level can be chosen from here (key 7). Debug level can be changed also during runtime from the terminal program pressing key 2 to increase it and key 1 to decrease it. For more information about how to control debug from your terminal or console see the file /sys/debug.c in kernel sources.
Saturday, November 13, 2010
No hot-plugging in libusb 1.0
libusb 1.0 lacks of hot-plugging support, this feature is expected in version 1.1. This means that I can’t use Aranym to totally develop the hot-plugging support for the stack, may be i can add a simulation of device connected/disconnected in the low-level code (natfeat USB driver).
Sunday, November 7, 2010
/dev directory in UNIX like systems
Today has been the time to look at the /dev directory in the UNIX family systems.
The /dev directory is where the device nodes are kept by the OS.
When a device driver wants to have an interface with the user space a new file for the device is created in /dev.
Each OS has its own way to handle this directory, the classic one and still present in some systems is the use of mknod command and the script MAKEDEV, this method it’s used for example by NetBSD and OpenBSD.
Linux had it until version 2.2, from version 2.4 and until version 2.6.17 the method used was devfs a pseudo or virtual filesystem that allows to keep the /dev contents dynamically. From that version a new approach has been developed called udev that it differences from devfs in that runs in user space and that makes used from the new, since kernel 2.6, filesystem sysfs.
FreeBSD uses also since version 5.0 devfs, note that although the name of the filesystem is the same than the one used by Linux the backend mechanism can be different. For example FreeBSD got rid of the mayor number.
From FreeBSD System Programming:
Our favorite new feature in FreeBSD-5.x is devfs. Prior to this branch, the /dev directory was filled with more than a thousand files. These files where device nodes and almost every supported device had an entry as a file in the /dev directory. As one can surmise, this directory became quite big and contained a lot of unnecessary files. For example, a system with IDE drives will contain device entries for scsi devices in /dev, even though the system does not have a scsi device. Such annoyances are gone with devfs. The only entries in /dev now are for devices that actually exist on the system. In fact, unlike prior releases /dev is only a mount point to a file system called devfs.
The devfs file system is similar to the proc file system. They both are mount points that contain files that don’t exist on the hard disk. These files are created by the kernel and only appear as files. In fact, they are created after the system boots. Devfs allows much more flexibility because you can support multiple devfs mount points. For example if you wanted to chroot or jail a process, you don’t have to create the /dev directory by hand, but instead, you can simply create a new mount point for your process and mount devfs.
Another benefit of devfs is that you can easily tell what devices a system has. All you need to do is just cd into the /dev directory and list the files. This is a very convenient way for a user to tell what devices are on a box, or more importantly, what devices have been detected.
FreeMiNT also has a /dev directory where keeps the device files, in his case is handled by the biosfs filesystem and the call Dcntl().
Thursday, November 4, 2010
How other operating systems introduced USB
Because in some many aspects FreeMiNT kernel looks like an OS from the 90’s I have decided to travel to the past and take a look how some open source OSs introduced USB then.
Linux introduced USB into the kernel sources in version 2.2.7, before there was a solution written by a Spanish guy, it looks like Linus found it too messy and decided to code his own driver. Here there is the email from that moment:
http://marc.info/?l= … m=92282561930486&w=2
I have been following a little bit this thread. Some moths ago during a time with a lot of noise in the MiNT list I was asking myself if a so small community has that much noise how it would be in the mailing lists from the big ones, how they avoid apparition of “visionary” characters there, I didn’t read to much but I felt like they are not free of them either.
I love open source and internet and here is one of the reasons, the first published test done by Linus around USB:
ftp://ftp.kernel.org … nel/testing/old/usb/
And thanks to version control systems I can see how were Linux kernel sources in version 2.2.7 and the evolution of the USB stack.
NetBSD was the first one introducing USB, it was done by Lennart Augustsson from Sweden, from who i read some emails in the Linux mailing list thread I mentioned above. USB appeared in version 1.4 of NetBSD.
ftp://ftp.netbsd.org … BSD-1.4/source/sets/
OpenBSD and FreeBSD took the USB stack from NetBSD, OpenBSD introduced it in version 2.6:
http://www.openbsd.o … with_tag=OPENBSD_2_6
FreeBSD did it in version 3.1.0:
http://svn.freebsd.o … e/3.1.0/sys/dev/usb/
Although since version 8.0 they have a new one written from scratch by Hans Petter Selasky from Norway.
NOTE: According to “Linux Device Driver 2nd Edition” the USB driver appeared in version 2.2.18