2015年4月19日 星期日

Raspberry Pi : DIY 手機

http://goo.gl/jvmcGg

紀錄一下, 以後有空來試.

Now you can build your own DIY smartphone using Raspberry Pi

TyFone
Image Credit: Tyler Spadgenske

Walking into a store or going online to buy a smartphone is, like, so totally 2014. Why not just build your own?
Developer Tyler Spadgenske has been tinkering away at a basic DIY smartphone that runs on Raspberry Pi for more than a year now, and he’s posted an updated set of directions over at Instructables. His version builds on a previous iteration created by developer Dave Hunt.
According to the Raspberry Pi Foundation, the so-called “TyPhone” can “take photos (and send them to Dropbox or another device), send texts, and manage its own battery level, as well as placing and taking calls. Tyler wrote his own OS in Python, 3D-printed a rather smart enclosure, and now has a phone he’s built from the bottom up – hardware and software both.”
So, head on over to Instructables for the step-by-step directions and list of supplies, and get your Maker on. Or, if that seems too daunting, at least check out this video:


Raspberry Pi : raspivid


raspivid is one of the programs in the package

raspivid 是在這包 git 中的一個程式

 https://github.com/raspberrypi/userland


userland/host_applications/linux/apps/raspicam


Usage : can refer to this document
可參考這份文件

http://www.raspberrypi.org/wp-content/uploads/2013/07/RaspiCam-Documentation.pdf





ARM cortex-a 速度



Many people assume newer processors will be faster, or that 64-bit processor will provide a performance boost compared to 32-bit processors, but the reality can be quite different, and I’ve decided to have a look at ARM Cortex-A cores using ARMv7 (32-bit) and ARMv8 (64-bit) architecture, and see what kind of integer performance you can expect from each at a given frequency. To do so, I’ve simply use DMIPS/Mhz (Dhrystone MIPS/Megahertz) values listed on Wikipedia.
Vertical Scale: DMIPS / MHz
Vertical Scale: DMIPS / MHz

Drystone benchmark has no floating-point operating, so it’s a pure integer benchmark. I’m only looking at ARM core here, and once integrated in an SoC, other parameters like memory bandwidth, amount of cache,  GPU, etc.. will greatly affect the overall system performance. The figure above are per MHz, and it does not mean for example that a Cortex A5 processor will be slower than a Cortex A7 processor, as can be seen by the comparison between Amlogic S805 (4x Cortex A5) and Broadcom BCM2835 (4x Cortex A7), which shows the Amlogic processor is about 40% faster due to higher clock speed.
With that in mind, it can be seen than you may not expect all recent Cortex A53 processors to outperform existing Cortex A15 and A17 processors, and in some case even Cortex A9 processors, and the real performance benefit with 64-bit cores only start to show with Cortex A57, and especially Cortex A72 cores which is some cases could be twice as fast as Cortex A15 cores. The red zone on top of some bars represents the possible performance variation due to different implementations of the cores.
ARMv8 also brings some other improvement such as additional cryptographic extensions, an increase in the number of SIMD/floating point, and general purpose registers, and more, as shortly explained in that article. All of these should also deliver benefits provided the firmware and applications support them.


Read more: http://www.cnx-software.com/2015/04/09/relative-performance-of-arm-cortex-a-32-bit-and-64-bit-cores/#ixzz3XliGcof7

arduino beacon - iBeacon

http://evothings.com/diy-arduino-beacons/


記錄下來, 有空來試試.

DIY Arduino Beacons as an alternative to iBeacons

Mikael KindborgTutorials
Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+
Apple created a lot of interest in the IoT scene with the introduction of iBeacons. However, Apple placed restrictions such that generic BLE devices could not be used as iBeacons. In this tutorial we will show you how to have a fun time making a mobile app and create a custom implementation similar to iBeacons – based on the Arduino micro controller using standard BLE hardware.

In this tutorial, we will create a mobile app for Android and iOS, that uses an Arduino compatible board with a BLE shield to create a beacon. This can be thought of as a Do-It-Yourself version of Apple’s iBeacon technology – which is proprietary and restricts the way you can scan for beacons.
The reason we are using the Arduino for the beacons is that it can be easily programmed and that it is a cool tinker-friendly piece of technology that you can evolve far beyond the limits of iBeacons. The foundation of the iBeacon technology is the use of a small BLE (Bluetooth Low Energy) device that periodically advertises a UUID (Universally Unique Identifier) – however we will use the BLE name which is accessible across all mobile devices.
Arduino compatible boards with built in BLE will also work fine, such as the RedBearLab Blend Microboard, the RFduino or the LightBlue Bean.

The example app – Beacons for relaxation

The mobile application we have built for this tutorial is meant for use in a location where we want to give people time to relax and experience calm, for example a museum, an airport, a hospital or a public place such as a park. When approaching a beacon, the app will display a page that suggests a method for relaxation.
The beacon itself (the Arduino board) could be used as is, or be placed inside an object or display case that signifies the existence of the beacon, or be visually hidden. BLE devices have a range of up to 30 meters depending on the surroundings. You can be as many beacons as you like for your application, however we will use three of them to display the various relaxation states in the app.
Screenshots from the app:

relaxing-places-screen1relaxing-places-screen2relaxing-places-screen3relaxing-places-screen4
Below is a photo of an Arduino Uno we used as one of our beacons with a ReadBearLab BLE ShieldShield mounted on a SparkFun prototyping board:
relaxing-places-screen4
The LightBlue Bean is a small Arduino device with integrated BLE that we also used as DIY beacons:
relaxing-places-screen4

How to make the Arduino work as a Beacon

When a beacon is sending out signals, it uses the BLE advertising mode. The device repeatedly sends out an advertised name that you can set in your Arduino code. Additionally, you get the signal strength (RSSI = Received Signal Strength Indicator), which can be used to determine which beacon is the closest one.
As you walk around with your mobile device, another beacon will eventually become the closest one and the app will detect this and switch to the information that associated with that beacon. As you will see below it is remarkably simple to program this kind of mobile application using Evothings Studio.
The Arduino sketch will in essence do just one thing, set the name of the BLE shield. A limitation of the BLE name is that it is restricted to 10 characters, however with careful definition it can be enough to make the beacon IDs unique within your project setup.
It is important to note that you will have to set a unique BLE name onto every Arduino board you want to use as a beacon – if you would use the same name, there would be no way to tell the difference between them.
The Arduino sketch for the ReadBearLab BLE Shield and RedBearLab Blend Micro is shown below (file ArduinoBeacon.ino):
// Arduino code for example Arduino BLE Beacon.
// Evothings AB, 2014

// Include BLE files.
#include <SPI.h>
#include <boards.h>
#include <RBL_nRF8001.h>
#include <services.h>

// This function is called only once, at reset.
void setup()
{
    // Enable serial debug.
    Serial.begin(9600);
    Serial.println("Arduino Beacon example started");
    Serial.println("Serial rate set to 9600");

    // Set a custom BLE name for the beacon.
    // Note that each Arduino should be given a unique name!
    ble_set_name("BEACON1");

    // Initialize BLE library.
    ble_begin();

    Serial.println("Beacon activated");
}

// This function is called continuously, after setup() completes.
void loop()
{
    // Process BLE events.
    ble_do_events();
}

How the mobile application works

The mobile app that monitors beacons is developed in HTML5 and JavaScript using Evothings Studio. During the development process we used the Evothings Client app to utilize the HyperReload technology to effortlessly debug and develop our app.
When development is finished, there are several ways you can share your app. You can host the app on a web server so that visitors of the location where we have placed the beacons can easily access it. You could also build a native app and publish it on the app stores using exactly the same code.
The app continuously scans for advertising BLE devices and determines which of them belong to our application, then determines which beacon is closest and displays the HTML content associated with that beacon. The individual information pages are found in the file index.html. Each page is defined within its own div tag, which can be dynamically shown or hidden. If no beacons are in range, a default information page is shown.
Monitoring beacons and selecting which page to show is done in JavaScript code, found in the fileapp.js. The beacon to page mappings are defined as follows:
// Mapping of beacon names to page ids.
app.beaconPages =
{
    'BEACON1':'page-feet',
    'BEACON2':'page-shoulders',
    'BEACON3':'page-face'
}
Note that the names of your beacons must match the names used as keys in the above dictionary. Here is the code that gets called each time a BLE device advertisement is received by the app (this happens continuously):
app.deviceFound = function(deviceInfo)
{
    // Have we found one of our beacons?
    if (app.beaconPages[deviceInfo.name] && deviceInfo.rssi < 0)
    {
        // Update signal strength for beacon.
        app.beaconRSSI[deviceInfo.name] =
        {
            rssi: deviceInfo.rssi,
            timestamp: Date.now()
        }
    }
}
Logic for selection the closest beacon is found in the timer function app.runSelectPageTimer, which gets called at regular intervals.
In total, the app has the following code files:
  • index.html – main page, contains div tags for info pages
  • app.js – the JavaScript code for the app, included in index.html
  • page.css – style sheet definitions
  • ArduinoBeacon – folder with the ArduinoBeacon.ino file
There are also images used in the application. You will find all the project files on GitHub.

Running the app using Evothings Studio

  • To run the app, first download Evothings Studio.
  • Then install and start the Evothings Client app on your mobile device(s).
  • Download the code for the app from GitHub into a folder on your computer.
  • Drag the file index.html into Evothings Workbench.
  • Connect from the Evothings Client app to the Workbench.
  • Press RUN in the Workbench window, right next to the example.
  • Remember to configure your Arduinos with the proper names for the app to work!

Running the app from a web server

To share the app with others, you can host it on a web server. Do as follows:
  • Download the code for the app from GitHub and put it on a web server.
  • Ask your users to install and start the Evothings Client app on their mobile device(s).
  • Connect from the Evothings Client by entering the address of the web server (such as http://myserver.com/mybeaconapp) and tap CONNECT to start the application.
  • Remember to configure your Arduinos with the proper names for the app to work!

Use any BLE device as a beacon

You should be able to use almost any BLE device for this project. Being able to set the device name is a requirement for more serious projects – just enter the name in the dictionary app.beaconPages as shown above. You can use the app BLE Scan that comes as an example included with Evothings Studio to determine the names of your BLE devices.
The advantage of using an Arduino as a beacon is that you can change its advertising name. You can also change the name of the LightBlue Bean, by connecting to a bean using the Bean Loader App and clicking on the name and edit it (no coding required). Other devices may have other procedures for setting the name, and some devices you cannot change the name for.

Where to go from here

This tutorial introduced the concept of “Do-It-Yourself” beacons to allow you to use any BLE device as a beacon without using Apple’s proprietary iBeacon technology.
However, Evothings Client also supports Apple’s iBeacons by including the Cordova iBeacon plugin. If you wish to explore iBeacon technology, Evothings Studio makes it easy to get started. Check out theiBeacon Scan example app to get going.
You are always welcome to drop in on the Evothings Forum, to discuss technology, applications, ask questions, and share experiences.
Interesting links:

2015年4月10日 星期五

Raspberry Pi : LCD

http://www.wvshare.com/product/3.5inch-RPi-LCD-A.htm


http://www.waveshare.net/wiki/3.5inch_RPi_LCD_(A)

sudo raspi-config
确定已选择:Enable Boot to Desktop/Scratch -> Desktop Log in as user ‘pi’ at the graphical desktop
#3.5inch RPi LCD (A)运行
 
sudo ./LCD35-show
 

Raspberry Pi : Kernel image

Ref: https://www.raspberrypi.org/documentation/linux/kernel/building.md

在 PC 上用 cross compile 的方式來做 :

1. 安裝工具

$ git clone https://github.com/raspberrypi/tools

把目錄 : 

tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin 

設定到 PATH 

2. 安裝 source

$ git clone --depth=1 https://github.com/raspberrypi/linux

3. 把 SD card 插入, 用 lsblk 可以看到

sdb
   sdb1
   sdb2

4. 編譯 kernel 

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Open the following menu :
Device Drivers
Network device support
Wireless LAN

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 

如果 compile 時發現 libstdc++.so.6 有問題的話

sudo apt-get install libc6-i386 lib32z1 lib32stdc++6


5. 建立目錄 mnt/fat32 和 mnt/ext4, 並 mount
    
$ sudo mount /dev/sdb1 mnt/fat32
$ sudo mount /dev/sdb2 mnt/ext4

6. 安裝 kernel


$ sudo cp mnt/fat32/kernel.img mnt/fat32/kernel-backup.img
$ sudo cp arch/arm/boot/Image mnt/fat32/kernel.img

7. 安裝 module

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install

8. umount sd card

$ sudo umount mnt/fat32
$ sudo umount mnt/ext4


2015年4月8日 星期三

2015年4月5日 星期日

raspberry pi : broadcom video core

Broadcom Videocore

http://www.broadcom.com/docs/support/videocore/VideoCoreIV-AG100-R.pdf


Raspberry Pi Camera module introduction

http://elinux.org/Rpi_Camera_Module



  • Sensor type: OmniVision OV5647 Color CMOS QSXGA (5-megapixel)

"flat flex" cable (FFC, 1mm pitch, 15 conductor, type B contacts, Molex 21039-0843,

tiny connector (Hirose DF30 series, part DF30FC-24DP-0.4V)

  • Video: 1080p at 30 fps with codec H.264 (AVC)
  • 改裝

OV5647

2010 年 2 月 annouce
- 五百萬像素
低照度感光效果( 680-mV/lux-sec )
- 720p 60 fps or 1080p 30 fps

product feature : http://www.ovt.com/uploads/parts/OV5647.pdf



2015年4月3日 星期五

Raspberry Pi : 鍵盤設定

發現如果不更改鍵盤設定,  pipe | 符號 打不出來..

一開始沒 config 好. 重新 config :

$ sudo raspi-config

- Generic 105-Key

layout : Others

- English (US)

Compose Key : No compose key

Key to function as AltGr : Both Alt keys

是否可以用 Control + Alt + Backspace 來離開 x Server : Yes





Raspberry Pi : Camera

0. Raspberry Pi Camera module introduction



1. 安裝 camera module, 可以參考這段影片

http://www.raspberrypi.org/help/camera-module-setup/




2. 更新 apt

     $ sudo apt-get update

     $ sudo apt-get upgrade


3. 打開攝影機

     $ sudo raspi-config



4. raspivid


raspivid -o vid.h264

簡單測試, 會有 5 sec. 


5. 安裝 VLC

    $ sudo apt-get install vlc

6. raspivid -o - -t 0 -hf -w 1080 -h 720 -fps 24 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http, mux=ts, dst=:8160}' :demux=h264

7. 在 PC 端, 安裝 vlc, 並用 vlc 的 open network , 輸入 URL 

     http://樹莓派的IP:8160/



8. 相關畫面

     720p 畫面還算清晰. 如果是 fps 24 還可以(1到2秒 delay), 
     fps 30 時畫面會有毀損.. 


2015年4月1日 星期三

Raspberry Pi : 安裝 Raspbian

1. Raspbian




or



2.  SD card

     $ diskutil list

/dev/disk2
   #:                       TYPE NAME                                 SIZE           IDENTIFIER
   0:     FDisk_partition_scheme                        *15.9 GB        disk2

   1:             Windows_FAT_32 NO NAME          15.9 GB        disk2s1


3.  寫入 image

$ sudo dd if=2015-02-16-raspbian-wheezy.img of=/dev/disk2 bs=1m

如果出現

dd: /dev/disk2: Resource busy

表示 Finder 可能開啟, 關閉所有 Finder, 並執行

$sudo diskutil umount "/Volumes/NO NAME"

燒錄時沒有任何訊息, 要耐心等候, 約 二十多分鐘

3125+0 records in
3125+0 records out
3276800000 bytes transferred in 1503.801059 secs (2179012 bytes/sec)

4. 燒好之後, 放進 Raspberry Pi SD 插槽 (背面)

5. 插上 電源, USB keyboard, USB mouse, HDMI 輸出, 網路線, 

6. 開機


帳號 : pi
密碼 : raspberry 

7. 進入後 $startx , 就可以看到圖形介面