This post explains how to build an application using RTEMS with lwIP TCP/IP stack. At present lwIP is supported with BBB.
For building the application you need 4 things
1. Build the RTEMS BBB BSP
2. lwIP stack compiled as a static library archive to be linked with the
3. Driver for ethernet controller compatible/ported to lwIP stack compiled as a static library archive to be linked with the application.
4. The application that can use these libraries.
1. Clone the RTEMS master
git clone https://github.com/RTEMS/rtems.git
2. Disable the cache . Apply this patch to the BSP
https://raw.githubusercontent.com/ragunath3252/cpsw-lwip/master/BBB-cache-disable.patch
3. Build rtems-master for beagleboneblack bsp. It will create the necessary libraries we need.
Pls refer to older posts on how to build rtems-master for BBB. We need to give an extra option during configure to tell where to install the built files. So the sequence of steps would be
a. BBB_CACHE_DISABLE=1 ${HOME}/git-rtems/configure --prefix=${HOME}/sandbox/install -- target=arm-rtems4.11 --enable-rtemsbsp=beagleboneblack
Prefix can be any folder where you want to install the files. I am giving
"/home/ragu/development/install"
b. make
c. make install
For building the application you need 4 things
1. Build the RTEMS BBB BSP
2. lwIP stack compiled as a static library archive to be linked with the
3. Driver for ethernet controller compatible/ported to lwIP stack compiled as a static library archive to be linked with the application.
4. The application that can use these libraries.
1. Build RTEMS BBB BSP
We need to build the RTEMS BBB BSP first so that our application can link to it. For use with lwIP, we need to disable the cache. Networking is working only with cache disabled (Still debugging).1. Clone the RTEMS master
git clone https://github.com/RTEMS/rtems.git
2. Disable the cache . Apply this patch to the BSP
https://raw.githubusercontent.com/ragunath3252/cpsw-lwip/master/BBB-cache-disable.patch
3. Build rtems-master for beagleboneblack bsp. It will create the necessary libraries we need.
Pls refer to older posts on how to build rtems-master for BBB. We need to give an extra option during configure to tell where to install the built files. So the sequence of steps would be
a. BBB_CACHE_DISABLE=1 ${HOME}/git-rtems/configure --prefix=${HOME}/sandbox/install -- target=arm-rtems4.11 --enable-rtemsbsp=beagleboneblack
Prefix can be any folder where you want to install the files. I am giving
"/home/ragu/development/install"
b. make
c. make install
The prefix option is important because in the future commands we will use this path to specify where the libraries are stored
2. Building the lwIP stack
The lwIP stack is integrated with RTEMS source builder(RSB). You can clone the RSB and repo & build the lib. The following are the steps
a. Clone the RTEMS source builder repo
git clone https://github.com/RTEMS/rtems-source-builder.git
b. cd rtems
c. ../source-builder/sb-set-builder --log=logfile --with-tools=compiler-path
--host=x86_64-linux-gnu 4.11/net/lwip --prefix=bsp-install-path --rtems-bsp=arm/beagleboneblack --target=arm-rtems4.11
here
--with-tools ---> assign it to RTEMS compiler path
--prefix ---> Path where corresponding BSP is installed
--host ----> your host info
This will build and install the lib & header files in the path $prefix/$bsp/lwip
For Example, for the command
../source-builder/sb-set-builder --log=logile --with-tools=/home/ragu/build_tools/rtems/compiler/4.11 --host=x86_64-linux-gnu 4.11/rtems-beagle-lwip --prefix=/home/ragu/build_tools/rtems_latest --rtems-bsp=arm/beagleboneblack --target=arm-rtems4.11
@ragu-ubuntu:~/work/gsoc/lwip/patch/test/rsb-make/rtems-source-builder/rtems$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/lib/
total 1796
-rw-r--r-- 1 root root 1641832 Aug 14 18:39 liblwip.a
a. Download the patch from the following link
https://raw.githubusercontent.com/ragunath3252/rtems-rsb-lwip/master/0001-CPSW-lwIP-driver-library-build-files.patch
b. Apply the patch to RTEMS RSB
c. Execute the following command
../source-builder/sb-set-builder --log=modem --with-tools=/home/ragu/build_tools/rtems/compiler/4.11 --host=x86_64-linux-gnu 4.11/net/cpsw --prefix=/home/ragu/build_tools/rtems_latest --rtems-bsp=arm/beagleboneblack --target=arm-rtems4.11
Change your command as explained for lwip.This will install the driver library & include files in the $prefix/bsp/lwip
For example
ragu@ragu-ubuntu:~/work/gsoc/lwip/lwip-patch/rtems-source-builder$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/
total 8
drwxr-xr-x 6 root root 4096 Aug 14 18:41 include
drwxr-xr-x 2 root root 4096 Aug 14 18:41 lib
ragu@ragu-ubuntu:~/work/gsoc/lwip/lwip-patch/rtems-source-builder$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/include/
total 72
drwxr-xr-x 2 root root 4096 Aug 14 18:39 arch
-rwxr-xr-x 1 root root 5278 Aug 14 22:31 beaglebone.h
-rwxr-xr-x 1 root root 3170 Aug 14 22:31 cache.h
drwxr-xr-x 2 root root 4096 Aug 14 18:39 lwip
-rw-r--r-- 1 root root 1066 Aug 14 22:31 lwip_bbb.h
-rwxr-xr-x 1 root root 9090 Aug 14 22:31 lwiplib.h
-rw-r--r-- 1 root root 7843 Aug 14 18:39 lwipopts.h
-rwxr-xr-x 1 root root 7325 Aug 14 22:31 mmu.h
drwxr-xr-x 3 root root 4096 Aug 14 18:39 netif
drwxr-xr-x 3 root root 4096 Aug 14 18:39 posix
-rwxr-xr-x 1 root root 9848 Aug 14 22:31 soc_AM335x.h
ragu@ragu-ubuntu:~/work/gsoc/lwip/lwip-patch/rtems-source-builder$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/lib/
total 1796
-rw-r--r-- 1 root root 1641832 Aug 14 18:39 liblwip.a
-rw-r--r-- 1 root root 194594 Aug 14 22:31 liblwipdrv.a
4. Build the application
a. Clone the repo
git clone https://github.com/ragunath3252/lwip-app.git
b. export RTEMS_MAKEFILE_PATH=path-to-your-installed-bsp-directory
We need to set this variable so that the app can see where the libraries and header files are installed.
c. make
d. It will create the lwip.exe in o-optimize/lwip.exe
e. This is a elf executable. You can use this to boot your BBB
Now this app is configured to use DHCP. So it will get an ip address using DHCP and stops.
You can ping to the ip address and see the response.
2. Building the lwIP stack
The lwIP stack is integrated with RTEMS source builder(RSB). You can clone the RSB and repo & build the lib. The following are the steps
a. Clone the RTEMS source builder repo
git clone https://github.com/RTEMS/rtems-source-builder.git
b. cd rtems
c. ../source-builder/sb-set-builder --log=logfile --with-tools=compiler-path
--host=x86_64-linux-gnu 4.11/net/lwip --prefix=bsp-install-path --rtems-bsp=arm/beagleboneblack --target=arm-rtems4.11
here
--with-tools ---> assign it to RTEMS compiler path
--prefix ---> Path where corresponding BSP is installed
--host ----> your host info
This will build and install the lib & header files in the path $prefix/$bsp/lwip
For Example, for the command
../source-builder/sb-set-builder --log=logile --with-tools=/home/ragu/build_tools/rtems/compiler/4.11 --host=x86_64-linux-gnu 4.11/rtems-beagle-lwip --prefix=/home/ragu/build_tools/rtems_latest --rtems-bsp=arm/beagleboneblack --target=arm-rtems4.11
@ragu-ubuntu:~/work/gsoc/lwip/patch/test/rsb-make/rtems-source-builder/rtems$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/lib/
total 1796
-rw-r--r-- 1 root root 1641832 Aug 14 18:39 liblwip.a
3. Build driver library
The driver files are not integrated with RTEMSa. Download the patch from the following link
https://raw.githubusercontent.com/ragunath3252/rtems-rsb-lwip/master/0001-CPSW-lwIP-driver-library-build-files.patch
b. Apply the patch to RTEMS RSB
c. Execute the following command
../source-builder/sb-set-builder --log=modem --with-tools=/home/ragu/build_tools/rtems/compiler/4.11 --host=x86_64-linux-gnu 4.11/net/cpsw --prefix=/home/ragu/build_tools/rtems_latest --rtems-bsp=arm/beagleboneblack --target=arm-rtems4.11
Change your command as explained for lwip.This will install the driver library & include files in the $prefix/bsp/lwip
For example
ragu@ragu-ubuntu:~/work/gsoc/lwip/lwip-patch/rtems-source-builder$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/
total 8
drwxr-xr-x 6 root root 4096 Aug 14 18:41 include
drwxr-xr-x 2 root root 4096 Aug 14 18:41 lib
ragu@ragu-ubuntu:~/work/gsoc/lwip/lwip-patch/rtems-source-builder$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/include/
total 72
drwxr-xr-x 2 root root 4096 Aug 14 18:39 arch
-rwxr-xr-x 1 root root 5278 Aug 14 22:31 beaglebone.h
-rwxr-xr-x 1 root root 3170 Aug 14 22:31 cache.h
drwxr-xr-x 2 root root 4096 Aug 14 18:39 lwip
-rw-r--r-- 1 root root 1066 Aug 14 22:31 lwip_bbb.h
-rwxr-xr-x 1 root root 9090 Aug 14 22:31 lwiplib.h
-rw-r--r-- 1 root root 7843 Aug 14 18:39 lwipopts.h
-rwxr-xr-x 1 root root 7325 Aug 14 22:31 mmu.h
drwxr-xr-x 3 root root 4096 Aug 14 18:39 netif
drwxr-xr-x 3 root root 4096 Aug 14 18:39 posix
-rwxr-xr-x 1 root root 9848 Aug 14 22:31 soc_AM335x.h
ragu@ragu-ubuntu:~/work/gsoc/lwip/lwip-patch/rtems-source-builder$ ls -l /home/ragu/build_tools/rtems_latest/arm-rtems4.11/beagleboneblack/lwip/lib/
total 1796
-rw-r--r-- 1 root root 1641832 Aug 14 18:39 liblwip.a
-rw-r--r-- 1 root root 194594 Aug 14 22:31 liblwipdrv.a
4. Build the application
a. Clone the repo
git clone https://github.com/ragunath3252/lwip-app.git
b. export RTEMS_MAKEFILE_PATH=path-to-your-installed-bsp-directory
We need to set this variable so that the app can see where the libraries and header files are installed.
c. make
d. It will create the lwip.exe in o-optimize/lwip.exe
e. This is a elf executable. You can use this to boot your BBB
Now this app is configured to use DHCP. So it will get an ip address using DHCP and stops.
You can ping to the ip address and see the response.