Adding new device support
If you need to add a new platform, see →add.new.platform
TODO
General Approach
- You already read hw.hacking.first.steps and gathered information about the soldered chips and also about available GNU/Linux drivers for that hardware.
- Read about OpenWrt in general user.advanced, and the toolchain buildroot in particular.
- maybe you should have obtained a (working) firmware for an already supported device according to obtain.firmware.sdk or build
- now retrieve the OpenWrt source code and modify it, to support your new device:
Examples
Device x
Regarding bla from https://forum.openwrt.org/viewtopic.php?pid=123105#p123105:
You have to do three things:
- Add the board definition to
arch/mips/bcm63xx/boards/board_bcm963xx.cfromshared/opensource/boardparms/boardparms.c - Adapt the
imagetag.cto create a different tag (seeshared/opensource/inlude/bcm963xx/bcmTag.hin the GPL tar for the layout) - Finally xor the whole image with '12345678' (the ascii string, not hex).
You can either try these yourself or wait until I get my SPW303V wink
Brcm68xx Platform
For the brcm68xx platform you can follow the following steps:
- Obtain the source and follow the compile procudure with the make menuconfig as last step.
- During menuconfig select the correct target system.
- Next generate the board_bcm963xx.c file for the selected platform with all board parameters execute the following command:
make kernel_menuconfig
- Add the board-id to the ./target/linux/brcm63xx/image/Makefile.
Example
> # Davolink DV2020 $(call Image/Build/CFE,$(1),DV2020,6348)
- 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,
- 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.cwhere 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.shfor 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.shto set a LED which OpenWRT should blink on bootupbase-files/lib/upgrade/platform.shto allow sysupgrade to work on your boardbase-files/etc/uci-defaults/networkto configure default network interface settings, particularly MAC addressesbase-files/etc/uci-defaults/ledsif you have configurable LEDs which should default to a behavior, like a WLAN activity LEDbase-files/etc/hotplug.d/firmware/10-rt2x00-eepromto extract the firmware image for the wireless modulebase-files/lib/preinit/06_set_iface_macto set the MAC addresses of any other interfaces
Example commits:
doc/devel/add.new.device.txt · Last modified: 2012/02/29 09:20 by trickv