2016/9/22

ssh config : 不同 server 給不同的 key, ignore key change

ssh 就是自己產生一對 key, 把public 的送給別人,讓別人可以用 你給的key 來認證你。

所以,也可以產生很多對key, 然後一個 server 給一個,每個 server 都給不同的 pub key
當然,這樣就要小心,在連線的時候,要拿對key
ssh -i id_rsa_therightone servername

這樣很麻煩,所以 ssh 就給一個 config, 讓你可以寫 key- sever 的對應。
這樣 ssh 就會自動照這格 config 拿正確的key 來連。

.ssh/config 的內容:
Host my3rd
    HostName the3.my.com
    user  charles
    IdentityFile ~/.ssh/id_rsa_key1

Host my4th
    HostName the4.my.com
    user checko
    IdentityFile ~/.ssh/id_rsa_key4

另外,如果 ssh 連線的 server 不在 .ssh/config 中,
ssh 也沒有加上 -i (指定 key file) 的選項。
ssh 就會用 .ssh/id_rsa 來連。



這個 config 很有趣,好像只會認得 Host,
以上面的例子來說..
ssh my3rd
會正確的使用 id_rsa_key1

但是用server 真正的名子:
ssh the3.my.com
就不會用 id_rsa_key4 了。

我猜這是為了一個 server 用不同user name login..
這樣才可以用 Host 來區分,

如果是 embedded system, 一直更換 key 的情況,ssh 連線出現:
Hostkey verification failed
M
可以在 config 加入:
$ cat .ssh/config
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
這樣都不會檢查了...

ssh-agent .真的就是一個agent

為了安全,用 ssh private, public key...
然後key還加上密碼。

這樣登入雖然安全了,但是又恢復到每次登入都要輸入密碼。
所以就出現 ssh-agent, 會聽你的通訊,在要輸入密碼的時候,自動幫你輸入密碼。
--- 這樣幫 key 加上密碼不就沒意義了?

所以,啟動 ssh-agent 邦你工作的時候,ssh-agent 會需要你輸入密碼,這樣他才能幫你。
所以:
ssh-add : 加入 key, 要 ssh-agent 幫你傳key
ssh-add 會對每一個 key, 如果有須要密碼的,請妳輸入密碼,他會記下來,以後好幫你輸入。

這樣就改成...只要啟動 ssh-agent 時輸入一次密碼就好,避免掉每次都需要輸入的問題。


2016/9/6

reboot ..

最後 reset 是...arm/arm/mach-kk40/reset.c
static void kk40_arch_reset(char mode, const char *cmd)
{
        u32 boot_flag = 0;
        u32 boot_mode = BOOT_MODE_REBOOT;

        if (cmd) {
                if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader"))
                        boot_flag = SYS_LOADER_REBOOT_FLAG + BOOT_LOADER;
                else if(!strcmp(cmd, "recovery"))
                        boot_flag = SYS_LOADER_REBOOT_FLAG + BOOT_RECOVER;
                else if (!strcmp(cmd, "charge"))
                        boot_mode = BOOT_MODE_CHARGE;
        } else {
                if (is_panic)
                        boot_mode = BOOT_MODE_PANIC;
        }
#ifndef RK30_PMU_BASE
        writel_relaxed(boot_flag, RK30_GRF_BASE + GRF_OS_REG4); // for loader
        writel_relaxed(boot_mode, RK30_GRF_BASE + GRF_OS_REG5); // for linux
#else
        writel_relaxed(boot_flag, RK30_PMU_BASE + PMU_SYS_REG0);        // for loader
        writel_relaxed(boot_mode, RK30_PMU_BASE + PMU_SYS_REG1);        // for linux
#endif
 ....

所以會reboot flag 和 mode 會被寫入 cpu register...

2016/8/23

fuchsia test build...

ref: https://fuchsia.googlesource.com/manifest/+/master/README.md

因為還在初期的開發過程,所以每天 builod 的狀況可能會不一樣。

在 debian jessie 上 build.
一開始 go language 得的版本有問題。
缺了 UnsetEvn 和 StringCompare 這兩個 function
jessie 是 1.3, 測試 1.4 還是不夠,最後用 1.5 才 OK

go 環境很簡單,就 到 go 網站 download 安裝包,解開,follow READE 設定 GOROOT path 和 update PATH 就可以呼叫到正確的 go 版本。
然後繼續 follow 說明...

出現 native_viewport 不認識 MX_DISPLAY_FORMAT_RGB_565
發現是新版本的 display.h 變更了 constant 的名子,改叫 MX_PIXEL_FORMAT_RGB_565. 所以全部修改。



上面好像是 user program.
下面這個好像才是 OS.... https://fuchsia.googlesource.com/magenta/+/HEAD/docs/getting_started.md

2016/8/16

fragement

fragement 可以視為 view 元件的一個擴展。
在 layout 的 xml 中可以擺放 fragment 元件。
然後再為 fragment 元件寫 layout, action handler

所以可以視為 "可以自訂內容的 view 元件"

既然是由 programmer 自己寫的元件,所以在 layout 中擺放時,fragment 區段就有一些規定,
像 name 就是實做那個 fragment 的 full class name

fragment 的 life cycle 跟一般 activity 有點類似。
也有自己的 layout

所以主要的 activity 把 自己的 layout view (包含 fragment的layout xml) 設定完畢後。
android 系統自然會知道 layout 內容,一一呼叫起對應的 fragment class

2016/8/15

android application profiling with Android Device Monitor

tools -- android -- android device monitor

Device tab 會列出所有正在 run 的 process
選一下要 monitor 的 process
按下device tab 上的一個有紅點的 icon (Start Method Profiling)
出現 "Profiling Options"
選 Trace base profiling -- 因為想知道是那一個 function 花時間。
按下去以後,就開始 monitor 了,所以要趕快去操作 app,
花時間的部份都操作完後,案一下 device tab 剛剛那個變成黑點的紅點 icon (stop method profiling)

device tab 右邊會出現 ddmsXXXXXXX 的 profiling 結果。

上面是時間條,下面是 function 的顏色和總共花的時間。
找一個長的按下去就會繼續看該 function 裡面花的匙間,
然後找出時間最長的...
repeat...


  • incl Cpu Time(%): Include caller & self
  • Excl Cpu Time(%):
  • Incl Real Time:
  • Excl Real Time:
  • Calls + Recur Calls / Total:function执行的次数,Call表示function call的次数,Recur Call表示recursive call 的次數
  • Cpu Time / Call:每次执行函数所用的cpu time。
  • Real Time / Call: 同上

systrace 好像更強

2016/8/3

implicit declaration of function 'strict_strtoul

3.x 的 driver code 拿到 4.x build 出現..
 error: implicit declaration of function 'strict_strtoul' [-Werror=implicit-function-declaration]


然後kernel source 竟然找不到 strict_strtoul

然後..http://dpdk.org/dev/patchwork/patch/1911/
strict_strtoul() was just a redefinition of kstrtoul() for a long
time. From kernel version of 3.18, strict_strtoul() will not be
defined at all. A compile time kernel version check is needed to
decide which function or macro can be used for a specific version
of kernel.

也就說..直接用 kstrtoul 就好了。