aboutsummaryrefslogtreecommitdiffstats
BranchCommit messageAuthorAge
mastergeneric: add mac-address property for NVMEM mac addressesDavid Bauer3 years
less-old-masterkernel: make kmod-ata-core selected by dependent modulesSungbo Eo5 years
upstreamkernel: make kmod-ata-core selected by dependent modulesSungbo Eo5 years
openwrt-19.07rssileds: add dependencies based on LDFLAGSAdrian Schmutzler5 years
openwrt-18.06ar71xx: ew-dorin, fix the trigger level for WPS buttonCatrinel Catrinescu5 years
lede-17.01mac80211: brcmfmac: fix PCIe reset crash and WARNINGRafał Miłecki5 years
old-masterramips: add support for HiWiFi HC5861BDeng Qingfang6 years
chaos_calmerCC: kernel: update to 3.18.45, refresh targetsZoltan HERPAI8 years
barrier_breakerBB: openssl: update to 1.0.2f (fixes CVE-2016-0701, CVE-2015-3197)Jo-Philipp Wich9 years
attitude_adjustmentAA: mac80211: merge ath9k fixes from bbFelix Fietkau10 years
 
TagDownloadAuthorAge
v22.03.6upstream-22.03.6.tar.gz  upstream-22.03.6.tar.bz2  upstream-22.03.6.zip  Hauke Mehrtens13 months
v23.05.2upstream-23.05.2.tar.gz  upstream-23.05.2.tar.bz2  upstream-23.05.2.zip  Hauke Mehrtens14 months
v23.05.1upstream-23.05.1.tar.gz  upstream-23.05.1.tar.bz2  upstream-23.05.1.zip  Hauke Mehrtens14 months
v23.05.0upstream-23.05.0.tar.gz  upstream-23.05.0.tar.bz2  upstream-23.05.0.zip  Hauke Mehrtens15 months
v23.05.0-rc4upstream-23.05.0-rc4.tar.gz  upstream-23.05.0-rc4.tar.bz2  upstream-23.05.0-rc4.zip  Hauke Mehrtens16 months
v23.05.0-rc3upstream-23.05.0-rc3.tar.gz  upstream-23.05.0-rc3.tar.bz2  upstream-23.05.0-rc3.zip  Hauke Mehrtens17 months
v23.05.0-rc2upstream-23.05.0-rc2.tar.gz  upstream-23.05.0-rc2.tar.bz2  upstream-23.05.0-rc2.zip  Hauke Mehrtens19 months
v23.05.0-rc1upstream-23.05.0-rc1.tar.gz  upstream-23.05.0-rc1.tar.bz2  upstream-23.05.0-rc1.zip  Hauke Mehrtens19 months
v21.02.7upstream-21.02.7.tar.gz  upstream-21.02.7.tar.bz2  upstream-21.02.7.zip  Hauke Mehrtens21 months
v22.03.5upstream-22.03.5.tar.gz  upstream-22.03.5.tar.bz2  upstream-22.03.5.zip  Hauke Mehrtens21 months
v21.02.6upstream-21.02.6.tar.gz  upstream-21.02.6.tar.bz2  upstream-21.02.6.zip  Daniel Golle21 months
v22.03.4upstream-22.03.4.tar.gz  upstream-22.03.4.tar.bz2  upstream-22.03.4.zip  Daniel Golle21 months
v22.03.3upstream-22.03.3.tar.gz  upstream-22.03.3.tar.bz2  upstream-22.03.3.zip  Hauke Mehrtens2 years
v21.02.5upstream-21.02.5.tar.gz  upstream-21.02.5.tar.bz2  upstream-21.02.5.zip  Hauke Mehrtens2 years
v22.03.2upstream-22.03.2.tar.gz  upstream-22.03.2.tar.bz2  upstream-22.03.2.zip  Hauke Mehrtens2 years
v22.03.1upstream-22.03.1.tar.gz  upstream-22.03.1.tar.bz2  upstream-22.03.1.zip  Hauke Mehrtens2 years
v21.02.4upstream-21.02.4.tar.gz  upstream-21.02.4.tar.bz2  upstream-21.02.4.zip  Hauke Mehrtens2 years
v22.03.0upstream-22.03.0.tar.gz  upstream-22.03.0.tar.bz2  upstream-22.03.0.zip  Hauke Mehrtens2 years
v22.03.0-rc6upstream-22.03.0-rc6.tar.gz  upstream-22.03.0-rc6.tar.bz2  upstream-22.03.0-rc6.zip  Hauke Mehrtens2 years
v22.03.0-rc5upstream-22.03.0-rc5.tar.gz  upstream-22.03.0-rc5.tar.bz2  upstream-22.03.0-rc5.zip  Hauke Mehrtens3 years
v22.03.0-rc4upstream-22.03.0-rc4.tar.gz  upstream-22.03.0-rc4.tar.bz2  upstream-22.03.0-rc4.zip  Hauke Mehrtens3 years
v22.03.0-rc3upstream-22.03.0-rc3.tar.gz  upstream-22.03.0-rc3.tar.bz2  upstream-22.03.0-rc3.zip  Hauke Mehrtens3 years
v22.03.0-rc2upstream-22.03.0-rc2.tar.gz  upstream-22.03.0-rc2.tar.bz2  upstream-22.03.0-rc2.zip  Paul Spooren3 years
v22.03.0-rc1upstream-22.03.0-rc1.tar.gz  upstream-22.03.0-rc1.tar.bz2  upstream-22.03.0-rc1.zip  Hauke Mehrtens3 years
v21.02.3upstream-21.02.3.tar.gz  upstream-21.02.3.tar.bz2  upstream-21.02.3.zip  Hauke Mehrtens3 years
v19.07.10upstream-19.07.10.tar.gz  upstream-19.07.10.tar.bz2  upstream-19.07.10.zip  Hauke Mehrtens3 years
v19.07.9upstream-19.07.9.tar.gz  upstream-19.07.9.tar.bz2  upstream-19.07.9.zip  Hauke Mehrtens3 years
v21.02.2upstream-21.02.2.tar.gz  upstream-21.02.2.tar.bz2  upstream-21.02.2.zip  Hauke Mehrtens3 years
v21.02.1upstream-21.02.1.tar.gz  upstream-21.02.1.tar.bz2  upstream-21.02.1.zip  Hauke Mehrtens3 years
v21.02.0upstream-21.02.0.tar.gz  upstream-21.02.0.tar.bz2  upstream-21.02.0.zip  Hauke Mehrtens3 years
v21.02.0-rc4upstream-21.02.0-rc4.tar.gz  upstream-21.02.0-rc4.tar.bz2  upstream-21.02.0-rc4.zip  Hauke Mehrtenspre { line-height: 125%; margin: 0; } td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #ffffff; } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
Linux is now one of the most widespread operating system for embedded devices due
to its openess as well as the wide variety of platforms it can run on. Many
manufacturer actually use it in firmware you can find on many devices: DVB-T 
decoders, routers, print servers, DVD players ... Most of the time the stock 
firmware is not really open to the consumer, even if it uses open source software.

You might be interested in running a Linux based firmware for your router for
various reasons: extending the use of a network protocol (such as IPv6), having
new features, new piece of software inside, or for security reasons. A fully 
open-source firmware is de-facto needed for such applications, since you want to
be free to use this or that version of a particular reason, be able to correct a
particular bug. Few manufacturers do ship their routers with a Sample Development Kit,
that would allow you to create your own and custom firmware and most of the time,
when they do, you will most likely not be able to complete the firmware creation process.

This is one of the reasons why OpenWrt and other firmware exists: providing a 
version independent, and tools independent firmware, that can be run on various 
platforms, known to be running Linux originally.

\subsection{Which Operating System does this device run?}

There is a lot of methods to ensure your device is running Linux. Some of them do
need your router to be unscrewed and open, some can be done by probing the device
using its external network interface  upstream-18.06.7.zip  
Jo-Philipp Wich5 years
v19.07.1upstream-19.07.1.tar.gz  upstream-19.07.1.tar.bz2  upstream-19.07.1.zip  Jo-Philipp Wich5 years
v19.07.0upstream-19.07.0.tar.gz  upstream-19.07.0.tar.bz2  upstream-19.07.0.zip  Hauke Mehrtens5 years
v18.06.6upstream-18.06.6.tar.bz2  upstream-18.06.6.zip  Hauke Mehrtens5 years
v19.07.0-rc2upstream-19.07.0-rc2.tar.gz  upstream-19.07.0-rc2.tar.bz2  upstream-19.07.0-rc2.zip  Hauke Mehrtens5 years
v18.06.5upstream-18.06.5.tar.gz  upstream-18.06.5.tar.bz2  upstream-18.06.5.zip  Jo-Philipp Wich5 years
v19.07.0-rc1upstream-19.07.0-rc1.tar.gz  upstream-19.07.0-rc1.tar.bz2  upstream-19.07.0-rc1.zip  Jo-Philipp Wich5 years
v18.06.4upstream-18.06.4.tar.gz  upstream-18.06.4.tar.bz2  upstream-18.06.4.zip  Jo-Philipp Wich6 years
v18.06.3upstream-18.06.3.tar.gz  upstream-18.06.3.tar.bz2  upstream-18.06.3.zip  Jo-Philipp Wich6 years
v17.01.7upstream-17.01.7.tar.gz  upstream-17.01.7.tar.bz2  upstream-17.01.7.zip  Jo-Philipp Wich6 years
v18.06.2upstream-18.06.2.tar.gz  upstream-18.06.2.tar.bz2  upstream-18.06.2.zip  Jo-Philipp Wich6 years
v17.01.6upstream-17.01.6.tar.gz  upstream-17.01.6.tar.bz2  upstream-17.01.6.zip  Hauke Mehrtens6 years
v18.06.1upstream-18.06.1.tar.gz  upstream-18.06.1.tar.bz2  upstream-18.06.1.zip  Jo-Philipp Wich6 years
v18.06.0upstream-18.06.0.tar.gz  upstream-18.06.0.tar.bz2  upstream-18.06.0.zip  Jo-Philipp Wich6 years
v17.01.5upstream-17.01.5.tar.gz  upstream-17.01.5.tar.bz2  upstream-17.01.5.zip  Hauke Mehrtens7 years
v18.06.0-rc2upstream-18.06.0-rc2.tar.gz  upstream-18.06.0-rc2.tar.bz2  upstream-18.06.0-rc2.zip  Jo-Philipp Wich7 years
v18.06.0-rc1upstream-18.06.0-rc1.tar.gz  upstream-18.06.0-rc1.tar.bz2  upstream-18.06.0-rc1.zip  Jo-Philipp Wich7 years
v17.01.4upstream-17.01.4.tar.gz  upstream-17.01.4.tar.bz2  upstream-17.01.4.zip  Stijn Tintel7 years
v17.01.3upstream-17.01.3.tar.gz  upstream-17.01.3.tar.bz2  upstream-17.01.3.zip  Stijn Tintel7 years
v17.01.2upstream-17.01.2.tar.gz  upstream-17.01.2.tar.bz2  upstream-17.01.2.zip  Alexander Couzens8 years
rebootupstream-reboot.tar.gz  upstream-reboot.tar.bz2  upstream-reboot.zip  Jo-Philipp Wich9 years
v15.05.1upstream-15.05.1.tar.gz  upstream-15.05.1.tar.bz2  upstream-15.05.1.zip  Felix Fietkau9 years
v15.05upstream-15.05.tar.gz  upstream-15.05.tar.bz2  upstream-15.05.zip  Felix Fietkau9 years
v14.07upstream-14.07.tar.gz  upstream-14.07.tar.bz2  upstream-14.07.zip  Felix Fietkau10 years
v12.09upstream-12.09.tar.gz  upstream-12.09.tar.bz2  upstream-12.09.zip  Florian Fainelli12 years
trunkupstream-trunk.tar.gz  upstream-trunk.tar.bz2  upstream-trunk.zip  OpenWrt Developers21 years
has been added to make the binary driver work with the Linux kernel. This code might not be useful if you plan on writing drivers from scratch for this hardware. \subsubsection{Using the device bootloader} The bootloader is the first program that is started right after your device has been powered on. This program, can be more or less sophisticated, some do let you do network booting, USB mass storage booting ... The bootloader is device and architecture specific, some bootloaders were designed to be universal such as RedBoot or U-Boot so that you can meet those loaders on totally different platforms and expect them to behave the same way. If your device runs a proprietary operating system, you are very likely to deal with a proprietary boot loader as well. This may not always be a limitation, some proprietary bootloaders can even have source code available (i.e : Broadcom CFE). According to the bootloader features, hacking on the device will be more or less easier. It is very probable that the bootloader, even exotic and rare, has a documentation somewhere over the Internet. In order to know what will be possible with your bootloader and the way you are going to hack the device, look over the following features : \begin{itemize} \item does the bootloader allow net booting via bootp/DHCP/NFS or tftp \item does the bootloader accept loading ELF binaries ? \item does the bootloader have a kernel/firmware size limitation ? \item does the bootloader expect a firmware format to be loaded with ? \item are the loaded files executed from RAM or flash ? \end{itemize} Net booting is something very convenient, because you will only have to set up network booting servers on your development station, and keep the original firmware on the device till you are sure you can replace it. This also prevents your device from being flashed, and potentially bricked every time you want to test a modification on the kernel/filesystem. If your device needs to be flashed every time you load a firmware, the bootlader might only accept a specific firmware format to be loaded, so that you will have to understand the firmware format as well. \subsubsection{Making binary drivers work} As we have explained before, manufacturers do release binary drivers in their GPL tarball. When those drivers are statically linked into the kernel, they become GPL as well, fortunately or unfortunately, most of the drivers are not statically linked. This anyway lets you a chance to dynamically link the driver with the current kernel version, and try to make them work together. This is one of the most tricky and grey part of the fully open source projects. Some drivers require few modifications to be working with your custom kernel, because they worked with an earlier kernel, and few modifications have been made to the kernel in-between those versions. This is for instance the case with the binary driver of the Broadcom BCM43xx Wireless Chipsets, where only few differences were made to the network interface structures. Some general principles can be applied no matter which kernel version is used in order to make binary drivers work with your custom kernel: \begin{itemize} \item turn on kernel debugging features such as: \begin{itemize} \item CONFIG\_DEBUG\_KERNEL \item CONFIG\_DETECT\_SOFTLOCKUP \item CONFIG\_DEBUG\_KOBJECT \item CONFIG\_KALLSYMS \item CONFIG\_KALLSYMS\_ALL \end{itemize} \item link binary drivers when possible to the current kernel version \item try to load those binary drivers \item catch the lockups and understand them \end{itemize} Most of the time, loading binary drivers will fail, and generate a kernel oops. You can know the last symbol the binary drivers attempted to use, and see in the kernel headers file, if you do not have to move some structures field before or after that symbol in order to keep compatibily with both the binary driver and the stock kernel drivers. \subsubsection{Understanding the firmware format} You might want to understand the firmware format, even if you are not yet capable of running a custom firmware on your device, because this is sometimes a blocking part of the flashing process. A firmware format is most of the time composed of the following fields: \begin{itemize} \item header, containing a firmware version and additional fields: Vendor, Hardware version ... \item CRC32 checksum on either the whole file or just part of it \item Binary and/or compressed kernel image \item Binary and/or compressed root filesystem image \item potential garbage \end{itemize} Once you have figured out how the firmware format is partitioned, you will have to write your own tool that produces valid firmware binaries. One thing to be very careful here is the endianness of either the machine that produces the binary firmware and the device that will be flashed using this binary firmware. \subsubsection{Writing a flash map driver} The flash map driver has an important role in making your custom firmware work because it is responsible of mapping the correct flash regions and associated rights to specific parts of the system such as: bootloader, kernel, user filesystem. Writing your own flash map driver is not really a hard task once you know how your firmware image and flash is structured. You will find below a commented example that covers the case of the device where the bootloader can pass to the kernel its partition plan. First of all, you need to make your flash map driver be visible in the kernel configuration options, this can be done by editing the file \ \textbf{linux/drivers/mtd/maps/Kconfig}: \begin{verbatim} config MTD_DEVICE_FLASH tristate "Device Flash device" depends on ARCHITECTURE && DEVICE help Flash memory access on DEVICE boards. Currently only works with Bootloader Foo and Bootloader Bar. \end{verbatim} Then add your source file to the \textbf{linux/drivers/mtd/maps/Makefile}, so that it will be compiled along with the kernel. \begin{verbatim} obj-\$(CONFIG_MTD_DEVICE_FLASH) += device-flash.o \end{verbatim} You can then write the kernel driver itself, by creating a \textbf{linux/drivers/mtd/maps/device-flash.c} C source file. \begin{verbatim} // Includes that are required for the flash map driver to know of the prototypes: #include <asm/io.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/mtd/map.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/vmalloc.h> // Put some flash map definitions here: #define WINDOW_ADDR 0x1FC00000 /* Real address of the flash */ #define WINDOW_SIZE 0x400000 /* Size of flash */ #define BUSWIDTH 2 /* Buswidth */ static void __exit device_mtd_cleanup(void); static struct mtd_info *device_mtd_info; static struct map_info devicd_map = { .name = "device", .size = WINDOW_SIZE, .bankwidth = BUSWIDTH, .phys = WINDOW_ADDR, }; static int __init device_mtd_init(void) { // Display that we found a flash map device printk("device: 0x\%08x at 0x\%08x\n", WINDOW_SIZE, WINDOW_ADDR); // Remap the device address to a kernel address device_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); // If impossible to remap, exit with the EIO error if (!device_map.virt) { printk("device: Failed to ioremap\n"); return -EIO; } // Initialize the device map simple_map_init(&device_map); /* MTD informations are closely linked to the flash map device you might also use "jedec_probe" "amd_probe" or "intel_probe" */ device_mtd_info = do_map_probe("cfi_probe", &device_map); if (device_mtd_info) { device_mtd_info->owner = THIS_MODULE; int parsed_nr_parts = 0; // We try here to use the partition schema provided by the bootloader specific code if (parsed_nr_parts == 0) { int ret = parse_bootloader_partitions(device_mtd_info, &parsed_parts, 0); if (ret > 0) { part_type = "BootLoader"; parsed_nr_parts = ret; } } add_mtd_partitions(devicd_mtd_info, parsed_parts, parsed_nr_parts); return 0; } iounmap(device_map.virt); return -ENXIO; } // This function will make the driver clean up the MTD device mapping static void __exit device_mtd_cleanup(void) { // If we found a MTD device before if (device_mtd_info) { // Delete every partitions del_mtd_partitions(device_mtd_info); // Delete the associated map map_destroy(device_mtd_info); } // If the virtual address is already in use if (device_map.virt) { // Unmap the physical address to a kernel space address iounmap(device_map.virt); // Reset the structure field device_map.virt = 0; } } // Macros that indicate which function is called on loading/unloading the module module_init(device_mtd_init); module_exit(device_mtd_cleanup); // Macros defining license and author, parameters can be defined here too. MODULE_LICENSE("GPL"); MODULE_AUTHOR("Me, myself and I <memyselfandi@domain.tld"); \end{verbatim} \subsection{Adding your target in OpenWrt} Once you spotted the key changes that were made to the Linux kernel to support your target, you will want to create a target in OpenWrt for your hardware. This can be useful to benefit from the toolchain that OpenWrt builds as well as the resulting user-space and kernel configuration options. Provided that your target is already known to OpenWrt, it will be as simple as creating a \texttt{target/linux/board} directory where you will be creating the following directories and files. Here for example, is a \texttt{target/linux/board/Makefile}: \begin{Verbatim}[frame=single,numbers=left] # # Copyright (C) 2009 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # include $(TOPDIR)/rules.mk ARCH:=mips BOARD:=board BOARDNAME:=Eval board FEATURES:=squashfs jffs2 pci usb LINUX_VERSION:=2.6.27.10 include $(INCLUDE_DIR)/target.mk DEFAULT_PACKAGES += hostapd-mini define Target/Description Build firmware images for Evaluation board endef $(eval $(call BuildTarget)) \end{Verbatim} \begin{itemize} \item \texttt{ARCH} \\ The name of the architecture known by Linux and uClibc \item \texttt{BOARD} \\ The name of your board that will be used as a package and build directory identifier \item \texttt{BOARDNAME} \\ Expanded name that will appear in menuconfig \item \texttt{FEATURES} \\ Set of features to build filesystem images, USB, PCI, VIDEO kernel support \item \texttt{LINUX\_VERSION} \\ Linux kernel version to use for this target \item \texttt{DEFAULT\_PACKAGES} \\ Set of packages to be built by default \end{itemize} A partial kernel configuration which is either named \texttt{config-default} or which matches the kernel version \texttt{config-2.6.x} should be present in \texttt{target/linux/board/}. This kernel configuration will only contain the relevant symbols to support your target and can be changed using \texttt{make kernel\_menuconfig}. To patch the kernel sources with the patches required to support your hardware, you will have to drop them in \texttt{patches} or in \texttt{patches-2.6.x} if there are specific changes between kernel versions. Additionnaly, if you want to avoid creating a patch that will create files, you can put those files into \texttt{files} or \texttt{files-2.6.x} with the same directory structure that the kernel uses (e.g: drivers/mtd/maps, arch/mips ..). The build system will require you to create a \texttt{target/linux/board/image/Makefile}: \begin{Verbatim}[frame=single,numbers=left] # # Copyright (C) 2009 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/image.mk define Image/BuildKernel cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.elf gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7 dd if=$(KDIR)/vmlinux.bin.l7 of=$(BIN_DIR)/openwrt-$(BOARD)-vmlinux.lzma bs=65536 conv=sync dd if=$(KDIR)/vmlinux.bin.gz of=$(BIN_DIR)/openwrt-$(BOARD)-vmlinux.gz bs=65536 conv=sync endef define Image/Build/squashfs $(call prepare_generic_squashfs,$(KDIR)/root.squashfs) endef define Image/Build $(call Image/Build/$(1)) dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/openwrt-$(BOARD)-root.$(1) bs=128k conv=sync -$(STAGING_DIR_HOST)/bin/mkfwimage \ -B XS2 -v XS2.ar2316.OpenWrt \ -k $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.lzma \ -r $(BIN_DIR)/openwrt-$(BOARD)-root.$(1) \ -o $(BIN_DIR)/openwrt-$(BOARD)-ubnt2-$(1).bin endef $(eval $(call BuildImage)) \end{Verbatim} \begin{itemize} \item \texttt{Image/BuildKernel} \\ This template defines changes to be made to the ELF kernel file \item \texttt{Image/Build} \\ This template defines the final changes to apply to the rootfs and kernel, either combined or separated firmware creation tools can be called here as well. \end{itemize}