TP-Link MR3420 setup OpenWRT

OpenWrt is a powerful Linux distribution for embedded devices. Main target is various router boards, but also other small devices like GuruPlug, ALIX Boards, OLPC.

List of all supported hardware: http://wiki.openwrt.org/toh/start

Using this distribution require little Linux skills and lot of time…
All documentation and howto: http://wiki.openwrt.org/doc/start

Check system prerequisites: http://wiki.openwrt.org/doc/howto/buildroot.exigence

Next quick setup and build instruction for MR3420 router with 3g/UMTS USB Dongle for WAN connection.

Get source (Chaos Calmer 15.05):

~ $> git clone git://git.openwrt.org/15.05/openwrt.git openwrt

Update source:

~ $> cd openwrt
~/openwrt $> git pull

Update all feeds:

~/openwrt $> ./scripts/feeds update -a

Install useful feeds:

~/openwrt $> ./scripts/feeds install luci luci-proto-3g

Configure buildsystem:

~/openwrt $> make menuconfig

Select router:

menuconfig

Select block-mount:

Base system --->  <*> block-mount
Kernel modules --->  USB Support --->  <*> kmod-usb-storage
Kernel modules --->  Filesystems --->  <*> kmod-fs-ext4

Select Luci web interface:

LuCI --->  
1. Collections --->  <*> luci

Select Dongle kernel support:

Kernel modules ---> USB Support ---> <*> kmod-usb-serial
Kernel modules ---> USB Support ---> <*> kmod-usb-serial-option
LuCI ---> 6. Protocols ---> <*> luci-proto-3g
Utilities ---> <*> usb-modeswitch

Build:

make -j4

Finally, we can find all in “bin/ar71xx/”

~/openwrt $> ls -hgG bin/ar71xx/
totale 23M
-rw-r--r-- 1  827 apr 17 16:59 md5sums
-rw-r--r-- 1 2,7M apr 17 16:59 openwrt-ar71xx-generic-root.squashfs
-rw-r--r-- 1 2,6M apr 17 16:59 openwrt-ar71xx-generic-root.squashfs-64k
-rw-r--r-- 1 3,8M apr 17 16:59 openwrt-ar71xx-generic-tl-mr3420-v1-squashfs-factory.bin
-rw-r--r-- 1 3,4M apr 17 16:59 openwrt-ar71xx-generic-tl-mr3420-v1-squashfs-sysupgrade.bin
-rw-r--r-- 1 1,3M apr 17 16:59 openwrt-ar71xx-generic-uImage-gzip.bin
-rw-r--r-- 1 903K apr 17 16:59 openwrt-ar71xx-generic-uImage-lzma.bin
-rwxr-xr-x 1 2,7M apr 17 16:59 openwrt-ar71xx-generic-vmlinux.bin
-rwxr-xr-x 1 2,8M apr 17 16:59 openwrt-ar71xx-generic-vmlinux.elf
-rw-r--r-- 1 1,3M apr 17 16:59 openwrt-ar71xx-generic-vmlinux.gz
-rw-r--r-- 1 960K apr 17 16:59 openwrt-ar71xx-generic-vmlinux.lzma
-rwxr-xr-x 1 973K apr 17 16:59 openwrt-ar71xx-generic-vmlinux-lzma.elf
drwxr-xr-x 2  16K apr 17 16:58 packages

Reference:
Working with Feeds: http://wiki.openwrt.org/doc/devel/feeds
Multiple targets in one single checkout: http://wiki.openwrt.org/doc/devel/env
Detailed build instructions: http://wiki.openwrt.org/doc/howto/build
Easy patch management: http://wiki.openwrt.org/doc/devel/patches
Creating packages: http://wiki.openwrt.org/doc/devel/packages
First Login: http://wiki.openwrt.org/doc/howto/firstlogin
Configuration files: http://wiki.openwrt.org/doc/uci

Posted in OpenWRT | Leave a comment

TP-LINK MR3420 hardware

TL-MR3420 is Wireless N Router with USB 2.0 Port for UMTS/HSPA/EVDO USB Modem.

Model Name
TL-MR3420
Dimensions
6.9 x 4.4 x 1.2 in. (174 x 111 x 30 mm)
Power
9VDC / 0.85A
Ports
#1 – USB 2.0
#1 – Ethernet WAN 10/100Mbps
#4 – Ethernet LAN 10/100Mbps
Antennas
#2 – 3dBi Detachable Omni Directional Antennas
Wireless Transmit Power
20dBm (Max. EIRP)
CPU
Atheros AR7241@400MHz
RAM
32 MB
Flash
4 MB
Posted in Hardware, Linux | Leave a comment

Arduino Nano v3 internal temperature sensor

Calibration data:

Download data & formulas in excel.
Atmega documentation says:
The voltage sensitivity is approximately 1 mV/°C and the accuracy of the temperature measurement is +/- 10°C.
Measured temperature is a sum of ambient temperature and chip’s TDP. In fact it rises up for few minutes after the chip is powered and may change in base of load.

// Read Atmega328P internal temperature sensor //
long read_temp()
{
  // Read temperature sensor against 1.1V reference
  ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3);
  // Start AD conversion
  ADCSRA |= _BV(ADEN) | _BV(ADSC);
  // Detect end-of-conversion
  while (bit_is_set(ADCSRA,ADSC));
  // return raw data
  return ADCL | (ADCH << 8);
}

// Convert raw temperature data to °C
double conv_temp(long raw_temp)
{
  // f(x) = (raw - offset) / coeff
  return((raw_temp - 324.31) / 1.22);
}

void setup()
{
  Serial.begin(115200);
}
 
void loop()
{
  Serial.println(conv_temp(read_temp()), 1);
  delay(500);
}

Atmega 328P – Datasheet

It is a curious fact that putting chips in the freezer, after a few minutes when the temperature drops below zero, the chip stops working.

Posted in Arduino, C++, Electronics | 8 Comments

Gentoo default Python interpreter

Gentoo default Python interpreter is set to version 3.1:
~ # eselect python list
Available Python interpreters:
[1] python2.6
[2] python3.1 *

Command to change default interpreter:
~ # eselect python set 1
And now interpreter version is 2.6:
~ # eselect python list
Available Python interpreters:
[1] python2.6 *
[2] python3.1

Installing version 2.7:
~ # nano /etc/portage/package.accept_keywords
=dev-lang/python-2.7*
^X (Ctrl+X) --> exit & save
~ # emerge --ask =dev-lang/python-2.7*

Rebuild Python modules:
~ # python-updater
* Starting Python Updater...
* Main active version of Python: 2.7
* Active version of Python 2: 2.7
* Active version of Python 3: 3.1

Happy python coding!

Posted in Linux, Python | 1 Comment

Gentoo web2py daemon

Gentoo RC init script for web2py framework

Save as “/etc/init.d/web2py”

#!/sbin/runscript
# Gentoo web2py init script

WORK_PATH="/home/web2py"
WORK_FILE="web2py.py"

PYTHON="/usr/bin/python2.6"
PIDFILE="/var/run/web2py.pid"

PASSWORD="<recycle>"
SRV_ADDR="0.0.0.0"
SRV_PORT="8000"
SRV_CRT=""
SRV_KEY=""

depend(){
  need net
}

start() {
  ebegin "Starting web2py"
  start-stop-daemon --start --quiet --background --chdir "$WORK_PATH" \
                    --pidfile $PIDFILE --exec "$PYTHON" \
                    -- "$WORK_PATH/$WORK_FILE" \
                    --nogui --password="$PASSWORD" \
                    --pid_filename="$PIDFILE" \
                    --ip=$SRV_ADDR --port=$SRV_PORT \
                    --ssl_certificate="$SRV_CRT" --ssl_private_key="$SRV_KEY"
  eend $?
}

stop() {
  ebegin "Stopping web2py"
  start-stop-daemon --stop --pidfile $PIDFILE
  eend $?
}

To make a file executable:
chmode +x /etc/init.d/web2py
Add to default runlevel:
rc-update add web2py default
Start daemon:
rc-config start web2py

Posted in Linux, Python | Leave a comment

Remove Windows 7 password

This is the most easiest way to remove password of Windows system. Works on all Windows [NT/XP/Vista/Seven] – [32/64] versions.

DANGER!
If used on users that have EFS encrypted files, and the system is XP or newer, all encrypted files for that user will be UNREADABLE! If you don’t know if you have encrypted files or not, you most likely don’t have them. (except maybe on corporate systems)

It’s floppy based Linux distribution, partially derived from floppyfw.
Boot [CD/Floppy] downloads and instructions can be found at:
http://pogostick.net/~pnh/ntpasswd/

This floppy image is in the SYSRESCUECD, also instructions to make Boot USB Pen Drive: http://www.sysresccd.org/Sysresccd-manual-en_How_to_install_SystemRescueCd_on_an_USB-stick

Posted in Windows | Leave a comment

Python GUI calc

Python GUI experiment. Simple calculator application made with Tk.
It’s a first choice because it’s integrated into Python, simple to use and powerful enough for most cases. It’s also cross platform like an interpreter.
However, there are many other libraries for GUI:
http://wiki.python.org/moin/GuiProgramming

#!/usr/bin/python

# Python GUI calculator 
# (C) 2011 - netquote.it
# Original code by Emanuele Chiabrera
# Enhanced by Toropov Ivan 

from Tkinter import *

# button text list
cmdlst = ['7', '8', '9', '+', '%',
          '4', '5', '6', '-', '**',
          '1', '2', '3', '*', '//',
          '.', '0', 'CL', '/', '=']

class MyButton(Button):
    
    backref = None
    
    def Click(self):
        # back reference
        self.backref.BtnCmd(self["text"])


class CalcApp:

    def __init__(self, master):
        frame = Frame(master)
        
        self.textbox = Entry(width=30, takefocus=1)
        self.textbox.pack(side=TOP)
        self.textbox.focus_force()

        self.buttons = []
        for n, c in enumerate(cmdlst):
            self.buttons.append(MyButton(frame, text=c, width=5))
            self.buttons[n]["command"] = self.buttons[n].Click
            self.buttons[n].backref = self
            self.buttons[n].grid(row=n/5, column=n%5)

        frame.pack()

    def BtnCmd(self, cmd):
        if cmd == '=':
            try:
                res = eval(self.textbox.get())
            except:
                res = "Error!"
            self.textbox.delete(0, END)
            self.textbox.insert(0, str(res))
        elif cmd == 'CL':
            self.textbox.delete(0, END)
        else:
            self.textbox.insert(END, cmd)

root = Tk()
root.title("EWCalc")

calcapp = CalcApp(root)
root.mainloop()

What comes out:

Posted in Python | Leave a comment

Voltage Drop Protection

DC motor drive circuit with automatic load regulation. Main concept is to cut off power from DC Motor and sustain the voltage in the circuit. Also detect low-battery state.

Components:
#1 – Dual Op-Amp CA158 (Like LM358)
#1 – Trimmer 4.7 kΩ (voltage limit regulator)
#1 – NPN-MOSFET IRF530 (14A, 100V)
#1 – Capacitor C 0,1 µF
#1 – Capacitor C 0,33 µF
#1 – Led (Green – Bat ok)
#1 – Led (Red – Bat low)
#2 – Resistor R 220 Ω
#3 – Resistor R 15 kΩ
#1 – Brushed DC-Motor Permax 400 (6V)

Posted in Electronics | Leave a comment

Liquid Armor

Mainboard
Asus Striker II NSE
Video
GeForce GTX 460 1 Gb ddr5 Pci-E Dual DVI / Mini HDMI OC Edition
RAM
OCZ DDR3 PC3-12800 Reape
HDD #2 RAID 0 (Striping)
WD Caviar Black 640 Gb
Audio
Creative X-Fi Titanium Fatal1ty Professional Series
Power
Cooler Master Real Power M620
Case
Thermaltake Armor+ LCS
Posted in Hardware | Leave a comment

Fonera 2.0n hardware

Model Name
FON2303
Dimensions
30 mm x 157 mm x 127 mm (excluding antenna)
Power
12VDC, 1A (It seems to work with 6VDC)
Ports
#1 – USB 2.0/1.1
#1 – Ethernet WAN 10/100Mbps
#4 – Ethernet LAN 10/100Mbps
Antennas
#2 – 3dBi Dipole Fixed Antennas
CPU
SoC Ralink RT3052F 320/384 MHz MIPS24KEc
RAM
64 MB – (32 MB cpu internal + 2×16 MB external PSC A3V56S40ETP-G6)
Flash
8 MB – MX29LV640DBTC-90G

External links:
Product briefing
RT3052F CPU Ref.
Ralink ApSoC SDK 3301
SDK User’s manual
MX29LV640DBTC-90G

Posted in Fonera, Hardware | Leave a comment