Sie sind auf Seite 1von 36

Software and development environment

For many contemporary microprocessor applications software development represents the bulk of the engineering effort

M07CDE Microprocessor Applications

Development approach
Hardware manufacturers provide reference designs For Broadcom 802.11 devices this includes fully functional software based on Linux or VxWorks Equipment manufacturers take the reference design software and brand, modify or improve it for their own product Developing from scratch is generally not feasible

M07CDE Microprocessor Applications

WRT54GL GPL Software


The reason we are using the WRT54GL is that it has a Linux based reference design that has been adapted by Linksys Under the GPL source code must be made publicly available This is excellent since we can work with the real Linksys production code and see exactly how the software development environment works VxWorks system is similar but closed
M07CDE Microprocessor Applications 3

This session
Will approach the application software via an extended demonstration You will see all the stages involved in installing the development environment, building the software from source and downloading an image to the WRT54GL At key points we will break-off to discuss details of what is involved The laboratory sessions will give an opportunity to try this out for yourself
M07CDE Microprocessor Applications 4

Cross-platform development

DEVELOPMENT X86 2G RAM 200G HD LINUX PC

IMAGE

TARGET MIPS32 16M RAM 4M FLASH

M07CDE Microprocessor Applications

Development Machine
Linux distribution suitable for software development Native installation on hard disk (best) Other options
Run under windows in virtual machine Run from live CD distribution Run Linux from memory stick These approaches will drop performance
M07CDE Microprocessor Applications 6

Linux installation demo


Select BT2 / Slax live CD based distribution Partition hard drive (need Linux main and swap partitions in addition to windows for dual-boot) Format Linux main partition Boot from Linux live CD Install to hard disk partition Configure boot utility for dual-boot
M07CDE Microprocessor Applications 7

WARNING!
Editing disk partitions and installing dualboot operating systems always carries an element of risk This is especially true for inexperienced developers If you are not confident in your abilities practice on a non-critical machine first Always back-up critical data in advance
M07CDE Microprocessor Applications 8

Installation documentation
A useful tutorial on the installation of BT2 is provided in your resource pack Ref: BackTrack Development Team (2005) BackTrack Hard Drive Installation [on-line] available from remote-exploit.org There is one correction to this document, BackTrack installer source should be / not /boot Hard drive partitions used will also vary with development machine configuration
M07CDE Microprocessor Applications 9

BackTrack install underway

M07CDE Microprocessor Applications

10

Linux familiarisation
Once you have the Linux development machine operational it is necessary to become familiar with essential operations Using the file manager (Konqueror) Running commands in a console window (Terminal) Editing files with a suitable editor (eg KWrite)
M07CDE Microprocessor Applications 11

GPL Source
This can be downloaded from www.linksys.com The version used here is WRT54GL_US_v4.30.12.tgz Also provided on resources CD Copy this file to your home directory and unpack using tar tar xvvfz <filename> A file manager may do this for you in a window

M07CDE Microprocessor Applications

12

Surveying the build tree


The resulting set of files is generally referred to as the build tree or build root Its worth taking some time to browse the build tree to see what you have Note that the distribution is very large >600 MB unpacked

M07CDE Microprocessor Applications

13

Notable build tree contents


The Linux kernel source Various Linux packages that provide the functionality for the wireless router in source form, eg httpd the web server deamon for web configuration interface Auxiliary tools for processing firmware images, eg addpattern The cross-platform toolchains hndtoolsmipsel-linux and hndtools-mipsel-uClibc
M07CDE Microprocessor Applications 14

Router source in build tree

M07CDE Microprocessor Applications

15

Auxiliary image manipulation tools

M07CDE Microprocessor Applications

16

Toolchains
For cross-platform development the native x86 compiler cannot be used An x86 to MIPS32 cross compiler is needed Two of these are supplied with the distribution, one for the Linux kernel and the other for the wireless router application packages The toolchains need correct installation before the router firmware can be built

M07CDE Microprocessor Applications

17

Toolchain installation
Copy /tools/brcm to /opt/brcm This is necessary since parts of the build are looking for tools in this location Ensure both toolchains and the auxiliary binary tools are in the path before starting a build This was done by editing the make_all.sh script in the source installation tree
M07CDE Microprocessor Applications 18

Cross-compile tool chain

M07CDE Microprocessor Applications

19

Editing make_all.sh

M07CDE Microprocessor Applications

20

Linux build environment


Linux software development is a complex subject but there are 3 critical aspects to understand The use of the gcc compiler and its options to set up include files and libraries The make system for controlled compilation of source packages The configuration system that allows control of exactly how the software is built
M07CDE Microprocessor Applications 21

Trying a build
At this stage you should be ready to build Simply go to the top level installation directory of the build tree and run the make script ./make.sh Watch the console output as many source packages are compiled and the firmware image is built
M07CDE Microprocessor Applications 22

Result of a successful build : code.bin

M07CDE Microprocessor Applications

23

GCC
gcc, the gnu c compiler is employed for cross compilation It must be pre-configured to generate MIPS32 output and requires suitable libraries for standard functions For any serious software modifications a good competence working in the C language in a Linux environment is essential
M07CDE Microprocessor Applications 24

Make
The Linux make utility is used to control conditional compilation of the source packages In general every source package has its own make file which is called by higher level make files until the entire application can be built with one call The details of make are complex and require significant study and experience to master all the intricate details
M07CDE Microprocessor Applications 25

Makefile extract building the kernel


all: clean_target $(obj-y) $(LINUXDIR)/.config # Also build kernel # first make dep $(MAKE) -C $(LINUXDIR) dep if ! grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \ $(MAKE) -C $(LINUXDIR) zImage ; \ fi if grep -q "CONFIG_MODULES=y" $(LINUXDIR)/.config ; then \ $(MAKE) -C $(LINUXDIR) modules ; \ fi
M07CDE Microprocessor Applications 26

Configuring
Kernel developers employ the Linux configuration system to specify exactly what kernel modules and features are included in a particular build Here the approach is extend to the packages employed within the wireless router application The configurator can be run by executing make menuconfig in the /release/src/router directory

M07CDE Microprocessor Applications

27

.config files
The results from the menu configure utility are stored in .config files which are then included into the make files during the build You may need to set your file manager to Show hidden files before you can see the .configs In some systems a number of .configs will be stored for different target systems and swapped to control the build

M07CDE Microprocessor Applications

28

Configuring the kernel

M07CDE Microprocessor Applications

29

Configuring the router

M07CDE Microprocessor Applications

30

Sample .config output


# # Automatically generated make config: don't edit # CONFIG_NAT=y # # Base Features # CONFIG_RC=y CONFIG_NVRAM=y CONFIG_SHARED=y CONFIG_LIBBCM=y CONFIG_BUSYBOX=y CONFIG_BUSYBOX_CONFIG=router CONFIG_WLCONF=y
M07CDE Microprocessor Applications 31

Source detail example


With such a large software system it is not realistic to attempt to understand all the details of the source That would take many months of study! Instead to give confidence that the build is creating the correct firmware imaged lets focus on the web interface feature The files for this are stored in the release/src/router/www directory
M07CDE Microprocessor Applications 32

Web interface asp pages

M07CDE Microprocessor Applications

33

Template for web index page

M07CDE Microprocessor Applications

34

Exercise
Gain familiarity with the build environment by browsing around the directory tree Make a few changes in configuration and source files (cosmetic changes suggested) Re-build the system and confirm that you produce a final firmware image Please do not install trial images on a real router as it is quite a big job to recover them from a bad image
M07CDE Microprocessor Applications 35

Further issues
Working at the command line is a little archaic an IDE front end can be used to the software development and build process Eclipse is one of the best known examples of this under Linux Version control features will often also be involved Others ?
M07CDE Microprocessor Applications 36

Das könnte Ihnen auch gefallen