I am trying to build openswan from source for a WRT54Gv2(CAN) router. While I have followed the article at http://wiki.linuxops.net/tiki-read_article.php it is incomplete; --specifically, I cannot build the kernel driver.
I would very much appreciate any help on this. Once I am successful, I will post the full set of commands that work to this thread for all to benefit...
Please note that if you don't add the "modules" option to the openswan ipkg/rules, the ipkg is made, but, not the modules package. Obviously, I am missing something here...
Thanks in advance!
Here's what I've done:
Building WRT54G v2 firmware
using BusyBox v1.00-rc2 (2004.08.11-21:27+0000)
1) cvs -d:pserver:anonymous@openwrt.ksilebo.net:/openwrt login
2) cvs -d:pserver:anonymous@openwrt.ksilebo.net:/openwrt co buildroot
3) cd buildroot
4) make
If this is the first time on the router...
5) Open LinkSys admin page: http://192.168.1.1
6) Open LinkSys update firmware page.
7) Upload openwrt-g-code.bin
8) Reboot
First time logging in...
1) Ethernet cable to a LAN port...
2) ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up
3) route add default gw 192.168.1.1
4) telnet 192.168.1.1
5) firstboot
NOTE: I am running BusyBox v1.00-rc2 (2004.08.14-00:22+0000).
And if this is first time in, run...
Set boot wait...
1) nvram set boot_wait=true
2) nvram commit
3) reboot
as the ping hack doesn't work on the WRT54Gv2 (Canadian version).
OpenSwan:
1) Edit sources/openwrt/busybox/busybox.config as follows:
a) CONFIG_ID=y (from not set)
b) CONFIG_TR=y (from not set)
c) CONFIG_DIRNAME=y (from not set)
d) CONFIG_HOSTNAME=y (from not set)
EXTRA (my choice):
i) CONFIG_IP=y (from not set)
ii) CONFIG_IPADDR=y
iii) CONFIG_IPLINK=y
iv) CONFIG_IPROUTE=y
v) CONFIG_IPTUNNEL=y
Turned on for network settings; --I don't want to rebuild again for these.
2) Build firmware.
Now we want to build GMP (a prereq to openswan)...
3) wget ftp://ftp.sunet.se/pub/gnu/gmp/gmp-4.1.3.tar.gz
4) tar xvzf gmp-4.1.3.tar.gz
5) cd gmp-4.1.3/
6) wget http://www.linuxops.net/ipkg/gmp-4.1.3-ipkg.tar.gz
7) tar xvzf gmp-4.1.3-ipkg.tar.gz
8) vi ipkg/rules
Edit OPENWRTBR to point to the OpenWRT buildroot directory.
9) vi ipkg/control
Edit and add name to Maintainer field.
10) export PATH=$PATH:/home/me/linksys/openwrt-cpp/buildroot/build_mipsel/staging_dir/bin
11) ../../buildroot/build_mipsel/staging_dir/bin/ipkg-buildpackage
NOTE: I am building openswan in .../buildroot/
NOTE: If building again one may have to remove /tmp/gmp/ and /tmp/gmp.build/.
This works.
Now we want to build openswan...
12) wget http://www.openswan.org/code/openswan-2.1.2.tar.gz
13) tar xvzf openswan-2.1.2.tar.gz
14) cd openswan-2.1.2
15) wget http://www.linuxops.net/ipkg/archived/o … pkg.tar.gz
16) tar xvzf openswan-2.1.2-ipkg.tar.gz
17) vi ipkg/rules
Edit OPENWRTBR to point to the OpenWRT buildroot directory.
Eg.: OPENWRTBR:=/home/me/linksys/openwrt-cpp/buildroot
18) vi ipkg/control
Edit and add name to Maintainer field.
19) Edit ipkg/rules...
a) to have /tmp/gmp.build instead of /tmp/gmp:
USERCOMPILE:=$(TARGET_CFLAGS) -L/usr/local/openwrt/buildroot/build_mipsel/root/lib/ -L/tmp/gmp.build/usr/lib -I/usr/local/openwrt/buildroot/build_mipsel/root/include -I/tmp/gmp.build/usr/include
b) to have KERNELSRC="$(STAGING_DIR)/../linux" and module added...
$(MAKE) DESTDIR=$(DESTDIR) $(TARGET_CONFIGURE_OPTS) USERCOMPILE="$(USERCOMPILE)" KERNELSRC="$(STAGING_DIR)/../linux" programs module
20) ../../buildroot/build_mipsel/staging_dir/bin/ipkg-buildpackage
And then I get...
Now we can build openswan...
12) wget http://www.openswan.org/code/openswan-2.1.2.tar.gz
13) tar xvzf openswan-2.1.2.tar.gz
14) cd openswan-2.1.2
15) wget http://www.linuxops.net/ipkg/archived/o … pkg.tar.gz
16) tar xvzf openswan-2.1.2-ipkg.tar.gz
17) vi ipkg/rules
Edit OPENWRTBR to point to the OpenWRT buildroot directory.
Eg.: OPENWRTBR:=/home/me/linksys/openwrt-cpp/buildroot
18) vi ipkg/control
Edit and add name to Maintainer field.
19) Edit ipkg/rules...
a) to have /tmp/gmp.build instead of /tmp/gmp:
USERCOMPILE:=$(TARGET_CFLAGS) -L/usr/local/openwrt/buildroot/build_mipsel/root/lib/ -L/tmp/gmp.build/usr/lib -I/usr/local/openwrt/buildroot/build_mipsel/root/include -I/tmp/gmp.build/usr/include
b) to have KERNELSRC="$(STAGING_DIR)/../linux" and module added...
$(MAKE) DESTDIR=$(DESTDIR) $(TARGET_CONFIGURE_OPTS) USERCOMPILE="$(USERCOMPILE)" KERNELSRC="$(STAGING_DIR)/../linux" programs module
20) ../../buildroot/build_mipsel/staging_dir/bin/ipkg-buildpackage
And then I get as output...
[snip]
/home/me/linksys/openwrt-cpp/buildroot/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-gcc -DIPCOMP_PREFIX -include /home/me/linksys/openwrt-cpp/openswan/openswan-2.1.2/packaging/linus/config-all.h -I../../include -I/home/me/linksys/openwrt-cpp/buildroot/build_mipsel/staging_dir/../linux/include -I../../lib/zlib -Wall -DARCH=i386 -DMODVERSIONS -include /home/me/linksys/openwrt-cpp/buildroot/build_mipsel/staging_dir/../linux/include/linux/modversions.h -DMODULE -D__KERNEL__ -I/home/me/linksys/openwrt-cpp/buildroot/build_mipsel/WRT54GS/release/src/linux/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -DKBUILD_BASENAME=ipsec_sa -c -o ipsec_sa.o ipsec_sa.c
{standard input}: Assembler messages:
{standard input}:1348: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($16)'
{standard input}:1350: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($16)'
{standard input}:1570: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($4)'
{standard input}:1572: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($4)'
{standard input}:1677: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($16)'
{standard input}:1679: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($16)'
{standard input}:1753: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($5)'
{standard input}:1755: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($5)'
{standard input}:1996: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($17)'
{standard input}:1998: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($17)'
{standard input}:2021: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($3)'
{standard input}:2023: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($3)'
{standard input}:2259: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($17)'
{standard input}:2261: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($17)'
{standard input}:2267: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($16)'
{standard input}:2269: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($16)'
{standard input}:2453: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($17)'
{standard input}:2455: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($17)'
{standard input}:2490: Error: opcode not supported on this processor: mips1 (mips1) `ll $2,4($17)'
{standard input}:2492: Error: opcode not supported on this processor: mips1 (mips1) `sc $2,4($17)'
make[2]: *** [ipsec_sa.o] Error 1
make[2]: Leaving directory `/home/me/linksys/openwrt-cpp/openswan/openswan-2.1.2/linux/net/ipsec'
make[1]: *** [module] Error 2
make[1]: Leaving directory `/home/me/linksys/openwrt-cpp/openswan/openswan-2.1.2'
make: *** [build-stamp] Error 2
Build failed
me@electron:~/linksys/openwrt-cpp/openswan/openswan-2.1.2$