03 Mar 2010 à 15:59 par isontheline
Prerequisites
In order to build (i.e cross-compile) applications for La Fonera you must have La Fonera's sources and toolchain on YOUR machine (not La Fonera itself).If you don't want to build these, we have already done it and you can download the tarball from :
- x86 processors : http://mirrors.itimeteo.com/fon/toolchains/lafonera-x86-toolchain.tar.gz

- x86_64 processors : http://mirrors.itimeteo.com/fon/toolchains/lafonera-x86-64-toolchain.tar.gz

If you have downloaded one of these toolchains, you can now jump to Build your first application!
Build La Fonera's Toolchain
If your processor is not listed or if you want to setup your own toolchain, there are 3 steps to follow :Step 1 : Prepare your environment
| 1. | # Make a new directory for La Fonera's sources : |
| 2. | $ mkdir /some/where/fonera-sources |
| 3. | |
| 4. | # Go to your newly created directory : |
| 5. | $ cd /some/where/fonera-sources |
| 6. | |
| 7. | # Retrieve the La Fonera's sources : |
| 8. | $ wget http://download.fon.com/firmware/fonera/latest/fonera.tar.bz2 ![]() |
| 9. | |
| 10. | # Extract the downloaded file : |
| 11. | $ tar jxvf fonera.tar.bz2 ./ |
Note :
La Fonera's sources are avaible from :- http://download.fon.com/firmware/fonera/latest/fonera.tar.bz2
(Original Location)
- http://mirrors.itimeteo.com/fon/sources/lafonera-sources.tar.bz2
(Itimeteo Mirror Location)
Step 2 : Configure the build process
| 1. | # Configure the build : |
| 2. | $ make menuconfig |
| 3. | |
| 4. | # Select the option "Build the OpenWrt SDK" by enabling the row with your space key. |
| 5. | |
| 6. | # Press Esc key and select the "Yes" button in order to save the build's configuration |
Step 3 : Build the toolchain
| 1. | # Launch the build process : |
| 2. | $ make V=99 |
Wait for about 30 minutes, or more!
During the build process, two important directories are created :
- bin Contains your prepackaged toolchain. For your arch only!
- staging_dir_mips Contains your own toolchain.
- staging_dir_mips Contains your own toolchain.
Build your first application!
| 1. | # Setup your PATH environment variable : |
| 2. | $ PATH=$PATH:/some/where/fonera-sources/staging_dir_mips/bin |
| 3. | $ export PATH |
| 4. | |
| 5. | # Make a new directory for your app : |
| 6. | $ mkdir /some/where/my-first-app |
| 7. | |
| 8. | # Go to your app directory : |
| 9. | $ cd /some/where/my-first-app |
| 10. | |
| 11. | # Create a simple hello world app : |
| 12. | $ cat > hello.c << EOF |
| 13. | #include |
| 14. | |
| 15. | int main(int argc, char *argv[]) { |
| 16. | printf("Hello World! |
| 17. | "); |
| 18. | } |
| 19. | EOF |
| 20. | |
| 21. | # Compile your application : |
| 22. | $ mips-linux-uclibc-gcc hello.c -o hello |
| 23. | |
| 24. | # Send it to La Fonera : |
| 25. | $ scp hello root@192.168.10.1:/tmp |
| 26. | |
| 27. | # Connect to La Fonera : |
| 28. | $ ssh root@192.168.10.1 |
| 29. | |
| 30. | # Run your first application : |
| 31. | $ /tmp/test |
| 32. | |
| 33. | # This will display : |
| 34. | Hello World! |