Why use a CDK when I can already easily copy scripts, binaries and configuration files directly to the console server?
The custom development kit (CDK) allows changes to be made to the software in console server firmware image. The CDK is freely available to all users and using it 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. The # /bin/config --set= tools will update the configuration files in /etc/config which are read/write whereas with the CDK you can change the files in /etc which 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.
Updated (April 2016) CDK information can be found in the CDK User Guide
How do I use the CDK to build custom firmware?
- Download a copy of the CDK for the particular console server you are working with from http://ftp.opengear.com/download/cdk/. The CDK will be a gzipped tarball. Extract it to a local directory and cd into it.
- 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 - 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.
- 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".
- 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 - 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.
Tips for using the CDK
- 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. - Using the CDK does require you to have Linux kernal skills and it is important to remember that Opengear does not provide free technical support for you while using the CDK to generate custom images. (Nor can we provide support for systems modified using the CDK so the changes you make do become your responsibility). However we are keen to ensure the CDK is a usefull tool, so your input on improvements needed to documentation etc is welcome.
- Of course the simple alternative to using the CDK is to use custom scripting. Scripts can be written so they run whenever the console boots, or each time a particular alert triggers, or whenever any particular configurator runs (referfaq 255)
Other questions
With what version of gcc is the official firmware built? What arch does the Opengear CM4116 console server run on? (is it a pure ARM?) What toolchain do you use internally to produce your official firmware builds?
We use the uClinux distribution as a base, and this includes su as part of busybox. It does not include sudo. With the CDK and the toolchain it should be fairly easy for you to generate yourself. The toolchain we use internally is GCC version 3.4.4. You need the version compiled on 2006-12-13. The CPU in the CM4116 (and all other Opengear console servers) is a Micrel KSZ8695P which may also show up as a Kendin CPU. A quick google showed a few hits on people using this chip with Emdebian.
Comments
0 comments
Article is closed for comments.