Wednesday, August 10, 2016

Qualcomm bugs exposed nearly 1 billion Android devices

Qualcomm snapdragon cpu is a very popular ARM based SoC CPU used by many Android devices.

These are some of the popular mobile phone which use snapdragon:

Samsung Note 7, Snapdragon 820

OnePlus 3, Snapdragon 820

HTC 10, Snapdragon 820

Reference:

Qualcomm bugs expose nearly 1 billion Android devices to exploits, Extreme Tech.

Wednesday, June 15, 2016

Fighting with Ruby on Rails on old Snow Leopard


Finally I give it a try for Ruby on Rails. The first thing I want to do is install Ruby on Rails. According to the tutorial, I need ruby 1.9.3, then using ruby gem to install rails 2.3.2.

This is not a tutorial, but just show what doesn't works for me. You might not able to get you solution here.

There are a few ways to install Ruby on Rails on Mac OS X:
1. Use Gem on OS X system.
2. Homebrew
3. RVMß (this works for me)

Homebrew

Since then gem version (1.8.7) is a bit too old, I use homebrew to install.
$ brew install ruby
The gem came with ruby, use gem to install rails. Before install rails, I disable ruby document.
$ edit ~/.gemrc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
gem: --no-ri
gem: --no-rdoc

$ export GEM_HOME=$HOME/.gems
$ export PATH=$GEM_HOME/bin:$PATH

This suppose to be the way, unfortunately I can't get homebrew to compile ruby on OS X 10.6.

Compile from source

I try to compile from downloaded source, both ruby-2.3.1, ruby-2.3.0 are unable to compile successfully on my OS X 10.6.3. So I compile ruby on another machine with OS X 10.9 Mavericks, and copy the binary to OS X 10.6. The binary can't execute properly.

This really drive me crazy.

I try to use the system gem to install rails, but since the gem version is too old, it can't install the later rails.

RVM, Ruby Version Manager

Try Install ruby on rail with rvm version 1.27.0
$ curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --rails
OR just install ruby
$ curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --ruby
Ok
Finally the RVM works. The binaries installed in $HOME/.rvm directory

Note:

After some time later, I try to install ruby with homebrew again, and it works! I don't know what changes or configuration I have done.

$ ruby -v
ruby 2.3.1p112
$ gem -v
2.6.4
$ rails -v
4.2.6

Tuesday, June 09, 2015

How to create embedded Java 8

What is embedded java? Embedded Java is not J2ME (Java Micro Edition), is a normal java runtime in smaller size, suitable to be installed in embedded system.

Normal Java runtime is about 80-100Mb in size. The compact embedded java can be as small as 11Mb.

Started with Java 8 (or 1.8), Java use jrecreate to generate embedded java for specific target platform. The targeting platform is for ARM Linux and x86 Linux. It can be generated on a host with Linux or Windows (prefer to have 1Gb or memory?).

My target platform is DNS-320 with fun_plug hack. It is an ARM cpu (ARMv5TE with soft floating point), 128Mb ram (Yes, is 128Mb). You can create target for Raspberry Pi (with hard floating point).

You need a Java (JDK or JRE) on the host system. After generated, you can just move over the embedded JRE to the target platform.

Download Embedded Java from Oracle technical network.

For my case here, I use:

Embedded Java 1.8, ARM v5 with soft floating point (ejdk-8u33-fcs-linux-arm-sflt.gz).
OpenJDK 1.7 on Debian (32-bits), and build it on Debian 7 runs on Virtualbox VM (on Mac OS X).

Debian$ sudo apt-get install openjdk-7-jre



Extract embedded java 1.8

Debian $ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
Debian $ export EJDK=<target directory>
Debian $ cd ejdk1.8.0_33
Debian ejdk1.8.0_33 $ bin/jrecreate.sh --profile compact1 --dest compact1-minimal --vm minimal
Building JRE using Options {
...
target: linux_arm_sflt
vm: minimal
runtime: compact1 profile
debug: false
keep-debug-info: false
no-compression: false
dry-run: false
verbose: false
extension: []
}

Target JRE Size is 10,837 KB (on disk usage may be greater).
Embedded JRE created successfully

The size is 11Mb.

Debian$ du -sh compact1-minimal/.
11M compact1-minimal/.



I write a HelloWorld java to test.

$ cat > HelloWorld.java <<-EOF public class HelloWorld { public static void main(String args[]) { System.out.println("Hello, world!"); } } EOF $ gcc HelloWorld.java ⇒ HelloWorld.class $ java HelloWorld Hello, world!


I move the hello world program and compact1-minimal to my target platform (the ARM Linux) /opt/java/ejre-1.8.

arm$ export JAVA_HOME=/opt/java/ejre-1.8
arm$ export PATH=$JAVA_HOME/bin:$PATH

arm$ file HelloWorld.class
HelloWorld.class: compiled Java class data, version 49.0 (Java 1.5)

arm$ java -version
java version "1.8.0_33"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_33-b05, profile compact1, headless)
Java HotSpot(TM) Embedded Minimal VM (build 25.33-b05, mixed mode)

arm$ java HelloWorld
Hello, world!

Now you can create an embedded java 8 for Raspberry Pi.