Thursday, December 18, 2014

Bus Pirate SPI Protocol Analyzer Training


Hardware overview


SOIC Version
  

Last Version


 

  

1. Mini-B USB port. Connects the Bus Pirate to a PC. The Bus Pirate draws power from the USB port, and uses the data connection to communicate with the PC.
2. USB transmit indicator. This LED flashes when there's traffic from the PIC to the PC.
3. Power indicator. This LED lights when the Bus Pirate is powered by the USB supply.
4. Mode indicator. This LED lights when the Bus Pirate is configured for a protocol mode from the user terminal (menu 'm'). The I/O pins might be active when the mode indicator is on. The pins should be in a safe, non-powered, high-impedance state when the mode LED is off.
5. Voltage regulator indicator. This LED lights when the on-board power supplies have been activated from the user terminal (command capital 'W' ).
6. I/O pins. This 2x5 block of 0.1" pin header connects the Bus Pirate to external circuits. See the pinout table below, or the Bus Pirate manual.


 Image shows Colors from BusPirate ProbeKit available at Seeed Studio on latest Version
Bus Pirate - IO Pins
Pin NameDescription (Bus Pirate is the master)
MOSIMaster data out, slave in (SPI, JTAG), Serial data (1-Wire, I2C, KB), TX* (UART)
CLKClock signal (I2C, SPI, JTAG, KB)
MISOMaster data in, slave out (SPI, JTAG) RX (UART)
CS*Chip select (SPI), TMS (JTAG)
AUXAuxiliary IO, frequency probe, pulse-width modulator
ADCVoltage measurement probe (max 6volts)
VpuVoltage input for on-board pull-up resistors (0-5volts).
+3.3v+3.3volt switchable power supply
+5.0v+5volt switchable power supply
GNDGround, connect to ground of test circuit
Notes: * TX moved from CS to MOSI in firmware v0g
7. In circuit serial programming (ICSP) header. This 1x5 block of 0.1" pin header is the programming connection for the PIC 24FJ64GA002 microcontroller. These pins can be used to write new firmware to the microcontroller with a programmer like the PICKIT2 or ICD2 . The Bus Pirate firmware can also be updated over the USB connection using a bootloader, so the ICSP header is normally only used to program it the first time at the factory. Put a jumper between the PGC and PGD pins to trigger the on-board bootloader for firmware updates.
8. Serial terminal (ST) header. Version v2go only. This unpopulated header is a tap into the UART connection between the PIC microcontroller and the FTDI 232BL chip that provides the USB connection. The Bus Pirate firmware defaults to a 115200bps/8/N/1 UART.
 

FTDI driver install and configuration

ftdi-driver
Windows will request a driver the first time the Bus Pirate connects to a PC. Extract the 2.08.28 virtual com port drivers from FTDI into a folder and browse to them using the 'Found New Hardware' wizard. Note: the 2.08.30 drivers gave some people connection errors between the Windows terminal and the Bus Pirate. For now we advise to install the 2.08.28 drivers. Install guides and drivers for other systems are also available on the FTDI driver download page.
com-port
To find the COM port number assigned to the Bus Pirate go to the Windows device manager (Start->Settings->Control panel->System->Hardware->Device manager). Look in 'Ports (COM & LPT)' for 'USB Serial Port', ours is COM5.
com-port-change.ii
You can change the serial port assigned to the FTDI chip. Go to USB Serial Port properties->Port settings tab->Advanced, change the COM port in the drop-down box.

Terminal setup

Windows terminal is cranky, but it appears to work with the Bus Pirate when VT100 emulation is enabled. We highly recommend a better terminal, we like Tera Term Profor Windows.
Teraterm-setup2.png
First, configure the correct COM port and settings. The Bus Pirate operates at 115200bps/8/N/1 on the COM port assigned by Windows. Flow control is no longer required. Disable it!
tt-setup2
Next, check the terminal setup. Turn off local echo and use a VT100 terminal type. The Bus Pirate should work with any type of new-line character, but we use the CR setting.

Get to know the terminal interface


The Bus Pirate is controlled by text commands entered through the serial terminal. If the terminal is blank, press enter to show the command prompt. Press '?', followed byenter, to show the help menu.
  • Menus configure various Bus Pirate options like pull-up resistors, terminal speed, data display format (DEC, HEX, BIN), etc. Type the menu command, followed byenter, to display the options.
  • Syntax is used to interact with a device connected over a bus. Commands are mostly single characters, such as 'r' to read a byte. Enter up to 4000 characters of syntax, press enter to execute the sequence.
Each menu and syntax option is documented fully in the Bus Pirate manual.
Most menus have a default option shown in () before the prompt:
Output type:
1. High-Z outputs (H=input, L=GND)
2. Normal outputs (H=Vcc, L=GND)
(1) > <<< option 1 is the default
Press enter to select the default option.

Bus modes, protocol libraries

?
General                                 Protocol interaction
---------------------------------------------------------------------------
?       This help                       (0)     List current macros
=X/|X   Converts X/reverse X            (x)     Macro x
~       Selftest                        [       Start
#       Reset                           ]       Stop
$       Jump to bootloader              {       Start with read
&/%     Delay 1 us/ms                   }       Stop
a/A/@   AUXPIN (low/HI/READ)            "abc"   Send string
b       Set baudrate                    123
c/C     AUX assignment (aux/CS)         0x123
d/D     Measure ADC (once/CONT.)        0b110   Send value
f       Measure frequency               r       Read
g/S     Generate PWM/Servo              /       CLK hi
h       Commandhistory                  \       CLK lo
i       Versioninfo/statusinfo          ^       CLK tick
l/L     Bitorder (msb/LSB)              -       DAT hi
m       Change mode                     _       DAT lo
o       Set output type                 .       DAT read
p/P     Pullup resistors (off/ON)       !       Bit read
s       Script engine                   :       Repeat e.g. r:10
v       Show volts/states               .       Bits to read/write e.g. 0x55.2
w/W     PSU (off/ON)            //<0>   Usermacro x/assign x/list all
HiZ>m 
<<< bus mode menu
1. HiZ
2. 1-WIRE
3. UART
4. I2C
5. SPI
6. 2WIRE
7. 3WIRE
8. LCD
9. DIO
x. exit(without change)

The 'bus mode' menu (M) configures the Bus Pirate for a specific protocol, like 1-Wire, I2C, SPI, etc. The default start-up mode is HiZ, all pins are inputs and all power supplies are off.


(1)>5 
<<< enter SPI bus modeSet speed:
 1. 30KHz
 2. 125KHz
 3. 250KHz
 4. 1MHz

(1)>1
Clock polarity:
 1. Idle low *default
 2. Idle high

(1)>1
Output clock edge:
 1. Idle to active
 2. Active to idle *default

(2)>2
Input sample phase:
 1. Middle *default
 2. End

(1)>1
CS:
 1. CS
 2. /CS *default

(2)>2
Select output type:
 1. Open drain (H=Hi-Z, L=GND)
 2. Normal (H=3.3V, L=GND)

(1)>2  
<<< option 1 is the default
Ready
SPI>W
Power supplies ON
SPI>w
Power supplies OFF
SPI>V
Syntax error at char 1
SPI>v
Pinstates:
1.(BR)  2.(RD)  3.(OR)  4.(YW)  5.(GN)  6.(BL)  7.(PU)  8.(GR)  9.(WT)  0.(Blk)
GND     3.3V    5.0V    ADC     VPU     AUX     CLK     MOSI    CS      MISO
P       P       P       I       I       I       O       O       O       I
GND     0.00V   2.43V   0.00V   0.00V   L       L       L       H       L
SPI>W
Power supplies ON
SPI>


Power supplies
3.3volt and 5volt on-board power supplies can provide up to 150mA for your project. Activate them with the w/W command from any mode except HiZ mode. HiZ mode is a safe mode and all outputs are disabled.
I2C>w<<
POWER SUPPLIES OFF
I2C>v<<
Voltage monitors: 5V: 0.0 | 3.3V: 0.0 | VPULLUP: 0.0 |
I2C>W<<
POWER SUPPLIES ON
I2C>v<<
Voltage monitors: 5V: 4.9 | 3.3V: 3.2 | VPULLUP: 0.0 |
I2C>
Capital 'W' activates the on-board supplies, small 'w' turns them off. Turn the power supplies on, then press v to show a power supply voltage report.
Note that W is syntax and not a menu option, it can be used with other syntax to toggle the power in the middle of complex bus operations.
The power supplies will try to protect your project with over current protection. Additionally, the Bus Pirate will measure the voltage shortly after the supplies are enabled. If a short is detected it will disable them and show a warning. This may help minimize damage to a project when there is a short or problem on a new board.


Demo with AT25080A/160A/320A/640A on Aardvark I2cC/SPI Activity Board

 
Instruction Set for the AT25080A/160A/320A/640A
Instruction Name     Instruction Format Operation
WREN                     0000 0110              Set Write Enable Latch
WRDI                      0000 0100              Reset Write Enable Latch
RDSR                      0000 0101              Read Status Register
WRSR                     0000 0001              Write Status Register
READ                     0000 0011              Read Data from Memory Array
WRITE                   0000 0010              Write Data to Memory Array

A quick way to find the command to access a register:
  • Use the Bus Pirate to find the binary equivalent (= command)
SPI>[ 0000 0101 r]
Lower chip select ([), then setup the register to access(0x05), read a byte (r), and raise chip select (]).
/CS ENABLED
WRITE: 0x00
WRITE: 0x4D
READ: 0x00
/CS DISABLED


Open Logic Analyzer Client

http://www.lxtreme.nl/ols/







The Bus Pirate V3 can store 4kB of data and can sample at a maximum rate of 1MHz. In this example we analyzed
communication at 125kHz  on the aardvark so we need to set the speed at a fast enough rate to be able to capture
the transitions from high to low and low to high. It is recommended that you choose a sampling rate 10x your
communication rate but in reality it can be lower.



Click on the Trigger Enabled tick box to turn the triggers on.

At the bottom of this screen you will see Mask / Value tick boxes going from 0 to 31. Our Bus Pirate only has 5 logic inputs so 5 through to 31 are greyed out. Tick in the Mask boxes any inputs that you want a trigger enabled on. Value bits are currently ignored, any change triggers the capture.
For SPI select 0,1,2,3 where
























wget - Download a sub directory only

wget -r -l1 --no-parent http://www.domain.com/subdirectory/

-r: recursive retrieving
-l1: sets the maximum recursion depth to be 1
--no-parent: does not ascend to the parent; only downloads from the specified subdirectory and downwards hierarchy

Tuesday, September 23, 2014

iPhone 6 battery life

Overall Apple executed well on one of the most important feature : battery life ranking #1

http://www.tomsguide.com/us/iphone-6-battery-life,news-19591.html

Now after 2 days of excitements here is a fact that I discover on the iPhone 6 plus with iOS

Facebook is a battery hog!

Facebook background activity took away 24% of battery life for shit that most of the time I don't care about!

Facebook needs to come up with a real plan to add more settings in order to save battery life and data bandwidth as well if they want to move away from the #1 spot of worse battery usage!

Here is few features ideas :


  1. While roaming don't sync the news speed. When you are travelling and posting to facebook you don't want to sync the news feed. Actually you only want to post and access your home page eventually to confirm that your content was posted.
  2. Auto play video on mouse over os a stupid feature and should be turned off automatically while roaming.
  3. Add a feature to hide all pictures (no download) expect the one you just posted. Make more important facebook settings available through the OS/App settings option not some obscure settings inside the human interface within the phone app.




Monday, August 11, 2014

First-person Hyperlapse Videos @ SIGGRAPH

https://www.youtube.com/watch?v=sA4Za3Hv6ng

"We present a method for converting first-person videos, for example, captured with a helmet camera during activities such as rock climbing or bicycling, into hyperlapse videos: time-lapse videos with a smoothly moving camera.

This video accompanies our SIGGRAPH paper and provides a technical explanation of our system.

Check out our project page for more details:"

http://research.microsoft.com/hyperlapse

Wednesday, August 06, 2014

Adding new harddrive live to Ubuntu VMWARE image


Very useful after doing a repo sync on a gigantic repo...

Create the disks in the Virtual Infrastructure Client


Right click on the guest, click “Edit Settings…”

Under the “Hardware” tab, click “Add”

For the device type, select “Hard Disk”, click “Next”, and “Next” again

Specify the size of your disk, optionally enable Thin Provisioning, and click “Next”, “Next”, “Finish”, “Ok”


Re-scan the scsi bus for new hardware


cat /proc/partitions

Note the list of devices

sudo apt-get install scsitools

sudo rescan-scsi-bus.sh

cat /proc/partitions

See what devices got added


Format the new disk

Format the newly detected drive using fdisk

fdisk /dev/sdb

    n (for new partition)

    p (for primary partition)

    1 (partition number)

    (keep the other values default)

    w (write changes)

    

sudo mkfs -t ext3 /dev/


Add the devices to /dev/disk/by-uuid/


sudo partprobe

sudo blkid /dev/

Note the UUID


Add the new mount to /etc/fstab, and mount the filesystem


sudo vi /etc/fstab

mount -a 

Thursday, July 24, 2014

Housing Trends, Short and Long Term




SOURCE: ROBERT J. SHILLER, "IRRATIONAL EXUBERANCE," SECOND EDITION (PRINCETON UNIVERSITY PRESS), AS UPDATED BY AUTHOR 



By JEFF SOMMER
April 15, 2013

4/16/13 | Updated to reflect new figures on housing starts and building permits.
Home prices in the United States have been on a roller coaster ride for the last decade — soaring through 2005, then plunging in the steepest decline since the Great Depression. In 2012, though, prices began moving upward.
How solid is the incipient housing recovery, and what are the prospects for home prices in the decade ahead?
Some fresh clues about the short-term trends began arriving this week. And an analysis of the long-term prospects for home prices began appearing in a three-part series of columns in Sunday Business by Robert Shiller, the Yale economist.

First, the short-term trend: based, at least, on a report on Monday morning, it appeared to be taking a zigzag path rather than a straight line upward. According to the National Association of Home Builders/Wells Fargo Housing Market index, sentiment among home builders declined in April for the third consecutive month, to 42 from 44 the previous month. While that index climbed in 2012, it has not been above the neutral level of 50 since April 2006, when the market collapse was already under way.
In another report, on Tuesday — the tally of housing starts and building permits in March — Wall Street economists were expecting another set of strong numbers, but the picture was mixed. The Commerce Department said housing starts climbed to a 1.04 million annual rate, the fastest pace since June 2008, and up from a revised rate of 968,000 in February. But while construction surged for multifamily units — many intended as rentals — the building of single-family homes declined. And building permits over all fell 3.9 percent from the previous month.
Still, the short-term trend for the housing market seemed clear and strong enough for Michael E. Feroli, chief United States economist at JPMorgan Chase, to conclude in a report on April 10 that residential investment – including home building, repairs, renovation and brokers’ fees – would rise enough this year to add 0.5 percent to G.D.P. growth.

As for home prices, no major reports were imminent. But in the fourth quarter of 2012, the latest home period included in the Standard & Poor’s Case-Shiller 20-city index, prices rose sharply, at the fastest rate since June 2006.

Professor Shiller, who helped devise the Case-Shiller index, says in his Economic View column on Sunday even if the upward trend for prices continues for a while, historical data shows that it’s not necessarily meaningful over the long haul.
“One-year home price increases, after correcting for inflation, have had almost no statistical relationship to increases 10 years down the road,” he writes. “Thus, the upturn last year is irrelevant to long-run forecasting. Booms are typically followed by busts, usually in far less than 10 years. In a decade, an entire housing boom, if there is one in inflation-corrected terms, is likely to have been reversed and completely washed away.”

In assessing long-term price trends, he says, prospective home buyers ought to emphasize fundamental factors like inflation and construction costs, which he discusses in his first column. While inflation creates the illusion that real home prices are increasing, rising productivity in the construction industry often drives down the cost of housing.
Next Sunday’s column will deal with real estate bubbles, and with the speculative effects of years of declining interest rates on housing and other markets. The third will consider cultural and demographic trends, including the stimulative market influence of a rising population — and the potential constraints on prices that could occur as America ages..


Xiaomi's 49-inch Android TV boasts 4K for just $640

The Mi Pad wasn't Xiaomi's only announcement 2 months ago. Following the Chinese company's first smart TV from last September, 2 months ago it has unveiled a slightly larger model with a nice surprise: 4K for just CN¥3,999 or about $640! Like its affordable predecessor, this 49-inch TV comes with built-in Android (with MIUI TV skin), though you can easily side-load other TV apps. On the hardware side, you'll find a 4K 3D panel made by either LG or CSOT within a 6.2mm aluminum bezel, and underneath that lies a MediaTek MStar 6A918 chip (1.45GHz quad-core CPU, Mali-450 MP4 GPU) plus 2GB of RAM to drive all those pixels. On top of the built-in 8GB space, you also get to add up to 64GB of storage via microSD.


http://www.engadget.com/2014/05/15/xiaomi-mi-tv-2-4k/

Tuesday, July 22, 2014

libwebviewchromium.so is a memory hog Android 4.4.4_r1 inside Ubuntu 13 VM

A very good alternative is to install openbox which takes about 1/2 memory to load instead of standard ubuntu Windows Manager http://openbox.org/

target SharedLib: libwebviewchromium (out/target/product/hammerhead/obj/SHARED_LIBRARIES/libwebviewchromium_intermediates/LINKED/libwebviewchromium.so)
collect2: error: ld terminated with signal 9 [Killed]
make: *** [out/target/product/hammerhead/obj/SHARED_LIBRARIES/libwebviewchromium_intermediates/LINKED/libwebviewchromium.so]

When building inside a VM with Ubuntu VM in case you only created a swap partition of 2 GB, you need to add more swap because you need about 3GB of swap to link this monster libwebviewchromium...

1. Create empty file:
This file will contain virtual memory contents so make file big enough for your needs. This one will create 1Gb file which means +1Gb swap space for your system:
dd if=/dev/zero of=/var/swapfile.img bs=1024 count=3M
If you want to make 3Gb file then change count value to count=3M. See man dd for more information.
2. Bake swap file:
Following command is going to make "swap filesystem" inside your fresh swap file.
mkswap /var/swapfile.img
3. Bring up on boot:
To make sure that your new swap space is activated while booting up computer you should add it to filesystem configuration file 
/etc/fstab. Add it to end of file, this is recommended because other filesystems (at least one that contains swap file) must be mounted in read-write mode before we can access any files.
# Add this line to /etc/fstab
/var/swapfile.img swap swap sw 0 0

or

echo /var/swapfile.img none swap defaults 0 0 | sudo tee -a /etc/fstab


4. Activate:
You can either reboot your computer or activate new swap file by hand with following command:
swapon /var/swapfile.img

 If swapon fail please use sudo gparted and try to turn all swap partition off then on again 

If everything goes well
you should see that more swap space is available for use. You can use following commands to check your new swap and confirm that it is active:
cat /proc/swaps  
Filename                   Type       Size    Used    Priority
  /dev/sda5                partition  2094076 2094056 -1  
  /var/swapfile.img        file       4194300 383604  -2

grep 'Swap' /proc/meminfo
  SwapCached:        380992 kB
  SwapTotal:        6288376 kB
  SwapFree:         3838044 kB