2020/1/21

frameworks/base/core/java/com/android/internal/policy/PhoneWindow.java 的 onKeyDown 開頭有:
       /* ****************************************************************************
         * HOW TO DECIDE WHERE YOUR KEY HANDLING GOES.
         *
         * If your key handling must happen before the app gets a crack at the event,
         * it goes in PhoneWindowManager.
         *
         * If your key handling should happen in all windows, and does not depend on
         * the state of the current application, other than that the current
         * application can override the behavior by handling the event itself, it
         * should go in PhoneFallbackEventHandler.
         *
         * Only if your handling depends on the window, and the fact that it has
         * a DecorView, should it go here.
         * ****************************************************************************/

make error : ninja: subcommand failed.

make 出現 ninja: subcommand failed

所以用
make nothing
先產生 combined-xxx.ninja,然後用
ninja -v -j12 -f out/combined-xxx.ninja 2>&1 | tee ninjalog
用 -v 命列出完整命令,然後從 ninijalog 來看。
flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
參考Ubuntu 18.04 编译 AOSP 问题总结:
解决方法 : 在编译脚本中执行

export LC_ALL=C
LC_ALL=C 是为了去除所有本地化的设置,让命令能正确执行, 但是不可以修改~/.bashrc,会导致终端内中文显示为数字(应该是对应的编码)

作者:BlackJava
链接:https://www.jianshu.com/p/c3bb9d86fd22
来源:简书

2020/1/17

install nvidia driver for pytorch in ubuntu 18.04

最好先去 Pytorch 的網頁看一下支援的版本
像現在只有支援 cuda 9.2 跟 cuda 10.1

所以去 cuda 的頁面,選 舊release.. 選 10.1
有兩個 update.. 看一下,update 1 好像是完整的 deb,所以下載下來,然後 follow instruction:
`sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.168-418.67_1.0-1_amd64.deb`
`sudo apt-key add /var/cuda-repo-/7fa2af80.pub`
`sudo apt-get update`
`sudo apt-get install cuda`
第二個命令其實在第一個命令完成後會顯示,舊 copy paste and run 舊可以。

cuda 安裝因為加了 apt source,所以 nvidia driver 也會更新,像裝完 cuda10.1 之後,nvidia driver 由 410 更新到 430

20/06/29

Y720 install SSD

這次 follow CUDA Toolkit 10.1 update2 Archive
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda
結果安自動安裝 driver 450

folloow pytorch gettting start 的 instruction,安裝 miniconda3,create env ,然後run pytorch install command:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
會安裝 python 3.8,和 cudatoolkit-10.1
但是因為是再 conda env 內安裝,所以這些 package 只有在 env 李才看得到。


20/08/3

再到 Start Locally | PyTorch 去看, (那個selection table)已經可以選 cuda 10.2 了。

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
然後 driver 是 440 了..

follow pytorch install,有安裝 miniconda.

titan rtx 一直有問題,終於,conda install tensorflow-gpu 後,不能動作。
到 nvidia 選 18.04 cuda 11.X 安裝。
結果 driver 要 520
最後一部 apt install cuda 一直 fail,說要nvidia-drvier-520,但是部會裝。
後來,移除 apt.d/sourcelist.d 中 cuda 10.1 的 sources,update 後,purge 完,再做 apt install cuda 才安裝 520 driver....

2020/1/14

[4/977] including MINE/my_i2c_utils/Android.mk ...
build/make/core/base_rules.mk:139: warning: *** Module name: my_i2c
build/make/core/base_rules.mk:140: warning: *** Makefile location: MINE/my_i2c_utils/Android.mk
build/make/core/base_rules.mk:141: warning: * 
build/make/core/base_rules.mk:142: warning: * Module is attempting to use the 'user' tag.  This
build/make/core/base_rules.mk:143: warning: * used to cause the module to be installed automatically.
build/make/core/base_rules.mk:144: warning: * Now, the module must be listed in the PRODUCT_PACKAGES
build/make/core/base_rules.mk:145: warning: * section of a product makefile to have it installed.
build/make/core/base_rules.mk:146: warning: * 
build/make/core/base_rules.mk:147: error: user tag detected on module..
如果再 MINE/my_i2c_utils/Android.mk 中加入 PRODUCT_PACKAGES += ..
會抱怨說 PRODUCT_PACKAGES 是 read only variable..

2020/1/10

2020/1/8

bye bye debian


跟著升級,用了10年的debian...因為nvidia driver 的關係,最後還是要換ubuntu 了...
先是裝了 server 版(因為手邊正好有...),是console mode,然後加裝 mate-desktop,然後用 nvidia driver 340。
結果 螢幕反應超頓的...
只好改裝 desktop 版,然後改 mate..

tasksel加 mate-desktop 時,ubuntu-desktop 一樣要存在
輸入法 : ibus-chewing
關閉 usb automount : 要用 dconf-editor:
org/mate/desktop/media-handling:
automount : off
automount-open : off
autorun-never : on
重新啟動 usb-ethernet , dhcp..
用 networkmanager: /etc/netplan:
network:
  version: 2
  renderer: NetworkManager
netplan apply
這樣就會用 icon 上的 edit network 來設定 網路(卡)
Manual. 值都設定正確才會出現 save button
router 也一樣設定

dnsmasq:
因為系統改用 systemd-resolve
所以dnsmasq 的 dns 功能要關閉 (不然就要把 systemd-resolve 關閉)
dnsmasq 關閉的方法是follow dnsmasq.conf 的說明,把 port=0

/etc/dnsmasq.conf 中把所有的 log 都打開
# For debugging purposes, log each DNS query as it passes through
# dnsmasq.
log-queries

# Log lots of extra information about DHCP transactions.
log-dhcp
這樣在 /var/log/syslog (dnsmasq 沒有自己的 log file),就會有詳細的...
Jul  6 17:50:26 beaver dnsmasq-dhcp[27344]: DHCP, IP range 172.16.200.1 -- 172.16.200.15, lease time 12h
Jul  6 17:50:26 beaver dnsmasq-dhcp[27344]: DHCP, sockets bound exclusively to interface enx00e04c361590
Jul  6 17:50:26 beaver systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Jul  6 17:51:11 beaver dnsmasq-dhcp[27344]: 819189787 available DHCP range: 172.16.200.1 -- 172.16.200.15
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 client provides name: Ambarella
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 DHCPREQUEST(enx00e04c361590) 172.16.200.7 4e:2d:27:e0:b9:a8
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 tags: enx00e04c361590
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 DHCPACK(enx00e04c361590) 172.16.200.7 4e:2d:27:e0:b9:a8 Ambarella
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 requested options: 1:netmask, 28:broadcast, 2:time-offset, 121:classless-static-route,
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 requested options: 15:domain-name, 6:dns-server, 12:hostname,
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 requested options: 40:nis-domain, 41:nis-server, 42:ntp-server,
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 requested options: 26:mtu, 119:domain-search, 3:router, 121:classless-static-route,
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 requested options: 249, 33:static-route, 252, 42:ntp-server,
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 requested options: 17:root-path
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 next server: 172.16.200.1
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  1 option: 53 message-type  5
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  4 option: 54 server-identifier  172.16.200.1
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  4 option: 51 lease-time  12h
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  4 option: 58 T1  6h
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  4 option: 59 T2  10h30m
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  4 option:  1 netmask  255.255.255.0
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  4 option: 28 broadcast  172.16.200.255
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  4 option:  3 router  172.16.200.1
Jul  6 17:51:12 beaver dnsmasq-dhcp[27344]: 819189787 sent size:  9 option: 12 hostname  Amburr


如果是ubuntu 20.04,就用 network-manager 就可以了。
選擇要提供 dhcp 的網卡,ipv4/6 設定選 "share to other computers" 就可以了,其他都不用安裝/設定。
-- 只是 ip range 好像不能設,default 就是 10.24.X.X


2024/01/30
因為 support 的 GLIBC 不夠新,所以 upgrade 到 22.04
用 do_release_upgrade 的方法。
一開始說 broken package : ubuntu-desktop,所以 follow link remove colord, mesa-utils 之後,ubuntu-desktop 也移除,這樣就可以繼續下去...

upgrade 完是 console mode。要安裝 gnome-control-utils 跟 ubuntu-desktop,結果 fail。
發現是 pipewire 的原因。
因為當初 20.04 的 bt handfree 是 failed,要手動安裝 pipewire,所以把所有卡住的 pipewire 和相關 package 都移除。
就可以安裝 gnome-control 跟 ubuntu-desktop,
之後reboot 就是圖形模式了。

因為移除 pulseaudio 和 pipewire,所以到setting 去看,沒有 audio device。
參考: 做這個:
sudo touch /usr/share/pipewire/media-session.d/with-pulseaudio
systemctl --user restart pipewire-session-manager
沒效,再加上:
pulseaudio -k
pulseaudio -D
reboot之後,就出現了。

2020/1/6

Import and build Spydroid-ipcamera

clone spydroid-ipcamera 後,用 Android Studio import 完。
他會 convert 成Grandle Project.

然後出現 Error:
ERROR: Could not find com.android.tools.build:gradle:3.5.3.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom
  - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.jar
Required by:
    project :
Add Google Maven repository and sync project
Open File
這是因為 grandle 之後的版本都在 google,不在 jcenter 了 (可以到 jcenter 去看)。
所以要照著他的說明,把 Google Moven repository 加到 build.gradle 的 repository 中..
buildscript {
    repositories {
        google()       --- 加上這個
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
    }
}

allprojects {
    repositories {
        google()   --- 這個也加,是等一下 aapt error 時要改的
        jcenter()
    }
}
改完,Sync 後出現..
ERROR: Minimum supported Gradle version is 5.4.1. Current version is 4.8.

Please fix the project's Gradle settings.
Fix Gradle wrapper and re-import project
Open Gradle wrapper properties
Gradle settings
選 "Fix Gradle wrapper..." 那一項,會把grandle-wrapper.property 中的版本改為 5.4.1,繼續...
出現 ..
ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the
defaultConfig in the build.gradle file.
Remove minSdkVersion and sync project
Affected Modules: app
選 "remove minSdkVersion..." 他會去 search minSdkVersion,找到AndroidManifest.xml,裡面有..
    
把這個刪掉..

那個自己產生的 build.grandle(Module:app) 內容是
apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "net.majorkernelpanic.spydroid"
        minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
}

dependencies {
    compile files('libs/GoogleAdMobAdsSdk-6.1.0.jar')
    compile files('libs/acra-4.4.0.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/gcm.jar')
    compile files('libs/sc-light-jdk15on-1.47.0.2.jar')
    compile files('libs/scpkix-jdk15on-1.47.0.2.jar')
    compile files('libs/scprov-jdk15on-1.47.0.2.jar')
}
SdkVersion 很重要,不能太新,因為裡面的 apache http module 在新版Sdk 已經拿掉了..
還有一堆 IOException class 也是。

所以可能要讓他出現 minSdkVersion Error 再刪AndroidManifest.xml,不然他沒辦法產生build.grandle正確的 sdk 版本。