Random Noise

cat /dev/random >> /dev/dsp

Linksys EA9500 GPIOs

leave a comment »

Function GPIO # Active Low/High
Reset Button 10 Active Low
WPS Button 3 Active Low
WPS LED 22 Active Low
WIFI Button 16 Active Low
WIFI LED 0 Active Low
USB0 LED 1 Active Low
USB1 LED 2 Active Low
LOGO_LED 4 Active High
WHITE_BARS_LED 5 Active High
BLUE_BAR1_LED 12 Active High
BLUE_BAR2_LED 13 Active High
BLUE_BAR3_LED 15 Active High -> Low
BLUE_BAR4_LED 18 Active High
BLUE_BAR5_LED 19 Active High
BLUE_BAR6_LED 20 Active High
BLUE_BAR7_LED* 21 Active High
BLUE_BAR8_LED 8 Active High
USB0Enable 13 Active High
USB0Enable 14 Active High


*Next Hardware iteration will use GPIO 23 for BAR7_LED


Written by Vivek Unune

February 2, 2017 at 8:53 pm

Posted in linux, openwrt

Tagged with , , , , ,

Linksys EA9500 Stuff

with 6 comments

Firmware Source: 


Hardware Info:

CPU Broadcom BCM4709C0KFEBG dual-core @ 1.4 GHz
Switch in BCM4709C0KFEBG & BCM53125
RAM 256 MB
Flash 128 MB
2.4 GHz Radio BCM4366 4×4 2.4/5G single chip 802.11ac SoC
Skyworks SE2623L 2.4 GHz power amp (x4)
5 GHz radio BCM4366 4×4 2.4/5G single chip 802.11ac SoC
RFMD RFPA5542 5 GHz PA module (x4)
NOTE: There are two 5 GHz radios.
PCIe PLX Technology PEX8603 3-lane, 3-port PCIe switch

Serial Port:


Possible JTAGs:

Blue seems to be the possible JTAG for BCM4709 SoC

Green, Red and Purple seem to be related to the BCM4366 radio SoCs.


Flash Layout:

Notice this router has two copies of the firmware. You can force the router to boot from one or the other by partially booting the router 3 times.

cat /proc/mtd:
 dev: size erasesize name
 mtd0: 00080000 00020000 "boot"
 mtd1: 00180000 00020000 "nvram"
 mtd2: 01d00000 00020000 "linux"
 mtd3: 01ad2504 00020000 "rootfs"
 mtd4: 03300000 00020000 "linux2"
 mtd5: 030d245c 00020000 "rootfs2"
 mtd6: 02e00000 00020000 "brcmnand"

You can confirm partial boots from CFE/NVRam

CFE> nvram show | grep -i boot



Found a Toshiba NAND flash:
Total size: 128MB
Block size: 128KB
Page Size: 2048B
OOB Size: 64B
Sector size: 512B
Spare size: 16B
ECC level: 8 (8-bit)
Device ID: 0x98 0xf1 0x80 0x15 0xf2 0x16
find_devinfo: devinfo block found at 0x00180000!


CFE> show devices
Device Name          Description
-------------------  ---------------------------------------------------------
uart0                NS16550 UART at 0x18000300
uart1                NS16550 UART at 0x18000400
nflash0              Toshiba NAND flash size 131072KB
nflash0.boot         Toshiba NAND flash offset 0 size 512KB
nflash0.nvram        Toshiba NAND flash offset 80000 size 1024KB
nflash0.devinfo      Toshiba NAND flash offset 180000 size 512KB
nflash0.trx          Toshiba NAND flash offset 200000 size 1KB
nflash0.os           Toshiba NAND flash offset 20001C size 29696KB
nflash0.trx2         Toshiba NAND flash offset 1F00000 size 1KB
nflash0.os2          Toshiba NAND flash offset 1F0001C size 29696KB
nflash1.boot         Toshiba NAND flash offset 0 size 512KB
nflash1.nvram        Toshiba NAND flash offset 80000 size 1024KB
nflash1.devinfo      Toshiba NAND flash offset 180000 size 512KB
nflash1.trx          Toshiba NAND flash offset 200000 size 29696KB
nflash1.trx2         Toshiba NAND flash offset 1F00000 size 29696KB
nflash1.brcmnand     Toshiba NAND flash offset 3C00000 size 69632KB
eth0                 Broadcom BCM47XX 10/100/1000 Mbps Ethernet Controller

VLAN Configs:

br0_ifnames=vlan1 eth1 eth2 eth3
vlan2ports=4 8
fwd_wlandevs=eth1 eth2 eth3
lan_ifnames=vlan1 eth1 eth2 eth3
vlan1ports=2 1 3 0 5 7 8*
evlan1ports=0 2 4 1 3 8
landevs=vlan1 wl0 wl1 wl2





Board Info:



CFE boot options

boot -raw -z -addr=0x8000 -max=0xef8000 nflash0.os2

root=/dev/mtdblock2 console=ttyS0,115200 init=/sbin/preinit earlyprintk debug blueLED=1


Flashing Custom Firmware is possible

1. Set machines IP to with Gateway =
2. Run Putty and connect to serial port (115200 8-bits per character, no parity, and 1 stop bit)
3. Ctrl+C to CFE prompt
4. Run TFTP Server and point to to use it as server address.

5. Click Show Dir and select the file the transfer and click “Copy”
6. On CFE console type following commands one at a time and wait for each of them to finish. Make sure Image is not more than 28MB for this router or else you end up overwriting important partitions.

CFE> flash -noheader nflash0.trx
CFE> flash -noheader nflash1.trx

I tried to flash a generic dd-wrt firmware. It did boot however got kernel panics as expected.

Written by Vivek Unune

February 1, 2017 at 9:44 pm

Posted in Hardware, linux, openwrt

Tagged with , ,

Print TRX Header (Router Firmware)

leave a comment »

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TRXHeader
    public UInt32 Magic;                 /* "HDR0" */
    public UInt32 Len;                   /* Length of file including header */
    public UInt32 CRC32;                 /* 32-bit CRC from flag_version to end of file */
    public UInt16 Flag;                  /* flags */
    public UInt16 Version;               /* version */
    public UInt32 LzmaLoaderOffset;
    public UInt32 KernelOffset;
    public UInt32 RootFSOffset;
    public UInt32 BinHeaderOffset;       /* Only valid for V2 */

void Main()

public static void PrintTRXHeader(string path)
    using (FileStream fileStream = new FileStream(path, FileMode.Open, System.IO.FileAccess.Read))
        Console.WriteLine("\r\n************ {0} ***************\r\n", path);

        var header = fileStream.ReadStruct<TRXHeader>();
        Console.WriteLine("TRX Magic = 0x{0:X}", header.Magic);
        Console.WriteLine("File Length = {0}", header.Len);
        Console.WriteLine("CRC = 0x{0:X}", header.CRC32);
        Console.WriteLine("Flag = {0}", Convert.ToString(header.Flag, 2));
        Console.WriteLine("Version = {0}", header.Version);
        Console.WriteLine("LzmaLoaderOffset = 0x{0:X}", header.LzmaLoaderOffset);
        Console.WriteLine("KernelOffset = 0x{0:X}", header.KernelOffset);
        Console.WriteLine("RootFSOffset = 0x{0:X}", header.RootFSOffset);
        Console.WriteLine("BinHeaderOffset = 0x{0:X}\r\n", header.BinHeaderOffset);

public static class StreamExtensions
    public static T ReadStruct<T>(this Stream stream) where T : struct
        var sz = Marshal.SizeOf(typeof(T));
        var buffer = new byte[sz];
        stream.Read(buffer, 0, sz);
        var pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
        var structure = (T)Marshal.PtrToStructure(
            pinnedBuffer.AddrOfPinnedObject(), typeof(T));
        return structure;

Written by Vivek Unune

February 1, 2017 at 8:34 pm

Posted in .NET, Hardware, openwrt

Tagged with , ,

BDA Graph using GraphEdit for Genpix

leave a comment »

genpix-graph genpix-graph-2

Pictures speak thousand words.

Written by Vivek Unune

January 1, 2013 at 4:53 pm

Posted in VC++

Tagged with ,

ssh: Server refused our key

leave a comment »

I know you must be banging your head against the wall over this. I did.

Make sure use are logged in as the user you want to give ssh permission to:

su sshuser
cd ~/

All you need to do is fix the permissions and owner on .ssh and authorized_keys:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chown sshuser:sshuser ~/.ssh
chown sshuser:sshuser ~/.ssh/authorized_keys

This should do the work.

Written by Vivek Unune

December 17, 2012 at 4:47 pm

Posted in linux

Tagged with , ,

Windows 8 or not to Windows 8

leave a comment »

I clearly remember how exited I was when I got the Windows XP Beta CD with one of the magazines my friend use to subscribe (BYTE?). I used Windows 98 then. And I knew in and out of the OS like nothing else. After observing the UI overhaul in XP I was truly impressed. I actually use to peek inside the system dlls for cool icons shipped with XP.

Fast Forward 10 years and I’m in same situation. After using Windows 7 for over 2 years – I have my brain wired to it. And I love it. I have a win7 on laptop and HTPC which run 24/7. With dedicated linux NAS to store media. Windows 8  RTM was out on MSDN over two months ago, immediately I wanted to take it for a spin. So, I installed it on my HTPC. After two months all I can say is that the pain is unbelievable!

1. Start button – I must be the millionth person to say this. Listen MS – ability to view installed applications and quickly access it is necessary. Now you would argue you can do the same from Metro screen. No – it takes up lot of scrolling and searching for the “tile” and trying to recognize the icon for that application! I end up creating shortcuts of all the frequent programs on desktop -which is ugly. Even my wife misses the start button utterly. Utter pain without it.

2. Take me directly to desktop if I’m using a desktop! – Why do we have the metro welcome/lock screen? Then again I have to go through the metro apps screen to get to desktop!

3. Dropping out the HD codecs and filters! – the whole idea of skipping the hd codecs was pretty lame on MS part. I have a sizable bluray and hd library stored on NAS. With AV receiver and a flat screen hooked to the HTPC – it needs hd codecs out of the box to play these files. After the first day of installation – my wife got frustrated as to why those files aren’t working anymore. She resorted to the win7 laptop instead. When I was back from work I had to install FFDshow filters to get the files to work. Seriously MS – if people have to end up using opensource directshow filters why bother paying for windows at all. I will be more than happy to install Ubuntu or Openelec (XBMC).

4. I’m a power user and let me control my machine – The biggest gripe that I have is getting things done. It has become difficult on Windows 8 to perform day-today activities. Like accessing Control Panel, Searching for files, Shutting down PC, Restarting it, accessing Device manager etc. It is a desktop not a tablet. I was so use to accessing the search. running any app was just few keys away! Why take out the search? Why is Shut Down under Settings?

5. Mouse vs. touch gestures – When I park my mouse at right edge of the desktop it shows me unnecessary options. Also while trying to close a window using the ‘x’,  the options shows up. Again while trying to open the first app (windows explorer) on the task bar. It is not only confusing but frustrating. If I’m using a desktop and when I have no devices that support touch guestures – why does windows enable touch gestures?

After two months of using Win8, yesterday I went back to Windows 7.

Written by Vivek Unune

October 25, 2012 at 9:08 pm

Posted in Uncategorized

Managing personal media and Custom NAS

with one comment

For over a year I used Buffalo Linkstation Duo Pro with 2x1TB mirrored drives. It served me well, but it was starting to gradually fill up – pictures, videos, taxes/documents, more pictures. And there were other things I wanted to move from my local drives, but still needed them to be accessible on-demand – ISOs – Linux, Windows, IDE installers, Old code etc. And then was wife’s music collection, docs etc.

Judging from above I came up with following requirements:

1. At least 4-6TB space. Future proof for 3-4 years
2. Gigabit Network Capable. I’m done with slooow speed NAS
3. Expandable. Add more space as needed.

There were three options available:
Plan A – Buy new NAS drive(s) – solves the problem for now. Average cost $300
Plan B – Build a new low power PC, install FreeNAS or something similar. Move the old NAS drives to this and add more drives. Around $300-$500
Plan C – Purchase Cloud Storage subscription – varies, from monthly to year plans.

Considering the requirements, clearly my options were limited to Plan B. Plan A and Plan C were pre-baked solutions that did not offer me what I really needed. Plan B meant I needed to spend some time for this project.


I’m a big fan of Micro Center because I can pickup components as and when I need them. Also, they offer pretty good deals and match NewEgg’s prices – minus the shipping costs. Returning stuff is hastle free as well.

So I started looking for best motherboard to get the job done. Essentially, I was looking for a mordern (but not latest and greatest) mobo that had 6 SATA ports, on board graphics chip and a gigabit ethernet. So, I picked up the cheapest one – Gigabyte GA-78LMT-S2P for $43 after MIR, Sempron 145 – 45W, Diablotek EVO Mid Tower ATX case, a 500W power supply and 2x1TB drives.

After spending sometime with the board, I realized that there is a known issue with the GA-78LMT-S2P – it fails to recognize the drives when switched to AHCI mode!! So back I returned it and got the next in line Asrock 880GM-LE FX. This one cost me $10 more, but has a better graphics chip (HD 4250). Not that I would need it. I installed the CPU and spare 4GB ram that I had. Sempron’s can be unlocked to a dual core CPUs, this one didn’t. But that was OK since I needed less power hungry machine. Then I plugged in four drives (500GB, 750GB, 2x1TB new drives)


I Initially installed FreeNAS on a 8GB flash drive. Now, all my drives were ntfs and soon enough I ran into issues. Drives were failing to mount since they had errors – threre is no way to fix them on linux. These needed to be fixed by connecting them to a windows machine and running CHDISK /force. I took a step back(read below), and thought that if all my drives are ntfs why not run windows instead? More over Windows 8 has this new feature so that you can run it off a usb drive!

New requirement:

At least 32GB is needed for Windows-To-Go. Which meant I need to buy a 32GB flash drive. So I did – Sandisk Glide 32 GB. Installing windows 8 on the flash drive is real pain. With help of GImageX you can copy the install.wim image on to the flash drive. The copy took around 90 minutes!! Argh! Booting from the flash drive and initial setup took around 30 minutes more! Also, using windows-to-go is really really really slow. I cannot stress it enough. Partly the issue was the Sandisk Glide drive but I think more due to how windows worked. It kept hammering the flash drive. I read that USB 3.0 will improve the speed a little and in any case my 880GM-LE FX board didn’t have it. Finally I gave in.

So where was I? I have to convert all my drives to etx3/4 and move around few TB of data. Before I returned the 32GB flash drive, I CHDISK’d all my drives so at least they would mount on FreeNAS PartedMagic. Then I connected the new drives, formatted them to ext4 and copied over the data to new drives, formatted the nas drives to ext4 and copy back the data from new drives. Same for the old 500GB and 750GB – rinse repeat.

FreeNAS vs OpenMediaVault:

In short, OpenMediaVault is what you want. Stable, functional and actively developed.
Returned the dreadfully slow Sandisk Glide and installed OpenMediaValut on 8GB Kingston G3 drive.
Configured the shares and ftp. For detailed setup please read this blog


The last but not the least goal was to have gigabit copy speeds. I set the 9K MTU on the interface using the web interface and I was all set. I get around 80Mb/s copy speeds which I’m pretty satisfied.


I ended up removing the 500GB drive and moving all the important documents to it. I will pair that with another 500GB in a Raid 0 configuration. With 5 drives, I now have almost 4.75 TB of space. With 5 more drive slots to go  – it can continue to expand as needed.

As an engineers we are always on a quest to solve problems and in the process we sometimes over-engineer things. I think this to be true in this case. However, the new NAS would be good for another 3-4 years.

Written by Vivek Unune

September 4, 2012 at 6:12 pm

Posted in linux, NAS