0

I'm relitavely new to embedded development and I have a question, or more of a feedback, on building and linking the µIP library on an embedded device. For what it's worth, the following is using a FOX G20 V board with an ATMEL AT91SAM9G20 processor with no OS. I have done some research, and the way I see myself building and linking the library on the board is one of the following two options.

Option 1: The first option would be to compile the whole library (the .c files) in order to have a built static library in the form of a .a file. Then, I can link the created static library with my application code, before loading it on the device. Of course, the device driver will have to be programmed in order to allow the library to work on the platform (help was found here). This first option is using a Linux machine. For this first option as well, in order to load the static library linked with my application code, do I do so with an "scp"?

Option 2: The second option would be to compile and link the library to my application code directly without going through an intermediate static library. However, since my platorm does not contain an OS, I would need to install an appropraite GCC compiler in order to compile and link (if anyone has any leads for such an installation, that would be very helpful as well). However I'm quite unfamilier with the second option, but I've been told that it is easier to implement so if anyone as an idea on how to implement it, it would be very helpful.

I would appreciate some feedback along with the answers as to whether these options seem correct to you, and to be sure that I have not mentioned something that is false.

Adam
  • 2,384
  • 7
  • 29
  • 66

1 Answers1

4

There is no real difference between these options. In any case, the host toolchain is responsible for creating a binary file that contains a fully linked executable with no external dependencies, so you need a cross compiler either way, and it is indeed easiest to just compile uIP along with the rest of the application.

The toolchain will typically have a cross compiler (if you use gcc, it should be named arm-eabi-gcc or arm-none-eabi-gcc), cross linker (arm-eabi-ld), cross archiver (arm-eabi-ar) etc. You would use these instead of the native tools. For Debian, you can find a cross compiler for ARM targets without an OS in testing/unstable.

Whether you build a static library

arm-eabi-gcc -c uip.c
arm-eabi-ar cru uip.a uip.o
arm-eabi-ranlib uip.a
arm-eabi-gcc -o executable application.c uip.a

or directly link

arm-eabi-gcc -c application.c
arm-eabi-gcc -c uip.c
arm-eabi-gcc -o executable application.o uip.o

or directly compile and link

arm-eabi-gcc -o executable application.c uip.c

makes no real difference.

If you use an integrated development environment, it is usually easiest to just add uip.c as a source file.

Simon Richter
  • 28,572
  • 1
  • 42
  • 64
  • How would I go about directly compiling and linking the uIP to my application directly on the platform? On the machine, I would create the compiled library by doing `gcc -Wall -c uip.c` (uip.c being one of the .c files). Once I have all the object files created, I would create a library using `ar cr libname.a` followed by all the object files created. Then linking would be `gcc -Wall application.c libname.a -o executable`. So, could you tell me how to do the second option on the platform directly please? – Adam Apr 14 '14 at 08:15
  • The other way 'round, just add the uIP sources to your application project. Using gcc, you'd compile using `arm-eabi-gcc -o executable -static application.c uip.c` – Simon Richter Apr 14 '14 at 08:37
  • So I'd have to do that same step for all the uIP files while just changing uip.c to the appropriate file? Can I do this directly on my platform? Also, what is the command `arm-eabi-gcc`? – Adam Apr 14 '14 at 08:45
  • Thank you so much for your detailed response Simon! However, when directly linking, do I need to do compile and link other files along with uip.c to my application? Or would the uip.c file suffice to get all the uip functions? – Adam Apr 14 '14 at 09:30
  • Also, since my embedded board does not have an OS installed on it (hence no compilator), are you sure that I can compile using `arm-eabi-gcc`? Because I believe I would have to install something on the board to be able to compile, isn't that correct? – Adam Apr 14 '14 at 09:41
  • No, the board has too little resources to run a compiler; that's why you compile on your main PC and then transfer the code to the board, using either the built-in bootloader of the AT91 or a JTAG adapter. How this is best done is described in the board documentation. – Simon Richter Apr 14 '14 at 09:50
  • When I tried to compile the uip.c file by doing `arm-eabi-gcc -c uip.c` on my machine for example, I get the error `arm-eabi-gcc command not found`. Also, when you say "transfer the code", is this done using "scp"? – Adam Apr 14 '14 at 10:10
  • You need to install the compiler first; for the transfer method, this differs from board to board. – Simon Richter Apr 14 '14 at 10:48
  • If the machine that I am working on that the board is connected to has no internet connection, is it possible to install the compiler on a Windows machine and later transfer it to the Linux machine (the internet-less one)? – Adam Apr 14 '14 at 11:01
  • We're somewhat leaving the scope of the original question. You'd use the same [software development kit](http://www.atmel.com/tools/at91samsoftwarepackage.aspx) as for the rest of your project. If you develop on Windows, your best bet is probably the Keil environment -- in which case adding the uip source files to the project and ignoring gcc is your best bet. – Simon Richter Apr 14 '14 at 11:56