
Good day, community! I already
wrote about the remarkable board on the Allwinner A10 chip - MarsBoard. That post was something like “Getting Started”, the same will be devoted entirely to the transformation of this miracle of
hostile technology into a full-fledged WiFi access point and a part-time router. To create a point, the Debian Server build will help me (by the way, we will build the kernel too :)) and the TP-Link TL7200ND USB adapter. Type of connection with the provider - PPPoE. Interested? Welcome under cat.
Instead of the preface
To be honest, as soon as I came up with this idea, I didn’t even think that I would have to meet with so many pitfalls. Well, then he probably is Linux ... By the way, all the manipulations in the article will be performed using a computer running Ubuntu OS and a card reader for an SD card. And I immediately advise you to perform
sudo su
in the terminal session, from which we will perform all actions.
System
For my experiments, I decided to abandon the bulldozer that brings slippers to the bed, which offers us offsite. I managed to find a pre-built Debian Server build, but I had to mess around with the kernel. But more about that later. In fact, the installation is reduced to recording the image on 2 (or more) GB SDCard and installing the bootloader (from the offsite of the board).
')
So let's go. Connect the SDCard to the computer and use the
fdisk -l
find out the name of the card device. I have
/dev/sdc
. Further, the device card in the article will be denoted as
sdX
. Instead of
X
substitute your letter.
We download everything you need.
System (I will consider actions with the assembly
2013-Sep-20 10:32:33 ),
uboot.bin ,
sunxi-spl.bin .
Further:
- Go to the folder with the downloaded files
- We write the system on the card:
bzip2 -dc a10-debian-server-2gb.2013-09-20.img.bz2 > /dev/sdX
- We write bootloader:
dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8 dd if=u-boot.bin of=/dev/sdX bs=1024 seek=32
System set, great, go ahead.
The beginning of dance - driver
Actually, this is where the whole epic began to stumble on those very pitfalls. It turned out that the drivers for Ralink chips, for which the adapter works, there are 2 types - “old” and “new”. Older drivers are installed automatically via apt-get and work out of the box, but they only work in Managed mode, i.e. the adapter can only connect to an existing point, but cannot create this point itself. To create a point, you need to transfer the adapter to the Master mode, and for this you need those “new” drivers. Only now these new cool firewood need ... to collect. Well, collect so collect.
Go here:
www.ralinktech.com/support.php?s=2 and download RT2870_Firmware_V22. Unpack and write to / lib / firmware
in the file system on the SDcard .
Next, download compat-wireless:
www.orbit-lab.org/kernel/compat-wireless-2.6 . This is actually what we need to compile.
But not everything is so simple. Since I still understand Linux, I was very surprised when I discovered that to compile the drivers I would need the source code for my current kernel. And even more surprised when I did not find them in the system. Fortunately, the author of the assembly kindly provided the configuration of the kernel used there. We will take it to collect the source code. So, let's digress a bit from the drivers and review the reassembly of the kernel.
Core
As I said, we need kernel sources for building firewood, and for building specific sources we need ... universal sources linux-sunxi. We will also need to slightly adjust the configuration in order to bring the kernel versions of the drivers built into the modules. So we can replace them with compat-wireless.
First of all, we put everything necessary on the computer:
apt-get install git build-essential fakeroot kernel-package u-boot-tools zlib1g-dev libncurses5-dev
And we add this repository to the
/etc/apt/sources.list
file:
deb http://www.emdebian.org/debian/ unstable main
Next, update apt and set the cross compiler:
apt-get update apt-get install emdebian-archive-keyring apt-get install gcc-4.7-arm-linux-gnueabihf ln -sf `which arm-linux-gnueabihf-gcc-4.7 ` /usr/local/bin/arm-linux-gnueabihf-gcc
Next, we need to download the kernel source code from the githaba. Clone the repository yourself, go to the source folder and switch to version 3.4:
git clone https://github.com/linux-sunxi/linux-sunxi linux-sunxi cd linux-sunxi git checkout sunxi-3.4
Next, download the base kernel configuration
file , rename it to
.config
and put it in the root folder of the source code. Now a little configuration. We need to set everything related to 80211 to module mode. To do this, perform:
ARCH=arm make menuconfig
This command builds the pseudographic kernel configuration utility. We select in it
Networking
, then
Wireless
. Select the following lines one by one and press the M key on the keyboard:
cfg80211 - wireless configuration API Common routines for IEEE802.11 drivers Generic IEEE 802.11 Networking Stack (mac80211)
As a result, there should be something like this:

Next, click
Exit
and
Exit
again. We get to the main menu, scroll down and click
Save an Alternate Configuration File
. Confirm and exit the utility.
Everything, we have configured a kernel, now it is possible to collect. We execute the following commands:
export ARCH=arm export DEB_HOST_ARCH=armhf export CONCURRENCY_LEVEL=`grep -m1 cpu\ cores /proc/cpuinfo | cut -d : -f 2` fakeroot make-kpkg --arch arm --cross-compile arm-linux-gnueabihf- --initrd --append-to-version=-mykernel kernel_image kernel_headers make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- EXTRAVERSION=-mykernel uImage cp arch/arm/boot/uImage ../uImage
As a result, after compilation in the directory level up there will be 3 files: a package with a kernel, a package with sources, and a uImage. The flash drive with the image has not yet been disabled? We go there, fill all 3 files somewhere in the root root. Next, insert the USB flash drive into the board, with the help of SSH we put the kernel and source packages. Turning off, stick back into the computer. Next, go to the section with the kernel (there are files script.bin, uImage, etc.) and copy there with the replacement of the new uImage from the root of the second section. Boot with the new kernel and again, in the SSH terminal, we prescribe the commands:
ln -s /usr/src/linux-headers-$(uname -r) /lib/modules/$(uname -r)/source ln -s /usr/src/linux-headers-$(uname -r) /lib/modules/$(uname -r)/build
Everything, now the system is ready to compile drivers.
We continue to collect drivers
Go to the folder to the unpacked compat-wireless (remember downloaded?). We carry out:
./scripts/driver-select rt2x00 make make install
Next you need to write in the blacklist "old" driver. We add the following lines to the
/etc/modprobe.d/blacklist.conf
file:
blacklist rt2870sta blacklist rt5370sta
We are overloaded.
Configuring the router itself
So, it's time to install everything you need to distribute the Internet and the organization of the local network. I chose dnsmasq as the DHCP server, hostapd will control the access point, and the connection with the provider will be provided by the pppoeconf utility. I will not consider setting up a firewall using iptables here, since there is a lot of information on this case on the Internet, but I’ll show only basic forwarding. He is vital to us. So, drove.
We connect again via SSH and put everything you need:
apt-get install hostapd dnsmasq pppoeconf
1. Configure hostapd
hostapd - utility for creating and managing software WiFi access point. It has 2 places from which you can customize it.
The first is
/etc/default/hostapd
. Setup autorun. Replace all the scribbling there with the following lines:
RUN_DAEMON = yes DAEMON_CONF="/etc/hostapd/hostapd.conf"
Second place -
/etc/hostapd/hostapd.conf
. Basic settings. You can configure a lot of parameters here, but I will only give my configuration and explain what and why I entered there:
2. Configure dnsmasq
dnsmasq - DHCP-DNS-TFTP-server with an intuitive configuration file and a number of cookies. It also has a configuration file in
/etc/default/
, but we will not touch it, because there is nothing interesting there. Let's deal with the main config -
/etc/dnsmasq.conf
. As with hostapd, I will show and tell you about my configuration option:
3. Configuring Interfaces
The next step is to configure the interfaces, since their configuration is needed to properly configure a PPPoE connection. As you know, interfaces are configured in the / etc / network / interfaces file. We bring him to this form:
4. Configure PPPoE
The pppoeconf utility provides a pseudographic interface for semi-automatic configuration of the connection with the provider. This is done by typing the same command in the terminal:
pppoeconf
Then everything is intuitively clear, after a successful configuration, the following entry is added to the network interface configuration file:
auto ppp0 iface ppp0 inet ppp pre-up /sbin/ifconfig eth0 up provider dsl-provider
5. Basic forwarding
The last step is setting up packet forwarding from the local network to the external network and back (
masquerading ).
Perform the following to install this very MASQUERADE and autoload the configuration in iptables at system startup:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE iptables -A FORWARD -o eth0 -j ACCEPT iptables -A FORWARD -o ppp0 -j ACCEPT iptables-save > /etc/wifi-iptables.conf echo '#!/bin/sh' > /etc/network/if-up.d/iptables echo 'iptables-restore < /etc/wifi-iptables.conf' >> /etc/network/if-up.d/iptables chmod +x /etc/network/if-up.d/iptables
Rebooting ...
Instead of conclusion
Fuuuhhh, well, that's all. Are you tired? But now we have a working router based on a rather smart board, and with such a good adapter. According to my tests, ping in online games does not exceed 15-25ms, and in 2 weeks of uptime, the entire system has stopped once, which has been cured by jerking power.
Speaking of nutrition. It turned out that for stable operation of the device together with an adapter, a power supply is required that is designed for a power of at least 1000mA. Please note,
impulse chargers
are not suitable ! Do not get fooled by the coincidence of the plugs!
Finally, I want to express my gratitude to the person with the nickname RM and his wonderful
resource .
PS: I will be very grateful for constructive criticism, but I will
emphasize that it is not necessary to spit on foam here . If you know how to reduce the number of steps or make something better, share it, I will update the article.