Skip to content
/ miwifi Public
forked from comcat/miwifi

Kernel, Toolchain ... of Xiaomi Router R1D

Notifications You must be signed in to change notification settings

carabob/miwifi

 
 

Repository files navigation

        Xiaomi Router Core Support Package


1. Overview
============

Support Xiaomi R1D router (with 1T sata disk).

The Kernel version is 2.6.36
WLAN driver are binary object file from Broadcom located in 'drivers/net/wl'


2. Change History
==================

  - 2014/06: First version with kernel 2.6.36, support Xiaomi router R1D


3. Features
===========

3.1 Supported Features
-----------------------

  o General Platform
    + ARM Cortex A9 Dual-Core
    + 32 KB I-cache and 32 KB D-cache per core
    + 256 KB L2 Cache (shared)
    + 128-entry TLB
    + SMP

  o Bus
    + DDR3: Broadcom BCM4709 On-Chip DDR3 interface
    + PCI-E: Broadcom BCM4709 On-Chip PCI-E Controller 
    + USB: Broadcom BCM4709 On-Chip USB Controller
    + SPI: Broadcom BCM4709 On-Chip SPI Controller
    + SATA: ASMedia ASM1062 PCI-E SATA Controller

  o Network
    + Ethernet: Broadcom On-Chip 010/100/1000M  Ethernet Controller 
    + WLAN:
        + 2.4GHz: BCM43217, 802.11b/g/n Transceiver, PCIe 2.0 interface,
                   Radio + Baseband + MAC, 300Mbps
        + 5.0GHz: BCM4352, 2-Stream 802.11ac Transceiver (Support 802.11a/b/g/n)
                   PCIe 2.0 interface, Radio + Baseband + MAC, 867Mbps

  o Storage
    + NOR Flash: MXIC 25L12835F (16MB)
    + SATA Disk: Samsung 1T Sata disk 

  o MISC
    + Temp Sensor: TMP75
    + LED: Three LEDs (red, yellow, blue), GPIO interface


3.2 Unsupported Features
------------------------

Will be support in the furture:

  o MISC
    + PWM


4. Usage
==========

4.1 Build
----------

The following is validated in Ubuntu 12.04:

  $ sudo apt-get install lzma
  $ git clone git:https://github.com/comcat/miwifi.git
  $ cd miwifi/
  $ make

The output kernel image is vmlinuz, you can load it in CFE via tftpboot directly

The rootfs is located at miwifi/rootfs/

The root password is 'admin'

The wireless SSID is 'Jarvis' and 'Jarvis_5G' and the password is 'qwer1234'


4.2 Prepare the Rootfs
-----------------------

4.2.1 SATA Rootfs
------------------

The kernel is use the /dev/sda4 as the root fs by default. So you need to scp
the jarvis-rootfs.tgz into the router and unpack it into /dev/sda4:

root@XiaoQiang:/# mount -text4 /dev/sda4 /userdisk/
root@XiaoQiang:/# tar zxpf jarvis-rootfs.tgz -C /userdisk/
root@Jarvis:/# nvram set rootfs=sata
root@Jarvis:/# nvram commit

Now after bootup the kernel via tftp in CFE, the kernel will mount the
/dev/sda4 as the root fs by default.


4.2.2 NFS Rootfs
-----------------

4.2.2.1 Prepare the NFS Server
-------------------------------

If you want to use the NFS as the root fs. You need to setup a NFS server
in you PC:

$ sudo apt-get install nfs-kernel-server


Config the nfs directory:

$ sudo mkdir -p /tftpboot/rootfs
$ cat /etc/exports
/tftpboot/rootfs    *(async,rw,insecure,insecure_locks,no_root_squash)


Restart the nfs server:

$ sudo /etc/init.d/nfs-kernel-server restart


Testing the nfs server:

$ sudo mount -t nfs 192.168.31.2:/tftpboot/rootfs /mnt


4.2.2.2 Link the Rootfs
------------------------

$ sudo rm -rf /tftpboot/rootfs
$ sudo ln -sf /path/to/miwifi/rootfs /tftpboot/rootfs
$ sudo /etc/init.d/nfs-kernel-server restart



4.2.2.3 Setup the nvram
------------------------

Set the nvram varible 'rootfs' to 'nfs', then the kernel would be mount the 
192.168.1.2:/tftpboot/rootfs as the root fs:

root@XiaoQiang:/# nvram get rootfs
root@XiaoQiang:/# nvram set rootfs=nfs
root@XiaoQiang:/# nvram commit

Then after the kernel bootup, it will be mount the /tftpboot/rootfs as the
root fs.



4.3 Boot kernel
----------------

4.3.1 Prepare Network
----------------------

Make sure the LAN port (black one) of the Router and your PC ethernet port are
connected to the same Ethernet HUB.

Make sure the WAN port (blue one) of the Router is connected to the local
network.

The default ip addr of the CFE is 192.168.1.1 and the default tftp server ip is
192.168.1.2. So we need to setup a new ip for your PC eth0 port something like:

  $ sudo ifconfig eth0:0 192.168.1.2
  $ sudo ifconfig eth0:1 192.168.31.2


4.3.2 Setup TFTP Server
------------------------

We load the kernel through tftpboot. So we need to install a tftp server in your
desktop PC:

  $ sudo apt-get install tftpd tftp

Configure the tftp server via touching a file /etc/xinetd.d/tftp with following
contents:

$ cat /etc/xinetd.d/tftp
service tftp
{
    socket_type = dgram
    protocol = udp
    wait = yes
    user = root
    server = /usr/sbin/in.tftpd
    server_args = -s /tftpboot
    disable = no
    per_source = 11
    cps = 100 2
    flags = IPv4
}

$ ls /etc/xinetd.d/
chargen  daytime  discard  echo  tftp  time

$ sudo mkdir /tftpboot
$ sudo chmod 777 /tftpboot

$ sudo /etc/init.d/xinetd restart


Now you can place your vmlinuz into the /tftpboot:

$ cp /path/to/miwifi/vmlinuz /tftpboot/


4.3.3 Load kernel in CFE
-------------------------

You need to set the nvram parameter 'flag_tftp_bootup' to 'on' to make the
CFE to load the vmlinuz through tftp from tftp server:

root@XiaoQiang:/# nvram get flag_tftp_bootup
off
root@XiaoQiang:/# nvram set flag_tftp_bootup=on
root@XiaoQiang:/# nvram commit
root@XiaoQiang:/# nvram get flag_tftp_bootup
on
root@XiaoQiang:/# reboot
 
...........
CFE version v1.0.4
BSP: 6.37.14.34 (r415984) based on BBP 1.0.37 for BCM947XX (32bit,SP,)
Build Date: Wed Apr 30 18:03:21 CST 2014 (szy@shenzhiyong-ct)
 
...........
 
Device eth0:  hwaddr 8C-BE-BE-20-B7-48, ipaddr 192.168.1.1, mask 255.255.255.0
        gateway not set, nameserver not set
********** flag_tftp_bootup=on **********
tftp network: ifconfig eth0 -addr=192.168.1.1 -mask=255.255.255.0 -gw=192.168.1.1
Device eth0:  hwaddr 8C-BE-BE-20-B7-48, ipaddr 192.168.1.1, mask 255.255.255.0
        gateway 192.168.1.1, nameserver not set
kernel: boot -raw -z -addr=0x8000 -max=0x800000 192.168.1.2:vmlinuz
Loader:raw Filesys:tftp Dev:eth0 File:192.168.1.2:vmlinuz Options:(null)
Loading: ........ 5704544 bytes read
Entry at 0x00008000
Closing network.
Starting program at 0x00008000
......
......


5. APP build 
==============

Install an ARM basic debian on your x86 machine, The following is validated in
Ubuntu 12.04:

  $ sudo apt-get install qemu-user-static

 And create the core rootfs with the included debootstrap wrapper script:

  $ sudo qemu-debootstrap --arch armel stable rootfs
  I: Running command: debootstrap --arch armel --foreign stable rootfs
  I: Retrieving Release
  I: Retrieving Packages
  I: Validating Packages
  ...
  ...
  I: Base system installed successfully.

The basic debian successfully created in rootfs directory. Now you can chroot
into the rootfs:

  $ sudo chroot ./rootfs

  # ldd bin/bash 
  libtinfo.so.5 => /lib/arm-linux-gnueabi/libtinfo.so.5 (0xf67af000)
  libdl.so.2 => /lib/arm-linux-gnueabi/libdl.so.2 (0xf67a4000)
  libgcc_s.so.1 => /lib/arm-linux-gnueabi/libgcc_s.so.1 (0xf677a000)
  libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0xf6642000)
  /lib/ld-linux.so.3 (0xf6fda000)

  # cd bin
  # ls -l sh
  lrwxrwxrwx 1 root root 4 Mar  1  2012 sh -> dash
  # ln -sf bash sh
  # ls -l sh
  lrwxrwxrwx 1 root root 4 Jul  2 11:59 sh -> bash

  # cat etc/apt/sources.list
  deb https://mirrors.ustc.edu.cn/debian   wheezy main contrib non-free

  # apt-get update
  Get:1 https://mirrors.ustc.edu.cn wheezy Release.gpg [1672 B]
  ......
  ......

Now you can install the essential development packages:

  # apt-get install build-essential debhelper


Now you can use gcc with -static to build a 'hello world' app and then
run the app in the router.


About

Kernel, Toolchain ... of Xiaomi Router R1D

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published