FriendlyARM Mini2440 + Huawei E160 HSDPA USB modem

Brief description of how to hook up a Huawei E160 HSDPA USB modem to the FriedlyARM Mini2440 ARM9 development board without breaking a sweat.

The Linux kernel preinstalled on the board does not have the ppp driver, so the first order of business is to recompile and replace the kernel. Fetch the prepared kernel source package:

linux-2.6.32.2-mini2440_20100113.tgz

Extract and add the following options to the configuration matching your device, say config_mini2440_t35 for the common 3.5" display model:
CONFIG_PPP=y
CONFIG_PPP_MULTILINK=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPPOL2TP=y
Configure and compile the kernel using the GNU Toolchain sgpp compiler:

arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

Extract into /usr/src/mini2440/arm-2008q3 and set up the build environment.
$ PATH=$PATH:/usr/src/mini2440/arm-2008q3/bin
$ CC='arm-none-linux-gnueabi-gcc -march=armv4t -mtune=arm920t'
$ CROSS_COMPILE=arm-none-linux-gnueabi-
$ export CC CROSS_COMPILE
Configure by loading your modified configuration file into menuconfig, then build the lot.
$ make ARCH=arm menuconfig
$ make ARCH=arm -j4
Copy the new kernel/arch/arm/boot/zImage kernel image to the board. This can be done by writing a raw image over the old one using the "[k] Download linux kernel" BIOS option. No need to format the NAND or fiddle with u-boot.
Enter your selection: k
USB host is connected. Waiting a download.

Now, Downloading [ADDRESS:30000000h,TOTAL:2562214]
RECEIVED FILE SIZE: 2562214 (500KB/S, 5S)
Downloaded file at 0x30000000, size = 2562204 bytes
Found block size = 0x00280000
Erasing...    ... done
Writing...    ... done
Written 2562204 bytes
At this point the board should boot just as happily as before, now with a fresh kernel with both /dev/ppp and /dev/ttyUSB0 support.

Connect the E160 to the USB hub of the board and check that the kernel says something like:
usb 1-1: New USB device found, idVendor=12d1, idProduct=1003
usb 1-1: Product: HUAWEI Mobile
usb 1-1: Manufacturer: HUAWEI Technology
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
The preinstalled qtopia does not include any userspace tools for dialing or mangaging ppp connections. Rather than compiling all of wvdialer you can pretend it's 1993 all over and just use pppd + chat compiled from source:
$ wget ftp://ftp.samba.org/pub/ppp/ppp-2.4.5.tar.gz
$ tar xf ppp-2.4.5.tar.gz
$ cd ppp-2.4.5
$ ./configure
$ make
$ file pppd/pppd
pppd/pppd: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14
Copy the pppd and chat binaries to /usr/sbin/ on the board, and create the /etc/ppp/ directory for the configuration and control scripts. Use the defaults from the pppd scripts/ directory and modify to match your ISP. These work for the finnish Saunalahti operator:

/etc/ppp/ppp-on:
#!/bin/sh

DIALER_SCRIPT=/etc/ppp/ppp-on-dialer

route del default 2>/dev/null
exec /usr/sbin/pppd debug lock modem crtscts /dev/ttyUSB0 9600 \
    asyncmap 20A0000 escape FF kdebug 0 0.0.0.0:0.0.0.0 \
    noauth noipdefault netmask 255.255.255.0 defaultroute connect $DIALER_SCRIPT
/etc/ppp/ppp-on-dialer:
#!/bin/sh

exec chat -v \
        TIMEOUT       5 \
        ABORT         'BUSY' \
        ABORT         'NO ANSWER' \
        ''            'ATZ' \
        'OK'          'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' \
        'OK'          'AT+CGDCONT=1,"IP","internet.saunalahti"' \
        'OK'          'ATDT*99#' \
        'CONNECT'     ''
Replace internet.saunalahti and *99# with whatever your ISP requires, add CPIN to the initialization if needed. Execute /etc/ppp/ppp-on and check /var/log/messages for output like this:
Sep 17 16:43:59 pppd[773]: pppd 2.4.5 started by root, uid 0
..
Sep 17 16:44:02 chat[775]: ATDT*99#^M^M
Sep 17 16:44:02 chat[775]: CONNECT
Sep 17 16:44:02 chat[775]:  -- got it
..
Sep 17 16:44:02 pppd[773]: Connect: ppp0 <--> /dev/ttyUSB0
For manually testing and debugging the chat script you might want to install a terminal like picocom:
$ wget http://picocom.googlecode.com/files/picocom-1.4.tar.gz
$ tar xf picocom-1.4.tar.gz
$ cd picocom-1.4
$ make
That's it.

13 comments:

Dhaval said...

can you tell me how can i connect my E51 as 3g Modem. I tried to connect but it did not connected to any usb devices in my Mini2440

Yiğitalp Ertem said...

hello,

Thanks for the tutorial. I followed it until ppp-on and ppp-on-dial part. Here i don't know how to change the lines here. Is "internet.saunalahti" the APN? mine is "mgb" i've changed it. And i need to write a CPIN, but don't know where to write? When i check the var/log/messages, there is Error after that line about "internet..." . Can you give a little bit explanation about these two scripts. Thank you.

aLp

Yiğitalp Ertem said...

Ok, i solved my problem. It was all about my ISP, thank you so much random hax for great tutorial.

aLp

Anonymous said...

Can this work also with Huawei E170 USB??

Submetal said...

Hi,
I tried to follow this tutorial but I can't compilate the zImage file for the T35. Could you upload your zImage file?

m68k said...

There is a snapshot of the 2.6.32.2 with ppp support at http://m68k.org/ul/zImage_2.6.32.2_T35_ppp

Unknown said...

how to check /var/log/message ?
can you tell me ,i'm doing project about mini2440 board

Unknown said...

where i get information of CPIN , i need to write a CPIN, but don't know where to write?
When i use (./messages) , there is "text file busy"
Please help me !!

Anonymous said...

I have a problem. I'm using the exact same programs as in this tutorial, everything compiled fine. With picocom I'm able to talk with the modem just fine, but pppd's chat won't talk to it at all. No response. Therefore I'm unable to connect.

Picocom works, chat doesn't.

Any ideas?

Anonymous said...

Hello!

I have a problem with the kernel. I have done all steps. When i download the kernel zImage-File to the board and boot this i get the messeage:

Copy linux kernel from 0x00060000 to 0x30008000, size = 0x00700000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySA
C0"
MACH_TYPE = 1999
NOW, Booting Linux......
Uncompressing Linux...

ran out of input data

-- System halted

What is false?

Anonymous said...

Hi,
when I try to compile ppp (version 2.4.5) I receive the following error:
options.c:59:18: error: pcap.h: No such file or directory
options.c: In function 'setpassfilter':
options.c:1465: error: 'pcap_t' undeclared (first use in this function)
options.c:1465: error: (Each undeclared identifier is reported only once
options.c:1465: error: for each function it appears in.)
options.c:1465: error: 'pc' undeclared (first use in this function)
options.c:1468: warning: implicit declaration of function 'pcap_open_dead'
options.c:1468: error: 'DLT_PPP' undeclared (first use in this function)
options.c:1469: warning: implicit declaration of function 'pcap_compile'
options.c:1471: warning: implicit declaration of function 'pcap_geterr'
options.c:1474: warning: implicit declaration of function 'pcap_close'
options.c: In function 'setactivefilter':
options.c:1486: error: 'pcap_t' undeclared (first use in this function)
options.c:1486: error: 'pc' undeclared (first use in this function)
options.c:1489: error: 'DLT_PPP' undeclared (first use in this function)
make[1]: *** [options.o] Error 1
make[1]: Leaving directory `/home/emanuele/mini2440/ppp_user_space/ppp-2.4.5/pppd'
make: *** [all] Error 2

My OS is Slackware 13.37.
What I need to compile ppp?
libpcap and tcpdump are already installed in my system.
Thank you

Chandu said...

Hi I want to connect to the internet using usb modem. I follow the steps but i dont know how to compile the kernel (linux-2.6.32.2-mini2440_20100113.tgz) using the tool chain (arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2) can anyone please tell me the steps to follow.

shankar said...

Hi all,

how to Copy the pppd binaries to /usr/sbin/ on the board, and how to create the /etc/ppp/ directory for the configuration and control scripts?

I am using bellow path for that i.e
make install DESTDIR=$(ROOTFS/PATH)