Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Writing a network driver: (41 Items)
   
Writing a network driver  
Hello all,

I hope I'm not making a mistake by asking some help here...

I'm currently working on a Qnx 6.5.0 system and I need to use a Wi-Fi client device (RedPine RS 9110-N-11-02 ) ...so I 
need to develop a driver so to be abble to make it work...

Except that I don't have any example or sample code to have a basis to develop my driver (it is the first time I have to
 develop such a thing so it's kind of intimidating !)

Is there anyone who can enlighten me ...please ?

Regards,

Paul
Re: Writing a network driver  
I have attached a sample outline of an io-pkt network driver.

-- 
Hugh Brown
QNX Software Systems Limited
175 Terence Matthews Crescent,
Ottawa. ON. K2M 1W8.
Telephone: 613-591-0931







On 11-09-27 12:00 PM, "Thilloy Paul" <community-noreply@qnx.com> wrote:

>Hello all,
>
>I hope I'm not making a mistake by asking some help here...
>
>I'm currently working on a Qnx 6.5.0 system and I need to use a Wi-Fi
>client device (RedPine RS 9110-N-11-02 ) ...so I need to develop a driver
>so to be abble to make it work...
>
>Except that I don't have any example or sample code to have a basis to
>develop my driver (it is the first time I have to develop such a thing so
>it's kind of intimidating !)
>
>Is there anyone who can enlighten me ...please ?
>
>Regards,
>
>Paul
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post89096
>

Attachment: Text sample.tar.gz 20.61 KB
Re: Writing a network driver  
Hi Hugh,

Thanks a lot for your answer !
I'm reading the sample... and sorry to ask more but...do you have a documentation going with the code please ? 
I'm not sure to understand every line in the code and what I should modify/implement to make my own driver.

And if this is for io-pkt...I assume this code is for Qnx 6.5.0 ?

Again thanks for your help and thanks in advance for any further help !

Regards,

Paul
Re: Writing a network driver  
Here is all we have as far as documentation is concerned. Yes, io-pkt is
6.5.0.

Hugh.

-- 
Hugh Brown
QNX Software Systems Limited
175 Terence Matthews Crescent,
Ottawa. ON. K2M 1W8.
Telephone: 613-591-0931







On 11-09-28 10:34 AM, "Thilloy Paul" <community-noreply@qnx.com> wrote:

>Hi Hugh,
>
>Thanks a lot for your answer !
>I'm reading the sample... and sorry to ask more but...do you have a
>documentation going with the code please ?
>I'm not sure to understand every line in the code and what I should
>modify/implement to make my own driver.
>
>And if this is for io-pkt...I assume this code is for Qnx 6.5.0 ?
>
>Again thanks for your help and thanks in advance for any further help !
>
>Regards,
>
>Paul
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post89116
>

Attachment: Text native_drvr.txt 15.51 KB
Re: Writing a network driver  
So the doc covering how to write a native drive mentionned in the Momentics Help (part " Network Drivers" ) : /trunk/lib
/io-pkt/sys/dev_qnx/doc is not available ?
Re: Writing a network driver  
That is what I sent you.

-- 
Hugh Brown
QNX Software Systems Limited
175 Terence Matthews Crescent,
Ottawa. ON. K2M 1W8.
Telephone: 613-591-0931







On 11-09-28 10:49 AM, "Thilloy Paul" <community-noreply@qnx.com> wrote:

>So the doc covering how to write a native drive mentionned in the
>Momentics Help (part " Network Drivers" ) :
>/trunk/lib/io-pkt/sys/dev_qnx/doc is not available ?
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post89119
>
Re: Writing a network driver  
Oh ok...Thank you.

I was missleaded in the Momentics Help by : 
A tech note covering how to write a native driver is available in the source tree under /trunk/lib/io-pkt/sys/dev_qnx/
doc. Sample driver code is also available under the /trunk/lib/io-pkt/sys/dev_qnx/sample directory. 

Sorry if I bothered you.

Other question... if I want to compile sam.c in order to make my own .so... I should then compile the whole project ? Do
 you know where I can find the source code ?

Regards,

Paul
Re: Writing a network driver  
Does a "make" from the sample directory not work?

-- 
Hugh Brown
QNX Software Systems Limited
175 Terence Matthews Crescent,
Ottawa. ON. K2M 1W8.
Telephone: 613-591-0931







On 11-09-28 11:16 AM, "Thilloy Paul" <community-noreply@qnx.com> wrote:

>Oh ok...Thank you.
>
>I was missleaded in the Momentics Help by :
>A tech note covering how to write a native driver is available in the
>source tree under /trunk/lib/io-pkt/sys/dev_qnx/doc. Sample driver code
>is also available under the /trunk/lib/io-pkt/sys/dev_qnx/sample
>directory. 
>
>Sorry if I bothered you.
>
>Other question... if I want to compile sam.c in order to make my own
>.so... I should then compile the whole project ? Do you know where I can
>find the source code ?
>
>Regards,
>
>Paul
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post89121
>
Re: Writing a network driver  
Actually I have several errors... 

- Momentics cannot find definition of IRUPT_PRIO_DEFAULT ...I searched but nothing so far...
- same problem on ieee80211com
- As well as other functions are marked as not implemented ( IFQ_SET_READY ; if_attach ; ether_ifattach ...)

Re: Writing a network driver  
>>>ieee80211com
Remember, io-pkt is a netBSD stack - not original with QNX.  You will find this definition (an probably others you 
require) in...

http://ftp.riken.jp/NetBSD/NetBSD-release-5-0/src/sys/net80211/

IRUPT_PRIO_DEFAULT is defined as -1.

Re: Writing a network driver  
Look in /usr/include. IRUPT_PRIO_DEFAULT is defined in nw_intr.h. Do a
search for the other missing definitions.

-- 
Hugh Brown
QNX Software Systems Limited
175 Terence Matthews Crescent,
Ottawa. ON. K2M 1W8.
Telephone: 613-591-0931







On 11-09-29 2:06 AM, "Thilloy Paul" <community-noreply@qnx.com> wrote:

>Actually I have several errors...
>
>- Momentics cannot find definition of IRUPT_PRIO_DEFAULT ...I searched
>but nothing so far...
>- same problem on ieee80211com
>- As well as other functions are marked as not implemented (
>IFQ_SET_READY ; if_attach ; ether_ifattach ...)
>
>
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post89142
>
Re: Writing a network driver  
I've just started the process of trying to port a driver for a Redpine radio module to QNX, so I've found this thread to
 be very useful. I've been reading thru the guide and comparing it to what's in the sam.c file, and I've come up with 
the first of what will probably be several questions.

At about line 45 of sam.c is the declaration of the sam_syms array of type nw_dll_syms. The comment just before this 
declaration in sam.c says "This is what gets specified in the stack's dl.c". Does this mean I have to add this 
declaration to the dl.c file in the io-pkt source code, and rebuild the io-pkt stack?

Thanks for any clarification you can provide!

Greg Ludewig
Re: Writing a network driver  
No, you don't have to re-compile the io-pkt stack. This entry is used by
io-pkt when it loads you driver as a dll.

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-07 5:12 PM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>I've just started the process of trying to port a driver for a Redpine
>radio module to QNX, so I've found this thread to be very useful. I've
>been reading thru the guide and comparing it to what's in the sam.c file,
>and I've come up with the first of what will probably be several
>questions.
>
>At about line 45 of sam.c is the declaration of the sam_syms array of
>type nw_dll_syms. The comment just before this declaration in sam.c says
>"This is what gets specified in the stack's dl.c". Does this mean I have
>to add this declaration to the dl.c file in the io-pkt source code, and
>rebuild the io-pkt stack?
>
>Thanks for any clarification you can provide!
>
>Greg Ludewig
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91398
>
Re: Writing a network driver  
OK, thanks. I was hoping it worked something like that.

So, I'm trying to compile the example project (sam.c) and I'm running into a few problems. I've been adding additional 
header files (such as the nw_intr.h as mentioned above) and that takes care of some of them. I had to remove the '#ifdef
 _KERNEL' around the definition of ieee80211com in ieee80211_var.h in order for the compiler to find it. Currently I'm 
stuck on the CFATTACH_DECL code at around line 75 in sam.c. 

CFATTACH_DECL(sam,
	sizeof(struct sam_dev),
	NULL,
	sam_attach,
	sam_detach,
	NULL);

The compiler generates an error that says: 'error: 'sam' undeclared here (not in a function)' as well as a warning about
 implicit declaration of function '__STRING'. I can see that CFATTACH_DECL is defined in the device.h header in usr/
include/io-pkt/sys, and that header is being included, but I can't figure out how to make the error about 'sam' being 
undeclared go away.
Re: Writing a network driver  
You need __STRING; should be in <sys/cdefs.h>.

And you should have _KERNEL defined for a driver
that gets loaded in io-pkt.

Regards,

-seanb

On Wed, Feb 08, 2012 at 02:54:07PM -0500, Greg Ludewig wrote:
> OK, thanks. I was hoping it worked something like that.
> 
> So, I'm trying to compile the example project (sam.c) and I'm running into a few problems. I've been adding additional
 header files (such as the nw_intr.h as mentioned above) and that takes care of some of them. I had to remove the '#
ifdef _KERNEL' around the definition of ieee80211com in ieee80211_var.h in order for the compiler to find it. Currently 
I'm stuck on the CFATTACH_DECL code at around line 75 in sam.c. 
> 
> CFATTACH_DECL(sam,
> 	sizeof(struct sam_dev),
> 	NULL,
> 	sam_attach,
> 	sam_detach,
> 	NULL);
> 
> The compiler generates an error that says: 'error: 'sam' undeclared here (not in a function)' as well as a warning 
about implicit declaration of function '__STRING'. I can see that CFATTACH_DECL is defined in the device.h header in usr
/include/io-pkt/sys, and that header is being included, but I can't figure out how to make the error about 'sam' being 
undeclared go away.
> 
> 
> 
> _______________________________________________
> 
> Networking Drivers
> http://community.qnx.com/sf/go/post91415
> 
Re: Writing a network driver  
You need __STRING; should be in <sys/cdefs.h>.

And you should have _KERNEL defined for a driver
that gets loaded in io-pkt.


-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-08 2:54 PM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>OK, thanks. I was hoping it worked something like that.
>
>So, I'm trying to compile the example project (sam.c) and I'm running
>into a few problems. I've been adding additional header files (such as
>the nw_intr.h as mentioned above) and that takes care of some of them. I
>had to remove the '#ifdef _KERNEL' around the definition of ieee80211com
>in ieee80211_var.h in order for the compiler to find it. Currently I'm
>stuck on the CFATTACH_DECL code at around line 75 in sam.c.
>
>CFATTACH_DECL(sam,
>	sizeof(struct sam_dev),
>	NULL,
>	sam_attach,
>	sam_detach,
>	NULL);
>
>The compiler generates an error that says: 'error: 'sam' undeclared here
>(not in a function)' as well as a warning about implicit declaration of
>function '__STRING'. I can see that CFATTACH_DECL is defined in the
>device.h header in usr/include/io-pkt/sys, and that header is being
>included, but I can't figure out how to make the error about 'sam' being
>undeclared go away.
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91415
>
Re: Writing a network driver  
Again, thanks for the help, I really appreciate it.

I've tried including sys/cdefs.h. I still get the warning about __STRING, and the error about 'sam' being undeclared 
still exists.

I had previously tried adding -D_KERNEL to the command line (by adding it to the Definitions line on the Compiler tab of
 the project properties). When I do this, I get dozens, if not hundreds, of compile errors in system include files, such
 as ieee80211_var.h.

Is this example driver not meant to built in the IDE for QNX 6.5.0?

Also, I have one other question. Around the sam_syms definition I've included below is a #ifdef VARIANT_a. The compiler 
automatically defines VARIANT_a if a set the project to be a static library. But I thought the driver was supposed to be
 a DLL. I assume that means it should be a .so type. Why isn't this a #ifdef VARIANT_so instead?

#ifdef VARIANT_a
#include <io-pkt/nw_dl.h>
/* This is what gets specified in the stack's dl.c */
struct nw_dll_syms sam_syms[] = {
        {"iopkt_drvr_entry", &IOPKT_DRVR_ENTRY_SYM(sam)},
        {NULL, NULL}
};
#endif

Greg
Re: Writing a network driver  
On Thu, Feb 09, 2012 at 01:21:18PM -0500, Greg Ludewig wrote:
> Again, thanks for the help, I really appreciate it.
> 
> I've tried including sys/cdefs.h. I still get the warning about __STRING, and the error about 'sam' being undeclared 
still exists.

It's there.  You'll have to look at the preprocessed file to see
why you're not seeing it.

> 
> I had previously tried adding -D_KERNEL to the command line (by adding it to the Definitions line on the Compiler tab 
of the project properties). When I do this, I get dozens, if not hundreds, of compile errors in system include files, 
such as ieee80211_var.h.
> 
> Is this example driver not meant to built in the IDE for QNX 6.5.0?
> 
> Also, I have one other question. Around the sam_syms definition I've included below is a #ifdef VARIANT_a. The 
compiler automatically defines VARIANT_a if a set the project to be a static library. But I thought the driver was 
supposed to be a DLL. I assume that means it should be a .so type. Why isn't this a #ifdef VARIANT_so instead?

Don't use a static library project.

> 
> #ifdef VARIANT_a
> #include <io-pkt/nw_dl.h>
> /* This is what gets specified in the stack's dl.c */
> struct nw_dll_syms sam_syms[] = {
>         {"iopkt_drvr_entry", &IOPKT_DRVR_ENTRY_SYM(sam)},
>         {NULL, NULL}
> };
> #endif
> 
> Greg
> 
> 
> 
> _______________________________________________
> 
> Networking Drivers
> http://community.qnx.com/sf/go/post91444
> 
Re: Writing a network driver  
See the comments in-line.

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-09 1:21 PM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>Again, thanks for the help, I really appreciate it.
>
>I've tried including sys/cdefs.h. I still get the warning about __STRING,
>and the error about 'sam' being undeclared still exists.

HB: It's there.  You'll have to look at the preprocessed file to see why
you're not seeing it.

>
>I had previously tried adding -D_KERNEL to the command line (by adding it
>to the Definitions line on the Compiler tab of the project properties).
>When I do this, I get dozens, if not hundreds, of compile errors in
>system include files, such as ieee80211_var.h.
>
>Is this example driver not meant to built in the IDE for QNX 6.5.0?
>
>Also, I have one other question. Around the sam_syms definition I've
>included below is a #ifdef VARIANT_a. The compiler automatically defines
>VARIANT_a if a set the project to be a static library. But I thought the
>driver was supposed to be a DLL. I assume that means it should be a .so
>type. Why isn't this a #ifdef VARIANT_so instead?

HB: Don't use a static library project.


>#ifdef VARIANT_a
>#include <io-pkt/nw_dl.h>
>/* This is what gets specified in the stack's dl.c */
>struct nw_dll_syms sam_syms[] = {
>        {"iopkt_drvr_entry", &IOPKT_DRVR_ENTRY_SYM(sam)},
>        {NULL, NULL}
>};
>#endif
>
>Greg
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91444
>
Re: Writing a network driver  
Thanks again for all the help on this. 

I've managed to get sam.c to compile, although I had to pull some definitions out of system include files and put them 
in a separate file to make it work. Like I said before, if I define _KERNEL, I get lots of compile errors. Do you have 
any idea what I'm doing wrong that's causing this? If I collect the definitions I need in a separate file, I get around 
the errors, but I am wondering if there are any other flags I should have defined (such as QNXNTO or ALTQ, for example) 
for a network driver.

I also have another basic question. The driver I'm trying to port is a Linux driver, and it references the Linux 
net_device struct alot. I'm assuming the closest thing to the Linux net_device struct in QNX is the device struct in the
 io-pkt/sys/device.h include file. Does anyone know if that's the correct structure I should be using?
Re: Writing a network driver  
On Mon, Feb 20, 2012 at 03:23:29PM -0500, Greg Ludewig wrote:
> Thanks again for all the help on this. 
> 
> I've managed to get sam.c to compile, although I had to pull some definitions out of system include files and put them
 in a separate file to make it work. Like I said before, if I define _KERNEL, I get lots of compile errors. Do you have 
any idea what I'm doing wrong that's causing this? If I collect the definitions I need in a separate file, I get around 
the errors, but I am wondering if there are any other flags I should have defined (such as QNXNTO or ALTQ, for example) 
for a network driver.


If you have the source presumably you have the makefiles?
A straight 'make' should build it; otherwise, this works
for me on 6.5

# qcc -shared -Wl,-Bsymbolic -o devnp-sample.so -I /usr/include/io-pkt/ -D_KERNEL sam.c

> 
> I also have another basic question. The driver I'm trying to port is a Linux driver, and it references the Linux 
net_device struct alot. I'm assuming the closest thing to the Linux net_device struct in QNX is the device struct in the
 io-pkt/sys/device.h include file. Does anyone know if that's the correct structure I should be using?

No idea on that one.  Try starting with a BSD based driver
if possible.

Regards,

-seanb
Re: Writing a network driver  
Please see comments below.

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931




On 12-02-20 3:23 PM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>Thanks again for all the help on this.
>
>I've managed to get sam.c to compile, although I had to pull some
>definitions out of system include files and put them in a separate file
>to make it work. Like I said before, if I define _KERNEL, I get lots of
>compile errors. Do you have any idea what I'm doing wrong that's causing
>this? If I collect the definitions I need in a separate file, I get
>around the errors, but I am wondering if there are any other flags I
>should have defined (such as QNXNTO or ALTQ, for example) for a network
>driver.

If you have the source presumably you have the makefiles?
A straight 'make' should build it; otherwise, this works
for me on 6.5

# qcc -shared -Wl,-Bsymbolic -o devnp-sample.so -I /usr/include/io-pkt/
-D_KERNEL sam.c

>
>I also have another basic question. The driver I'm trying to port is a
>Linux driver, and it references the Linux net_device struct alot. I'm
>assuming the closest thing to the Linux net_device struct in QNX is the
>device struct in the io-pkt/sys/device.h include file. Does anyone know
>if that's the correct structure I should be using?

No idea on that one.  Try starting with a BSD based driver
if possible.


_______________________________________________

Networking Drivers
http://community.qnx.com/sf/go/post91676

Re: Writing a network driver  
If I unzip the tar file and then do a 'make' I get the following error:

C:\QNXDriver\sample>make
make -j 1 -Carm -fMakefile
make[1]: Entering directory 'C:/QNXDriver/sample/arm'
make -j 1 -Cdll.le -fMakefile
make[2]: Entering directory 'C:/QNXDriver/sample/arm/dll.le' 
../../common.mk:18: C:/QNXDriver/prodroot_pkt.mk: No such file or directory
make[2]: *** No rule to make target 'C:/QNXDriver/prodroot_pkt.mk'. Stop.
make[2]: Leaving directory 'C:/QNXDriver/sample/arm/dll.le'
make[1]: *** [all] Error 2
make[1]: Leaving directory 'C:/QNXDriver/sample/arm'
make *** [all] Error 2

If I call qcc directly using the command line you suggest, I get lots of errors in system include files, which is the 
same thing I get if I try to build in the IDE with _KERNEL defined.

Like I said, if I copy all of the defines I need from the system headers into a separate file, I can get it to compile 
without defining _KERNEL. Do you know if there are other things that don't get included if I don't define _KERNEL that 
will result in the driver not working?

Unfortunately, there is no NetBSD based driver for the radio module we're using that I can start my port from.

Thanks again.

Greg
Re: Writing a network driver  
Unfortunately, I don't know what tar file you were given.
Attached is your missing prodroot_pkt.mk.  Not sure if you'll
see other issues.

Regards,

-seanb

On Thu, Feb 23, 2012 at 10:30:58AM -0500, Greg Ludewig wrote:
> If I unzip the tar file and then do a 'make' I get the following error:
> 
> C:\QNXDriver\sample>make
> make -j 1 -Carm -fMakefile
> make[1]: Entering directory 'C:/QNXDriver/sample/arm'
> make -j 1 -Cdll.le -fMakefile
> make[2]: Entering directory 'C:/QNXDriver/sample/arm/dll.le' 
> ../../common.mk:18: C:/QNXDriver/prodroot_pkt.mk: No such file or directory
> make[2]: *** No rule to make target 'C:/QNXDriver/prodroot_pkt.mk'. Stop.
> make[2]: Leaving directory 'C:/QNXDriver/sample/arm/dll.le'
> make[1]: *** [all] Error 2
> make[1]: Leaving directory 'C:/QNXDriver/sample/arm'
> make *** [all] Error 2
> 
> If I call qcc directly using the command line you suggest, I get lots of errors in system include files, which is the 
same thing I get if I try to build in the IDE with _KERNEL defined.
> 
> Like I said, if I copy all of the defines I need from the system headers into a separate file, I can get it to compile
 without defining _KERNEL. Do you know if there are other things that don't get included if I don't define _KERNEL that 
will result in the driver not working?
> 
> Unfortunately, there is no NetBSD based driver for the radio module we're using that I can start my port from.
> 
> Thanks again.
> 
> Greg
> 
> 
> 
> _______________________________________________
> 
> Networking Drivers
> http://community.qnx.com/sf/go/post91734
> 
Attachment: Text prodroot_pkt.mk 704 bytes
Re: Writing a network driver  
Have you tried the following link?

http://www.qnx.com/download/feature.html?programid=9404

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-23 10:30 AM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>If I unzip the tar file and then do a 'make' I get the following error:
>
>C:\QNXDriver\sample>make
>make -j 1 -Carm -fMakefile
>make[1]: Entering directory 'C:/QNXDriver/sample/arm'
>make -j 1 -Cdll.le -fMakefile
>make[2]: Entering directory 'C:/QNXDriver/sample/arm/dll.le'
>../../common.mk:18: C:/QNXDriver/prodroot_pkt.mk: No such file or
>directory
>make[2]: *** No rule to make target 'C:/QNXDriver/prodroot_pkt.mk'. Stop.
>make[2]: Leaving directory 'C:/QNXDriver/sample/arm/dll.le'
>make[1]: *** [all] Error 2
>make[1]: Leaving directory 'C:/QNXDriver/sample/arm'
>make *** [all] Error 2
>
>If I call qcc directly using the command line you suggest, I get lots of
>errors in system include files, which is the same thing I get if I try to
>build in the IDE with _KERNEL defined.
>
>Like I said, if I copy all of the defines I need from the system headers
>into a separate file, I can get it to compile without defining _KERNEL.
>Do you know if there are other things that don't get included if I don't
>define _KERNEL that will result in the driver not working?
>
>Unfortunately, there is no NetBSD based driver for the radio module we're
>using that I can start my port from.
>
>Thanks again.
>
>Greg
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91734
>
Re: Writing a network driver  
And the previous qcc line was for a self hosted environment.
Try this:

qcc -shared -Wl,-Bsymbolic -o devnp-sample.so -I $QNX_TARGET/usr/include/io-pkt/ -D_KERNEL sam.c

-seanb


On Thu, Feb 23, 2012 at 10:39:43AM -0500, Sean Boudreau wrote:
> 
> Unfortunately, I don't know what tar file you were given.
> Attached is your missing prodroot_pkt.mk.  Not sure if you'll
> see other issues.
> 
> Regards,
> 
> -seanb
> 
> On Thu, Feb 23, 2012 at 10:30:58AM -0500, Greg Ludewig wrote:
> > If I unzip the tar file and then do a 'make' I get the following error:
> > 
> > C:\QNXDriver\sample>make
> > make -j 1 -Carm -fMakefile
> > make[1]: Entering directory 'C:/QNXDriver/sample/arm'
> > make -j 1 -Cdll.le -fMakefile
> > make[2]: Entering directory 'C:/QNXDriver/sample/arm/dll.le' 
> > ../../common.mk:18: C:/QNXDriver/prodroot_pkt.mk: No such file or directory
> > make[2]: *** No rule to make target 'C:/QNXDriver/prodroot_pkt.mk'. Stop.
> > make[2]: Leaving directory 'C:/QNXDriver/sample/arm/dll.le'
> > make[1]: *** [all] Error 2
> > make[1]: Leaving directory 'C:/QNXDriver/sample/arm'
> > make *** [all] Error 2
> > 
> > If I call qcc directly using the command line you suggest, I get lots of errors in system include files, which is 
the same thing I get if I try to build in the IDE with _KERNEL defined.
> > 
> > Like I said, if I copy all of the defines I need from the system headers into a separate file, I can get it to 
compile without defining _KERNEL. Do you know if there are other things that don't get included if I don't define 
_KERNEL that will result in the driver not working?
> > 
> > Unfortunately, there is no NetBSD based driver for the radio module we're using that I can start my port from.
> > 
> > Thanks again.
> > 
> > Greg
> > 
> > 
> > 
> > _______________________________________________
> > 
> > Networking Drivers
> > http://community.qnx.com/sf/go/post91734
> > 

> 
> # We link the stack with -E so a lot of the undefined
> # references get resolved from the stack itself.  If
> # you want them listed at link time, turn off
> # --allow-shlib-undefined and replace with --warn-once
> # if desired.
> 
> #LDFLAGS+=-Wl,--warn-once
> LDFLAGS+=-Wl,--allow-shlib-undefined
> 
> 
> HDR_PATH=$(INSTALL_ROOT_HDR)/io-pkt
> PUBLIC_HDR_PATH=$(QNX_TARGET)/usr/include/io-pkt
> 
> # Check for staging area first
> EXTRA_INCVPATH+= $(HDR_PATH) $(HDR_PATH)/sys-nto
> # Use headers installed in system if staging area not available
> EXTRA_INCVPATH+= $(PUBLIC_HDR_PATH) $(PUBLIC_HDR_PATH)/sys-nto
> CCFLAGS += -D_KERNEL
> 
> # gcc sometime after 2.95.3 added a builtin log()
> CCFLAGS += -fno-builtin-log
Re: Writing a network driver  
Sorry, that link was for an io-net driver. Please ignore.

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-23 10:30 AM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>If I unzip the tar file and then do a 'make' I get the following error:
>
>C:\QNXDriver\sample>make
>make -j 1 -Carm -fMakefile
>make[1]: Entering directory 'C:/QNXDriver/sample/arm'
>make -j 1 -Cdll.le -fMakefile
>make[2]: Entering directory 'C:/QNXDriver/sample/arm/dll.le'
>../../common.mk:18: C:/QNXDriver/prodroot_pkt.mk: No such file or
>directory
>make[2]: *** No rule to make target 'C:/QNXDriver/prodroot_pkt.mk'. Stop.
>make[2]: Leaving directory 'C:/QNXDriver/sample/arm/dll.le'
>make[1]: *** [all] Error 2
>make[1]: Leaving directory 'C:/QNXDriver/sample/arm'
>make *** [all] Error 2
>
>If I call qcc directly using the command line you suggest, I get lots of
>errors in system include files, which is the same thing I get if I try to
>build in the IDE with _KERNEL defined.
>
>Like I said, if I copy all of the defines I need from the system headers
>into a separate file, I can get it to compile without defining _KERNEL.
>Do you know if there are other things that don't get included if I don't
>define _KERNEL that will result in the driver not working?
>
>Unfortunately, there is no NetBSD based driver for the radio module we're
>using that I can start my port from.
>
>Thanks again.
>
>Greg
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91734
>
Re: Writing a network driver  
I really want to thank both you guys for all the help here! I'm sure I wouldn't have been able to figure this out 
without you.

The .tar file I got came from the link in post #2 of this thread. The prodroot_pkt.mk file must have been the only thing
 I was missing, because once I add that to my folder, it all builds correctly!

I have just one more thing that I don't understand. I asked about this once already, but I still don't get it. In sam.c,
 the define of the sam_syms structure has the following #ifdef around it:

#ifdef VARIANT_a
#include <nw_dl.h>
/* This is what gets specified in the stack's dl.c */
struct nw_dll_syms sam_syms[] = {
        {"iopkt_drvr_entry", &IOPKT_DRVR_ENTRY_SYM(sam)},
        {NULL, NULL}
};
#endif

 Now, I've attached the output from the make command for the arm/dll.le subdirectory. If I look at the qcc call, I can 
see that _KERNEL is defined, as well as VARIANT_dll and VARIANT_le, but that VARIANT_a is not defined.

Doesn't this mean that the sam_syms structure is not included? And if that's the case, how does the io-pkt stack know to
 execute the sam_entry() function? The documentation you provided on writing native network drivers for io-pkt says this
 structure is necessary.

Thanks once more for putting up with all my 'newbie' questions on this.

Greg
Attachment: Text make.out 1.45 KB
Re: Writing a network driver  
The VARIANT_a is only use if you want to build a library file that is
statically linked with io-pkt. If you create an arm/a.le directory, the
VARIANT_a will be created and can be statically linked with the stack.
This is only used for debugging purposes.


-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-23 3:20 PM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>I really want to thank both you guys for all the help here! I'm sure I
>wouldn't have been able to figure this out without you.
>
>The .tar file I got came from the link in post #2 of this thread. The
>prodroot_pkt.mk file must have been the only thing I was missing, because
>once I add that to my folder, it all builds correctly!
>
>I have just one more thing that I don't understand. I asked about this
>once already, but I still don't get it. In sam.c, the define of the
>sam_syms structure has the following #ifdef around it:
>
>#ifdef VARIANT_a
>#include <nw_dl.h>
>/* This is what gets specified in the stack's dl.c */
>struct nw_dll_syms sam_syms[] = {
>        {"iopkt_drvr_entry", &IOPKT_DRVR_ENTRY_SYM(sam)},
>        {NULL, NULL}
>};
>#endif
>
> Now, I've attached the output from the make command for the arm/dll.le
>subdirectory. If I look at the qcc call, I can see that _KERNEL is
>defined, as well as VARIANT_dll and VARIANT_le, but that VARIANT_a is not
>defined.
>
>Doesn't this mean that the sam_syms structure is not included? And if
>that's the case, how does the io-pkt stack know to execute the
>sam_entry() function? The documentation you provided on writing native
>network drivers for io-pkt says this structure is necessary.
>
>Thanks once more for putting up with all my 'newbie' questions on this.
>
>Greg
>
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91752
Re: Writing a network driver  
OK, so does that mean if I don't make this a static library, I don't need a sam_sysm structure? If that's the case, how 
does the io-pkt stack find out about the entry point for my driver?

Greg
Re: Writing a network driver  
Hello Greg,

I'm sorry if I'm impolite to get in the middle of your support, but I would also like to develop a driver for a RedPine 
Wifi module.

I hope I'm not being impolite too if I ask you to help me get through all this, I guess I'm more a newbie than you !

Is it possible that you give me a quick tour on how to develop a driver for Qnx, the steps and source code necessary.

Best regards,

Paul
Re: Writing a network driver  
How about the _iopkt_drvr_entry structure for your entry point? Yes, I
guess you can leave out the static entry if you don't need it.

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-23 4:13 PM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>OK, so does that mean if I don't make this a static library, I don't need
>a sam_sysm structure? If that's the case, how does the io-pkt stack find
>out about the entry point for my driver?
>
>Greg
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91754
>
Re: Writing a network driver  
In the dynamic (non static) case, io-pkt does a dlopen() on
your driver then a dlsym() on the following symbol:

# nm ./devnp-sample.so | grep iopkt_drvr_entry
00002320 D iopkt_drvr_entry

It then gets the entry point from that.

-seanb

On Thu, Feb 23, 2012 at 04:13:23PM -0500, Greg Ludewig wrote:
> OK, so does that mean if I don't make this a static library, I don't need a sam_sysm structure? If that's the case, 
how does the io-pkt stack find out about the entry point for my driver?
> 
> Greg
> 
> 
> 
> _______________________________________________
> 
> Networking Drivers
> http://community.qnx.com/sf/go/post91754
> 
Re: Writing a network driver  
Hugh and Sean,

Thanks, I think I understand now.

Paul,

I'd be happy to try to work thru this task together. I'm not sure I know what I'm doing any more than you do. I was kind
 of hoping you'd gotten further than me, and I could ask you for help!

Anyway, it might be easier if we communicated outside the forum. That way we don't have to bother Hugh and Sean anymore 
than necessary. My email address is gludewig@minnetronix.com if you want to send me an email.

Greg
Re: Writing a network driver  
So, I have another question about the driver entry point. In the sample driver, the sam_entry() function has 3 arguments
, a pointer to dll_hdl, a pointer to an io_pkt structure, and a pointer to an options string. Is there some explanation 
of what these arguments are for? Only the dll_hdl argument is actually referenced in the sample code. I assume the 
options argument is how command line arguments are passed to the driver, but I don't know what the format of the options
 argument is. And I have no idea what the iopkt argument is for.

Is there another document somewhere that would explain some of these questions?

Thanks!

Greg
Re: Writing a network driver  
I'm not aware of any document that describes these parameters, so I have
attached the source to our speedo driver that you can refer to.

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-02-27 12:29 PM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>So, I have another question about the driver entry point. In the sample
>driver, the sam_entry() function has 3 arguments, a pointer to dll_hdl, a
>pointer to an io_pkt structure, and a pointer to an options string. Is
>there some explanation of what these arguments are for? Only the dll_hdl
>argument is actually referenced in the sample code. I assume the options
>argument is how command line arguments are passed to the driver, but I
>don't know what the format of the options argument is. And I have no idea
>what the iopkt argument is for.
>
>Is there another document somewhere that would explain some of these
>questions?
>
>Thanks!
>
>Greg
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91814
>

Attachment: Text speedo.src.tar.gz 23.62 KB
Re: Writing a network driver  
Hugh,

thanks for the source to the speedo driver, it helps a lot. Would be possible to get the source for one of the wireless 
io-pkt drivers? That might help me understand better how to use some of the ieee80211 data structures and interfaces.

Thanks!

Greg
Re: Writing a network driver  
Greg,

All of the wireless drivers are covered by NDA agreements, so I cannot
give you any source. You might want to see if there are any FreeBSD
wireless driver sources available.

Hugh.

-- 
Hugh Brown
QNX Software Systems Limited
1001 Farrar Rd.,
Ottawa. ON. K2K 0B3.
Telephone: 613-591-0931







On 12-03-06 9:36 AM, "Greg Ludewig" <community-noreply@qnx.com> wrote:

>Hugh,
>
>thanks for the source to the speedo driver, it helps a lot. Would be
>possible to get the source for one of the wireless io-pkt drivers? That
>might help me understand better how to use some of the ieee80211 data
>structures and interfaces.
>
>Thanks!
>
>Greg
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post91917
>
Re: Writing a network driver  
I second the request of a sample wifi driver.

I got the sample code, the speedo driver and on the other side, a linux driver for the RedPine module.... but now 
putting the pieces together is quite tricky...
Re: Writing a network driver  
I have a couple more basic questions:

1) Is there any documentation anywhere on using the dev_attach(), if_attach(), and ieee80211_ifattach() functions? 
Something that explains what the purpose of the functions are and what each of the arguments do?
2) Are there any restrictions on threading in an io-pkt driver? Can my driver be multi-threaded?

Thanks!

Greg
Re: Writing a network driver  
Is the QNX networking source code the best place to go for answers to these questions? The ieee80211com structure in the
 QNX net80211/ieee80211_var.h header file doesn't match the NetBSD and FreeBSD versions I can find on line. In 
particular, most of the fields related to VAPs don't exist in the QNX version of the structure. Does the QNX networking 
stack not include VAPs? The documentation I can find online for the ieee80211_ifattach() function spends alot of time 
talking about VAPs and how they're used.