Interesting Hardware Issue: Photoelectric Effect on R Pi 2

Recently Raspberry Pi 2 released. One of the user trying to take a photo of his board (at that time board in running condition). When his camera flash went off, board power also went off. After testing few times, user posted this issue in the forum. R Pi team analysed and found out an interesting hardware issue – Photoelectric Effect Issue (similar to ESD in early days).

Read this blog: http://www.raspberrypi.org/xenon-death-flash-a-free-physics-lesson/

Posted in Uncategorized

Intel NUC – Tiny but powerful

Today I brought one Intel NUC for experiment purpose. Totel cost is ~1K SGD (NUC-i5, 16GB RAM, 250GB mSATA SSD, 1TB 2.5″ HDD).

Performance is okay. Remember not to compare the NUC processor (less speed and less cache) with regular i5 processors. Max RAM is 16GB. Tested with Win8.1, Ubuntu 14.04 and running few VMs also on it. Slit lag during heavy operations like starting VM. Otherwise okay.

IMG_20150129_185939

IMG_20150129_190048

IMG_20150129_194604

Posted in Uncategorized

Porject Ara – DevConf @ SG

Today, I manage to reach the Google Project Ara – DevConf by 10:30AM. Interesting talks and Ideas. Met interesting people like Greg Kroah-Hartman, George Grey, Ara Team. Saw interesting modules like Pluggable camera, UniPro Bridge Chip, Blood Glucometer, Water Tester, Processor module, etc. The ProjectAra DevBoard is not yet ready for pure software development. If you are a core hardware developer with interesting idea, you can apply for DevBoard loan.

Posted in Uncategorized

LDAP: Multiple Provider URLs

The LDAP service provider uses this URL to configure its connection to the directory server. Only the host, port, and dn parts of the URL are relevant in this setting. Supplying other parts of the URL results in a ConfigurationException(in the API reference documentation). Most commonly we use just one URL. But we can also supply a space-separated list of URLs. In this case, the LDAP provider will attempt to use each URL in turn until it is able to create a successful connection. How to determine, on which server, are we connected to?? The LDAP provider set Context.PROVIDER_URL property to the successful URL, so that the application can determine which URL is being used. Here is an example of how to specify a list of URLs.

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, “com.sun.jndi.ldap.LdapCtxFactory”);

// Specify list of space-separated URLs
env.put(Context.PROVIDER_URL, “ldap://host1:389/o=JNDITutorial ” + “ldap://host2:389/o=JNDITutorial ” + “ldap://host3:389/o=JNDITutorial ” + “ldap://host4:389/o=JNDITutorial”);

// Create initial
context DirContext ctx = new InitialDirContext(env);

// See which server was used
System.out.println(ctx.getEnvironment().get(Context.PROVIDER_URL));

For more info: http://docs.oracle.com/javase/jndi/tutorial/ldap/misc/url.html

Posted in Uncategorized

Find the Yesterday

On GNU/Linux platform finding the particular date from current date is a no brainer task. For example:

Yesterday: date –date=’yesterday’
Nextday: date –date=’next day’ OR date –date=’tomorrow’
Other Tricks:
date –date=’10 year’
date –date=’10 year ago’
date –date=’this sunday’

But on Solaris, you don’t have this luxury. So you can use the following trick:
TZ=GMT+24 date

Tagged with: , ,
Posted in Uncategorized

Android Udev Rules

Linux Udev rule file to interface Android Hardware for Application/System development.

# Acer 0502
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", GROUP="plugdev"
# ASUS 	0b05
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="plugdev"
# Dell 	413c
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", GROUP="plugdev"
# Foxconn 	0489
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="plugdev"
# Fujitsu 	04c5
# Fujitsu Toshiba 	04c5
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", GROUP="plugdev"
# Garmin-Asus 	091e
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", GROUP="plugdev"
# Google 	18d1
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
# Haier 	201E
SUBSYSTEM=="usb", ATTR{idVendor}=="201e", MODE="0666", GROUP="plugdev"
# Hisense 	109b
SUBSYSTEM=="usb", ATTR{idVendor}=="109b", MODE="0666", GROUP="plugdev"
# HTC 	0bb4
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
# Huawei 	12d1
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
# K-Touch 	24e3
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666", GROUP="plugdev"
# KT Tech 	2116
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666", GROUP="plugdev"
# Kyocera 	0482
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666", GROUP="plugdev"
# Lenovo 	17ef
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", GROUP="plugdev"
# LG 	1004
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
# Motorola 	22b8
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
# MTK 	0e8d
SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev"
# NEC 	0409
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666", GROUP="plugdev"
# Nook 	2080
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666", GROUP="plugdev"
# Nvidia 	0955
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", GROUP="plugdev"
# OTGV 	2257
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666", GROUP="plugdev"
# Pantech 	10a9
SUBSYSTEM=="usb", ATTR{idVendor}=="10a9", MODE="0666", GROUP="plugdev"
# Pegatron 	1d4d
SUBSYSTEM=="usb", ATTR{idVendor}=="1d4d", MODE="0666", GROUP="plugdev"
# Philips 	0471
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666", GROUP="plugdev"
# PMC-Sierra 	04da
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666", GROUP="plugdev"
# Qualcomm 	05c6
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
# SK Telesys 	1f53
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666", GROUP="plugdev"
# Samsung 	04e8
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
# Sharp 	04dd
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", GROUP="plugdev"
# Sony 	054c
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666", GROUP="plugdev"
# Sony Ericsson 	0fce
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="plugdev"
# Teleepoch 	2340
SUBSYSTEM=="usb", ATTR{idVendor}=="2340", MODE="0666", GROUP="plugdev"
# Toshiba 	0930
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666", GROUP="plugdev"
# ZTE 	19d2
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"
Tagged with: , ,
Posted in Uncategorized

Netbeans: Headers to Java File

In the Netbeans IDE, whenever you create a project/file, it adds the following header.

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

Here we will see, how to change or customize this header to suit our needs.

  • Select Tools -> Templates -> Template Manager
  • Change the License statement
    • Select: Licenses -> Default License
    • Click the “Open in Editor” Button, Remove the existing text and add the following lines:

<#if licenseFirst??>
${licenseFirst}
</#if>
${licensePrefix} (c) ${date?date?string(“yyyy”)} Your/ Company Name
<#if licenseLast??>
${licenseLast}
</#if>

  • Save
  • Change the Program Header
    • Java -> Java Main class
    • Click the “Open in Editor” Button
    • Replace the following lines:

 /**
* @author ${user}
*/

  • With this lines:

/**
* File Name:    ${nameAndExt}
* Project Name: ${project.name}
*
* @since  ${date}, ${time}
* @author ${user}
*
* File Description:
* Provide a 2 line short description.
**/

  • Save
  • Repeats the previous step, for the following templates also:
    • Java Class
    • Java Interface
    • Java Singleton Class
    • Java Exception
  • Set Proper User Name: In Template Manager, Click the “Settings” Button and add the following line:

   user=Your Full Name <Your_Mail_Id@domain.com>

Tagged with: ,
Posted in Uncategorized

HP V1910 L3 Switch – Review

My experience with HP L3 Switch (formally 3Com) V1910 (16 and 24 Ports)

Pros:

  1. Low cost. It is a simple smartly managed switch.
  2. HP Support (so for so good)
  3. Suitable for simple /24 based network

Cons:

  1. Only web based interface. It can be accessed from any VLAN interface with IP. Normally, it is allowed only from Management VLAN. So may not be suitable for public IP routing.
  2. Some compatibility issue with Cisco Router. No documentation.
Tagged with: , ,
Posted in Uncategorized

Solaris 10: Replace the failed mirrored Boot Disk

I was lucky to identify Disk IO Error in one of our SunFire v215. The Disk contains the boot-able partition. So I have to replace ASAP. Here is the steps, that I followed to replace the failed mirror root disk.

System is having 4 disks. Disks are RAID1 mirrored (1+1). Partitions are UFS. (Not ZFS).

  • Mirror 1 – Boot-able
  • Disk 1 (c0t0d0)
  • Disk 2 (c0t1d0)  <- Failed Disk
  • Mirror 2 – Data
  • Disk 3 (c1t0d0)
  • Disk 4 (c1t0d0)

Steps:

  1. Check the mirror status:
    • metastat -ac — Disk contains the partitions with (maint) are in the trouble.
    • iostat -En — Shows if there is any errors
  2. Important note
    • Don’t reboot, if s0 in “maint” state and md:mirrored_root_flag=1 not set in /etc/system file.
    • If you have chance to reboot the system, then do the following before the reboot
    • echo “set md:mirrored_root_flag=1” >> /etc/system
    • echo “set md_mirror:md_resync_bufsz = 2048” >> /etc/system
  3. Problem is conformed and Replacement disk is ready in the hand
    • metadb -i — Get metadb locations
    • cfgadm -al — Get disk config detail and Note down faulty disk detail
  4. Detach the faulty disk from the mirror
    • metadetach -f  d0 d20 — Detach the sub mirror d20 from mirror d0 and do the same for other mirrored slices (s1, s5, s7)
    • metaclear d20 — Clear sub mirror and do the same for other slices
    • metastat -ac — Just to verify
  5. Remove the faulty disk from the mirror
    • metadb -d c0t1d0s3 — In my case, Metadb in slice 3. you can get this info from metadb -i command
  6. Format the disk
    • As per your company policy, if you need to format the disk. You can do it now. Warning: Format may take 2 Hrs or more.
    • format
  7. Detach the faulty disk from OS
    • cfgadm -c unconfigure c0::dsk/c0t1d0
    • cfgadm -al — Just to conform, check faulty disk is unconfigured
    • Blue light should be ON. Now you can replace the disk.
  8. Attach the new disk to OS
    • cfgadm -c configure c0::dsk/c0t1d0 — Attach the disk
    • cfgadm al — Verify
  9. Copy the partition table to new disk
    • prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s – /dev/rdsk/cot1dos2
    • installboot /usr/platform/`uname -`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
  10. Create meta db in the new disk
    • metadb -c 2 -a c0t1d0s3
  11. Create and attach sub mirrors in the new disk as RAID1
    • metainit d20 1 1 c0t1d0s0 — Do the same for other slices (s1, s5, s7)
    • metattach d0 d20 — Do the same for the other slices (s1, s5, s7)
  12. Now mirror will starts sync the data between disks.
    • metastat -ac

 

Tagged with: , ,
Posted in Uncategorized

Retail MAC Calculation in Java

The following java code shows Cryptographic checksum calculated using ISO/IEC 9797-1 MAC algorithm 3 with block cipher DES, zero IV (8 bytes), and ISO/IEC 9797-1 padding method 2. No external library like Bouncy Castle, used.

public byte[] retailMac(byte[] key, byte[] data) {
 int loc = 0;
 byte[] edata;
 // Create Keys
 byte[] key1 = Arrays.copyOf(key, 8);
 byte[] key2 = Arrays.copyOfRange(key, 8, 16);

 // ISO/IEC 9797-1 or ISO 7816d4 Padding for data (adding 80 00 ..)
 byte[] pdata = pad-iso-7816d4(data, 8);

 try {
  SecretKey ka = new SecretKeySpec(key1, "DES");
  Cipher cipherA = Cipher.getInstance("DES/CBC/NoPadding");
  cipherA.init(Cipher.ENCRYPT_MODE, ka, new IvParameterSpec(new byte[8]));

  SecretKey kb = new SecretKeySpec(key2, "DES");
  Cipher cipherB = Cipher.getInstance("DES/CBC/NoPadding");
  cipherB.init(Cipher.DECRYPT_MODE, kb, new IvParameterSpec(new byte[8]));

  // Encrypt block by block with Key-A
  edata = cipherA.doFinal(pdata);

  byte[] x = new byte[8];
  for (loc = 0; loc < pdata.length; loc += 8) {
    System.arraycopy(pdata, loc, x, 0, 8);
    byte[] y = xor-array(edata, x);
    edata = cipherA.doFinal(y);
  }

  // Decrypt the resulting block with Key-B
  edata = cipherB.doFinal(edata);
  // Encrypt the resulting block with Key-A
  edata = cipherA.doFinal(edata);
 } catch (Exception e) {
  e.printStackTrace();
  return null;
 }
 return edata;
} 

This is not a perfect code, like repeated XOR part can be replaced by single doFinal.

Tagged with: ,
Posted in Uncategorized
Follow

Get every new post delivered to your Inbox.