Syllable Forum Index Syllable
Syllable Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Device Driver , Question

 
Post new topic   Reply to topic    Syllable Forum Index -> Syllable Desktop
View previous topic :: View next topic  
Author Message
cipri
Guest





PostPosted: Sun Nov 18, 2007 10:06 am    Post subject: Device Driver , Question Reply with quote

I have written a fake driver (similar to the one from the tutorial).
It has the functions: device_init, device_uninit, pl2303_open, pl2303_close.

In device_init I put a KERNEL_WARNING, but in /var/log/kernel I don't find that warning. I placed the driver in /system/drivers/dev/misc/pl2303
When I try to open the driver I see in /var/log/kernel the following Error:

0:TestSerial::TestSerial : Error: load_device() failed to load image /boot/system/drivers/dev/misc/pl2303

What does that Error mean? I why is the kernel warning of device_init not in the kernel log file?

(TestSerial is the name of my test application, and pl2303 is the fake driver I want to test )
Back to top
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2204
Location: Friesland

PostPosted: Sun Nov 18, 2007 10:19 am    Post subject: Reply with quote

It's what it says: your binary is not correct somehow, so it never got to your message.
Back to top
View user's profile Send private message Visit poster's website
cipri
Guest





PostPosted: Sun Nov 18, 2007 11:02 am    Post subject: Reply with quote

I made a side-project, I added libknernel to the libraries to be linked.
In the Preferences of side I have:
Target: pl2303
Category: Ignore
Install path: Ignore
Compiler flags: -kernel -fno-PIC -c -D__ENABLE_DEBUG__
Linker flags: -shared

Is here something missing?

The source code has the functions:
device_init, device_uninit, pl2303_open, pl2303_close

The source code compiles without warnings.

What could be the reason for not beeing able to load that binary?
Back to top
Vanders
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 849

PostPosted: Sun Nov 18, 2007 12:39 pm    Post subject: Reply with quote

It could be a number of things, but it's a bit tough to tell without seeing the source & Makefile etc. Could you ZIP it all up and mail it to me, and I'll take a look (& report back here!)
Back to top
View user's profile Send private message Send e-mail
Vanders
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 849

PostPosted: Mon Nov 19, 2007 5:19 am    Post subject: Reply with quote

The "pl2303" target was wrong, specifically the options to GCC to perform the linking.

Your Makefile had "-shared -lkernel", which will produce a shared library which is linked against libkernel.so, but what you need to use is "-kernel". -kernel has implications both when you are compiling and linking. If you change the target to the following

[code:1]
"pl2303": $(OBJS)
@echo Linking...
@$(CC) $(OBJS) -o "pl2303" -kernel
[/code:1]

that will work and you can load the driver. Note that the "addattrib" is unnecessary also, because this is a driver, not an application.

The "install" target is also wrong by the way, as no target directory is specified. Something like

[code:1]
install: all
@echo Installing
@mkdir -p /system/drivers/dev/misc
@cp "pl2303" /system/drivers/dev/misc/pl2303
[/code:1]

Will work.
Back to top
View user's profile Send private message Send e-mail
cipri
Guest





PostPosted: Mon Nov 19, 2007 8:25 am    Post subject: Reply with quote

thanks.
Since I use sIDE for compiling , "addattrib" is necessary, otherwise (if living the sIDE-preference Category empty) it will have problems at linking, perhaps that's a bug of sIDE.
Back to top
Vanders
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 849

PostPosted: Mon Nov 19, 2007 8:29 am    Post subject: Reply with quote

[quote="cipri"]thanks.
Since I use sIDE for compiling , "addattrib" is necessary, otherwise (if living the sIDE-preference Category empty) it will have problems at linking, perhaps that's a bug of sIDE.[/quote]

Yes, that would be an sIDE bug then.
Back to top
View user's profile Send private message Send e-mail
cipri
Guest





PostPosted: Mon Nov 19, 2007 4:09 pm    Post subject: Reply with quote

In the pl2303 driver (USB to Serial Adapter) I used
g_psBus->add_driver( g_pcDriver )
I made the following experience:
If I pluged in the usb adapter before booting, the driver was recognized, and after I was logged in I was able to connect and disconnect it without problems.
But if the usb adapter was not pluged in before booting, than connecting the adapter to the usb didn't work correctly. The driver was not recognized and not loaded.

After I changed from "g_psBus->add_driver( g_pcDriver )" to g_psBus->add_driver_resistant( g_pcDriver ) it worked correctly, and connecting the adapter before booting wasn't necessary any more.

I took a look at the usb_printer driver and there is also g_psBus->add_driver( g_pcDriver ) and not g_psBus->add_driver_resistant( g_pcDriver ).
Does that mean, that the usb_printer will have the same troubles, and that it will work olny if it's connected before booting?
(I don't have a usb-printer , so I can't test it)
Back to top
Vanders
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 849

PostPosted: Mon Nov 19, 2007 4:24 pm    Post subject: Reply with quote

I'm not certain. add_driver_persistent() is a new function added in 0.6.5. I'll test it with a USB printer on a dev build and check with Arno. add_driver() should Just Work, though.
Back to top
View user's profile Send private message Send e-mail
cipri
Guest





PostPosted: Tue Nov 20, 2007 4:29 pm    Post subject: Reply with quote

I'm now thinking about how to port the generic usb-to-serial driver, but there is a real problem:
How should that generic driver claim the usb device? Because it's generic no VendorID or DeviceID is specified. For example if I would connect a usb-cd-drom that generic usb-driver could claim the device before the usb-cd-drom driver has the possibility to do that.
Is there a possiblitiy to say: claim the device, but only if no other driver wants to claim it ?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Syllable Forum Index -> Syllable Desktop All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group