2017/12/29

tensorflow - some links

原始說明使用 tensorflow 學 fibonacci 的文章只剩下 這邊 有說明到。
原始作者已經把 sample code 刪掉了。

這一篇應該就是 Josh Gordon 說明tensorflow 的投影片。

example 已經改成比較有意義(?)的用 tensorflow 做回歸分析。

這樣的範力就很多..像 這個 就是中文的。

結果是 AI 神奇寶貝訓練大師的 教學有...ML Lecture 9-3: Fizz Buzz in Tensorflow (sequel)
上面的 Link 就是原 po...

2017/12/19

yocto qt-gstreamer

qt-gstreamer 的 recipes 在 meta-qt5-extra 中。
所以把 meta-qt5-extra clone 下來。(top folder)。
然後修改 meta-st/meta-st/demo/recipes-core-st/images/st-demo-qt-image.bb
在 IMAGE_QT_OPTIONAl_PART 最後加上 qt-gstreamer

然後 照一邊 bitbake image 就可以。

然後是做 sdk。

在 meta-qt5/ercipes-qt/packagegroup-qt5-toolchain-target.bb
RDEPENDS_${PN} += ..
加上 qt-gstreamer-dev

然後 bitbake meta-toolchain-qt5

2017/12/15

try Qualcomm NPE SDK

就是照著 snapdragon-neural-processing-engine
另外,forume 有一篇問到 625 - Forums - Snapdragon 625 (MSM8953) is available for using GPU?
I'd like to know that Snapdragon 625 is available for GPU.
 
On this URL, SnapDragon 625(MSM8953) supports SNPE.
 
https://developer.qualcomm.com/software/snapdragon-neural-processing-engine
 
Supported devices: 
SnapDragon 820, 835, 625, 626, 650, 652, 653, 660 and 630
 
So I measured to Qualcomm's SNPE demo app(alexnet) on MSM8953 device.
Then I changed device CPU to GPU on demo app, But it seems not to work GPU.
 
MSM8953
   CPU
      ave: 0.209[sec]
      max: 0.150[sec]
      min: 0.163[sec]
   
   GPU
      ave: 0.182[sec]
      max: 0.170[sec]
      min: 0.172[sec]
 
On MSM8953 device, libOpenCL.so is allocated here:
 
    /system/vendor/lib/libOpenCL.so
 
 
And on this document, it looks that SnapDragon 625(MSM8953) is not supported device.
 
snpe-1.2.2/doc/html/overview.html
Supported devices: 
SnapDragon 835, 821, 820, 660, 652
 
I'd like to know Snapdragon 625 (MSM8953) is not supported or not.
Or what is needed to check this device is available for GPU ?
(OpenCL's version or other infomation?)
 
FYI, other device's perfomance that I tried on Qualcomm's SNPE demo app(alexnet).
 
Snapdragon 820(MSM8996)
   CPU 
      ave: 1.777[sec]
      max: 1.947[sec]
      min: 1.671[sec]
 
   GPU
      ave: 0.035[sec]
      max: 0.033[sec]
      min: 0.034[sec]
 
Snapdragon 810(MSM8994)
 
   CPU
      ave: 0.216[sec]
      max: 0.167[sec]
      min: 0.187[sec]
 
   GPU
      ave: 0.077[sec]
      max: 0.048[sec]
      min: 0.059[sec]
看起來625 的 gpu 似乎無作用。


follow : getting start

要先註冊,所以用公司的 email 註冊。
password:AKB48hellokitty

登入,下載..snpe-1.8.0

為了跟 getting start 一樣,所以從 android studio 的 android sdk manager 安裝 ndk:install ndk from sdk manager
Download tensorflow model 時,要先active tensorflow (因為是裝在virtualenv):
source ~/tensorflow/bin/activate
python ./models/inception_v3/scripts/setup_inceptionv3.py -a ./temp-assets-cache -d
需要 Android-26 版本的 Sdk
用androidstudio build fail,說他不認識,沒辦法讀取 raw_alexnet.zip.flat 的 metadta.
用 command build 說找不到 gradlw-3.0.1

follow debug message,到 https://jcenter.bintray.com/com/android/tools/build/gradle/ 去看,只有 2.3.3,所以改 build.gradle:
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
    
然後出現找不到 tools.jar..
apt-get install default-jdk..
build 成功。

adb install app-debug.apk 到 APQ8053EVB
要記得 adb remount,然後 安裝 3 次才成功,前兩次都是download 到一半 no response。
執行..
因為解析度的關係,影像幾乎看不到,但是一樣可以測試。
發現 使用 CPU 和 GPU 的差異不大(和論壇內容一致)

使用 alex 的 zenfone ? (625) 的手機測試:

sample program 內建5張圖:
分別可以選擇使用 cpu , gpu 辨識。

2017/12/12

phabricator -- test install

ref: 但是..
stretch (9), default php 版本是 7
所以第一個安裝就fail...
apt-get install git mysql-server apache2 dpkg-dev php5 php5-mysql php5-gd php5-dev php5-curl php-apc php5-cli php5-json
php-apc 沒有,然後 php5 的一堆not meet dependency..

所以先裝 php 就好...
就自動裝了 apache2, php7.0-cli, php7.0-json
其他還要自己裝 (?)

2017/12/11

test .. video from twitter embedded code..

這只是測試一下 twitter 的內嵌影片的標記

2017/12/7

就 download snpe-1.8.zip
解開,follow getting start, rename to snpe-sdk

follow instructions, install tensorflow on ~/tensorflow:
sudo apt-get install python-pip python-dev python-virtualenv 
mkdir ~/tensorflow; virtualenv --system-site-packages ~/tensorflow; source ~/tensorflow/bin/activate 
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0-cp27-none-linux_x86_64.whl
其實就是參考 tensorflow, intall linux

run dependencies.sh 和 check_python_depends.sh 檢查系統需要的 package 是不是都 OK 了。
設好環境變數 ANDROID_NDK_ROOT 之後,run tensorflow 的環境設定:
source ~/snpe-sdk/bin/envsetup.sh -t ~/tensorflow/
INFO: Setting TENSORFLOW_HOME=/home/charles-chang/tensorflow/
INFO: Found ANDROID_NDK_ROOT at /home/charles-chang/Android/Sdk/ndk-bundle
WARNING: Cannot find /home/charles-chang/snpe-sdk/lib/arm-android-gcc4.9/libgnustl_shared.so
         libgnustl_shared.so found at /home/charles-chang/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so
         copying to /home/charles-chang/snpe-sdk/lib/arm-android-gcc4.9
INFO: Adding libgnustl_shared.so to /home/charles-chang/snpe-sdk/android/snpe-release.aar
  adding: jni/armeabi-v7a/libgnustl_shared.so (deflated 66%)
WARNING: Cannot find /home/charles-chang/snpe-sdk/lib/aarch64-android-gcc4.9/libgnustl_shared.so
         libgnustl_shared.so found at /home/charles-chang/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_shared.so
         copying to /home/charles-chang/snpe-sdk/lib/aarch64-android-gcc4.9
INFO: Adding libgnustl_shared.so to /home/charles-chang/snpe-sdk/android/snpe-release.aar
  adding: jni/arm64-v8a/libgnustl_shared.so (deflated 73%)

download tensorflow model
source ~/tensorflow/bin/active
python models/inception_v3/scripts/setup_inceptionv3.py -a ./temp-assets-cache -d



2021 update --

snpe-1.49
說需要知道 tensorflow install folder.
我是用 conda 安裝,所以是在
~/miniconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow

額外需要...說..
SDK Android binaries built with clang require libc++_shared.so which is shipped with the SDK. (See Platform Runtime Libraries below).
但是好像是用 ndk build native C++ program 才要?

這個在/usr/lib/x86_64-linux-gnu/libatomic.so.1
system ld path,所以應該不用 copy...

2017/11/8

MINIX 作者給 intel 的公開信

最近的大新聞,intel 讓 CPU 的 Management Engine Run MINIX。
然後就是 MINIX 的作者的公開信:An Open Letter to Intel

大意是說,他也是看報紙知道的...

但是他想想,前幾年好像就有些蛛絲馬跡了。
例如,intel 的工程師要求減少 memory footprint和把一些功能用 #ifdef 關閉。
也有討論過 license 問題。

他本人是覺得 OK, 本來 MINIX 3 就是 BSD license,
使用,修改者沒有義務通知原作者。

他很開心,但是他小小聲說,要是 intel 的工程師可以私底下通知他,他會更高興。


雖然 BSD license 而不是 GPL 可能是intel 選擇 MINIX 3 的原因。
但是他寧可相信是 MINIX 3 優異的 micro kernel 設計,高度模組化的 OS function ,
讓 intel 選擇了 MINIX。


* 後續:
computer vendors start disabling intel management engine

2017/11/3

build qt5-toolchain for Qt Creator

bitbake meta-toolchain-qt5
然後...
ERROR: meta-toolchain-qt5-1.0-r0 do_populate_sdk: Function failed: do_populate_sdk
ERROR: Logfile of failure stored in: /home/charles-chang/ann3/buildqtwayland/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/meta-toolchain-qt5/1.0-r0/temp/log.do_populate_sdk.27843
ERROR: Task (/home/charles-chang/ann3/meta-qt5/recipes-qt/meta/meta-toolchain-qt5.bb:do_populate_sdk) failed with exit code '1'

去看一下 log ..有..
ERROR: Unable to install packages. Command 
'/home/charles-chang/ann3/buildqtwayland/tmp/sysroots/x86_64-linux/usr/bin/opkg 
 --volatile-cache 
 -f /home/charles-chang/ann3/buildqtwayland/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/meta-toolchain-qt5/1.0-r0/opkg.conf
 -t /home/charles-chang/ann3/buildqtwayland/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/meta-toolchain-qt5/1.0-r0/temp/ipktemp/
 -o /home/charles-chang/ann3/buildqtwayland/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/meta-toolchain-qt5/1.0-r0/sdk/image/opt/poky-st/2.2.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi
 --force_postinstall
 --prefer-arch-to-version
 install
 packagegroup-qt5-toolchain-target
 packagegroup-core-standalone-sdk-target
 packagegroup-core-standalone-sdk-target-dbg
' returned 255:
...
Installing libsegfault (2.24) on root.Collected errors:
 * calculate_dependencies_for: Cannot satisfy the following dependencies for packagegroup-qt5-toolchain-target:
 *      qtenginio-mkspecs *     qtenginio-qmlplugins *
 * opkg_solver_install: Cannot install package packagegroup-qt5-toolchain-target.
去devshell 單獨 run 這個 command 試試看...
$ bitbake meta-toolchain-qt5 -c devshell

# /home/charles-chang/ann3/buildqtwayland/tmp/sysroots/x86_64-linux/usr/bin/opkg --volatile-cache -f /home/charles-chang/ann3/buildqtwayland/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/meta-toolchain-qt5/1.0-r0/opkg.conf -t /home/charles-chang/ann3/buildqtwayland/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/meta-toolchain-qt5/1.0-r0/temp/ipktemp/ -o /home/charles-chang/ann3/buildqtwayland/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/meta-toolchain-qt5/1.0-r0/sdk/image/opt/poky-st/2.2.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi  --force_postinstall --prefer-arch-to-version   install packagegroup-qt5-toolchain-target packagegroup-core-standalone-sdk-target packagegroup-core-standalone-sdk-target-dbg

...
...
...
Collected errors:
 * calculate_dependencies_for: Cannot satisfy the following dependencies for packagegroup-qt5-toolchain-target:
 *      qtenginio-mkspecs *     qtenginio-qmlplugins * 
 * opkg_solver_install: Cannot install package packagegroup-qt5-toolchain-target.

然後,就去 b/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb 把 qtenginio-mkspec 和 qtenginio-qmlplugins 移除,再 build 一次,就沒有問題。

diff --git a/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb b/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb
index 25bc530..aa9631d 100755
--- a/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb
+++ b/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb
@@ -60,8 +60,6 @@ RDEPENDS_${PN} += " \
     qttranslations-qmlviewer \
     qttranslations-qtdeclarative \
     qtenginio-dev \
-    qtenginio-mkspecs \
-    ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'qtenginio-qmlplugins', '', d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'qtgraphicaleffects-qmlplugins', '', d)} \
     qtimageformats-dev \
     qtimageformats-plugins \

另一個,在 bitbake release image target 的 bb file 中,把 qtenginio-mkspecs , qtenginio-qmlplugins 加到 IMAGE_QT_OPTIONAL_PART 中 看看...
結果 build fail..
所以.. 大概真的 build 不出來...

這裡 下載 Qt Creator installer

sdk 和 qt creator 安裝參考:
直接 run, 不用 root,sudo .. 安裝在自己的 home 下 (~/pokyqtsdk/2.2.1)
Poky (Yocto Project Reference Distro) SDK installer version 2.2.1
=================================================================
Enter target directory for SDK (default: /opt/poky-st/2.2.1): /home/charles-chang/pokyqtsdk/2.2.1
You are about to install the SDK to "/home/charles-chang/pokyqtsdk/2.2.1". Proceed[Y/n]? 
Extracting SDK.................................................................................................................................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /home/charles-chang/pokyqtsdk/2.2.1/environment-setup-cortexa7hf-neon-poky-linux-gnueabi


然後裝 qtcreator..
用 debian 付的,所以會莊一堆 for x86 的 tool..

然後就是最麻煩的設定 Qtcreator...
要設定的東西大概是...
  • 先新增加一個 target device -- 例如 imx, st, rpi..-- 其實這個就是你的 toolchain-sdk 板子
  • 再增加 tool,給他一個名子(通常就是 target device 的名子) -- g++, gcc -- 指定到sdk 安裝目錄中的 ooxx-g_++, ooxx-gcc
  • 設定 sdk 的 sysroot 的位置,qt creator 會自己找出Qt 版本和 qmake 位置
  • 把上面的 整合在 Kits -- 指定 Device, tool, sysroot 位置..
這樣就產生了 Kits
以後 New Project 就可以指定是用那一個 Kits

然後 new project 來測試,一直 fail, 說 sdk 裡的 lib (Gui, Core... etc) 都不合。
看一下 Makefile (qmake 產生的)。
CC = g++
沒有用 sdk 的環境變數 (OE_QMAKE_CC)
Makefile 一開始會有...
# Command: /home/charles-chang/pokyqtsdk/2.2.1/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake 
 -spec linux-g++ 
 CONFIG+=debug CONFIG+=qml_debug 
 -o Makefile ../ooow/ooow.pro
這格好像是錯的, -spec 應該要是 linux-oe-g++

所以去 Qt creator 的 OPtion , Kits 設定,有一項:Qt mkspec 是空的,填上 linux-oe-g++ 之後,clean 再 build,就 OK 了。

另外,要 run qtcreator 之前,要先 run sdk 的環境變術設定。

2017/10/25

gerrit ssh

先用 openID 認證方式進入mygerrit 網頁。
利用網頁功能在mygerrit註冊一個新帳號 ggininder

ggininder 的 user 功能表裡,有一個 ssh public key。
凡是想要線到 mygerrit 的機器,都要把 他的 public key 加進來。

所以到另一台 pc 上,把 id_rsa.pub 的內容 copy 到 mygerrit, ggininder 功能網頁的 ssh public key 框框裡。
按下 add 之後,就可以了。

pc 測試 ssh 連線道 mygerrit:
ssh -p 29418 ggininder@mygerrit

Unable to negotiate with mygerrit port 29418: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
fail.
google 說新版debian 就會有這個問題,參考 openssh 的 legacy issue
改:
ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -p 29418 ggininder@mygerrit

Connection to 192.168.145.137 closed by remote host.
Connection to 192.168.145.137 closed.
這樣就 OK 了。,

因為太麻煩,所以可以寫在 .ssh/config 裡...
Host mygerrit
Port 29418
    user ggininder
    KexAlgorithms +diffie-hellman-group1-sha1

順便把 login port 和 user name 都寫了,
這樣,只要:
ssh mygerrit
就可以。

commit 的時候 git config 的 email address 必須要跟 mygerrit 的 user:ggininder 設定的 contact info 的 email address 一樣。
並且,在mygerrit 中填完 email 帳號後,要在 mail 中 confirm 後才會有效。


.ssh/config
如果同一個 host 有 gerrit 和 ssh,上面的寫法,會讓一般的 ssh 反而沒辦法連線。
所以要加一個...
Host mygerritssh
    Hostname mygerrit
    Port 22
這樣,就用 ssh mygerritssh 代表一般 ssh 連線。
ref:simplify your life with an ssh config file

2017/10/19

gerrit test

就照這個 來吧,比較新...

在 pi3, stretch lite 上。

..配合這個,..在 debian 系統上..

openjdk-8-jre
git
apache2-utils

要是只是測試一下。
參考 https://gerrit-review.googlesource.com/Documentation/linux-quickstart.html
java -jar gerrit-2.14.5.1.war init -d /home/gerrit2/sitedata


第一次 push 出現錯誤;
Counting objects: 3, done.
Writing objects: 100% (3/3), 238 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done    
remote: ERROR: [6f52422] missing Change-Id in commit message footer
remote: 
remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 charles.chang@raspberrypi:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend
remote: 
To ssh://172.16.110.4/test1.git
 ! [remote rejected] HEAD -> refs/for/master ([6f52422] missing Change-Id in commit message footer)
參考 這一篇,好像可以disable 掉..

在 project settings 中把 Change0-Id 改 FALSE 就可以了。

2017/10/17

raspberry pi 3, stretch. wifi setup

raspbian 下載 lite
unzip, dd 到 sd
mount sd part 1 進來,修改 config.txt,最後加一行
dtoverlay=pi3-disable-bt

這樣就可以用 版邊,從角落開始算,3(GND), 4(TX), 5(RX) 做 console
開機。
sudo raspi-config
expand root partition
reboot

?

今天..dd lite image,修改 config.txt,加入 wpa_supplicant.conf,之後開機。
竟然 wifi 就 ready 了,已經連好了。
然後 boot 也自動 resize root partition。


紀錄一下 rapbian stretch (不是 lite),設定完 wifi 後的一些 config..
在 /etc/network/ 下..
if-up/if-down/if-pre-up/if-post-down .d 下,都有 wpasupplicant 這個 link,link 到 ../../wpa_supplicant/ifupdown.sh

/etc/wpa_supplicant/wpa_supplicant.conf:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=TW

network={
 ssid="MySSID"
 psk="MyPassword"
 key_mgmt=WPA-PSK
}

jessie 也有支援boot 直接設定喔:headless raspberry setup
這一篇有 jessie, stretch 設定方式的比較

2017/10/13

yocto -- devshell

要是想要自己下 make 命令。可以用
bitbake recipes-name.bb -c devshell

會開一個 terminal,把 source unpack and patch 好,然後環境變數都設好。

如果Makefile 有設置良好,有時候 make 時,會有 Error:
ERROR: ld.so: object 'libpseudo.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
參考這一篇
export PSEUDO_UNLOAD=1
之後,ERROR 就消失了。

2017/10/11

reading notes on ..embedded linux with yocto project

Bitbake 源自於 Gentoo 的 portage 系統,雖然現在已經完全分開了。

bitbake 使用的資料(metadata) 可以分為三種類型:
  • configuration : .conf
    Global 放的設定
  • classes : .bbclass
    給recipes include 用的,避免一堆 recipes 要重複寫一堆code
  • recipes: .bb,bbappend
    bitbake 看這個決定動作

bitbake parsing 的順序:
先到目前目錄 (build) 下,找 bblayares.conf,裡面的 BBLAYERS 變數會指出需要parse 的 其他 layer 目路。
BBLAYERS 有次序之分,所以要先被parse 的要放在前面。

bitbake 到 BBLAYERS 指定的每個 layer 去,先找看看有沒有 meta/conf/bitbake.conf
並且follow include 命令去 include 其他 file

麻煩的recipes 相依

recipes 中可以用 DEPENDS 和 PROVIDES 兩個變數來說明這個recipes 需要的東西。

DEPENDS 和 PROVIDES 有點問題。
foo_1.0.bb 有 DEPENDS += bar
那磨:
  • bar_version.bb
  • XOXO.bb 中有: PRIVIDES = bar
以上都會被 foo_1.0.bb 列為依賴的 recipes

所以,有可能很多 recipes 都有 PROVIDES = bar,所foo_1.0.bb 有很多package 可以選。
這就要用 PREFERRED_PROVIDER_name = XOXO 來指定foo_1.0.bb 真的想用那一個。

fetch -- download files

bitbake 執行 do_fetch 時,會去看 recipes 中的 SRC_URI 變數。
其中,可以用 ${PV} 代表版本號。
bitbake 會去下載source 到 DL_DIR 這格目錄。
同時檢查md5dum, sha256sum 和 bb 中數值一部一樣。
檢查正確,就會在 DL_DIR 中另外create 一個 XXOO.filename.done ,

do_fetch 和 git

SRC_URI 是 git://uri...的話,bitbake 就會clone source 到 DL_DIR/git2/-git url- 下。

Bitbake 的 tasks

用 bitbake recipes-name -c listtasks
可以列出該 recipes 所有的 task

root filesystem 製作

每個 recipes 與 rootfs 相干的部份會由 do_rootfs 這格 subtask 來完成。
IMAGE_INSTALL 和 IMAGE_FEATURES 包函了會加入rootfs 的 packages。

之後, PACKAGE_EXCLUDE 包含不要放入 rootfs 的 package 列表。
bitbake 把 IMAGE_INSTALL/FEATURES 統整後,再比對,挑出要放進去的 package。
但是如果有相依性的需求,即使被劣在 EXCLUDE 中,也一樣會被放進 rootfs。

build 目錄的內容

fetch 的時候,download source 到 DL_DIR。
解開/clone source 到 tmp/wocdrk,有需要 patch 的也patch 好。
然後在 tmp/work 下做 configure,build。
build 完,有要做make install 之類動作的,就會放到各自 tmp/work/..../image 下。
之後,把其他package 需要的header file,share library 都放到tmp/sysroot,讓其他 package build 的匙時候使用。

work 目錄

2017/10/6

在 qtbase/../git/src/plugins/platforms/eglfs
然後 platforms 下的 platform.pro 有:
contains(QT_CONFIG, eglfs) {
    SUBDIRS += eglfs
    SUBDIRS += minimalegl
}
所以 QT_CONFIG 要有 eglfs
在 src/configure 可以看到是在 call configure 時以參數傳進來的。

到 meta-qt/recipes-qt/qt5/ 下, qtbase_git.bb 有..
qtbase_git.bb:PACKAGECONFIG[eglfs] = "-eglfs,-no-eglfs,drm"
所以 package config 要有 eglfs

2017/9/27

reading notes : uarts in raspberry pi 3

ref:
PI 3 因為BT 的關係,所以原來的 uart console 被拿去給 bt 用了,
所以有一堆..

PI3 有兩個 uart:
  • PL011 : /dev/ttyAMA0 -- BT
  • mini UART : /dev/ttyS0 --console
Primary Console : /dev/serial0 是被指定給 console 用的,
所以指定 誰是 /dev/serial0,誰就會變 console。

miniUART 有些問題。
他的 baurate 是從 VPU 的 clk 除的。
所以跟 VPU 的頻率相關。
當使用 dvfs時,VPU 的頻率是會變的,有時候甚至會關閉,
這樣就導致 miniUART 的 baudrate 無法固定,關閉時甚至無法是用。

可以在 config.txt 中加上 enable_uart=1
這樣,VPU 的 core_freq 就會固定 250MHz,
如果加上 force_turbo 就會固定 400MHz。

enable_uart 只跟 miniUART 有關,不會影響到 PL011

UART 和 GPIO

pi 的 kernel 是用 devicetree overlay 來處理不同 device tree 配置問題。
有兩個:
  • pi3-disable-bt : 這個會 關掉 ttyAMA0,並且把 tx, rx 接到 GPIO 14, 15 pin 上
  • pi3-miniuart-bt : 這個會讓 bt 使用 miniuart (ttyS0),一樣把 ttyAMA0 的 tx, rx 接到 GPIO 14, 15 pin 上
所以簡單(不用bt)的作法,就是在 boot/config.txt 加上
dtoverlay=pi3-disable-bt
就可以用 最旁邊的第3(GND), 4(TX), 5(RX) 做 console uart 了。


在 yocto project 中
在自己增加的 layer 中...
recipes-bsp/bootfiles/rpi-config_git.bbappend:
SRCREV = "648ffc470824c43eb0d16c485f4c24816b32cd6f"

do_deploy_append() {
    if [ -n "${ENABLE_RPI3_SERIAL_CONSOLE}" ]; then
        echo "" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
        echo "## Disable RPi3 bluetooth to enable serial console on UART0" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
        echo "dtoverlay=pi3-disable-bt" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
    fi
}

2017/9/26

another one : build yocto for rpi

這次是 這一篇

git clone -b krogoth git://git.yoctoproject.org/poky
git clone -b krogoth git://git.openembedded.org/meta-openembedded
git clone -b krogoth git://git.yoctoproject.org/meta-raspberrypi

oe-init-env build之後,到 build/conf 下 修改 local.conf..
加上:
MACHINE = "raspberrypi3"
PREFERRED_VERSION_LINUX-raspberrypi = "4.%"
DISTRO_FEATURES_remove += "x11 wayland"
DISTRO_FEATURES_append += "systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"

bblayers.conf 修改成..
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""


BBLAYERS ?= " \
  /home/charles-chang/rpi2016/sources/poky/meta \
  /home/charles-chang/rpi2016/sources/poky/meta-poky \
  /home/charles-chang/rpi2016/sources/poky/meta-yocto-bsp \
  /home/charles-chang/rpi2016/sources/meta-openembedded/meta-oe \
  /home/charles-chang/rpi2016/sources/meta-openembedded/meta-multimedia \
  /home/charles-chang/rpi2016/sources/meta-raspberrypi \
  "

BBLAYERS_NO_REMOVABLE ?= " \
  /home/charles-chang/rpi2016/sources/poky/meta \
  /home/charles-chang/rpi2016/sources/poky/meta-poky \
  "

然後 bitbake rpi-basic-image 就成工了。
build 完 dd , 可以開機。
但是 dtoverlay=pi3-disable-bt 沒作用。
uart 還是沒辦法當 console。只能用 hdmi + keyboard

Qt5 for embedded

Qt5 - embedd Linux
以前有 Qt for embedded,現在好像變成 plugin 了。
這一篇就在說明 plugin 的內容。

至於 license... 好像不清楚。
這一頁的各個 component 沒有列出..

2017/9/25

try : yocto for raspberry pi 3

先是參考 這一篇

clone git.yoctoproject.org/poky。
clone git,openembedded,org/meta-openembedded
clone github.com/meta-qt5/meta-qt5
clone git.yoctoproject.org/meta-raspberrypi
clone github.com/jumpnow/meta-rpi

作者的 meta-rpi 有提供 conf 下的 local.conf 和 bblayers.conf。
copy 過來,修改一下 bblayers.conf 裡的 path..

bitbake qt5-basic-image 出現 error:
Please use a locale setting which supports utf-8.
Python can't change the filesystem locale after loading so we need a utf-8 when python starts or things won't work.

進入 python, 用 sys.getfilesystemencoding() 看,過然,是 ANSI....
所以 follow 這一篇:
$sudo apt-get install locales
$sudo dpkg-reconfigure locales 
$sudo locale-gen en_US.UTF-8
Generating locales
 en_US.UTF-8... done
Generation complete.
$sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
$export LANG=en_US.UTF-8

然後 build 出現 error:
ERROR: bcm2835-bootfiles-20170530-r60 do_fetch: Fetcher failure for URL: 
'https://codeload.github.com/raspberrypi/firmware/tar.gz/0f315f88ac91f9be93544bfd757f8d55ca4cf099'. Checksum mismatch!
File: '/home/charles-chang/rpi-yocto/build/downloads/0f315f88ac91f9be93544bfd757f8d55ca4cf099' 
has md5 checksum c8bf818d14ee260c6d318a8ab037b1b8 when 2fe42603602158796625989c73e5088b was expected
File: '/home/charles-chang/rpi-yocto/build/downloads/0f315f88ac91f9be93544bfd757f8d55ca4cf099' 
has sha256 checksum bfeb5471762bef90fb8accb135e9cf4bb08c4a7556df42f31987bd4184f52d10 
when 79dcd9f47fbae16e9ec80f96a48e4e04c0ee2076ddbb7f73429510d812a8ef89 was expected
If this change is expected (e.g. you have upgraded to a new version without updating the checksums) then you can use 
these lines within the recipe:
SRC_URI[md5sum] = "c8bf818d14ee260c6d318a8ab037b1b8"
SRC_URI[sha256sum] = "bfeb5471762bef90fb8accb135e9cf4bb08c4a7556df42f31987bd4184f52d10"
Otherwise you should retry the download and/or check with upstream to determine if the file has become corrupted or 
otherwise unexpectedly modified.

ERROR: bcm2835-bootfiles-20170530-r60 do_fetch: Fetcher failure for URL: 
'https://codeload.github.com/raspberrypi/firmware/tar.gz/0f315f88ac91f9be93544bfd757f8d55ca4cf099'. Unable to fetch URL from any source.
ERROR: bcm2835-bootfiles-20170530-r60 do_fetch: Function failed: base_do_fetch
ERROR: Logfile of failure stored in: /home/charles-chang/rpi-yocto/build/tmp/work/raspberrypi2-poky-linux-gnueabi/bcm2835-bootfiles/20170530-r60/temp/log.do_fetch.10803
ERROR: Task (/home/charles-chang/rpi-yocto/meta-raspberrypi/recipes-bsp/bootfiles/bcm2835-bootfiles.bb:do_fetch) failed with exit code '1'
這個是 meta-rpi/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend 裡的:
RPIFW_DATE = "20170530"
SRCREV = "0f315f88ac91f9be93544bfd757f8d55ca4cf099"
SRC_URI[md5sum] = "2fe42603602158796625989c73e5088b"
SRC_URI[sha256sum] = "79dcd9f47fbae16e9ec80f96a48e4e04c0ee2076ddbb7f73429510d812a8ef89"

RPIFW_SRC_URI = "https://codeload.github.com/raspberrypi/firmware/tar.gz/${SRCREV}"
RPIFW_S = "${WORKDIR}/firmware-${SRCREV}"

PR = "r60"

do_unpack() {
    tar -C ${WORKDIR} -xzf ${DL_DIR}/${SRCREV}
}
所以到 github.com/raspberrypi/firmware/,按下release" 會到每次 release 的 tarball 頁面。
裡面沒有20170530..

最接近的是https://github.com/raspberrypi/firmware/archive/1.20170515.tar.gz 他的linkname 也不是直接 ${SRCREV}, 而是 1.${RREPFW_DATE}。
反而比較像 meta-raspberrypi/recipes-bsp/bootfiles/../common/firmware.inc:
RPIFW_DATE ?= "20170405"
RPIFW_SRC_URI ?= "https://github.com/raspberrypi/firmware/archive/1.${RPIFW_DATE}.tar.gz"
RPIFW_S ?= "${WORKDIR}/firmware-1.${RPIFW_DATE}"

SRC_URI = "${RPIFW_SRC_URI}"
SRC_URI[md5sum] = "ea82d14a7cd8cfae9b78e00d4e56bc71"
SRC_URI[sha256sum] = "2f4e5bddbac1372590db203002c35cbba3fb9d6172a93c314ee27bf05ae13bff"

PV = "${RPIFW_DATE}"

是 bbappend,所以刪掉這個bootfile.bbappend,重新build 一次...
faile 在其他地方:
| arm-poky-linux-gnueabi-strip omxplayer.bin
| make: *** [omxplayer.1] Error 52
| ERROR: Function failed: do_compile (log file is located at 
/home/charles-chang/rpi-yocto/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/omxplayer/git-r4/temp/log.do_compile.16373)
ERROR: Task (/home/charles-chang/rpi-yocto/meta-raspberrypi/recipes-multimedia/omxplayer/omxplayer_git.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3371 tasks of which 1026 didn't need to be rerun and 1 failed.
看log,看不出fail 在那裡。
bitbake omxplayer
OK
再 bitbake qt5-basic-image
OK

loopback filesystem, growable loopback device

ref:
就是做出一個loopback filesystem,是用多少,長多少,不用先 dd 一個位子出來。

2017/9/21

bitbake -- print environment variable

ref: https://douglasfranca.tech.blog/2016/12/29/yocto-printing-environments-variables/

在 bitbake 的 conf, layer, bb 等有一堆變數。
要怎麼知道這些變數在 make 得時候,是什麼內容?

bitbake -e recipts-name 印出所有build 內容,然後用 grep ^VARNAME= 來取出..

例如,最後 build image 的 command 是 ..
bitbake fsl-image-qt5
我想知道所有的 DISTRO_FEATURES 是?
$ bitbake -e fsl-image-qt5 | grep ^DISTRO_FEATURES=

DISTRO_FEATURES="alsa argp bluetooth ext2 irda largefile pcmcia usbgadget usbhost wifi xattr nfs zeroconf pci 3g nfc 
ipv4 ipv6 libc-backtrace libc-big-macros libc-bsd libc-cxx-tests libc-catgets libc-charsets libc-crypt libc-crypt-ufc 
libc-db-aliases libc-envz libc-fcvt libc-fmtmsg libc-fstab libc-ftraverse libc-getlogin libc-idn libc-inet-anl 
libc-libm libc-locales libc-locale-code libc-memusage libc-nis libc-nsswitch libc-rcmd libc-rtld-debug libc-spawn 
libc-streams libc-sunrpc libc-utmp libc-utmpx libc-wordexp libc-posix-clang-wchar libc-posix-regexp 
libc-posix-regexp-glibc libc-posix-wchar-io largefile opengl ptest multiarch bluez pulseaudio sysvinit bluez5 
gobject-introspection-data"

bitbake another tools - bb

ref:https://github.com/kergoth/bb

git clone 下來後 run
bb/bin/bb init
# Load bb automatically by adding
# the following to ~/.bash_profile:

eval "$(/home/charles-chang/bb/bin/bb init -)"
所以就照著他說...
姊果不能用...

bitbake -- function document..

bitbake 一堆 conf, layer, bb 裡面用的語法,function,說明文件都在...source code 裡..
bb.utils.contains('DISTRO_FEATURES', 'wayland', 'west-init', '',d) 為例...
poky/bitbake/lib/bb/utils.py:
def contains(variable, checkvalues, truevalue, falsevalue, d):
    """Check if a variable contains all the values specified.

    Arguments:

    variable -- the variable name. This will be fetched and expanded (using
    d.getVar(variable, True)) and then split into a set().

    checkvalues -- if this is a string it is split on whitespace into a set(),
    otherwise coerced directly into a set().

    truevalue -- the value to return if checkvalues is a subset of variable.

    falsevalue -- the value to return if variable is empty or if checkvalues is
    not a subset of variable.

    d -- the data store.
    """

2017/9/15

docker -- embedded system 開發團隊使用docker 做開發環境的方法

先規定 一個 共用帳號,在 container 中,除了 root,就會使用這個帳號。

如果沒有辦法提供 dnsmasg, 而又需要修改 /etc/hosts 的話,可能會有點麻煩。
因為 container 每次從 image 啟動的時候,id 都不一樣,所以 docker 會複寫 /etc/hosts。
導致 image 中的 /etc/hosts 被修改。

所以如果要提供自己的 hosts,必須要在 container 啟動之後,自己加 (用 command 或 script)

docker -- share folder with host

docker vm (container) 可以跟 host 共用 folder。
應該說,可以把 host 的 folder mount 進來。
只有 container 可以,而且是在 start 時指定。
用:
-v "host\folder\path:container\path"
用這個方式,host 的 found 會被擺在 container 中,但是 file attr, uid/gid 都不變。

如果

docker . lxc + aufs

docker 的 image, container 概念大概就是出自於他使用的 aufs 檔案系統。
image 就是 DVD 類似的媒體。一般是 read only.
docker 的 'vm' 要啟動時,就以image 為base,上面疊上另一個 aufs 的 overlay。
這樣,任何的檔案修改,都只會紀錄在 aufs 上面那一層,不會改到下面的 image

所以docker 就有 image 和 container 兩種分類的命令。

docker 把放置所有 image 的地方叫 registry。
如果不另外自行配置,都會用官方的 registry (在 github?)。每個人都可以註冊帳號。之後就可以使用自己的帳號存放自己做的 image

container 一旦啟動之後,即使 exit, stop。container 的狀況依然保留著(裝過的packeg,修改的 file 部會消失),
大概是因為那個放container 上層 filesystem 的 folder 沒有刪除。
所以任何時候都可以再 star。
也因為 container 有自己要用的上層 filesystem (folder),所以整個 server 中,同樣的 container 只能有一個。
user A start 後, user B 無法再 start。
但是 user B stop 的話,user A 也會被 exit

container 狀態要保存的話,可以用 commit 命令把他變成 image。
這樣每個 user 都可以自己從這格image run 出一個 container 來。

另外,也可以用 export 命令,把 container export 成一個檔案。
當然,這格檔案就變成 image 了 (ro)
然後這個檔案可以 copy 到任何機器上,用 import 命令吃進 docker 系統,變成docker 系統的 image
-- 這樣就不用經過 docker registry server 了。

2017/9/14

docker ... misc

follow 這一篇,大概就是,把 https://download.docker.com 加到 apt source 中。
install docker-ce

會順便裝 aufs

裝完run docker info 說我 permission deny
所以把自己加到 docker 的 groupe 中,再是一次 , OK
ps 看,果然增加 docker-containerd, dockerd 兩個 daemon

docker build 之後, file 有錯,修改完,直接再 build 一次就可以。

run 過的 image 會產生一個 container,即使exit 了,container 依然在,所以 image 沒辦法rm
要先 docker rm container-id 之後,才能 docker rmi image-id
container id 可以用 docker ps -a -q 列出。
如果有兩個 reposity 使用相同的 image-id,就要加上 -f 才能刪除。
docker login 後,才能用 docker push images 到 docker hub 上自己的目錄。

docker swarm init 因為機器有兩個 網卡,所以要加上 --advertise-addr eth0 指定使用 eth0


docker run image 後就會產生一個 container,並且在其中執行。
之後這個container 就一直存在著,即使 exit 或是用 stop command 停止他,他都還在。
只要用 start command 啟動他,他的裝態都還是持續著 (安裝,修改過的東西不會reset)。

但是如果這個
另外,這個 github example 很不錯。

這一篇: How can I use docker without sudo 說,某一版之後,只要加入 docker group,就可以不用sudo 了。
但是要注意,docker group 有類似 root 的權限。
這個 是官方的說明。

更新 stretch

update
upgrade
dist-upgrade (沒事)
修改 sources.list
update
upgrade (一堆)
dist-upgrade (爆多,3G)

更新完後,要改 lightdm.conf 成autologin
dnsmasq,conf 也要改。
最後 apt-get autoremove

dmesg

升級完後,dmesg 竟然說 permission deny。
follow 這一篇, 用:
% sudo sysctl kernel.dmesg_restrict=0
kernel.dmesg_restrict = 0

所以把
kernel.dmesg_restrict = 0
加到 /etc/sysctl.conf 後面..就 OK 了。

nfs

mount v4 的 nfs 卻出現fail..dmesg 出現..NFS: nfs4_discover_server_trunking unhandled error -22. Exiting with error EIO
google 一下是新 bug..,所以 follow 這一篇 ...
echo 'blacklist rpcsec_gss_krb5' > /etc/modprobe.d/blacklist-rpcsec-gss-krb5.conf
reboot
結果 一樣..

sudo use vi, and no password
ref:https://askubuntu.com/questions/539243/how-to-change-visudo-editor-from-nano-to-vim
$sudo update-alternatives --config editor

ref:https://www.mxp.tw/2014/06/25/ubuntu-sudo-nopasswd-%E4%B8%8D%E7%94%A8%E8%BC%B8%E5%85%A5%E5%AF%86%E7%A2%BC%E8%A8%AD%E5%AE%9A/
就是...把 "NOPASSWD:" 插到..
sudo   ALL=(ALL:ALL) NOPASSWD:ALL

10/10 apt repository update

apt-get update 先出現 /var/lib/apt/list/lock (?)不能 lock。
去找一下,發現這個 lock file 存在,所以手動刪除,繼續...
然後出現一堆 /var/lib/apt/list/ooxx 的Error
follow 說明 apt-get clean 再 updat...
然後說 deb-multimedia.org 的 hash 不對。
所以手動,把 /var/lib/apt/lists 下所有檔案刪除,,,
OK

2017/9/11

隨便的 agl worklog...

有一個 Error
ERROR: weston-1.9.0-r0 do_populate_sysroot: The recipe weston is trying to install files into a shared area when those files already exist. Those files and their manifest location are:
   /home/charles-chang/AGL/build/tmp/sysroots/raspberrypi3/lib/systemd/system/weston.service
 Matched in manifest-raspberrypi3-weston-init.populate_sysroot

Please verify which recipe should provide the above files.

The build has stopped as continuing in this scenario WILL break things, if not now, possibly in the future (we've seen builds fail several months later). 
If the system knew how to recover from this automatically it would however there are several different scenarios which can result in this and we don't know 
which one this is. 
It may be you have switched providers of something like virtual/kernel (e.g. from linux-yocto to linux-yocto-dev), in that case you need to execute the clean
 task for both recipes and it will resolve this error. 
It may be you changed DISTRO_FEATURES from systemd to udev or vice versa. Cleaning those recipes should again resolve this error however switching
 DISTRO_FEATURES on an existing build directory is not supported, you should really clean out tmp and rebuild (reusing sstate should be safe). 
It could be the overlapping files detected are harmless in which case adding them to SSTATE_DUPWHITELIST may be the correct solution. 
It could also be your build is including two different conflicting versions of things (e.g. bluez 4 and bluez 5 and the correct solution for that would be to
 resolve the conflict. 
If in doubt, please ask on the mailing list, sharing the error and filelist above.

ERROR: weston-1.9.0-r0 do_populate_sysroot: If the above message is too much, the simpler version is you're advised to wipe out tmp and rebuild (reusing sstate
 is fine). That will likely fix things in most (but not all) cases.
ERROR: weston-1.9.0-r0 do_populate_sysroot: Function failed: sstate_task_postfunc

ERROR: Logfile of failure stored in: /home/charles-chang/AGL/build/tmp/work/cortexa7hf-neon-vfpv4-agl-linux-gnueabi/weston/1.9.0
-r0/temp/log.do_populate_sysroot.21390

ERROR: Task 311 (/home/charles-chang/AGL/meta-agl/meta-agl/recipes-graphics/wayland/weston_1.9.0.bb, do_populate_sysroot) failed with exit code '1'

三代 pi

一個是roy的..
一片1325



糟糕,pi 3 原本的 console uart 已經被拿去給 bt 用,所以uart console 不能用了。
因為修改方式好像很麻煩,而且會喪失 bt 功能,所以還是用 hdmi + keyboard/mouse 開機好了。
開機超快,插上電大概 3 sec..

桌面是 LXDE,browser 是 chrome。

裝 FlintOS (ChromeOS), 很慢,不堪用。

2017/9/6

開機後 進入 文字模式

無法啟動 gui
login 後手動 startx
出現 error message : cannot find display

所以把 /etc/X11/xorg.conf 刪除就可以了。

2017/8/31

linux distro in wandboard

這一篇 https://eewiki.net/display/linuxonarm/Wandboard 很有趣呀。
用以前的方是,手動,...build kernel, prepare root, dd ..

然後這一篇https://github.com/Nuand/bladeRF/wiki/Creating-Linux-based-Embedded-System-Images-with-Yocto 是用yocto 手動寫 bblayer 和 拉 meta-receipt build 出 system。

大概就是..
checkout poky (yotco)
checkout yocto sdr (what's this?)
checkout oe
checkout meta-fsl-arm
checkout meta-fsl-arm-extra ( git clone -b jethro git://github.com/Freescale/meta-fsl-arm-extra.git )
然後用 openembedded 的環境設定 script 產生一個基本的 configuration folder 外型
source poky-jethro-2.0/oe-init-build-env buildfolder
然後就會有 conf 出現在 buildfolder 下..

這個只雛型,要修改他成為你要的設定..
修改 conf/local.conf
  • 指定 MACHINE
  • 指定 download 到...
  • 因為有 meta-fsl-arm, 所以要加一行 ACCEPT_FSL_EULA 到最後
然後修改 bblayer, 裡面是你要的東西...
一些 linux system 基本的,都在 meta-openembedded 裡面了。
只要把你要的寫進 BBLAYERS ..

然後就可以 bitbake core-image-minimal
一樣,image 在 ..../deploy/images/wandboard/,用 gzip 解開
gzip -d --force core-image-minimal-wandboard.sdcard.gz
dd 到 sdcard。
wandboard 一樣,uart , null-modem + gender-changer
boot OK, login-name : root, no password

2017/8/30

最後參考...http://git.freescale.com/git/cgit.cgi/imx/meta-nxp-agl.git/tree/README.txt?h=krogoth :
This builds the Wayland-Weston AGL image with the basic AGL interface. 
Demos can then be run on top of this.

This image has only been run on i.MX 6QP Sabre and Sabre Auto.
It is not supported nor tested.  It is simply a demo showing that the basic image runs.
It runs on the 4.1.15-1.0.0 Freescale release of Linux.

Build instructions:
To get the BSP you need to have `repo` installed.

Install the `repo` utility (only need to do once per user):
--------------------------------------------------

$: mkdir ~/bin
$: curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$: chmod a+x ~/bin/repo
$: PATH=${PATH}:~/bin

Download the BSP Yocto Project Environment into your directory:
-------------------------------------------

$: mkdir fsl-arm-yocto-bsp
$: cd fsl-arm-yocto-bsp
$: repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth -m imx-4.1.15-2.0.0-agl-demo.xml

$: repo sync

Setup and Build for Wayland (currently, only one supported)
-------------------------------------------
$: DISTRO=nxp-imx-agl-wayland MACHINE=imx6qpsabreauto source nxp-setup-agl.sh -b bld-agl

IMAGES
-------------------------------------------
Most interesting results currently seen with:
$: bitbake agl-demo-platform

Other images:
$: bitbake agl-image-minimal
$: bitbake agl-image-ivi
$: bitbake agl-image-weston

The "navi" demo is also included.  To run it, follow the instructions in the README.md in sources/gpsnavi-agl.

The CES2016 demo is in this image.  To run it, you need to connect an HDMI monitor in the "portrait" orientation.
The dimensions in the demos are hard coded.  The files used are in /opt/AGL/CES2016 and /etc/xdg/weston.  
然後machine 改 wandboard 再 build, failed...
WARNING: wayland-ivi-extension-1.9.1-r0 do_fetch: Failed to fetch URL file://wandboard_fix_build.patch, attempting MIRRORS if available
ERROR: wayland-ivi-extension-1.9.1-r0 do_fetch: Fetcher failure: Unable to find file file://wandboard_fix_build.patch anywhere. 
...
...
ERROR: wayland-ivi-extension-1.9.1-r0 do_fetch: Function failed: Fetcher failure for URL: 'file://wandboard_fix_build.patch'. Unable to fetch URL from any source.
ERROR: Logfile of failure stored in: /home/charles-chang/fsl-arm-yocto-bsp/bld-agl-wandboard/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/wayland-ivi-extension/1.9.1-r0/temp/log.do_fetch.1143
ERROR: Task 3832 (/home/charles-chang/fsl-arm-yocto-bsp/sources/meta-nxp-agl/recipes-graphics/wayland/wayland-ivi-extension_1.9.1.bb, do_fetch) failed with exit code '1'

yocto - wandboard , FSL_EULA

延續上一篇。ACCEPT_FSL_EULA 的設定。
參考 meta-agl/templates/machine/imx6qsabrelite/50_setup.sh:
find_and_ack_eula $METADIR/meta-fsl-arm EULA 
export EULA_FLAG_NAME="ACCEPT_FSL_EULA"
對照 imx6sabrelite 跟 wandboard,缺 50_setup.sh
所以 copy 過去..

結果一樣...

cache image size

很奇怪,明明改了 cache image size,不知謂何又被改回去。
所以,,
在 build 下 grep cacheimage..找到
core/Makefile:.PHONY: cacheimage-nodeps
所以 make cacheimage-nodeps
make_ext4fs -s -T -1 -S out/target/product/msm8953_64/root/file_contexts -L cache -l 268435456 -a cache out/target/product/msm8953_64/cache.img out/target/product/msm8953_64/cache out/target/product/msm8953_64/system
果然...

所以找一下,這個值是 device/,.../BoardConfig.mk:
BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456

所以修改一下,..
BOARD_CACHEIMAGE_PARTITION_SIZE := 1317011456
再 run 一次make 測試。OK

2017/8/29

AGL on wandboard

這一篇 Download Source 有說明...
repo init -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo
repo sync
然後選平台:
source meta-agl/scripts/aglsetup.sh -h
------------ aglsetup.sh: Starting
Usage: . aglsetup.sh [options] [feature [feature [... ]]]

Version: 1.1.0
Compatibility: bash, zsh, ksh

Options:
   -m|--machine 
      what machine to use
      default: 'qemux86-64'
   -b|--build 
      build directory to use
      default: './build'
   -s|--script 
      file where setup script is generated
      default: none (no script)
   -f|--force
      flag to force overwriting any existing configuration
      default: false
   -v|--verbose
      verbose mode
      default: false
   -d|--debug
      debug mode
      default: false
   -h|--help
      get some help

Available machines:
   [meta-agl]
       beaglebone
       cyclone5
       dra7xx-evm
       dragonboard-410c
       h3ulcb
       imx6qsabreauto
       imx6qsabrelite
       intel-corei7-64
       joule
       m3ulcb
       m3ulcb-nogfx
       nitrogen6x
       porter
       porter-nogfx
       qemux86
     * qemux86-64
       raspberrypi2
       raspberrypi3
       raspberrypi3-64
       wandboard

Available features:
   [meta-agl]
       agl-all-features :( agl-demo  agl-appfw-smack  agl-devel  agl-netboot  agl-sota  agl-sdl )
       agl-appfw-smack
       agl-archiver
       agl-ci
       agl-ci-change-features :( agl-demo  agl-appfw-smack  agl-devel  agl-devel  agl-netboot  agl-appfw-smack  agl-sdl )
       agl-ci-change-features-nogfx :( agl-devel  agl-netboot  agl-appfw-smack )
       agl-ci-snapshot-features :( agl-demo  agl-appfw-smack  agl-devel  agl-devel  agl-netboot  agl-appfw-smack  agl-isafw  agl-archiver  agl-sdl )
       agl-ci-snapshot-features-nogfx :( agl-devel  agl-netboot  agl-appfw-smack  agl-isafw  agl-archiver )
       agl-devel
       agl-isafw
       agl-netboot
       agl-sota
   [meta-agl-demo]
       agl-demo :( agl-appfw-smack  agl-devel )
       agl-iotivity
       agl-sdl
   [meta-agl-devel]
       agl-egvirt
       agl-oem-extra-libs
       agl-renesas-kernel
   [meta-agl-extra]
       agl-localdev
要 build wandboard...
所以..參考 build for raspberry pi 的部份..
$source meta-agl/scripts/aglsetup.sh -m wandboard agl-demo agl-netboot agl-appfw-smack
------------ aglsetup.sh: Starting
Generating configuration files:
   Build dir: /home/charles-chang/AGL/build
   Machine: wandboard
   Features: agl-appfw-smack agl-demo agl-devel agl-netboot 
   Running /home/charles-chang/AGL/poky/oe-init-build-env
   Templates dir: /home/charles-chang/AGL/meta-agl/templates/base
   Config: /home/charles-chang/AGL/build/conf/bblayers.conf
   Config: /home/charles-chang/AGL/build/conf/local.conf
   Setup script: /home/charles-chang/AGL/build/conf/setup.sh
   Executing setup script ... --- beginning of setup script
--- fragment /home/charles-chang/AGL/meta-agl/templates/base/01_setup_EULAfunc.sh
--- fragment /home/charles-chang/AGL/meta-agl/templates/base/99_setup_EULAconf.sh
--- end of setup script
OK
Generating setup file: /home/charles-chang/AGL/build/agl-init-build-env ... OK
------------ aglsetup.sh: Done

### Shell environment set up for builds. ###

You can now run 'bitbake '

Common targets are:
  - meta-agl:          (core system)
    agl-image-minimal
    agl-image-minimal-qa
    
    agl-image-ivi
    agl-image-ivi-qa
    agl-image-ivi-crosssdk
    
    agl-image-weston

  - meta-agl-demo:     (demo with UI)
    agl-demo-platform  (* default demo target)
    agl-demo-platform-qa
    agl-demo-platform-crosssdk
    
    agl-demo-platform-html5

然後 build..
$bitbake agl-demo-platform
然後就出現 error:
ERROR: Layer directory '/home/charles-chang/AGL/meta-fsl-arm' does not exist! Please check BBLAYERS in /home/charles-chang/AGL/build/conf/bblayers.conf
... 難怪 imx 的都沒 prebuild 了...

然後倒退...chinook 3.0.2 版,不會出現這個 error
3.0.1/0 都會出現 meta-rcar sha error

build fail
ERROR: imx-gpu-viv-1_5.0.11.p8.4-hfp-r0 do_unpack: To use 'imx-gpu-viv' you need to accept the Freescale EULA at '/home/charles-chang/AGL/meta-fsl-arm/EULA'. Please read it and in case you accept it, write: ACCEPT_FSL_EULA = "1" in your local.conf.
ERROR: imx-gpu-viv-1_5.0.11.p8.4-hfp-r0 do_unpack: Function failed: do_unpack
ERROR: Logfile of failure stored in: /home/charles-chang/AGL/build/tmp/work/cortexa9hf-neon-mx6qdl-agl-linux-gnueabi/imx-gpu-viv/1_5.0.11.p8.4-hfp-r0/temp/log.do_unpack.8709
ERROR: Task 2321 (/home/charles-chang/AGL/meta-fsl-arm/recipes-graphics/imx-gpu-viv/imx-gpu-viv_5.0.11.p8.4-hfp.bb, do_unpack) failed with exit code '1'
所以遵照說明,在 build/conf/local.confg 最後加上:
ACCEPT_FSL_EULA = "1"
test build
build$ bitbake -b /home/charles-chang/AGL/meta-fsl-arm/recipes-graphics/imx-gpu-viv/imx-gpu-viv_5.0.11.p8.4-hfp.bb 
重 build 一次,出現 Error:
ERROR: aim-network-0.1-r0 do_compile: oe_runmake failed
ERROR: aim-network-0.1-r0 do_compile: Function failed: do_compile (log file is located at /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/temp/log.do_compile.3681)
ERROR: aim-sound-0.1-r0 do_compile: oe_runmake failed
ERROR: aim-sound-0.1-r0 do_compile: Function failed: do_compile (log file is located at /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/temp/log.do_compile.3589)
ERROR: Logfile of failure stored in: /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/temp/log.do_compile.3681
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: make -j 8 KERNEL_SRC=/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source KERNEL_PATH=/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source KERNEL_VERSION=3.14.28_1.0.0_ga-wandboard+ge2df042 CC=arm-agl-linux-gnueabi-gcc  -mno-thumb-interwork -marm -fuse-ld=bfd LD=arm-agl-linux-gnueabi-ld.bfd   AR=arm-agl-linux-gnueabi-ar  O=/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-build-artifacts
| make -C /home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source M=/home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network modules
| make[1]: Entering directory `/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source'
|   CC [M]  /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.o
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.c: In function 'aim_probe_channel':
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.c:366:23: error: macro "alloc_netdev" passed 4 arguments, but takes just 3
|           most_nd_setup);
|                        ^
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.c:365:4: error: 'alloc_netdev' undeclared (first use in this function)
|     alloc_netdev(0, "meth%d", NET_NAME_UNKNOWN,
|     ^
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.c:365:4: note: each undeclared identifier is reported only once for each function it appears in
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.c: At top level:
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.c:293:13: warning: 'most_nd_setup' defined but not used [-Wunused-function]
|  static void most_nd_setup(struct net_device *dev)
|              ^
| make[3]: *** [/home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network/networking.o] Error 1
| make[2]: *** [_module_/home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/git/driver/aim-network] Error 2
| make[1]: *** [sub-make] Error 2
| make[1]: Leaving directory `/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source'
| make: *** [all] Error 2
| WARNING: exit code 1 from a shell command.
| ERROR: oe_runmake failed
| ERROR: Function failed: do_compile (log file is located at /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-network/0.1-r0/temp/log.do_compile.3681)
ERROR: Task 632 (/home/charles-chang/AGL/meta-agl-demo/recipes-kernel/aim-network/aim-network.bb, do_compile) failed with exit code '1'
ERROR: Logfile of failure stored in: /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/temp/log.do_compile.3589
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: make -j 8 KERNEL_SRC=/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source KERNEL_PATH=/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source KERNEL_VERSION=3.14.28_1.0.0_ga-wandboard+ge2df042 CC=arm-agl-linux-gnueabi-gcc  -mno-thumb-interwork -marm -fuse-ld=bfd LD=arm-agl-linux-gnueabi-ld.bfd   AR=arm-agl-linux-gnueabi-ar  O=/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-build-artifacts
| make -C /home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source M=/home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/git/driver/aim-sound modules
| make[1]: Entering directory `/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source'
|   CC [M]  /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/git/driver/aim-sound/sound.o
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/git/driver/aim-sound/sound.c: In function 'audio_probe_channel':
| /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/git/driver/aim-sound/sound.c:598:8: error: implicit declaration of function 'snd_card_new' [-Werror=implicit-function-declaration]
|   ret = snd_card_new(NULL, -1, card_name, THIS_MODULE,
|         ^
| cc1: some warnings being treated as errors
| make[3]: *** [/home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/git/driver/aim-sound/sound.o] Error 1
| make[2]: *** [_module_/home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/git/driver/aim-sound] Error 2
| make[1]: *** [sub-make] Error 2
| make[1]: Leaving directory `/home/charles-chang/AGL/build/tmp/work-shared/wandboard/kernel-source'
| make: *** [all] Error 2
| ERROR: oe_runmake failed
| ERROR: Function failed: do_compile (log file is located at /home/charles-chang/AGL/build/tmp/work/wandboard-agl-linux-gnueabi/aim-sound/0.1-r0/temp/log.do_compile.3589)
ERROR: Task 646 (/home/charles-chang/AGL/meta-agl-demo/recipes-kernel/aim-sound/aim-sound.bb, do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3603 tasks of which 827 didn't need to be rerun and 2 failed.
Waiting for 0 running tasks to finish:

Summary: 2 tasks failed:
  /home/charles-chang/AGL/meta-agl-demo/recipes-kernel/aim-network/aim-network.bb, do_compile
  /home/charles-chang/AGL/meta-agl-demo/recipes-kernel/aim-sound/aim-sound.bb, do_compile
Summary: There were 7 WARNING messages shown.
Summary: There were 4 ERROR messages shown, returning a non-zero exit code.
試試看 3.0.5 --- 之後的 tag 都沒有 meta-fsl 了...

變成;
ERROR: imx-gpu-viv-1_5.0.11.p8.4-hfp-r0 do_configure: QA Issue: imx-gpu-viv: LIC_FILES_CHKSUM points to an invalid file: /home/charles-chang/AGL/build/tmp/work/cortexa9hf-neon-mx6qdl-agl-linux-gnueabi/imx-gpu-viv/1_5.0.11.p8.4-hfp-r0/imx-gpu-viv-5.0.11.p8.4-hfp/gpu-core/usr/include/gc_vdk.h [license-checksum]
ERROR: imx-gpu-viv-1_5.0.11.p8.4-hfp-r0 do_configure: Fatal QA errors found, failing task.
ERROR: imx-gpu-viv-1_5.0.11.p8.4-hfp-r0 do_configure: Function failed: do_qa_configure
ERROR: Logfile of failure stored in: /home/charles-chang/AGL/build/tmp/work/cortexa9hf-neon-mx6qdl-agl-linux-gnueabi/imx-gpu-viv/1_5.0.11.p8.4-hfp-r0/temp/log.do_configure.4436
ERROR: Task 2317 (/home/charles-chang/AGL/meta-fsl-arm/recipes-graphics/imx-gpu-viv/imx-gpu-viv_5.0.11.p8.4-hfp.bb, do_configure) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3431 tasks of which 1284 didn't need to be rerun and 1 failed.
Waiting for 0 running tasks to finish:

Summary: 1 task failed:
  /home/charles-chang/AGL/meta-fsl-arm/recipes-graphics/imx-gpu-viv/imx-gpu-viv_5.0.11.p8.4-hfp.bb, do_configure
Summary: There was 1 WARNING message shown.
Summary: There were 3 ERROR messages shown, returning a non-zero exit code.
找一下,是..meta-fsl-arm/recipes-graphics/imx-gpu-viv/imx-gpu-viv.inc..
LIC_FILES_CHKSUM = "file://gpu-core/usr/include/gc_vdk.h;beginline=5;endline=11;md5=12c028cbbbedb4b8770267131500592c"
ref:http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html#usingpoky-configuring-LIC_FILES_CHKSUM

2017/8/24

AIDL

AIDL 宣告了 service 提供的 function。
所以:
  • service 要實做這些 function
  • client 可以要求 service 執行這些 function

aidl 這額 compiler,就是把 *.aidl 轉成 *.java
一個 java 檔,完成以上兩件事,讓..
  • service focuse 在實做 function
  • client 簡單呼叫這些 functrion
而 client 呼叫 function 時,把對應 argument 包裝起來,呼叫 Binder,交給 service 處理,
然後service處理完,把 result 包裝起來,傳回 binder,
clien5 再把 result 解開,交給 caller

這些動作,都坐在 *.aidl 轉成的 *.java 裡。

所以 *.aidl 轉成的 *.java,包含了給 client 和 service 兩人用的 code
-- 當然,兩人各用各的 function,只是寫在同一個 *.java 裡。

aidl 做出來的 *.java,最外層是直接翻譯 *.aidl 內容,class。
裡面是 static abstract class : Stub
這個 Stub 是上面寫的做雜事的主體,
雖然是同時給 service 和 client 用。但是大部分是給 service 用的。
給 client 用的只有一個 static class : Proxy

然後提供一個生成函式給 client 用: asInterface( )
他的內容就是把 Proxy new 出來。

至於service,就直接拿 Stub class 來用,實做 aidl 宣告的 interface function 就可以。


這一篇StackOverflow 的回答...
'Stub' is a class that implements the remote interface in a way that you can use it as if it were a local one. 
It handles data marashalling/unmarshalling and sending/receiving to/from the remote service. 
The term 'stub' is generally used to describe this functionality in other RPC methods (COM, Java remoting, etc.), 
but it can mean slightly different things.

所以programmer 建

2017/8/21

https://gitea.io/zh-TW/

來試試這個好了,開個container run 一下,最好還能順便碰一下 golang

2017/8/18

BaseNetworkObsever 定義要 Monitor Interface的狀態時的 動作:
StateChange
Add
Remove
叫 Network Manager 在出現 interface .. StateChange, Add, Remove 時分別 call 這三個 function.
所以..
我們寫下我們自己 implement 的 class
    private class InterfaceObserver extends BaseNetworkObserver {
        @Override
        public void interfaceLinkStateChanged(String iface, boolean up) {
            updateInterfaceState(iface, up);
        }

        @Override
        public void interfaceAdded(String iface) {
            maybeTrackInterface(iface);
        }

        @Override
        public void interfaceRemoved(String iface) {
            stopTrackingInterface(iface);
        }
    }
然後在系統啟動的時候,向 Network Management Service 註冊:
        // Start tracking interface change events.
        mInterfaceObserver = new InterfaceObserver();
        try {
            mNMService.registerObserver(mInterfaceObserver);
        } catch (RemoteException e) {
            Log.e(TAG, "Could not register InterfaceObserver " + e);
        }

ethernet interface config -- android

在 frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactoty.java:
/**
 * Manages connectivity for an Ethernet interface.
 *
 * Ethernet Interfaces may be present at boot time or appear after boot (e.g.,
 * for Ethernet adapters connected over USB). This class currently supports
 * only one interface. When an interface appears on the system (or is present
 * at boot time) this class will start tracking it and bring it up, and will
 * attempt to connect when requested. Any other interfaces that subsequently
 * appear will be ignored until the tracked interface disappears. Only
 * interfaces whose names match the config_ethernet_iface_regex
 * regular expression are tracked.
 *
 * This class reports a static network score of 70 when it is tracking an
 * interface and that interface's link is up, and a score of 0 otherwise.
 *
 * @hide
 */
參考的地方是...
        mIfaceMatch = context.getResources().getString(
                com.android.internal.R.string.config_ethernet_iface_regex);
 
         ...
    private boolean maybeTrackInterface(String iface) {
        // If we don't already have an interface, and if this interface matches
        // our regex, start tracking it.
        if (!iface.matches(mIfaceMatch) || isTrackingInterface())
            return false;

        Log.d(TAG, "Started tracking interface " + iface);
        setInterfaceUp(iface);
        return true;
    }

2017/8/16

frameworks/base/core/java/android/net
ConnectivityManager.java:
裡面有定義各類連線類型: TYPE_WIFI, TYPE_MOBILE_MMS, TYPE_BLUETOOTH, TYPE_DUMMY, TYPE_ETHERNET, TYPE_PROXY,

跟 "目前網路狀態" 有關的,好像是...
    /**
     * Returns details about the currently active default data network. When
     * connected, this network is the default route for outgoing connections.
     * You should always check {@link NetworkInfo#isConnected()} before initiating
     * network traffic. This may return {@code null} when there is no default
     * network.
     * 

This method requires the caller to hold the permission * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. * * @return a {@link NetworkInfo} object for the current default network * or {@code null} if no default network is currently active */ public NetworkInfo getActiveNetworkInfo() { try { return mService.getActiveNetworkInfo(); } catch (RemoteException e) { return null; } } /** * Returns a {@link Network} object corresponding to the currently active * default data network. In the event that the current active default data * network disconnects, the returned {@code Network} object will no longer * be usable. This will return {@code null} when there is no default * network. *

This method requires the caller to hold the permission * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. * * @return a {@link Network} object for the current default network or * {@code null} if no default network is currently active */ public Network getActiveNetwork() { try { return mService.getActiveNetwork(); } catch (RemoteException e) { return null; } }

還有一個,好像是要使用網路之前,要call 的...

另外在 frameworks/opt/net 下也有.. ethernet, ims, voip, wifi 四個 categories..

2017/8/10

filesytem 的 uid/gid : AID_XXXX 定義在 system/core/include/private/android_filesystem_config.h
/* This is the master Users and Groups config for the platform.
 * DO NOT EVER RENUMBER
 */

#define AID_ROOT             0  /* traditional unix root user */

#define AID_SYSTEM        1000  /* system server */

#define AID_RADIO         1001  /* telephony subsystem, RIL */
#define AID_BLUETOOTH     1002  /* bluetooth subsystem */
#define AID_GRAPHICS      1003  /* graphics devices */
#define AID_INPUT         1004  /* input devices */
#define AID_AUDIO         1005  /* audio devices */
#define AID_CAMERA        1006  /* camera devices */
#define AID_LOG           1007  /* log devices */
#define AID_COMPASS       1008  /* compass device */
#
...
...
#define AID_EVERYBODY     9997  /* shared between all apps in the same profile */
#define AID_MISC          9998  /* access to misc storage */
#define AID_NOBODY        9999

#define AID_APP          10000  /* first app user */


2017/8/9

android 為了 sdcard/usbdisk 使用 Fuse filesystem,寫了一個 tool : sdcard
/system/core/sdcard

其中 option 的部份:
    while ((opt = getopt(argc, argv, "u:g:U:mw")) != -1) {
        switch (opt) {
            case 'u':
                uid = strtoul(optarg, NULL, 10);
                break;
            case 'g':
                gid = strtoul(optarg, NULL, 10);
                break;
            case 'U':
                userid = strtoul(optarg, NULL, 10);
                break;
            case 'm':
                multi_user = true;
                break;
            case 'w':
                full_write = true;
                break;
            case '?':
            default:
                return usage();
        }
    }
其中 multi-user 的意思:
    if (multi_user) {
        /* Multi-user storage is fully isolated per user, so "other"
         * permissions are completely masked off. */
        if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                || fuse_setup(&fuse_read, AID_EVERYBODY, 0027)
                || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0027)) {
            ERROR("failed to fuse_setup\n");
            exit(1);
        }
    } else {
        /* Physical storage is readable by all users on device, but
         * the Android directories are masked off to a single user
         * deep inside attr_from_stat(). */
        if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                || fuse_setup(&fuse_read, AID_EVERYBODY, full_write ? 0027 : 0022)
                || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0022)) {
            ERROR("failed to fuse_setup\n");
            exit(1);
        }
    }

2017/8/3

OpenGapp

好有趣,竟然還有這個:OpenGAPP
就是把 google 的 gapp 包裝成 update file

download zip, 解開後...
update-binary 實際上是一個 shellscript。但是最終還是 call install.sh

有關 core app 部份:
for gapp_name in $core_gapps_list; do
  get_apparchives "Core/$gapp_name"
  for archive in $apparchives; do
    case $gapp_name in
      setupwizarddefault) if [ "$device_type" != "tablet" ]; then extract_app "$archive"; fi;;
      setupwizardtablet)  if [ "$device_type"  = "tablet" ]; then extract_app "$archive"; fi;;
      *)  extract_app "$archive";;
    esac
  done
done;
ui_print " ";
也就是 extract_app:
extract_app() {
  tarpath="$TMP/$1.tar" # NB no suffix specified here
  if "$TMP/unzip-$BINARCH" -o "$OPENGAZIP" "$1.tar*" -d "$TMP"; then # wildcard for suffix
    app_name="$(basename "$1")"
    which_dpi "$app_name"
    echo "Found $1 DPI path: $dpiapkpath"
    folder_extract "$tarpath" "$dpiapkpath" "$app_name/common"
  else
    echo "Failed to extract $1.tar* from $OPENGAZIP"
  fi
}
就是 folder_extract:
  elif [ -e "$archive.lz" ]; then
    for f in "$@"; do
      if [ "$f" != "unknown" ]; then
        "$TMP/tar-$BINARCH" -xf "$archive.lz" -C "$TMP" "$f" && install_extracted "$f"
      fi
    done
    rm -f "$archive.lz"
解開m,然後 install_extracted:
install_extracted() {
  file_list="$(find "$TMP/$1/" -mindepth 1 -type f | cut -d/ -f5-)"
  dir_list="$(find "$TMP/$1/" -mindepth 1 -type d | cut -d/ -f5-)"
  for file in $file_list; do
      install -D "$TMP/$1/${file}" "$SYSTEM/${file}"
      ch_con "$SYSTEM/${file}"
      set_perm 0 0 644 "$SYSTEM/${file}";
  done
  for dir in $dir_list; do
    ch_con "$SYSTEM/${dir}"
    set_perm 0 0 755 "$SYSTEM/${dir}";
  done
  case $preodex in
    true*)
      installedapkpaths="$(find "$TMP/$1/" -name "*.apk" -type f | cut -d/ -f5-)"
      for installedapkpath in $installedapkpaths; do  # TODO fix spaces-handling
        if ! checkmanifest "$SYSTEM/$installedapkpath" "classes.dex"; then
          ui_print "- pre-ODEX-ing $gapp_name";
          log "pre-ODEX-ing" "$gapp_name";
          odexapk "$SYSTEM/$installedapkpath"
        fi
      done
    ;;
  esac
  bkup_list=$'\n'"${file_list}${bkup_list}"
  rm -rf "$TMP/$1"
}

install 是 busybox 提供的...
ch_con 是 chcon:
ch_con() {
  chcon -h u:object_r:system_file:s0 "$1";
}
所以間單來說,只要 gms 的話,要裝 gms 跟 gsf . 然後 permission 也要。
所以就是解開:之後,把 priv-app push 到 /system/priv-app, 把 permission push 到 /system/etc/permissions , 把 sysconfig push 到 /system/etc/sysconfig 之後,重開機就可以。
我解開(install) 的有:
  • Core/defaultetc-comm : permissions and sysconfig
  • Core/gmscore-arm64 : PrebuiltGmsCore
  • Core/gsf-all : GoogleServiceFramework
  • Core/gsflogin-all : GoogleLoginService
-- permission 好像還是沒過,所以還是有改 framework 的 PackageManagerService, 把 Permission 都改 GRANT

2017/8/1

Error Message 出自於:
    private void enforce(
            String permission, int resultOfCheck,
            boolean selfToo, int uid, String message) {
        if (resultOfCheck != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException(
                    (message != null ? (message + ": ") : "") +
                    (selfToo
                     ? "Neither user " + uid + " nor current process has "
                     : "uid " + uid + " does not have ") +
                    permission +
                    ".");
        }
    }
Fail 檢查是: 第二個argument : int resultOfCheck
從 caller 看:
    public void enforceCallingOrSelfPermission(
            String permission, String message) {
        enforce(permission,
                checkCallingOrSelfPermission(permission),
                true,
                Binder.getCallingUid(),
                message);
    }

第二個argument 是 checkCallingOrSelfPermission()
他call的是:
    public int checkCallingOrSelfPermission(String permission) {
        if (permission == null) {
            throw new IllegalArgumentException("permission is null");
        }

        return checkPermission(permission, Binder.getCallingPid(),
                Binder.getCallingUid());
    }

所以就是 checkPermission( )
    public int checkPermission(String permission, int pid, int uid) {
        if (permission == null) {
            throw new IllegalArgumentException("permission is null");
        }

        try {
            return ActivityManagerNative.getDefault().checkPermission(
                    permission, pid, uid);
        } catch (RemoteException e) {
            return PackageManager.PERMISSION_DENIED;
        }
    }

跑到 : services/core/java/com/android/server/am/ActivityManagerService.java:
    public int checkPermission(String permission, int pid, int uid) {
        if (permission == null) {
            return PackageManager.PERMISSION_DENIED;
        }
        return checkComponentPermission(permission, pid, uid, -1, true);
    }

   ...
   ...
   ...
    int checkComponentPermission(String permission, int pid, int uid,
            int owningUid, boolean exported) {
        if (pid == MY_PID) {
            return PackageManager.PERMISSION_GRANTED;
        }
        return ActivityManager.checkComponentPermission(permission, uid,
                owningUid, exported);
    }

在:core/java/android/app/ActivityManager.java
    public static int checkComponentPermission(String permission, int uid,
            int owningUid, boolean exported) {
        // Root, system server get to do everything.
        final int appId = UserHandle.getAppId(uid);
        if (appId == Process.ROOT_UID || appId == Process.SYSTEM_UID) {
            return PackageManager.PERMISSION_GRANTED;
        }
        // Isolated processes don't get any permissions.
        if (UserHandle.isIsolated(uid)) {
            return PackageManager.PERMISSION_DENIED;
        }
        // If there is a uid that owns whatever is being accessed, it has
        // blanket access to it regardless of the permissions it requires.
        if (owningUid >= 0 && UserHandle.isSameApp(uid, owningUid)) {
            return PackageManager.PERMISSION_GRANTED;
        }
        // If the target is not exported, then nobody else can get to it.
        if (!exported) {
            /*
            RuntimeException here = new RuntimeException("here");
            here.fillInStackTrace();
            Slog.w(TAG, "Permission denied: checkComponentPermission() owningUid=" + owningUid,
                    here);
            */
            return PackageManager.PERMISSION_DENIED;
        }
        if (permission == null) {
            return PackageManager.PERMISSION_GRANTED;
        }
        try {
            return AppGlobals.getPackageManager()
                    .checkUidPermission(permission, uid);
        } catch (RemoteException e) {
            // Should never happen, but if it does... deny!
            Slog.e(TAG, "PackageManager is dead?!?", e);
        }
        return PackageManager.PERMISSION_DENIED;
    }
最後,就是 getPackageManager().checkUidPermission( ) 了..
base/services/core/java/com/android/server/pm/PackageManagerService.java:
    public int checkUidPermission(String permName, int uid) {
        final int userId = UserHandle.getUserId(uid);

        if (!sUserManager.exists(userId)) {
            return PackageManager.PERMISSION_DENIED;
        }

        synchronized (mPackages) {
            Object obj = mSettings.getUserIdLPr(UserHandle.getAppId(uid));
            if (obj != null) {
                final SettingBase ps = (SettingBase) obj;
                final PermissionsState permissionsState = ps.getPermissionsState();
                if (permissionsState.hasPermission(permName, userId)) {
                    return PackageManager.PERMISSION_GRANTED;
                }
                // Special case: ACCESS_FINE_LOCATION permission includes ACCESS_COARSE_LOCATION
                if (Manifest.permission.ACCESS_COARSE_LOCATION.equals(permName) && permissionsState
                        .hasPermission(Manifest.permission.ACCESS_FINE_LOCATION, userId)) {
                    return PackageManager.PERMISSION_GRANTED;
                }
            } else {
                ArraySet perms = mSystemPermissions.get(uid);
                if (perms != null) {
                    if (perms.contains(permName)) {
                        return PackageManager.PERMISSION_GRANTED;
                    }
                    if (Manifest.permission.ACCESS_COARSE_LOCATION.equals(permName) && perms
                            .contains(Manifest.permission.ACCESS_FINE_LOCATION)) {
                        return PackageManager.PERMISSION_GRANTED;
                    }
                }
            }
        }

        return PackageManager.PERMISSION_DENIED;
    }



final SparseArray<ArraySet<String>> mSystemPermission = systemConfig.getSystemPermissions();
framework/base/services/core/java/com/android/server/SystemConfig.java:
readPermissionsFromXml
整個 read system config/permission file 的 code:
    SystemConfig() {
        // Read configuration from system
        readPermissions(Environment.buildPath(
                Environment.getRootDirectory(), "etc", "sysconfig"), false);
        // Read configuration from the old permissions dir
        readPermissions(Environment.buildPath(
                Environment.getRootDirectory(), "etc", "permissions"), false);
        // Only read features from OEM config
        readPermissions(Environment.buildPath(
                Environment.getOemDirectory(), "etc", "sysconfig"), true);
        readPermissions(Environment.buildPath(
                Environment.getOemDirectory(), "etc", "permissions"), true);
        // Remove android extension pack for opengles version 3.0
        int value = SystemProperties.getInt("ro.opengles.version", 0);
        if (value > 0 && (value == 196608)) {
           if (mAvailableFeatures.remove("android.hardware.opengles.aep") != null) {
               Slog.d(TAG, "Removed android.hardware.opengles.aep feature for opengles 3.0");
           }
        }
    }

2017/7/18

CP2105 dual uart in one USB

http://community.silabs.com/t5/Interface/CP2105-driver-questions/td-p/89191

不用hub 哦,有linux driver.

kmesg
[20172.062093] usb 3-1.1: new full-speed USB device number 4 using xhci_hcd
[20172.164457] usb 3-1.1: New USB device found, idVendor=10c4, idProduct=ea70
[20172.164464] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=5
[20172.164468] usb 3-1.1: Product: CP2105 Dual USB to UART Bridge Controller
[20172.164470] usb 3-1.1: Manufacturer: Silicon Labs
[20172.164473] usb 3-1.1: SerialNumber: 00775A41
[20172.232931] usbcore: registered new interface driver usbserial
[20172.232971] usbcore: registered new interface driver usbserial_generic
[20172.233003] usbserial: USB Serial support registered for generic
[20172.258589] usbcore: registered new interface driver cp210x
[20172.258646] usbserial: USB Serial support registered for cp210x
[20172.258718] cp210x 3-1.1:1.0: cp210x converter detected
[20172.342494] usb 3-1.1: reset full-speed USB device number 4 using xhci_hcd
[20172.443147] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d48
[20172.443155] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d00
[20172.443158] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d35c8
[20172.443160] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3580
[20172.443879] usb 3-1.1: cp210x converter now attached to ttyUSB0
[20172.443955] cp210x 3-1.1:1.1: cp210x converter detected
[20172.444112] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0
[20172.444145] cp210x 3-1.1:1.0: device disconnected
[20172.526619] usb 3-1.1: reset full-speed USB device number 4 using xhci_hcd
[20172.627173] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d48
[20172.627182] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d00
[20172.627185] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d35c8
[20172.627188] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3580
[20172.627595] cp210x 3-1.1:1.0: cp210x converter detected
[20172.710760] usb 3-1.1: reset full-speed USB device number 4 using xhci_hcd
[20172.811375] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d48
[20172.811383] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d00
[20172.811387] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d35c8
[20172.811390] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3580
[20172.812071] usb 3-1.1: cp210x converter now attached to ttyUSB0
[20172.812417] usb 3-1.1: cp210x converter now attached to ttyUSB1
[20172.838229] cp210x ttyUSB1: failed to set baud rate to 300
cp2105 的datasheet
有兩個 port: enhanced, standard
Enhanced UART Interface Features

Data formats supported:
- Data bits: 5, 6, 7, and 8
- Stop bits: 1, 1.5, and 2
- Parity: odd, even, mark, space, no parity
Baud rates: 300 bps to 2.0 Mbps
320 Byte receive and transmit buffers
Two GPIO signals for status and control
RS-485 mode with bus transceiver control

Standard UART Interface Features

Data format: 8 data bits, 1 Stop bit
Parity: Even, Odd, No parity
Baud rates: 2400 bps to 921600 bps
288 Byte receive and transmit buffers
Three GPIO signals for status and control
果然enhanced 比較快,也可以必較慢。
-- 但是 ti 的 evb 卻選 standard port 為 data port....

Audio Latency and Roundtrip Delay

結果google 有 android audio latency.

Linux Alsa 有一個軟體測 roundtrip delay


2017/7/12

Android 6. external SD Card mount path

ref: AnExplorer

這是一個 file Explorer,會正確列出 SD Card 和 internal eMMC storage 的內容。
也會顯示 "SD Card" 和 "Internal Storage"

他得的方法是用 StorageManager 的 static function : "getVolumeList"
取得完整mount list,
然後一一取出 mount 資訊,再自己分類...

所以找得出 SD mount point..


另外... 這一篇的 sample function 可以正常動作。
其中的 function:
/* returns external storage paths (directory of external memory card) as array of Strings */
public String[] getExternalStorageDirectories() {

        List<String> results = new ArrayList<>();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //Method 1 for KitKat & above
        File[] externalDirs = getExternalFilesDirs(null);

        for (File file : externalDirs) {
            String path = file.getPath().split("/Android")[0];

            boolean addPath = false;

            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                addPath = Environment.isExternalStorageRemovable(file);
            }
            else{
                addPath = Environment.MEDIA_MOUNTED.equals(EnvironmentCompat.getStorageState(file));
            }

            if(addPath){
                results.add(path);
            }
        }
    }

        if(results.isEmpty()) { //Method 2 for all versions
            // better variation of: http://stackoverflow.com/a/40123073/5002496
            String output = "";
            try {
                final Process process = new ProcessBuilder().command("mount | grep /dev/block/vold")
                .redirectErrorStream(true).start();
                process.waitFor();
                final InputStream is = process.getInputStream();
                final byte[] buffer = new byte[1024];
                while (is.read(buffer) != -1) {
                    output = output + new String(buffer);
                }
                is.close();
            } catch (final Exception e) {
                e.printStackTrace();
            }
            if(!output.trim().isEmpty()) {
                String devicePoints[] = output.split("\n");
                for(String voldPoint: devicePoints) {
                    results.add(voldPoint.split(" ")[2]);
                }
            }
        }

        //Below few lines is to remove paths which may not be external memory card, like OTG (feel free to comment them out)
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            for (int i = 0; i < results.size(); i++) {
                if (!results.get(i).toLowerCase().matches(".*[0-9a-f]{4}[-][0-9a-f]{4}")) {
                    Log.d(LOG_TAG, results.get(i) + " might not be extSDcard");
                    results.remove(i--);
                }
            }
        } else {
            for (int i = 0; i < results.size(); i++) {
                if (!results.get(i).toLowerCase().contains("ext") && !results.get(i).toLowerCase().contains("sdcard")) {
                    Log.d(LOG_TAG, results.get(i)+" might not be extSDcard");
                    results.remove(i--);
                }
            }
        }

        String[] storageDirectories = new String[results.size()];
        for(int i=0; i<results.size(); ++i) storageDirectories[i] = results.get(i);

        return storageDirectories;
    }

把他包起來放在 github 囉:https://github.com/checko/Getsdpath

2017/7/5

unionfs

ref:https://datahunter.org/unionfs
UnionFs 好像很有趣的,很像以前的 coda filesystem

是一種 layer 的概念: union folders
就是把 folder1 + folder2 加在一起變成 folderM,
然後 folderM 裡可以看到 folder1 和 folder2 的檔案。

然後不一樣的是...有layer 個概念:
folderM (f11,f12,f13,f21,f22,f23)
 |
 +--- folder2 (f21,f22,f23)
 |
 +--- folder1 (f11,f12,f13)
folderM


配上:http://www.linuxjournal.com/article/7714
可以把不同 filesystem 的folder 合在一起
-- 用 mount 的化,不同 filesystem 一定要不同 folder

另一個,好像是比較好(先進)的 unionfs 時做是 aufs
可以參考這篇 說明,在 linux 上試試看。

2017/6/30

v4l-utils , Android

glob.h:
./prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8/sysroot/usr/include/glob.h
./prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/glob.h
./kernel/include/linux/glob.h
./ndk/sources/host-tools/make-3.81/glob/glob.h
./external/openssh/openbsd-compat/glob.h
./external/ltrace/glob.h


我是 clone 這裡的:https://github.com/garbear/v4l-utils
他也是從 linuxtv clone 的,
他大概是 stable-1.0,然後加上 Android.mk

這個需要 stlport
我用 google 的:https://android.googlesource.com/platform/external/stlport
用 tag android05.1.1_r9 (好像是最新的 tag)

先 build stlport (就mm)
再 build v4l-utils

他說指有 utils 下的 folder 有 Android.mk, 可以用 find 找出來。
然後分別進去 mm 就可以。


其實版本有點亂,...反正checkout 出有Android.mk 的就可以。
還有一些新的版本,lib 下也有Android.mk,但是不知道是不是因為 path 的關係,所以 buid fail...
把 lib 下 build faile 的 find no glob.h 的 file 的include comment 掉,lib 就 build Ok

2017/6/28

adb over tcp

ref: https://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp

首先手機端,要設定 adb service 使用 tcp., 然後重新啟動 adb...
#setprop service.adb.tcp.port 5555
#stop adbd
#start adbd


PC 端,啟動 adb 連線前,要先設定使用 tcp 連線到 裝置的 IP, PORT
$adb connect 10.202.208.55:5555
* daemon not running. starting it now at tcp:5037 *
* daemon started successfully *
connected to 10.202.208.55:5555
看看有沒有出現..
$ adb devices
List of devices attached
10.202.208.55:5555 device
連線:
$ adb shell
OK,
PC 要回到 usb mode,就下
$adb usb

2017/6/23

使用 screen, emacs 做 uart termianl .. (serial port)

ref: serial port rs232 terminal

就是直接用
screen /dev/ttyUSB0 115200
就可以了,用 man screen 可以看一下 command

缺點大蓋是沒有辦法 log

emacs 的話就是開啟 emacs 後,輸入 M x (就是 Alt-x) , 然後輸入 serial-term ,接著照著回答 ttyUSB0, baudrate 115200.. 就可以了。
emacs 會開啟 X/GUI mode, 要開啟console mode, 要用 emacs -nw

2017/6/20

lxc-clone

man:
lxc-clone [-s ] [-K ] [-M ] [-H ] [-B backingstore] [-L fssize] [-p lxcpath] [-P newlxcpath] {-o orig} {-n new} [-- hook arguments]
 

所以從 folder A copy 到 folder B 同時改名...
sudo lxc-clone -p ~/hd/lxc -P ~/60g -o myhd -n myhdr

修改完,手動修改:
  • /etc/network/interfaces : ip adderss
  • /etc/hosts : new guest os hostname

2017/6/19

install pip 9.1 on Jessie

原來安裝過 python-pip 就不行。
裝 python (python-dev) 就好。
然後 follow 這一篇, download get-pip.py
然後用
sudo python get-pip.py
就可以正常安裝 pip 9.1 了。

pip install 會利用執行人的home 目錄的 .cache 做工作目錄。
download and unpack package source.

安裝到 /usr/local/lib/python2.7/...
如果有權限問題。
只好安裝到 自己的 home 目錄下。
會是 ~/.local/
system.journal corrupted or uncleanly shut down, renaming and replacing.
用了幾分鐘,console 開始鈍鈍的...
top 看,systemd 第一名...

2017/6/16

ARM Fast Models

ARM 的 Fast Models 好像是 ARM 出的 emulator。
配合自家的 DS-? 開發環境,可以用來模擬 ARM 的 CPU, 即使還沒 release 的...

2017/6/13

console color not work. TERM vt102

大概是這一篇說的...
For some reason, it appears that "vt102" is compiled into the version of
getty on Ubuntu as default while "linux" is compiled into the version of
getty on Fedora as default.  The man pages also make clear that this
version of getty does not reference /etc/gettydefs.  :-P  Getty is the
culprit and I don't see any other workaround for lxc-console.  That same
change may need to be made in /etc/init/console.conf but I don't quite
see where it's coming into play.
所以解決方法是在 invoke 時,加上 TERM=linux
<-- 沒效
最後是加在 .profile... TERM=linux

nfs 權限問題

nfs server 同一個user 的 uid/gid 和 local 的 uid/gid 不一樣,所以 mount 起來後,會有權權限問題。
正確方法好像是 用 mapid 轉一下 uid/gid。

如果只是為了當 storage 用,可以在 nfs server create 一個專用 folder, set owner 是local uid/gid 的 user,
然後在 /etc/export 中,用
rw,no_root_squash
這樣 mount 起來,local 就可以當自己的 storage 用了。


比較複雜的方法是用 anonuid, anongid 來來對應。
在exports 的share option 中加上 anonuid=1001, anongid=1001 的話,意思是說,凡是被mapping 成為 anonymous 的 client (幾乎就是全部的 client),都會被轉成 uid. gid 1001 的 user。
如果要強制 client root 維持root,不要強制轉為 anonymous的話,option 就要加上 no_root_squash

所以一般使用 anonuid, anongid 指定的話,都是指定為 share folder 的 owner uid/gid

try tensorflow..

先 create 一個 jessie 的 lxc 環境,這次在 nfs mount 的 folder 中..
所以要用 -P 指定 path:
sudo lxc-create -P ~/3rdhome/lxc -n tensorflow -t download
...
...
Distribution: debian
Release: jessie
Architecture: amd64

The cached copy has expired, re-downloading...
Downloading the image index
The cache is already up to date.
Using image from local cache
Unpacking the rootfs

---
You just created a Debian container (release=jessie, arch=amd64, variant=default)

To enable sshd, run: apt-get install openssh-server

For security reason, container images ship without user accounts
and without a root password.

Use lxc-attach or chroot directly into the rootfs to set a root password
or create user accounts.
就 follow 這一篇 把剩下都做完...

ping 過兩層 nat 的機器..

host/nat (172.16.200.1) ----- 172.16.200.10/nat (172.16.110.1) ----- 172.16.110.2/siteA
從 host 要 ping siteA ping 不到。
用 route -n 檢查一下:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.144.254 0.0.0.0         UG    1024   0        0 eth0
172.16.200.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.144.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
用 traceroute 172.16.110.2,結果潮 default gw (192.168.144.254) 過去...
所以要把 172.16.110.0 這個network 加到 routing table 中。
這個 network 要靠 nat 172.16.200.10 轉發(ip_forward=1),就是他的 gateway..
route add -net 172.16.110.0 netmask 255.255.255.0 gw 172.16.200.10 eth1
這樣就 OK 了...

2017/6/12

raspberry pi . relay

ref:
pi 的 gpio 好像是 3.3v, 所以買 relay 的時候要這注意要買推得動的。
我是買:這一家, 因為我只要一路,控制有 3.3v。

relay 上的 VCC, GND 用 pi 上面的 5V, Ground。
然後 gpio 用 gpio25,pin 腳22,外側倒數第三跟。

先用 ref 裡面的 relay 程式(因為他是控制 gpio 24, 25),看 relay 可以正常開關。
就可以開始其他的...

用 python..先啟動 python..到 interactive..
pi@raspberrypi:~/Relay$ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.setup(25,GPIO.OUT)
Traceback (most recent call last):
  File "", line 1, in 
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(25,GPIO.OUT)
__main__:1: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.
>>> GPIO.output(25,False)
>>> GPIO.output(25,True)
>>> 
原來 GPIO 的數字命名有兩種:依照 排針 pin 腳數字,還是 BCM datasheet 的gpio 數字。
這裡用的是 datasheet 數字。
最後 output False, True 就可以聽到 relay 動作...

接著做自動開關..
關 15 sec
開 10 min
>>> import time
>>> GPIO.output(25,True)
>>> for i in range(10):
...     GPIO.output(25,False)
...     time.sleep(15)
...     GPIO.output(25,True)
...     print i
...     time.sleep(10*60)
... 

2017/5/25

reconfig timezone

dpkg-reconfigure tzdata

lxc 不使用default path

default path 是 /var/lib/lxc
要是要改(使用)其他位置,所有的 lxc-XXX 都可以加 -P 指定位置。
例如,要在 ~/hd/lxc 下 create newvm:
lxc-create -P ~/hd/lxc -n newvm
然後啟動的時候要...
lxc-start -F -P ~/hd/lxc -n newvm

-F 是run 在forground mode (有console)