DreamBox 7025+ as internet router, with 3G USB stick !!!!

Well, it’s a bit late, but hey, late better than never…

As soon as I moved from Duabi-UAE to Cairo-Egypt, I had absolotly no internet access except via a 3G USB stick that I borrowed from my friend, that 3G USB Stick model was Huawei E1550…

So i had that wacky idea, why not stick this stick to the back of my DM7025 and make it share the internet access, I’ve always used that set top box as a NAS server (via Samba), torrent download station (using Transmission), and it did pretty well, so let’s add “Internet router” to the pile, this shouldn’t be hard right??

Well, think again…

We need to

  • Build kernel modules for PPP, IPTables, usb-serial dongles
  • Flip the USB stick to the serial interface mode (Huh!!!!!!)
  • Load the proper modules and create needed /dev files
  • Get a tool to run pppd, to dial, and connect
  • Enable IPTables and IP-Forwarding
  • The E1550 is one of those "dual mode" devices which upon insertion are identified as a CD-ROM drive, and switch to a serial device (modem) when prodded with a particular control sequence. The CD-ROM includes some software by the operator and a driver. I didn’t even try to install this stuff, believing that it would be much better to rely only on standard Linux components.

    To start with, I already have Debian 4.0 MIPS installed on that compact flash, and I can easily chroot to it and do all the cool linux stuff I like, I got gcc installed in no time using apt-get install gcc, see, easy!

    So, here’s what needed to be done

    1. Compile kernel modules for kernel 2.6.12.6 (which seems to be only version released by Dream Multimedia)
      • That seemed a bit challenging, I have GCC installed, but the CPU power in that box is just poor to compile the entire kernel tree, I estimated this to take around 4 hours just to finish “make modules”, and guess what, it just did 🙂
      • I also choose to build it on my Ubuntu VBOX VM using a tool chain and compare the time/size/compatibility of the generated code
      • The tool chain configuration itself was a bit challenging, however crosstools-NG really helped alot; however building the entire tool chain took over 2 hours, I had to build a few tool chains to test with which one will generate kernel modules that will be loadable by the DM
      • I could have used the tool chains provided by DM development guys everywhere on the planet, but I just wanted to get my hand dirty
      • Eventually I got all kernel modules for 2.6.12.6 compiled and can load properly
    2. Get the USB stick to expose it’s 3G serial ports VID/PID
      • That was done with the tool called usb_modeswitch that tool needed a few dependencies
      • libusb1.0, I grabbed 1.06 from here
      • libusb-compat-0.1.2 from here
      • There has been a slight catch here, the usb_modeswitch needed usb.h, i thought it needed that from the kernel tree, but I was wrong, it needed the usb.h you can find in libusb-compat-0.1.2/libusb/usb.h
    3. Get kernel modules to load and recognize the VID/PID
      • After running mod_switch, the USB stick shows VID/PID : 0x12d1/0x1001
      • On my ubuntu, it’s being handled by the option.ko module (kernel 2.6.23), but that wasn’t yet supported when 2.6.12.6 was release, so now I need to make some effort to back-port option.c 😦
      • Luckily I tried something really really stupid 😀 but it totally worked fine, I just added the VID/PID into the kernel module like this:
      • /* Vendor and product IDs */
        #define HUAWEI_VENDOR_ID                        0x12D1
        #define HUAWEI_PRODUCT_E1550                     0x1001

        ..

        ..

        static struct usb_device_id option_ids[] = {
                { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) },
                { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1550) },
                { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_WLAN) },
                { } /* Terminating entry */

      • Now the kernel can recognize the new serial device
    4. Create new /dev files
      • The following few commands got that, that was the easiest part so far 😀
      • mknod /dev/ttyUSB0 c 188 0
        mknod /dev/ttyUSB1 c 188 1
        mknod /dev/ttyUSB2 c 188 2
        mknod /dev/ttyUSB3 c 188 3

      • Now I can cat from those device files, which means they’re properly attached to the actual device, and minicom worked just as fine, and now I can write AT commands and talk to the device, YAAAAAY!!!!!
    5. Use those new /dev files to connect to the serial port and initiate PPPd
      • apt-get install wvdial did all the job, yet we still need to enable the ppp module, “modprobe ppp_async” would do the job
      • Thanks to a few posts (i’ll put the links below) I knew what needed to sent to the device to get to connect, here’s my /etc/wvdial.conf
      • [Dialer Defaults]
        Dial Command = ATD
        Init1 = ATZ
        Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
        Init3 = AT+CGDCONT=1,"IP","etisalat"
        Init4 = AT+CGATT=1
        Baud = 460800
        New PPPD = yes
        Modem = /dev/ttyUSB0
        Phone = *99#
        Password = internet
        Username = internet

    6. Enable forwarding and NAT
      • On normal linux that would be a snap, but here we still need to enable IPTABLES nat module as well MASQUERADE modules to get iptables to work, and enable kernel forwarding
      • modprobe iptable_nat
        modprobe ipt_MASQUERADE

        echo 1 > /proc/sys/net/ipv4/ip_forward
        iptables -A POSTROUTING -t nat -s 192.168.180.0/24 -j MASQUERADE

      See, easy, right??? hell yeah 😀

      Of course these has been several bumps along the road, for example when I messed up with the QOS of the 3G stick using AT+CGQREQ and AT+CGQMIN, that technically rendered the USB stick unable to connect at all, even when I tried to re-plug it, and even tried it on my windows machine, the SIM working just fine though as I tested it with my laptop’s internal 3G module, got it only fixed by the following, that type of setting is stored somewhere within either the SIM or the 3G stick itself…

      ATCGEQMIN=1,0,0,0,0,0
      ATCGEQREQ=1,0,0,0,0,0

      Should anybody need assistance or would like to have a copy of the files esp. the kernel modules, please let me know…

      Thanks to all who made the real effort of coding, discovering, who eventually all helped the entire community and me to realize and actually do this…

      http://www.woggledog.com/index.asp?subject=GPRS

      http://www.santinoli.com/open/e1692-howto.html

      http://cc.jlab.org/docs/services/linux/linux-ppp.html

      Thanks you all guys…

      Now I can close all those tabs in FireFox that I kept open for over 2 months just to make sure I don’t lose those references above …

      Advertisements

      6 Responses

      1. Looks very interesting indeed!

        I have a dreambox 7020 which I want to use as a router as well, however I am missing the NAT and MASQUERADE modules –

        I am assuming these can be copied over on the image then loaded? Could you provide a link to these modules please?

        • I don’t think that dreambox 7020 can load these modules as it uses a different CPU arch. …
          More over I think it runs enigma1, however, if you can tell us the output of ‘uname -a’ , maybe I can be able to shed some light on that…

      2. hi there, great job – i am looking since ……
        for some help or a patched kernel modul for the dm800 (mipsel)
        i live in brasil and here a 3g is the only way out of metropolitan area. Allways using a pc or a router box for the connection is expensive and “sucks”. May i have your files or just the kernel ?

      3. ps, i and most off my friends using huawei e220 or e156b

        • I can’t provide you a kernel to load instead of your own, becuase then you won’t be able to load the DVB modules needed for the normal operation of the DreamBox as a receiver, you know what I mean…

          However, if you can tell me the result of ‘uname -a’ from within the dm800, maybe we can use the precompiled modules (which I already compiled) out of the box…

          As for the patched driver, let’s 1st see if we can load the modules, then if so we can try to patch and build a custom module for you…

          I won’t be able to post a link – for many reasons – however, I can send them to you over email…

          • hi,
            the box (clone) i using shows for uname -a
            Linux dm800 2.6.12-5.1-brcmstb-dm800 #1 Thu Dec 10 21:10:32 CET 2009 7401c0-nand unknown

            this days will install the “stinky linux” to play with and also making tests with the “buildimage” prog for the db.

            regards, pedro

      Leave a Reply

      Fill in your details below or click an icon to log in:

      WordPress.com Logo

      You are commenting using your WordPress.com account. Log Out / Change )

      Twitter picture

      You are commenting using your Twitter account. Log Out / Change )

      Facebook photo

      You are commenting using your Facebook account. Log Out / Change )

      Google+ photo

      You are commenting using your Google+ account. Log Out / Change )

      Connecting to %s

      %d bloggers like this: