What should I do if your router is not on the list of supported OpenWRT devices? Of course, make your port. This can be done quite quickly if support for this platform has already been implemented.
In this article I will talk about the process of porting the firmware as a whole and about my experience of porting OpenWRT to ASUS DSL N12U.
First you need to determine how much it will actually do. To do this, you need to know the configuration of your router. There are a lot of options for developments, for example, my router showed all the necessary parameters in the log at boot time and in dmesg. Here you should accurately determine the amounts of RAM, ROM, partition addresses in mtd, and of course, on the basis of which chip the router itself is made.
')
An example of the full log of loading in my case is
here .
I will note the most important lines for us:
M25P128(20 20180000) (16384 Kbytes) mtd .name = raspi, .size = 0x01000000 (16M) .erasesize = 0x00040000 (256K) .numeraseregions = 0 Creating 5 MTD partitions on "raspi": 0x00000000-0x01000000 : "ALL" 0x00000000-0x00040000 : "Bootloader" 0x00040000-0x00080000 : "Config" 0x00080000-0x000c0000 : "Factory" 0x000c0000-0x00800000 : "Kernel"
Here there are addresses of partitions, there is a volume and type of ROM memory. Hooray.
There is also a memory capacity and a specific platform is indicated:
ASIC 3052F (DSL-N12U) (Port5<->None) Total memory: 32 MBytes
Now you need to try to find in the
table of compatible devices the most similar to your router (the main thing is the platform), if there is nothing like this, then this instruction will not help you.
My router showed all the necessary information in dmesg and in the console to the port. But other options and directions of search for this and other useful information are possible. The main ones are the GPL firmware release (if any) and the firmware dump of the router.
We also need to connect to the UART or Serial port of the router, the probability of success of the venture without this connection tends to zero. As USB -> UART, you can use Arduino, but you need to remember that in Arduino the signal level is 5V (and for most similar devices it is 3.3V). And you need to take examples to solve this problem (at least add a resistor to the RX router).
How to detect the Serial port is the topic of a separate article, but usually there is almost any router or device with Linux inside, in my case just Google was enough.
We now turn to build the firmware.
The system should at least have packages installed to build the toolchain:
sudo apt-get install subversion git build-essential
I did a build on Debian 7, but in general there should be no problems at this stage.
Clone repository:
svn co svn://svn.openwrt.org/openwrt/trunk wrt
Run recursive update of firmware and toolchain components:
cd ~/wrt ./scripts/feeds update -a ./scripts/feeds install -a
Putting the toolchain:
make prereq
Next, set up the firmware for the most similar supported router model
make menuconfig
Here we are interested in the fields:
Target System (Ralink RT288x/RT3xxx) ---> Subtarget (RT3x5x/RT5350 based boards) ---> Target Profile (Asus RT-N13U) --->
I chose ASUS RT-N13U as the most similar to my router. In fact, this choice is not very important, since the difference in specific profiles is minimal, and we will correct most of the differences, the main thing is to correctly guess the platform.
More in menuconfig you do not need to change anything.
During the first build, you also need to build the toolchain and utilities once:
make tools/install -j9 V=-1 && make toolchain/install -j9 V=-1
The assembly itself will be held by
make -j9 V=-1
The result will be in bin / ramips
Ramips to describe the device uses DTS which are in target / linux / ramips / dts. The original DTS for ASUS DSL RT-N13U is
here .
Here we will replace the cfi @ 1f000000 block with our new one. Obviously, this is not what is suitable for our ROM chip. A quick search on neighboring dts made it possible to find that the configuration example should look something like this (this is again a block for DTS):
palmbus@10000000 { spi@b00 { status = "okay"; m25p80@0 {
Hoping for a successful outcome with a minimum of work, I assembled the firmware for ASUS RT-N13U with the changes made and tried to fill it with recovery mode, but the router refused to accept it with an error
wrong product id.
At the moment I could not find out what id he is checking, so installing the firmware without access to the Serial port is impossible.
But the router without problems was stitched in 2 uboot mode
2: System Load Linux Kernel then write to Flash via TFTP. Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N) Please Input new ones /or Ctrl-C to discard Input device IP (192.168.1.1) ==:192.168.0.2 Input server IP (192.168.1.20) ==:192.168.0.20 Input Linux Kernel filename () ==:fw.bin
It does not use a TFTP server, as in ASUS 'recovery, but the router itself goes to the specified server and downloads the specified file.
From the first attempt, the router did not start because it was impossible to mount /, but the boot log showed that there were problems with the ROM
[ 0.550000] m25p80 spi32766.0: found mr25h256, expected w25q128 [ 0.560000] m25p80 spi32766.0: mr25h256 (32 Kbytes) [ 0.570000] 4 ofpart partitions found on MTD device spi32766.0 [ 0.580000] Creating 4 MTD partitions on "spi32766.0": [ 0.590000] 0x000000000000-0x000000030000 : "u-boot" [ 0.600000] mtd: partition "u-boot" extends beyond the end of device "spi32766.0" -- size truncated to 0x8000 [ 0.620000] 0x000000030000-0x000000040000 : "u-boot-env" [ 0.640000] mtd: partition "u-boot-env" is out of reach -- disabled [ 0.650000] 0x000000040000-0x000000050000 : "factory" [ 0.660000] mtd: partition "factory" is out of reach -- disabled [ 0.670000] 0x000000050000-0x000001000000 : "firmware" [ 0.680000] mtd: partition "firmware" is out of reach -- disabled
A quick glance at the
m25p80 driver combined with a suspicious error
[ 0.470000] rt2880-pinmux pinctrl: pin io3 already requested by pinctrl; cannot claim for 10000b00.spi [ 0.490000] rt2880-pinmux pinctrl: pin-3 (10000b00.spi) status -22 [ 0.500000] rt2880-pinmux pinctrl: could not request pin 3 (io3) from group spi on device rt2880-pinmux
allowed to understand that the problem is in some pinctr and it seems that the driver cannot access the chip (he identified it as the most primitive with id 0). As it turned out, it was enough to erase the line with spi from the pinctrl section in DTS, it was she who prevented the m25p80 driver from gaining access to spi.
The next time I tried to load the device, it became clear that the ROM was determined correctly, and the only thing left was to set the correct addresses for the mtd partitions.
The result was this:
palmbus@10000000 { spi@b00 { status = "okay"; m25p80@0 {
We are stitching, and suddenly everything is loaded, Hurray!
Log successful boot device.
As a result, that's all: the router earned on OpenWRT without any problems and failures. Naturally, DSL does not work, but everything else works better than on the original firmware. Even the display on the case earned correctly.
This article is written to show that launching OpenWRT on a new device (provided that the platform is supported) is very simple, I hope it will help someone to make an OpenWRT port on their device.