|
Why use a CDK when I can already easily copy scripts, binaries and configuration files directly to the console server?
Opengear provides a custom development kit (CDK) which allows changes to be made to the software in console server firmware image, so using the CDK you can:
- generate a firmware image without certain programs, such as telnet, which may be banned by company policy
- generate an image with new programs, such as custom Nagios plugin binaries or company specific binary utilities
- generate an image with custom defaults e.g. it may be required that the console server be configured to have a specific default serial port profile which is reverted to even in event of a factory reset
- place configuration files into the firmware image, which cannot then be modified e.g. # /bin/config –-set= tools update the configuration files in /etc/config which are read/write, whereas the files in /etc are read only and cannot be modified
The CDK is essentially a snapshot of the Opengear build process. It is taken after the programs have been compiled and copied to a temporary directory (romfs) just before the compressed filesystems are generated.
How do I use the CDK to build custom firmware?
First, acquire a copy of the Opengear CDK for the particular appliance
you are working with from ftp://ftp.opengear.com/cdk. The CDK will be a gzipped tarball. Extract it to a local directory, and cd into it.
Second, edit the Makefile to add appropriate sections to the "user" and
"clean" sections. An example might be:
user:
# Build a binary
make -C example
# Install it into the file system
make -C progdir romfs
clean:
make -C example clean
Last, execute the "make" command to build new firmware. It will be
placed in the "images" directory as "image.bin".
How do I use the CDK to build custom binaries?
Again firstly acquire a copy of the Opengear CDK for the particular appliance
you are working with. The CDK will be a gzipped tarball. Extract it to
a local directory, and cd into it.
Second, place a copy of your source code in a new directory. For the
purposes of these instructions, we will be working on the program
"myprog" in a directory called "myprogdir".
Third, edit the Makefile to add appropriate sections to the "user" and
"clean" sections. An example might be:
user:
# Build a binary
make -C myprogdir
# Install it into the file system
make -C progdir romfs
clean:
make -C myprogdir clean
Fourth, start a new Makefile in your directory. If you already have a
Makefile, name it makefile. If you already have a makefile, whether or
not you have a Makefile, name it GNUmakefile. An example makefile is below:
include ../opengear.mk
export
CONFOPTS=
all: build/build
$(MAKE) -C build
build/build: makefile
rm -rf build
mkdir build
( \
cd build; \
export CXXFLAGS="$(CXXFLAGS)"; \
export CFLAGS="$(CFLAGS)"; \
export LIBS="$(CXX_LDFLAGS)"; \
ac_cv_func_strnstr=no \
ac_cv_header_openssl_sha_h=yes \
sh ../configure $(CONFIGURE_OPTS) $(CONFOPTS) \
)
touch build/build
clean:
rm -rf build
romfs:
$(ROMFSINST) build/ctorrent /bin/ctorrent
This makefile has three main actions. First, it creates a new directory
called build to carry out the compilation in, configures the
application, and carrys out the actual compilation. Secondly, it uses
the romfs-inst.sh script in tools/ to copy appropriate files to the
final filesystem. Lastly, it includes a "clean" command which simply
removes the build directory.
What tips do you have when using the CDK developing for the Opengear appliance?
- The Opengear Appliances have three different boot modes:
- The first mode is the normal boot sequence where whatever is
programmed into flash is loaded and executed.
- The second mode is called "recovery mode" and is used by holding in
the erase button during boot. In this mode the appliance will attempt
to contact a dhcp server for it's IP information and a file name. It
will then attempt to tftp the given file from the dhcp server, and boot
from this image. This mode is primarily used for rapid prototyping
where you don't want to wait for the full flashing cycle, although it
does have an impact on the amount of available RAM. The erase button is
safe to be held in for the duration of the test.
- The third mode is rarely used, but can be accessed using Ctrl-C
during a recovery boot. This will drop you to the uboot prompt, from
where you can run simple tests on the RAM, erase and program flash, or
make changes to boot arguments. Most of these options are redundant as
if you can get to here, you can probably boot an image and do things
more easily through the Linux environment.
- When flashing new firmware, you may have issues with versions. Using
the -i option will override this check. When flashing from the firmware
a typical command is:
netflash -Fi
- When testing new binaries you can copy them to /tmp, which is
actually a link to /var/tmp. If the partition is too small, you can use
the following command to resize it :
mount -t tmpfs -o remount,size= tmpfs /var
This will reduce the amount of available RAM.
As an alternative, it is possible to use an NFS file share to mount a
directory from your PC.
- Finally it is important to remember that while you can use the CDK freely to generate custom images Opengear does not provide free technical support for this activity, or for systems modified using the CDK (and any changes you make are your responsibility).
|