AMiLDA FORUM

You are not logged in.

Announcement

### Our Homepage is down at the moment...work in progress !! ###

#1 2006-07-04 14:03:39

MrZack
Administrator
Austria
Registered: 2006-02-15
Last visit: 2017-10-23
Posts: 106

New packages--HOW?

Hi

Can someone post a small how to on adding extra packages to the source tree of AMiLDA?
Lets say tcpdump-3.7.2...

1. You download it from the web.
2. You unpack it to the /apps/tcpdump-3.7.2 directory
3. Then you run ./configure (with --???? for the mipsel toolchain?) in the /apps/tcpdump-3.7.2 directory
4. Then you add it to the Makefile in /apps
5. After that you run make from the AMiLDA root

I have problems in step 3. How do i configure a new software package to use the toolchain?
Can someone make a step-by-step How-To on one software package like tcpdump and explane why you have to do the things that have to be done?  big_smile

I need to adapt AMiLDA for a wireless sociaty and for that i need other tools in the source tree.

Thanx


Nothing is impossible....except that the state of your mind makes it so.

Offline

 

#2 2006-07-09 21:09:24

parcival
New member
Registered: 2006-06-17
Last visit: 2006-07-12
Posts: 3

Re: New packages--HOW?

Here is the way, that doesen't work for me - I know you want to have the right way, but maybe someone can see my misstake.

1. download dropbear 0.48.1 & untar
2. set enviroment:
export CROSS=/export/tools/mipsel-linux-uclibc/bin/mipsel-uclibc-
export CC=${CROSS}gcc
export LD=${CROSS}ld
export CPP=${CROSS}cpp
export CXX=${CROSS}g++
export AR=${CROSS}ar
export CXXCPP=${CROSS}cpp
export RANLIB=${CROSS}ranlib
3. ./configure --host=mipsel --disable-zlib
4. options.h: /dev/random -> /dev/urandom
5. make PROGRAMS="dropbear dbclient scp" MULTI=1 SCPPROGRESS=1
6. asking myself what went wrong

Offline

 

#3 2006-07-11 01:49:11

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: New packages--HOW?

Hi

--host=mipsel defines the host architecture, not the target one. I think you should specify --target intead of --host.

I'm trying to build a new toolchain based on gcc 3, using Gentoo's crossdev toolkit. Yet i have no success..

Regards,

Sergio

Offline

 

#4 2006-07-11 23:31:03

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: New packages--HOW?

I have the beginnings of a toolchain/package builder setup working pretty nicely.  It's loosely based on OpenWrt and buildroot.  It's not exactly like OpenWrt because they use ipkg (debian-like) for their packages and I didn't see any benefit in that since our routers don't have enough flash to support a permanent jffs2 filesystem where you can install and de-install packages on the fly.

One thing to be aware of is that it's based on the regular Edimax Linux 2.4.18 code.  With a little work it could support AMiLDA's newer Linux kernel without too much trouble.  In fact, both could co-exist.  I'm stuck with 2.4.18 because of the IPN2220 binary-only wlan kernel module.  I have more information on that but will save it for another thread.

For Mr. Zack's question, I have done that with several "packages".  Not tcpdump, but iptables, dropbear, strace, pciutils, portmap and tcp_wrappers.  To add them in all you have to do is create a subdirectory in the tree and a sub-makefile for it.  You can use any of the existing ones as a template.  If you know GNU Make, and you do need to know it well, setting one up is very easy.

There are 2 key elements (not exactly full "packages" but they exist in the tree like packages) that let you set up 2 directories that are combined into your final runtime ext2 ramdisk root partition.  One is a sub-tree that has all the critical top-level directories and files, such as /bin/busybox and all those symlinks, as well as /lib which contains all the uClibc runtime libraries.

The second "customize" package contains a separate top-level tree with other files that get merged into the top-level ramdisk root directory.  I use that as the target install directory for the packages.  When the main Make is run, those 2 directories are combined into a ramdisk.bz2, copied into the Linux arch/mips/ramdisk directory and Linux is built.  After that the wrapcsys utility is run and a firmware file is generated.

It's very slick and I've been using it and perfecting it for 2 months.  It's still not perfect smile but it works.

As a bonus big_smile there are patches for Linux 2.4.18 (Edimax, not AMiLDA) and userspace code for "nvram", which works just like OpenWrt's nvram but for Edimax-style devices.  It uses the last 64KB of the flash device to store non-volatile variables.  Much more flexible IMO than the fixed structure used by Edimax.  It also lessens the stress on the flash chip because changes are not written to the flash until you run "nvram commit".  With the Edimax-style "flash" program, every time you change a variable with "flash set x=y" the flash sector is erased and written.  With nvram you can make 100 changes and there is only 1 erase/write cycle.  This might not be a good solution if you only have a 2 MB flash chip, but if you have 4 MB, as I am fortunate to have, it's nice.  There is no requirement to use this if you don't want to.  It is quite independent from the overall buildroot system.  This, too, could be adapted for AMiLDA.  The code I based it on was from OpenWrt (Broadcom GPL source code) which is closer to AMiLDA's Linux version than 2.4.18 is.  It would be very easy to do.

The biggest thing you need to know is Makefiles.  There is a base Makefile that includes all the other Makefiles in the tree, so it acts like one huge makefile.  That's what buildroot basically is.  There are a few scripts that are run but in general everything you want to do you do with "make xyz" instead of running a script.

It also downloads and builds an entire gcc-2.96 toolchain from source code.  You can put it anywhere you want, it doesn't have to be in /export/tools.  Like all toolchains, once you build it you can't move it, but you have the freedom to select where you want it to be.  Many hours of testing shows that it produces the exact same binary code as the Edimax toolchain.  It is based on the work of H.J. Lu and Steven Hill who were very active in Linux-MIPS approx. 4 years ago in the gcc-2.96 days.  I believe Edimax used H.J. Lu's work as the source for their toolchain.  This one is better IMO because it is purely a native cross-compiler.  You will see 2 complete sets of uClibc libraries in the Edimax /export/tools tree because they used a "wrapper" approach to building their compiler and libraries.  I incorporated Steven Hill's work into my procedure and there is no wrapper anymore, it builds one set of libraries only.

It will also download, if you choose, the big Edimax GPL tarball and fix it up so that you will have a baseline Linux source tree without all the extra junk in it.  It fixes file permissions and gets rid of extra files that are in the Edimax tree that are not needed.  With that base in place it is fairly easy to generate patches.  I've included a few patches for it as well that fix up some problems in the Edimax code.  The final result is this:  Lunux 2.4.18 builds with no errors and only 2 warnings.  This feature requires that you have Perl on your Linux system along with some extra Perl packages.

I have no interest in supporting any of it smile nor do I want to release it as a complete distro a la AMiLDA.  But if anyone wants to try it out or even modify it to use with AMiLDA then I would be happy to post it somewhere.

Last edited by HH (2006-07-12 01:30:56)

Offline

 

#5 2006-07-12 10:11:33

MrZack
Administrator
Austria
Registered: 2006-02-15
Last visit: 2017-10-23
Posts: 106

Re: New packages--HOW?

Like i sead, i need to adapt AMiLDA for a very specific wireless project "Funkfeuer". This is a (free internet) wireless sociaty that i am also a part of.

The things that are needed are:
-OpenVPN
-OSLR
-Iptables
-Tcpdump (if there is room for that)
-SSH
-Wireless Support for the 5Ghz Atheros card (i think MADWIFI will do)
-?

And that's about it  big_smile

That's why i need more info on how to adapt new packages to the AMiLDA source.
In making this AMiLDA version for this project will get AMiLDA VERY known around EU and maybe world.
There are many, almost same, sociaties that need a better support for the 5Ghz wireless and giving them the possibility to do it with AMiLDA would be mega COOL  cool

So i'm for any and all the help i can get  big_smile


Nothing is impossible....except that the state of your mind makes it so.

Offline

 

#6 2006-07-12 22:05:12

parcival
New member
Registered: 2006-06-17
Last visit: 2006-07-12
Posts: 3

Re: New packages--HOW?

@sergioag
are you sure that  "--taget" ist right? I get:
./configure --target=mips
checking for gcc... /export/tools/mipsel-linux-uclibc/bin/mipsel-uclibc-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
See `config.log' for more details.

@HH
You said, you compiled dropbear. Can you please go in more detail?
What Toolchain did you use (or: have you tried any other, than "your own"). Wich configure- and make-command? Any patches?
Why do you use a gcc-2.96 Toolchain and do not build a newer on?

Offline

 

#7 2006-07-13 00:17:22

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: New packages--HOW?

parcival, I will answer your last question first:  there are 3 reasons why I use gcc-2.96.

1. The kernel source code for Linux 2.4.18 will not compile cleanly with some newer versions of gcc.  There are macros and string concatenation issues with the source code.  I'm not exactly sure but I think anything newer than gcc-3.2 will not build the Linux 2.4.18 kernel unless you make a lot of changes to the source code.

2. gcc-2.96 produces smaller code than newer compilers.  Not in every case, but it generally does.

3. This is related to (1) because it's the reason I stick with 2.4.18.  I am undertaking to reverse-engineer the IPN2220AP.o wireless chipset driver.  To do that I need to be able to verify that the source code I generate compiles to the exact same binary code in IPN2220AP.o.  If you are attempting to make binary code that matches someone else's binary code it only makes sense to use the same tools that the other person is using.

Once I am finished I will be more than happy to dump Linux 2.4.18 and the older compiler.

Now, for your first question smile ...

In my build setup I unpacked dropbear 0.48 into its own subdirectory.  I created a makefile fragment that gets included into my main makefile.  The fragment looks like this:

Code::

#############################################################
#
# dropbear
#
#############################################################
DROPBEAR_VER:=0.48
DROPBEAR_SOURCE:=dropbear-$(DROPBEAR_VER).tar.gz
DROPBEAR_SITE:=http://matt.ucc.asn.au/dropbear/releases/
DROPBEAR_DIR:=$(BUILD_DIR)/dropbear-$(DROPBEAR_VER)
DROPBEAR_CAT:=zcat
DROPBEAR_BINARY:=dropbearmulti
DROPBEAR_TARGET_BINARY:=usr/sbin/dropbear

$(DL_DIR)/$(DROPBEAR_SOURCE):
        $(WGET) -P $(DL_DIR) $(DROPBEAR_SITE)/$(DROPBEAR_SOURCE)

dropbear-source: $(DL_DIR)/$(DROPBEAR_SOURCE)

dropbear-unpacked: $(DROPBEAR_DIR)/.unpacked
$(DROPBEAR_DIR)/.unpacked: $(DL_DIR)/$(DROPBEAR_SOURCE)
        $(DROPBEAR_CAT) $(DL_DIR)/$(DROPBEAR_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
        toolchain/patch-kernel.sh $(DROPBEAR_DIR) package/dropbear dropbear\*.patch
        toolchain/patch-kernel.sh $(DROPBEAR_DIR) package/dropbear patches/*.patch
        $(SED) 's,^/\* #define DROPBEAR_MULTI.*,#define DROPBEAR_MULTI,g' $(DROPBEAR_DIR)/options.h
        touch $(DROPBEAR_DIR)/.unpacked

$(DROPBEAR_DIR)/.configured: $(DROPBEAR_DIR)/.unpacked
        (cd $(DROPBEAR_DIR); rm -rf config.cache; \
                autoconf; \
                $(TARGET_CONFIGURE_OPTS) \
                CFLAGS="$(TARGET_CFLAGS)" \
                ./configure \
                --target=$(GNU_TARGET_NAME) \
                --host=$(GNU_TARGET_NAME) \
                --build=$(GNU_HOST_NAME) \
                --prefix=/usr \
                --exec-prefix=/usr \
                --bindir=/usr/bin \
                --sbindir=/usr/sbin \
                --libexecdir=/usr/lib \
                --sysconfdir=/etc \
                --datadir=/usr/share \
                --localstatedir=/var \
                --mandir=/usr/man \
                --infodir=/usr/info \
                --disable-nls \
                --with-shared \
                --disable-pam \
                --enable-openpty \
                --disable-shadow \
                --disable-syslog \
                --disable-lastlog \
                --disable-loginfunc \
                --disable-utmp \
                --disable-utmpx \
                --disable-wtmp \
                --disable-wtmpx \
                --disable-pututline \
                --disable-pututxline \
        );
ifeq ($(strip $(BR2_PACKAGE_DROPBEAR_URANDOM)),y)
        $(SED) 's,^#define DROPBEAR_RANDOM_DEV.*,#define DROPBEAR_RANDOM_DEV \"/dev/urandom\",' \
                $(DROPBEAR_DIR)/options.h
endif
        $(SED) 's,^#define DO_HOST_LOOKUP,/* & */,g' $(DROPBEAR_DIR)/options.h
        touch $(DROPBEAR_DIR)/.configured

dropbear-build: $(DROPBEAR_DIR)/$(DROPBEAR_BINARY)
$(DROPBEAR_DIR)/$(DROPBEAR_BINARY): $(DROPBEAR_DIR)/.configured
        $(MAKE) $(TARGET_CONFIGURE_OPTS) LD=$(TARGET_CC) \
                PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" \
                MULTI=1 SCPPROGRESS=1 -C $(DROPBEAR_DIR)

$(TARGET_DIR)/$(DROPBEAR_TARGET_BINARY): $(DROPBEAR_DIR)/$(DROPBEAR_BINARY)
        install -d -m 755 $(TARGET_DIR)/usr/sbin
        install -d -m 755 $(TARGET_DIR)/usr/bin
        install -m 755 $(DROPBEAR_DIR)/$(DROPBEAR_BINARY) \
                $(TARGET_DIR)/$(DROPBEAR_TARGET_BINARY)
        $(STRIP) $(TARGET_DIR)/$(DROPBEAR_TARGET_BINARY)
        ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/scp
        ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/ssh
        ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/dbclient
        ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/dropbearkey
        ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/dropbearconvert
        cp $(DROPBEAR_DIR)/S50dropbear $(TARGET_DIR)/etc/init.d/
        chmod a+x $(TARGET_DIR)/etc/init.d/S50dropbear

dropbear: zlib $(TARGET_DIR)/$(DROPBEAR_TARGET_BINARY)

dropbear-clean:
        $(MAKE) DESTDIR=$(TARGET_DIR) $(TARGET_CONFIGURE_OPTS) \
                LD=$(TARGET_CC) -C $(DROPBEAR_DIR) uninstall
        -$(MAKE) -C $(DROPBEAR_DIR) clean

dropbear-dirclean:
        rm -rf $(DROPBEAR_DIR)

#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(strip $(BR2_PACKAGE_DROPBEAR)),y)
TARGETS+=dropbear
endif

All of the package makefile fragments look like this one.  When I type in "make dropbear" it does these things, in order:

download source
untar source
patch source
configure dropbear
compile and link dropbear
install dropbear into $(TARGET_DIR)

Makefiles work on dependencies.  For instance, if the source is already downloaded it will not download it again.  If the source is already untarred it will not do that again.  If the source is already configured it will not do that again.  Etc., etc. etc.  Notice that "make -C" will change the directory before running "make".  This means that dropbear's own makefile is also used.  It is not included with the build system makefiles.  It remains separate.  You just need to make sure it has all the information it needs when it's invoked.   For dropbear, and a lot of other programs, this is all taken care of by the "configure" script.  You can see the options passed to dropbear's configure script above.

Of course, you can also do all this manually without the benefit of an overall encompassing buildroot tree.  Try it.  Run "configure" manually in the dropbear source code directory.  Subsitute these things:

$(CFLAGS) = "-O2"
$(GNU_TARGET_NAME) = mipsel-linux
$(GNU_HOST_NAME) ... leave this one out.  configure should be able to figure out the host.  I have it set to something for consistency but I don't remember what it is right now.  Something like i686-pc-linux-gnu.  It should not matter.

$(TARGET_DIR) is set in the main makefile.  So are many other variables that are common to everything you might build.  Here are some of them (without the makefile variable decoration): DL_DIR, TARGET_CONFIGURE_OPTS, TARGET_CFLAGS, GNU_TARGET_NAME, GNU_HOST_NAME, TARGET_CC.

You might need these too smile ...

Code::

PATH=/root/buildroot/staging_dir/bin:/root/buildroot/toolchain_build_mipsel/bin:/bin:/sbin:/usr/bin:/usr/sbin
AR=/root/buildroot/staging_dir/bin/mipsel-linux-ar
AS=/root/buildroot/staging_dir/bin/mipsel-linux-as
LD=/root/buildroot/staging_dir/bin/mipsel-linux-ld
NM=/root/buildroot/staging_dir/bin/mipsel-linux-nm
CC=/root/buildroot/staging_dir/bin/mipsel-linux-gcc
GCC=/root/buildroot/staging_dir/bin/mipsel-linux-gcc
CXX=/root/buildroot/staging_dir/bin/mipsel-linux-g++
CPP=/root/buildroot/staging_dir/bin/mipsel-linux-cpp
RANLIB=/root/buildroot/staging_dir/bin/mipsel-linux-ranlib
STRIP=/root/buildroot/staging_dir/bin/mipsel-linux-strip
OBJCOPY=/root/buildroot/staging_dir/bin/mipsel-linux-objcopy

Not every package needs all those variables but by setting them up as one variable, TARGET_CONFIGURE_OPTS, you only have to set it once and then you can forget about it.  If the package needs any of them they are there for it.  The most important ones in there are PATH and GCC.  Change all of the directory paths to whatever you have on your system, like /export/tools/..... or whatever you use.

Last edited by HH (2006-07-13 00:38:45)

Offline

 

#8 2006-07-13 00:56:42

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: New packages--HOW?

parcival wrote:

checking whether the C compiler works... configure: error: cannot run C compiled programs.

This was discussed previously I think.  I forget what the resolution was.

Offline

 

#9 2007-05-05 15:56:09

edmian
New member
Argentina
Registered: 2006-08-01
Last visit: 2009-05-28
Posts: 3

Re: New packages--HOW?

Hello HH,
           Im so interested in your nvram port, I will be thankful  if you post the source code, or send me it by email to edumail@gmail.com

Cheers.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB