Adding new device support

If you need to add a new platform, see →add.new.platform

TODO

General Approach

  1. You already read hw.hacking.first.steps and gathered information about the soldered chips and also about available GNU/Linux drivers for that hardware.
  2. Read about OpenWrt in general user.advanced, and the toolchain buildroot in particular.
  3. maybe you should have obtained a (working) firmware for an already supported device according to obtain.firmware.sdk or build
  4. now retrieve the OpenWrt source code and modify it, to support your new device:

Examples

Brcm63xx Platform

If you have the OEM sourcecode for your bcm63xx specific device, it may be useful some things for later adding the OpenWrt support:

  • Look for your Board Id at shared/opensource/boardparms/boardparms.c
  • Adapt the imagetag.c to create a different tag (see shared/opensource/inlude/bcm963xx/bcmTag.h in the GPL tar for the layout)
  • Finally xor the whole image with '12345678' (the ascii string, not hex).

(from https://forum.openwrt.org/viewtopic.php?pid=123105#p123105)

For creating the OpenWrt firmware your bcm63xx device, you can follow the following steps:

  1. Obtain the source and follow the compile procudure with the make menuconfig as last step.
  2. During menuconfig select the correct target system.
  3. Next generate the board_bcm963xx.c file for the selected platform with all board parameters execute the following command:
    make kernel_menuconfig
  4. Add the board-id to the ./target/linux/brcm63xx/image/Makefile.
    Example
    	# Davolink DV2020	
    	$(call Image/Build/CFE,$(1),DV2020,6348)
  5. add the board-id with the parameters to ./build_dir/linux-brcm63xx/linux-2.6.37.4/arch/mips/bcm63xx/boards/board_bcm963xx.c
    Example
    static struct board_info __initdata board_DV2020 = {
            .name                           = "DV2020",
            .expected_cpu_id                = 0x6348,
    
            .has_uart0                      = 1,
            .has_pci                        = 1,
            .has_ohci0                      = 1,
    
            .has_enet0                      = 1,
            .has_enet1                      = 1,
            .enet0 = {
                    .has_phy                = 1,
                    .use_internal_phy       = 1,
            },	
            .enet1 = {	
                    .force_speed_100        = 1,	
                    .force_duplex_full      = 1,	
            },	
    };	
    :
    :
    :
    	&board_DV2020,
    
  6. Finish the compile instructions according the procedure from the make step.

Ramips Platform

As long as you are adding support for an ramips board with an existing chipset, this is rather straightforward. You need to create a new board definition, which will generate an image file specifically for your device and runs device-specific code. Then you write various board-specific hacks to initialize devices and set the correct default configuration.

Your board identifier will be passed in the following sequence:

 (Image Generator puts it in the kernel command line)
          ↓
 (Kernel command line is executed with BOARD=MY_BOARD)
          ↓
 (Kernel code for ramips finds your board and loads machine-specific code)
          ↓
 (/lib/ramips.sh:ramips_board_name() reads the board name from /proc/cpuinfo)
          ↓
 (Several userspace scripts use ramips_board_name() for board-specific setup)

At a minimum, you need to make the following changes to make a basic build, all under target/linux/ramips/:

  • Add a new machine image in image/Makefile
  • Create a new machine file in arch/mips/ralink/$CHIP/mach-myboard.c where you register:
    • GPIO pins for LEDs and buttons
    • Port layout for the device (vlan configuration)
    • Flash memory configuration
    • Wifi
    • USB
    • Watchdog timer
    • And anything else specific to your board
  • Reference the new machine file in arch/mips/ralink/$CHIP/{Kconfig,Makefile}
  • Reference the new machine name in files/arch/mips/include/asm/mach-ralink/machine.h
  • Add your board to base-files/lib/ramips.sh for userspace scripts to read the board name

Then you'll want to modify some of these files depending on your board's features:

  • base-files/etc/diag.sh to set a LED which OpenWRT should blink on bootup
  • base-files/lib/upgrade/platform.sh to allow sysupgrade to work on your board
  • base-files/etc/uci-defaults/network to configure default network interface settings, particularly MAC addresses
  • base-files/etc/uci-defaults/leds if you have configurable LEDs which should default to a behavior, like a WLAN activity LED
  • base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom to extract the firmware image for the wireless module
  • base-files/lib/preinit/06_set_iface_mac to set the MAC addresses of any other interfaces

Example commits:

Tips

After add a new board, you may should clean the tmp folder first.

 cd trunk
 rm -rf tmp
 make menuconfig 

Back to top

doc/devel/add.new.device.txt · Last modified: 2013/05/22 15:25 by danitool