2021/4/30

bookmark: task switcher for X11

現在這個ubuntu 的task switcher 實在不清楚,都要切很多次。
以前debian 的會把windows 亮起,比較清楚。

來看看這個怎麼樣,順便了解一下x11 window manager.

2021/4/29

bookmark: keras, Save and load ...

可以把 trainning 中斷,save 起來。
也可以把 trainning 完的結果 save 起來。

存起來的model, data可以跟別人分享。

存起來的東西,包含 model, parameter, weight..

filesystem : reserved block

ref: 實際上是在 evb 上發現 lost+found 刪除後,df 會多 32M。
然後發現是在 gene2fs 之後,生成的 filesystem image 裡面,create 了 lost+found ,而且佔了blocks
所以查到上面 ref 的 patch,把 lost+found reserved 固定的 patch

然後查一下 filesystem 中,reserved block 的設定和用途。

reserved block 是 ext2 開始有的,大概是專屬 block 的意思,
在 format 的時候,保留一部分 block 給特定的user/group 用。

所以,可以設定reserve 的數量,還有可以使用的 uid/gid

另外,fsck 的時候也需要一些 block,所以reserved 可以避免 100% 沒辦法 fsck。

2021/4/28

bookmarks :rndis driver performace

原來有這個參數可以調...
# Increase RNDIS DL max aggregation size to 11K
echo 11264 > /sys/module/g_android/parameters/rndis_dl_max_xfer_size

還有 mtu 真的很厲害,可以讓 throughput 差到 3 倍。
-- 可惜一堆 nic 最大都固定是 1500 而已。

2021/4/27

ssh 登入,登出時自動執行script..

這個,利用 sshd_config 中 ForceCommand 的功能..
ForceCommand 是限制某個 user 使用 ssh 連線後只能做什麼事(command) 用的 (簡單來說是這樣)。
所以寫一個 wrapper script。
ssh 進來,就 run 這個 script....
你就可以把要做的事寫在 script裡。
做好之後,再 call shell
然後 user exit 的時候, wrapper 就會從 shell 之後繼續。
就可以在那邊寫 logout 時要做的事。

測試..

修改 /etc/ssh/sshd_config,加上一行
ForceCommand /usr/local/bin/ssh-wrapper.sh
然後 /usr/local/bin/ssh-wrapper.sh 的內容是:
#!/bin/bash
touch /data/aaaa
${SSH_ORIGINAL_COMMAND:-/bin/bash --login}
touch /data/bbbb
這樣在 ssh 連線時,/data 下會出現 aaaa,
exit 後,會有 bbbb

**
因為是做在 ssh,所以在 console login 的化,不會觸發這個 wrapper script


shell script 說明..(ref:bash man page)
${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion of word is substituted. 
Otherwise, the value of parameter is substituted.

2021/4/26

worklog : arduino-share-serial-to-keyboard

就是要照著這一篇 中的 digispark, attiny85 來做一個..

所以上一篇裝好,測試了 arduino ide.. 和 digispark 的 board support,
然後依照內容把 serial-to-keyboard clone 下來...
git clone https://github.com/andrewintw/arduino-serial-to-keyboard.git --recurse-submodules
然後用 arduino-ide 開啟 DigiSpark_SoftSerial_to_Keyboard.ino
一樣,做 upload 時,出現 Error
SoftSerial_INT0.h: No such file or directory
就是 source code 中 include <SoftSerial_INT0.h> 這一行,找不到 SoftSerial_INT0.h
文章中說依照 arduino ide 的 library 方式...
所以找一下,同時參考原 library 作者的說明...
猜測,應該是..
~/.arduino15/packages/digistump/hardware/avr/1.6.7/libraries
..... 竟然是隱藏目錄....

所以把 那個 Digispark_SoftSerial_INT0 目錄 copy 到這裡,
之後 Arduino IDE 的 upload 就成功了...
..其實有一個 Error..說 library 的版本不一樣...

但是 dmesg 有出現 INPUT device:
[22436.262378] usb 3-3.4: new low-speed USB device number 40 using xhci_hcd
[22436.631309] usb 3-3.4: New USB device found, idVendor=16c0, idProduct=27db, bcdDevice= 1.00
[22436.631315] usb 3-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[22436.631319] usb 3-3.4: Product: DigiKey
[22436.631322] usb 3-3.4: Manufacturer: digistump.com
[22436.704903] input: digistump.com DigiKey as /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4:1.0/0003:16C0:27DB.0006/input/input20
[22436.763071] hid-generic 0003:16C0:27DB.0006: input,hidraw1: USB HID v1.01 Keyboard [digistump.com DigiKey] on usb-0000:00:14.0-3.4/input0

Digispark ATTiny85 and Arduino IDE in ubuntu

基本上就是照著這一個 說明。
IDE 官網有 Linux 64 的 xz file。
下載 xz 解開 tar,再 tar xvf.. 到 folder
裡面有 install.sh
sudo 來 run,他會更改 /etc/...,和在 desktop 建 icon

完成以後在 menu 就可以看到 arduino ide 的 icon 了。

啟動後,在 preference 的 add additional ... 加入 link,
新的 board (digispark) 就會出現在 Tools - Board manager 裡,install 他..
這樣 Arduino 對 digispark 的 support 就算安裝完了。

在 Linux 上,要把digispark 的 vid/pid 加到 rules.d 中,reload udev。
之後插入 attiny 85 dmesg 就會...
[19430.442732] usb 3-3.4: new low-speed USB device number 37 using xhci_hcd
[19430.598442] usb 3-3.4: New USB device found, idVendor=16d0, idProduct=0753, bcdDevice= 1.05
[19430.598449] usb 3-3.4: New USB device strings: Mfr=0, Product=0, SerialNumber=0

測試一下...

Tools - Board 選Digispartk(Default -16.5mhz)。
然後把上面 ref 的 sample code...
void setup() {                
  pinMode(0, OUTPUT);      // LED on Model B
  pinMode(1, OUTPUT);      // LED on Model A   
}

void loop() {
  digitalWrite(0, HIGH);   // Turn the LED on
  digitalWrite(1, HIGH);
  delay(500);             // Wait for a second
  digitalWrite(0, LOW);    // Turn the LED off
  digitalWrite(1, LOW); 
  delay(500);             // Wait for a second
}
貼上去..
按下 upload。...,插入 Attiny85,下面 的 output 就會看到...
...
running : 100% complete
Micronucleus done, Thank yout!
然後board 上的一顆紅色 led 開始閃...

Bookmarks : RUST

Bookmark: netstat 檢查網路 ffmpeg video processing 和 sed 指令用法

2021/4/25

change mac address, ubuntu with network-manager

最後是用 macchanger,奇怪。用 ifconfig 跟 ip 來改都不行。
先要停止 network-manager
systemctl stop network-manager
macchanger -m 11:22:33:44:55 wlps30
systemctl start network-manager
那個 wlps30 就是 wifi 的 device name,用 nmcli device 可以看到..


如果是 chromebook 的話,要進入 ctrl-akt-(right arrow) 的 console。
ifconfig wlan0 down
ifconfig wlan0 hw ether aa:bb:cc:dd:ee
ifconfig wlan0 up
然後用 ctrl-alt-(left arrow) 回到 chromebook ui 後,wifi 就已經用新 mac 來連線了。

2021/4/21

Bookmark: 寫得很仔細的 eMMC 工作模式

像,power on 後,CMD low 持續 74 clk,會進入 Boot Mode,eMMC 會自動從 Data 輸出 boot part 的資料。
這一類的東西。

然後這個竟然是 linux kernel 的 說明...

2021/4/20

Snapdragon Profiler : running in ubuntu 18.04 (docker 16.04)

大神說app有問題就開 snapdragon profile 來看...
所以 follow instruction .. 安裝 mono 之後,啟動 snapdragonprofiler(2021.1)...
然後就出問題...
...
(SnapdragonProfiler:27412): Gtk-WARNING **: 17:08:08.793: Unable to locate theme engine in module_path: "xamarin",

=================================================================
	Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0x559c168b1139 - mono : 
	0x559c168b14b9 - mono : 
	0x559c1685d7af - mono : 
	0x559c168aab13 - mono : 
	0x7f9fc5bd2b30 - /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 : 
	0x7f9fc5bd3fa5 - /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 : g_build_filename
	0x7f9fc7b34b0a - /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 : 
	0x7f9fc7b37668 - /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 : gtk_rc_find_pixmap_in_path
	0x7f9fc7b39b86 - /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 : 
	0x7f9fc7b39fb5 - /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 : 
	0x7f9fc7b3a2d3 - /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 : 
	0x7f9fc7b3a395 - /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 : gtk_rc_parse
	0x406d79d3 - Unknown

=================================================================
	Telemetry Dumper:
=================================================================
Pkilling 0x140324309710592x from 0x140324382138176x
Could not exec mono-hang-watchdog, expected on path '/etc/../bin/mono-hang-watchdog' (errno 2)
Entering thread summarizer pause from 0x140324382138176x
Finished thread summarizer pause from 0x140324382138176x.
Failed to create breadcrumb file (null)/crash_hash_0x239c436ad

...
論壇上搜尋,有一些人有問題,一樣都是在 18.04 或 20.04/10...
所以,先到 tool and.. 去下載舊版.. 一樣。
所以,應該是 OS 版本的問題。

只好用 docker 來 run..
需要 X.. 跟 usb pass-through
以前還是白痴的時候試過了。
command 就照以前的 'final' 部份就行。
docker run -it --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev -v ~/ddata:/data  -v /sys:/sys ubuntu:16.04
run 起來之後,先處理比較簡單的 usb-passthrough 部份。
因為 啟動時已經把 所有 hardware sys 都 mapping 近來了。
所以只需要安裝啟動 udev...
sudo apt-get install udev
sudo /lib/systemd/systemd-udevd &
sudo udevadm trigger
這樣做完,插入 usb--phone,grant phone debug permission,之後就可以用 dmesg 看是不是有出現...

然後是比較麻煩的 X..
一樣,啟動時,已經將 local 的 .X11-unit 和 DISPLAY 變數 mapping 近來。
因為這個 X11 有 user permission 限制,所以在 docker container 中要件一個跟 host user 一樣的 uid/gid user..ref.
useradd -m -s /bin/bash -u 1000 charles-chang
這樣做完,可以安裝 x11-apps 測試一下,先 su charles-chang (只su,環境不要切,不然 DISPLAY 變數也要export)
然後 run xeyes

之後的動作就是 follow Snapdragon-profiler 裡的 README,裝完所有 package (mono 後段 llvm check 會花比較九)。
./run_sdp.sh
就成功 啟動了,選擇 connect to device..,他會安裝一些 package 到 phone (花一點時間),之後就成功啟動...



這一篇 是 Qualcomm 的 說明:Identify Application Bottlenecks

2021/4/19

bookmark: rain and ADAS

竟然被說是潑冷水...
本來就是問題呀,告訴火車司機前面有障礙物,是潑司機冷水?
『人家告訴你跟自己遇到不一樣。』
哪裡不一樣?撞到不是都會X ?

Analysis of Impact of Rain Conditions on ADAS就有提到這個問題,2020 的研究,證明開始有重視。
為了這個,還建了實驗車道,在車道上安裝下雨系統,針對雨量和可視距離做研究。
也證明對可視距離有影像。

這一篇 也把夜晚,雨天納入 adas 的 test case。
證明真實狀況就是會遇到。

實際現在沒有看到解決方法,所以有在capibility 上註明的,分為夜晚跟雨天/大霧/沙塵/下雪 不同狀況的但書。

我猜要根據雨天做前處理,例如,偵測到雨滴時 (這個一堆論文在做),代表目前下雨。
所以影像做pre processing,或是加入 GAN。
類似super-resolution 的方法,把下雨模糊的影像清晰化 (雖然 decocde 後的不是真實影像)。
或是以前的一堆古典方法,image enhancement,用在將與雨天與夜晚的影像清晰化。
夜晚的部份,可能要考慮單獨 train,所以分成白天的 parameter 跟 晚上的 parameter (如果network 用一樣)。
雨天路面反射也是一樣,獨立network & parameter。

使用正確清晰,定義清楚的 dataset,train 出 error rate 低的 network,舊可子涵蓋特定區域。
假設:白天晚上一起,train 不出來。

都是方法,工程師就是面對問題,找出可用方案。
沒有找不出的,只有cost跟滿意度的問題。
當然逃避也是一種方案,cost 是 0,滿意度也是 0


或許像 Tesla 說的:如果攝影機看不到的東西,人眼更看不到,如果採用攝影機的自動駕駛系統不能上路,那麼完全靠肉眼判斷路況的人類駕駛可能更不適合上路。

2021/4/17

複習:看看jni 現在如何了

jni example 可以直接用 studio build ...
project structure 竟然有ndk location.
sdk manager 也可以選擇ndk, default install path 就在sdk 下

google 的 jni example 已經包含很多類別,需要用 jni 的code..

第一個,以hello-jni 為例。
他需要..
Requested NDK version 21.2.6472646 did not match the version 21.3.6528147 requested by ndk.dir 
如果用22 板的話,因為.. 所以選22 之後的ndk 都會出現 ndk does not contain any plarform

所以就在 SDK manager 中,選擇他要的 21.2 ...(選 21.3 雖然沒有 platform not contained 問題,確有 ndk version 不 match 的問題

android 4 跟 jni 整合度很高,就選完這個 project structure -- SDK Location -- Android NDK Location 之後,他就自動 build 完了。

hello-jni 是 kotline,如果切到 Android.mk 就是用 java
hello-libs 是 java

google 的 ndk sample document 是用 Android.mk ,但是沒有說明使用 Android Studio build 的方法,猜是用 ndk-build 來make


這一個:Android Jni application ndk 是用 Android Create C++ Project。
這種 project 就是jni project,裡面會有 java jni wrapper 跟 C/C++ CMake file

其他:

2021/4/14

bookmark: mobile platform nn performance (qcmm,samsung,mtk)

mobile phone ai infer benchmark https://arxiv.org/pdf/2012.02328.pdf 另外,以前的...

novatek multicam dvr solution

NT96580
dual A9
HW CNN 2.5, 1.5T
8Mp30

NT98529/8
8Mp30 typical mode
8Mp60 single sensor hdr mode
2 HDR sensor with 2 frames each
528 ddr3 - 公板很多

640k/yr minimum

Bookmark: lens/camera quality test

imatest 就是用來算出 SFR. MTF 的軟體,包含 pattern image。
當然,印出來和拍照的環境就要靠自己。(好像也有賣印好的pattern)。

有趣的是..imatest 也有給 IR 波斷的 test image ...

一般的對鏡頭品質,拍攝...
  • MTF or SFR chart : an SFRPlus chart from ImaTest.
  • Distance of 120-200cm
  • illumination -- no over-exposure / under-exposure.

2021/4/12

bookmark, gvfs- mount in command line

ref: 有時候開 file manager 找不到,只好手動..
$ gvfs-mount smb://HOST/SHARE/

$ gvfs-ls smb://HOST/SHARE/

2021/4/8

結果是這個...macrosilicon...

Low-cost HDMI to USB 2.0 Video Capture Dongle Macrosilicon MS2109

也真的很便宜...250

standard uvc driver,所以會出現在 /dev/video,用 vlc capture 就可以..
delay 的話,大概 2 sec..不確定是 vlc 的 lag 還是 dangle 的