[plug] Any kernel hackers out there...?

Harry McNally harrymc at decisions-and-designs.com.au
Wed Mar 6 10:55:30 WST 2002


On 05 Mar 2002 16:55:42 +0800 Kim Covil wrote:

> Hi,
> 
> Is there anyone on the list who might be able to give me some hints on
> how to talk to a serial device from within a 2.2 kernel...?
> 
> I have a device running a 2.2 kernel on a strongarm processor. The
> kernel is not modular (and is quite highly modified). There is a serial
> device I would like to query on boot to determine whether it is attached
> and what id it returns, and then set a variable within the kernel before
> it carries on with the rest of its boot sequence. The initialisation
> sequence is pretty simple, so I just need to know how to send a few
> bytes to the device and read back a few bytes in reply with a timeout in
> case the device is not attached.

Hi Kim

Assuming you also need to talk to the external serial device after boot, I would examine the serial device driver source and look at simply adding the poll and response code into the end of the existing initialisation code (the init_module entry in the driver).

Depending on the drivers default serial port configuration, this might require serial mode setup (baud rate, stop bits etc) and then transmit and receive. After enabling the device interrupts, it should be possible to put chars into the output ring buffer and then use the response (or timeout) to set your kernel variable appropriately.

The driver source would be the first point of reference and then looking at Rubini's book "Linux Device Drivers" (O'Reilly ISBN1-56592-292-1 .. mine's a bit old .. I think there is a second addition now .. Boffins ?)   

The book talks about timing methods. While polling the serial port for a few characters pauses the boot at 9600 baud, we are only talking 4 milliseconds or so which is negligible. It assumes that the external device is available to respond as the boot proceeds. Make sure there is no long "warm up" or reset for the external device. This would not have mattered if your user code interrogated the device when it was ready (after the Linux boot itself) but might catch you out if it happens early in the boot process. Traps for young players.

A caveate here: this is munging a serial driver for a specific task which defeats the whole "layers of an onion" but you did say the kernel is highly modified anyway and you need to sqeeze the system into the available space .. 

Anyhoo, have fun. Playing with ARM boards sounds interesting :)

cu
Harry
 



More information about the plug mailing list