2008-03-11 10:28:55     Using functions from net.h in standalone application

Document created by Aaronwu Employee on Sep 17, 2013
Version 1Show Document
  • View in full screen mode

2008-03-11 10:28:55     Using functions from net.h in standalone application

Michiel Verschueren (BELGIUM)

Message: 52332    Hi,

 

I'm writing a standalone application for U-Boot. I would like to use some of the functions defined in net.h, much in the same way that do_ping() in cmd_net.c does. I have tried to include the header file (include <net.h>), but I get linker errors:

undefined reference to 'string_to_ip'

undefined reference to 'NetPingIP'

undefined reference to 'NetLoop'

 

What is the right way to do this?

And, more in general, how can I use functions that have not been included in exports.h and global variables in my standalone application?

 

Is there any place where I can find more information on writing standalone applications? I have been looking at the README.standalone file, but this was not very helpful to me.

 

Thanks in advance

QuoteReplyEditDelete

 

 

2008-03-11 10:44:55     Re: Using functions from net.h in standalone application

Mike Frysinger (UNITED STATES)

Message: 52333    only things found by including exports.h are available to your standalone u-boot application.  other functions in other headers are not available.  unfortunately, it's pretty much that cut and dry.

QuoteReplyEditDelete

 

 

2008-03-11 11:32:17     Re: Using functions from net.h in standalone application

Michiel Verschueren (BELGIUM)

Message: 52337    Hi Mike,

 

first of all thanks for your quick reply.

 

I've tried exporting the functions I need by adding them to exports.h, and by adding an EXPORT_FUNC to _exports.h. This has eliminated the linker errors for string_to_ip() and NetLoop(), but obviously not for the variable NetPingIP. Is there a warkaround for variables too? Or shouldn't I be altering exports.h anyway?

 

If I can't use any other functions than the ones in exports.h, then is there any other way to communicate with peripherals than through I2C and the Memory-Mapped Registers?

 

The application I'm trying to write uses the peripherals on my board extensively, so it would be most helpful if there's a way to use U-Boot's built-in I/O functionality.

 

Thanks,

 

Michiel

QuoteReplyEditDelete

 

 

2008-03-11 12:04:40     Re: Using functions from net.h in standalone application

Mike Frysinger (UNITED STATES)

Message: 52340    the design of u-boot is to provide an ABI that standalone applications can use and not require the application to be under the GPL (refer to the u-boot licensing for real information).  as soon as you start exporting more things to your application, your code is now under the GPL.

 

how you're making the modifications to add things to the export list is technically how you would go about it.  i believe that the way the export stuff is architected (a jump table rather than ELF relocations) means you will only be able to export functions.  but it's easy enough to write a function that returns a pointer:

int *GetNetPingIp(void) { return &NetPingIp; }

and then export that function ...

 

on the topic of making the export list more extensive, that question would have to be posed to Wolfgang on the u-boot mailing list as he's the one in charge.

QuoteReplyEditDelete

 

 

2008-03-12 11:03:54     Re: Using functions from net.h in standalone application

Michiel Verschueren (BELGIUM)

Message: 52392    Don't worry, I am well aware of the licensing issues.

 

As for the exporting: my code compiles and links without errors and warnings, but I get the following error when running the application:

 

code=[0x21], stack frame=0x3f9ba80, bad PC=0x3fc0130

 

Unhandled IRQ or exceptions!

Please reset the board

 

After this, U-Boot restarts.

 

- I have added "extern void NetSetPingIP (IPaddr_t);" to net.h, and an implementation of this function to net.c.

- I have added "#include <net.h>" to exports.h.

- I have added an "EXPORT_FUNC" for the three functions to _exports.h

- I have added "gd->jt[XF_NetLoop] = (void *) NetLoop;" (and likewise for the other two) to exports.c.

 

Do you (or anyone else) have an idea what's going wrong? I don't see a relevant difference between these functions and the others in exports.h.

 

Thanks

QuoteReplyEditDelete

 

 

2008-03-12 11:21:34     Re: Using functions from net.h in standalone application

Mike Frysinger (UNITED STATES)

Message: 52396    how are you booting the application ?  can you boot any of the example applications ?

 

looks like you're using u-boot from 2007R1, so the crash message is pretty useless ... the u-boot 2008R1+ has a much more useful crash message

Attachments

    Outcomes