2018/12/26

build openmv from source

參考 build openMV from source
結果,toolchain 部份就 fail
PPA 只有給 ubuntu 用。debian 是不行的。
結果,在 developer.arm.com 的 cross tool release page 中,連到 ppa 去..其中有..
The tools can be downloaded from any one of the following links:
* https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
* https://launchpad.net/~team-gcc-arm-embedded/+archive/ubuntu/ppa
所以 team-gcc-arm-embedded 的 crosstool 應該就是 developer.arm.com 的 cross tool

wiki 只有說明clone 下來,用Qtcreator 開 project,... 然後 build (?)
沒裝 QtCreator,直接到 src 下 make...
failed:
img/lsd.c:811:18: error: 'new_image_int_ini' defined but not used [-Werror=unused-function]
 static image_int new_image_int_ini( unsigned int xsize, unsigned int ysize,
找 Makefile,把 -Werror 刪掉。
build success!

東西都在 Makefile 裡..
default build target 是 OPENMV3,
果然 firmware/OPENMV3 下的 file 都是新的..所以應該是真的都 open source 無誤。


所以... cross toolchain 好像也沒有一定要是 ppa 的...(not sure, 要 download and run 後才能確認)
整個 build 動作就..
  • clone --recursive
  • cd src, modify Makefile, remove -Werror
  • make

Debian : Create Package From PPA..

竟然有一篇專門講Create Package From PPA

大概就是 ...
  • 一樣把 ppa 加到 repository 中
  • 修改 sources.d 中ppa 的 list,把他改成只能 install source
  • apt-get update, 然後安裝 package source
  • 自己用 debian build tool 把 download 下來的 source build 成 package

實際上,光是 add-apt-repository 時,就會出現 Error:
key D1FAA6ECF64D33B0:
3 signatures not checked due to missing keys
gpg: /tmp/tmpps7zy6_5/trustdb.gpg: trustdb created
gpg: key D1FAA6ECF64D33B0: public key "Launchpad PPA for GCC ARM Embedded Maintainers" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no valid OpenPGP data found.
Exception in thread Thread-1:
.....
FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.browser'

說是 debian 不認識 ubuntu server,所以
~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys  C2518248EEA14886
Executing: /tmp/apt-key-gpghome.tbG3r8NPkE/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886
key C2518248EEA14886:
14 signatures not checked due to missing keys
gpg: key C2518248EEA14886: public key "Launchpad VLC" imported
gpg: Total number processed: 1
gpg:               imported: 1
再..
實際參考 這一篇,但是 package 要改成自己的。
加入自己要 add 的 KEY (D1FAA6ECF64....)
然後還要參考 這一篇修改 ppa list,把 disco 改成ubuntu 的 release name
再做 apt-get update..才會 OK

然後..
~$ apt source --build gcc-arm-embedded
Reading package lists... Done
Need to get 176 MB of source archives.
Get:1 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu xenial/main gcc-arm-none-eabi 8-2018q4-1~xenial1 (tar) [176 MB]
然後會抱怨有 Unmet build depencies..
把抱怨的 apt-get install 補上..
繼續..
出現..
make[1]: Leaving directory '/home/charles-chang/gcc-arm-none-eabi-8-2018q4/build-native/gcc-first/libiberty'
debian/rules:24: recipe for target 'build-stamp' failed
make: *** [build-stamp] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
E: Build command 'cd gcc-arm-none-eabi-8-2018q4 && dpkg-buildpackage -b -uc' failed.
..

重新做一次,記下 log, 搜尋結果..
checking whether gcc supports -fno-rtti... yes
configure: error: C++ compiler missing or inoperational
if [ x"-fpic" != x ]; then \
          gcc -c -DHAVE_CONFIG_H -g -O2  -I. -I/home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  -D_GNU_SOURCE -fpic /home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/libiberty/rust-demangle.c -o pic/rust-demangle.o; \
        else true; fi
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"zlib\" -DVERSION=\"1.1.4\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_MEMCPY=1 -DHAVE_STRERROR=1 -DHAVE_UNISTD_H=1 -I. -I/home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/zlib      -g -O2 -c -o libz_a-inflate.o `test -f 'inflate.c' || echo '/home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/zlib/'`inflate.c
make: *** [configure-libcpp] Error 1
make: *** Waiting for unfinished jobs....

2018/12/7

IR High/Low ...

IR 就是用一連串的 high low來傳遞 1, 0 資料。
IR 有各家(NEC, SONY, PANASONIC)的規定。

以 NEC 來說,歸定了...
command

2018/12/3

anbox -- run android in linux container

在 linux containter 中 run android x86 (android 7.1)
並且把 hardware io 改為與 host linux 的 IPC。
所以可以跟 linux host "無縫" 接軌。

只 support ubuntu (好像是因為要改 kernel)

可惜,desktop 沒版法 run ubuntu installer,所以 沒辦法試...

2018/11/26

linux distro for atom ...

Linux-Lite 64bit.

linux-lite-4.1-64bit.iso
光是安裝..感覺就慢了..黑色畫面停留好久...游標才出來...,然後還要好久...title bar 出現..安裝時間好像快 2 hrs...
安裝好就可以用了,要是按下 update 的話.... update 時間比安裝時間更長...
  • browser 是 firefox, youtube 可以播放 480p OK, 720 不行,指示啟動很慢
  • video 用 vlc,可以正常播放 1080p 的 mp4
  • wifi OK, usb auto mount OK
  • apt source 是 ubuntu bionic
開機超慢,要 5 min...

suspend, hibernat 都失敗,會自己起來。
UI 操作還好,大概是因為 xfce,所以mount click 等都不會頓。


Porteus

Porteus-XFCE-v4.0-x86_64.iso
--iso 無法開機。


antiX

antiX-17.2_x64-base.iso
這個USA site 下載比台灣快。
安裝是開機進入 liveCD 後,在桌面有一個 install CD icon,再啟動安裝...

  • browser 是 firefox 跟 dillo, youtube 一樣播放 480p,感覺比 linux-lite 還卡
  • video 用 gnome mpv, 可以播放 1080p沒問題
  • wifi, ethernet 要用 console mode config program - ceni,不知道要怎麼關 wifi (目前是用 ifconfig)
  • apt source 是 debian stretch
  • usb mount OK
開機比較快,少於 1 min
做 apt-get update, upgrade 也是一堆問題要回答..

裝上 nginx,修改 /etcc/nginx/site-available/default,內容只有:
server {
    listen 12345 default_server;
    root /media;
    autoindex on;
    charset utf-8;
}

因為 usb driver c會自動 mount 在 /media/ 下...
但是 mount permission 是 700,只有 user 可以用。nginx 還是不能 access

AntiX 用 udevil,所以修改 /etc/udevil/udevil.conf
其中 ..
diff --git a/udevil.conf b/udevil.conf
index 75a4c0d..166020a 100644
--- a/udevil.conf
+++ b/udevil.conf
@@ -221,7 +221,7 @@ default_options_file      = nosuid, noexec, nodev, noatime, uid=$UID, gid=$GID,
 default_options_iso9660   = nosuid, noexec, nodev, noatime, uid=$UID, gid=$GID, ro, utf8
 default_options_udf       = nosuid, noexec, nodev, noatime, uid=$UID, gid=$GID
 default_options_vfat      = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID, utf8
-default_options_exfat     = nosuid, noexec, nodev, noatime, umask=0077, uid=$UID, gid=$GID, iocharset=utf8, namecase=0, nonempty
+default_options_exfat     = nosuid, noexec, nodev, noatime, umask=0000, uid=$UID, gid=$GID, iocharset=utf8, namecase=0, nonempty
 default_options_msdos     = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID
 default_options_umsdos    = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID
 default_options_ntfs      = nosuid, noexec, nodev, noatime, fmask=0133, uid=$UID, gid=$GID, utf8
@@ -252,7 +252,7 @@ allowed_options_smbfs     = nosuid, noexec, nodev, ro, rw, remount, port=*, user
 allowed_options_sshfs     = nosuid, noexec, nodev, noatime, ro, rw, uid=$UID, gid=$GID, nonempty, allow_other, idmap=user, BatchMode=yes, port=*
 allowed_options_curlftpfs = nosuid, noexec, nodev, noatime, ro, rw, uid=$UID, gid=$GID, nonempty, allow_other, user=*
 allowed_options_ftpfs     = nosuid, noexec, nodev, noatime, ro, rw, port=*, user=*, pass=*, root=*, uid=$UID, gid=$GID
-allowed_options_exfat     = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID, umask=0077, namecase=*, ro, rw, sync, flush, iocharset=*, remount, nonempty
+allowed_options_exfat     = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID, umask=0000, namecase=*, ro, rw, sync, flush, iocharset=*, remount, nonempty
.. 就是修改 umask,由 0077 改 0000
這樣mount permission 就會是 777 了。
--- 其實拿掉 dmask, fmask, umask 等 option 就可以了。

2018/11/6

VS code + python + vim

裝完 VS code 後,安裝 python plugin (當然,也要裝 python)。
然後因為習慣 vi,所以裝 vim edit extension,就可以用 vi 的 command

然後就可以開始寫 python code。

VS Code 可以作到 set break pointer, step 等 debugging 動作。
vscode 會把需要的設定放在 .vscode folder 中,
所以要用到這些 config,source code 就要有獨立的 folder。
-- 類似 project folder 的概念。

open folder -- new 一個。
new file -- save as *.py
開始寫 python code...
左邊 panel 有一個 bug 的 icon,按下去就進入 debug mode。
toolbar 會出現 run, debug 等icon。
在code 左邊邊條就可以按下,會出現紅點,就是 break point。
設完break point 再 run, 就會中斷,然後variablees window 就可以看 local variable.
同樣,上面的 icon 可以做 step , 單布執行。

輸出會在 debug console..


配合 conda

VSCode 的 python extension 會認得 home 中的 conda env
用 Ctrl-Shift-P 叫出設定,輸入 Python:Select,就會出現所有 conda env,選你要用的那個就可以。

2018/11/5

opencv : show hough space diagram

opencv 的 HoughLine( ) 只會給Line data,沒有給轉換成 hough space 的結果(二維陣列)。
所以沒辦法看出轉成 hough space 的樣子。

要作到要用 opencv_contrib 中 ximgproc::FastHoughTransform( )

這個 function有附 example:fast_hough_transform.cpp
如果在安裝opencv 時,build example 的 option 有打開,就會 build。
執行檔是: build/bin/example_ximgproc_fast_hough_transform

實際執行時,default read source : building.jpg 的相對位置好像有問題。
所以要加一層目錄,copy 到下一層目錄去..才能執行起來。

要加在自己的 source code 中,看看 hough space 的結果,要加的function ..
#include <opencv2/ximgproc.hpp>


void rescale(Mat const &src, Mat &dst, int const maxHeight=500, int const maxWidth=1000)
{
       double scale = min(min( static_cast<double>(maxWidth) /src.cols,
                                                       static_cast<double>(maxHeight)/src.rows), 1.0);
       resize(src,dst, Size(),scale,scale,INTER_LINEAR_EXACT);
}

void showhough(Mat const &fht)
{
       double minv(0),maxv(0);
       minMaxLoc(fht,&minv,&maxv);
       Mat ucharFht;
       fht.convertTo(ucharFht,CV_MAKETYPE(CV_8U,fht.channels()), 255.0/(maxv+minv), minv/(maxv+minv));

       rescale(ucharFht,ucharFht);
       imshow("fast hough transform", ucharFht);
}
然後才能在主程式 call FastHoughTransform..
       Mat hough;
       ximgproc::FastHoughTransform(dst,hough, CV_32S,6,2,1); // dst is source image
       showhough(hough);
       waitKey(0);


Example : building.jpg 做出來的 hough space image 是..



另外有一個人自己寫了 hough transform ,有提供 hough space 輸出:
hough transform c++ implementation
source code 在 github: https://github.com/brunokeymolen/hough