2013年12月29日 星期日

Risc-V on Arty A7 35T - scala design cpu & add instruction & jtag debug

The project fit for Arty A7-35T

1.
install Vivado 2019.2.1
run step 5 in http://fatalfeel.blogspot.com/2013/12/chisel-design-ic-for-risc-v.html
gedit /etc/environment
~add path
/opt/Xilinx/Vivado/2019.2/bin

2.
cd $HOME
mkdir -p riscv_cpu
cd $HOME/riscv_cpu
git clone --recursive https://github.com/SpinalHDL/VexRiscv

Risc-V on Ice40HX8K and Ice40UP5K - scala design cpu

1. preinstall
apt install build-essential cmake clang bison flex libreadline-dev gawk tcl-dev libffi-dev git mercurial graphviz xdot pkg-config libftdi-dev qt5-default libboost-all-dev libeigen3-dev

apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev texinfo gperf libtool patchutils bc zlib1g-dev git libexpat1-dev

apt install libhidapi-dev libusb-1.0-0-dev

install python3.7 + pip3
refer to http://fatalfeel.blogspot.com/2019/12/ai-with-cuda-install-step-and-yolov3-in.html

Rocket-chip Risc-V core design and debugging in IntelliJ IDE

Refer to:
https://github.com/chipsalliance/rocket-tools/blob/master/README.md
https://github.com/chipsalliance/rocket-chip/blob/master/README.md
https://fatalfeel.blogspot.com/2013/12/chisel-design-ic-for-risc-v.html
https://hardsecurity.github.io/docs/untether-v0.2/figures/pipeline.png

1.
#preinstall
apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev libfl-dev

2.
#export must add to last line of ~/.bashrc
export RISCV="/opt/riscv"
export ROCKETCHIP="/root/riscv_cpu/rocket-chip"
export MAKEFLAGS="$MAKEFLAGS -j8"

MQL5 auto trading source. (that's why you cannot beat the speed of large exchanges)

/* Do not use this code to trading, some bug inside*/

/*
MQL5 source, this code trade in CFD. Using QQE, EMA, RSI, MACD,
to do buy, sell, close and the other best actions. Length of time is 24 hours.
*/
#property copyright "Copyright 2000-2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"

#include <Trade\Trade.mqh>
input int     InpQQE_RSI_Period     = 14;            // QQE RSI Period
input double  InpQQE_RSI_Smooth     = 5;             // QQE RSI Smoothing Factor
input double  InpQQE_RSI_REF        = 50;
input int     InpEMA_Period         = 50;                // EMA Period
input int     InpRSI_Period         = 14;                // RSI Period
input int     InpMACD_PeriodFast    = 12;           // MACD Fast Period
input int     InpMACD_PeriodSlow    = 26;           // MACD Slow Period
input int     InpMACD_PeriodSignal  = 9;          // MACD Signal Period
input int     InpATR_Period         = 14;                // ATR Period
input double  InpLotSize            = 0.1;               // Lot Size

Cortex-m33 change modem shutdown time in assembly

When using nrf_modem_shutdown of libmodem.a. It need to wait 48 seconds and leave.
To fix it in assembly source.

///////////////////Trace into nrf_modem_shutdown()///////////////////
<nrf_modem_shutdown>
4B0C
          ldr r3, =0x20019441
B510           push {r4, lr}
781A           ldrb r2, [r3]
B18A           cbz r2, 0x00031464
2400            movs r4, #0
701C           strb r4, [r3]
4B0A           ldr r3, =0x20019442 <operation_mode>
781B           ldrb r3, [r3]
B12B           cbz r3, 0x00031456
2B01           cmp r3, #1
D007           beq 0x0003145E
F7FFFFB1  bl 0x000313B4 <modem_off>
4620            mov r0, r4
BD10           pop {r4, pc}
F000F80D   bl 0x00031474 <nrf_modem_platform_shutdown>
4604            mov r4, r0
E7F7           b 0x0003144E
F7FBFC87  bl 0x0002CD70 <nrfx_ipc_uninit>
E7F4           b 0x0003144E
F04F34FF   mov.w r4, #0xFFFFFFFF
E7F3           b 0x00031452
BF00           nop

2013年12月28日 星期六

Faster-Rcnn in Pytorch with tuberculosis ai detect

Theory:
https://arxiv.org/pdf/1506.01497.pdf
https://lilianweng.github.io/lil-log/2017/12/31/object-recognition-for-dummies-part-3.html
https://zhuanlan.zhihu.com/p/31426458
https://www.lablab.top/post/how-does-faster-r-cnn-work-part-ii

Loss function:
https://blog.csdn.net/qq_34106574/article/details/81669891

Roi align:
https://erdem.pl/2020/02/understanding-region-of-interest-part-2-ro-i-align

Source:
https://github.com/fatalfeel/faster_rcnn_pytorch
https://github.com/fatalfeel/tb_faster_rcnn

Demo:
https://www.mediafire.com/view/c96v330bq1i4hqg/faster-rcnn.png

Chisel design Risc-V cpu

Refer to:
https://github.com/schoeberl/chisel-lab/blob/master/Setup.md
https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html
https://github.com/OpenXiangShan/XiangShan

1.
#preinstall
apt install openjdk-8-jdk git make

2.
#install python 3.7:
http://fatalfeel.blogspot.com/2019/12/ai-with-cuda-install-step-and-yolov3-in.html
label: install python 3.7 + pip3 + labelimg + yolov3
Do step 1~9

Hog Pca Svm Slider Nms in C++

Refer to: http://fatalfeel.blogspot.com/2013/12/opencv-and-dlib-training.html

1. Preinstall:
opencv 3.4.16
https://opencv.org/releases
dlib 2022-03-22 21:32:14 sha1: 5cb036564c986fcc45eb16dd0174b1602ceb4f7f
https://github.com/davisking/dlib.git 

both make install to /opt

2. eclipse (option)
sudo apt install openjdk-8-jdk 
Luna Service Release 2 + cdt
https://www.eclipse.org/downloads/packages/release/luna/sr2

run it as root

BackTace caller name in C/C++

1. down binutils and build
~~~binutils 2.25.1 x86_64 & aarch64 both build pass other version may be not~~~
download: https://ftp.gnu.org/gnu/binutils
x86_64
./configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=$HOME/binutils-2.25.1/build
make && make install
or
aarch64
./configure --host=x86_64-linux-gnu --target=aarch64-linux-gnu --prefix=$HOME/binutils-2.25.1/build
make && make install

cp -f ~/binutils-2.25.1/build/bin/addr2line [your project path]

2013年12月27日 星期五

Cross Platform NRF9160 Cortex-M33 inter thread communication

Refer to:
https://www.boost.org/doc/libs/1_60_0/doc/html/signals/tutorial.html
http://fatalfeel.blogspot.com/2013/09/how-to-program-send-message-on-corss.html

//header
class EventManager
{
public:

typedef std::vector<EventFunctorBase<EventPack>*> EventMessageSlot_Vector;
typedef std::map<int, EventMessageSlot_Vector> EventMessageSlot_Map; //<message_ID, EventPack_Vector>
static EventManager* Get();
static void Free();
EventManager();
~EventManager();
// event sinks
//void ConnectEventSlot(int messageID, EventFunctorBase<EventPack>* functor);
void ProcessEvent(int type, int messageID, void* callmember, EventPack* event);
void    ConnectEventSlot(int messageID, void* callmember);
void    DisconnectEventSlot(void* callmember);
void    SendEventMessage(EventPack* event);

private:
// event sinks
EventMessageSlot_Map m_EventMessageSlotMap;
};






How to do thread context switch in RTOS

git clone --recursive  https://github.com/FreeRTOS/FreeRTOS

//vector table for a Cortex M3 interrupt
~/FreeRTOS/Demo/CORTEX_STM32F103_Keil/STM32F10x.s
//found
; Vector Table Mapped to Address 0 at Reset
                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors
__Vectors       DCD     __initial_sp              ; Top of Stack
                DCD     Reset_Handler             ; Reset Handler
                DCD     NMI_Handler               ; NMI Handler
                DCD     HardFault_Handler         ; Hard Fault Handler
                DCD     MemManage_Handler         ; MPU Fault Handler
                DCD     BusFault_Handler          ; Bus Fault Handler
                DCD     UsageFault_Handler        ; Usage Fault Handler
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     vPortSVCHandler           ; SVCall Handler
                DCD     DebugMon_Handler          ; Debug Monitor Handler
                DCD     0                         ; Reserved
                DCD     xPortPendSVHandler        ; PendSV Handler
                DCD     xPortSysTickHandler       ; SysTick Handler

2013年12月26日 星期四

8051 OS on µVision V5

1. multitask
in RTX51\project\src\ABS_TASK\absTask.c
~find
void Task_Init() _task_ INIT
~add your talk

2. help you do cpu simulation with peripheral hardware
https://developer.arm.com/documentation/kan145/latest
https://developer.arm.com/documentation/kan154/latest

3. µVision command window
https://www.keil.com/support/man/docs/uv4/uv4_debug_commands.htm
https://www.keil.com/support/man/docs/uv4/uv4_debug_functions.htm

4. keil plugin demo
http://www.neoegm.com/tech/hardware/8051/keil-plugins/keil-uvision-plugin-matrix-keyboard
http://www.neoegm.com/tech/hardware/8051/keil-plugins/how-to-install-a-keil-uvision-peripheral-plugin

How to build 4g LTE base station in very low cost

Refer to:
1. https://cyberloginit.com/2018/05/03/build-a-lte-network-with-srslte-and-program-your-own-usim-card.html
2. https://cloud.tencent.com/developer/article/1684051
3. https://blog.white-alone.com/%E4%BD%BF%E7%94%A8srsLTE%E6%90%AD%E5%BB%BA4G%E5%9F%BA%E7%AB%99%E7%94%A8%E4%BA%8E%E6%97%A5%E5%B8%B8%E6%B5%8B%E8%AF%95/
4. https://www.white-alone.com/%E4%BD%BF%E7%94%A8BladeRF%E6%88%96%E8%80%85B210%E5%BF%AB%E9%80%9F%E6%9E%84%E5%BB%BA4G%20LTE%E6%B5%8B%E8%AF%95%E7%BD%91/
5. https://www.mobibrw.com/2018/10729/comment-page-1

USRP N210 Taobao price 26000 RMB = 4030 US$
https://world.taobao.com/item/530598387626.htm

Some people may think N210 is too expensive.
USRP B210 transparent version 500 RMB = 714 US$
https://item.taobao.com/item.htm?spm=a230r.1.14.30.6ea326b6S8jv4c&id=618435712984

EMNIST handwritten dataset on libtorch c++

Refer to:
https://jovian.ai/goyalbhavya529/emnist-project
https://github.com/austin-hill/EMNIST-CNN
https://discuss.pytorch.org/t/libtorch-how-to-use-torch-datasets-for-custom-dataset/34221
https://github.com/pytorch/examples/blob/main/cpp/custom-dataset/custom-dataset.cpp

1. download emnist label and image
https://www.kaggle.com/datasets/crawford/emnist

2. explain emnist data
###emnist-balanced-train-labels-idx1-ubyte###
[offset]    [type]      [value]                        [description]
0000        32 bits     0x00000801(2049)     magic number     - big endian
0004        32 bits     0x0001b8a0(112800) number of items  - big endian
0008        unsigned    byte   ??                   label
0009        unsigned    byte   ??                   label
....
xxxx        unsigned    byte   ??                   label

labels   = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabdefghnqrt"
classes = 47

###emnist-balanced-train-images-idx3-ubyte###
[offset] [type]              [value]                        [description]
0000     32 bit integer  0x00000803(2051)     magic number          - big endian
0004     32 bit integer  0x0001b8a0(112800) number of images    - big endian
0008     32 bit integer  0x0000001c(28)         number of rows        - big endian
0012     32 bit integer  0x0000001c(28)         number of columns  - big endian
0016     unsigned byte   ??                              pixel
0017     unsigned byte   ??                              pixel
....
xxxx     unsigned byte   ??                              pixel

Pixels are arranged in row-wise 28 x 28 pixels
Pixel value between 0 to 255.
0     = background white.
255 = foreground black.
The original EMNIST images provided are inverted horizontally and rotated 90 anti-clockwise

nrf9160 soft uart - using gpio simulator uart

 static uint32_t get_BitWidth(uint32_t baudrate)
{
  uint32_t bit_width;

  switch( baudrate )
  {
    case 4800:
      bit_width = 0x7c; //123~152 for 4800, for nrf9160
      break;

    case 9600:
      bit_width = 0x68; //104
      break;

2013年12月25日 星期三

Intel arc xpu for pytorch in ubuntu install step

refer to:
1. https://github.com/intel/intel-extension-for-pytorch
2. https://pytorch.org/tutorials/recipes/recipes/intel_extension_for_pytorch.html
3. https://blog.csdn.net/m0_63007797/article/details/136606591

################## install step ##################
1. install xpu driver for arc
https://dgpu-docs.intel.com/driver/client/overview.html
if you buy Flex Series or Max Series try this
https://dgpu-docs.intel.com/driver/installation.html

RK3566 / RK3568 SWD debug

Refer to
http://notes.zahoryzontnik.com/
https://fatalfeel.blogspot.com/2015/12/openocd-with-eclipse-debug-kernel-of.html

1. openocd source download and install
https://github.com/fatalfeel/openocd_integrated
note: site include rk3566.cfg (fit for rk3568 too)

2. bus blaster dangerous prototypes v3c or v4.1a jtag to swd
https://fatalfeel.blogspot.com/2013/09/bus-blaster-flash-to-swd-mode-in-openocd.html

3. hardware dp_busblaster_kt-link connect to swd of rk3568
(a) remove off sdcard connector, or the connector spring will trigger jtag disable
https://www.mediafire.com/view/gljvlwq83nauxbc/sdcard_connector.jpg
(b) swd connect circuit, do not connect any vref like 3.3v or 5.0v
tck  - swclk
tms - swdio
gnd - gnd

Nrf9160 uart port to external pin

ubuntu host PC rs232usb:
nrf9160 target board:

Get log from PC /dev/ttyACM0 change to PC /dev/ttyUSB0
PC Tx ---- target rx p0.00
PC Rx ---- target tx p0.01

Build nrf9160dk projects on Zephyr OS and SEGGER Embedded Studio

Zephyr OS is RTOS - The Application bind with kernel and drivers into a image

##########################Zephyr Project 2.5.99###############################
################for console build projects
################
Refer to:
https://infocenter.nordicsemi.com/pdf/nRF9160_DK_HW_User_Guide_v1.0.pdf
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/getting_started/index.html
http://fatalfeel.blogspot.com/2019/12/ai-with-cuda-install-step-and-yolov3-in.html
https://apt.kitware.com/
https://docs.zephyrproject.org/latest/boards/arm/nrf9160dk_nrf9160/doc/index.html

2013年12月24日 星期二

PPO AI in raycasting game to simulate self driving for saving people's lives

Refer to:
a. https://permadi.com/1996/05/ray-casting-tutorial-1
b. https://raytomely.itch.io/raycasting-floorcasting
c. https://killerrobotics.me/2021/08/13/raycasting-game-in-python-and-pygame-part-1
d. https://www.mediafire.com/file/zo15gqjz5roxzk5/ray_trace_java.tar.gz
e. https://github.com/StanislavPetrovV/3D-Python-game-Raycast
f. https://github.com/jordansavant/doomengine.python
g. https://fatalfeel.blogspot.com/2013/09/build-3d-game-doom1-on-ubuntu-1604.html
h. http://www.peteflorence.com/ReinforcementLearningAutonomousDriving.pdf
i. https://github.com/peteflorence/Machine-Learning-6.867-homework
j. https://www.fatalerrors.org/a/lane-change-detection.html
k. https://github.com/HevLfreis/TrafficLight-Detector
l. https://www.fatalerrors.org/a/lane-change-detection.html
m. https://fatalfeel.blogspot.com/2013/12/ppo-and-awr-guiding.html
n. https://arxiv.org/pdf/1807.10913.pdf
o. https://github.com/lijx10/uwb-localization

Project Idea:
Using doom game simulate LiDAR raycasting. When opencv detect driver eyes closed too long, then switch to PPO AI driving and move to road side slowly.
Each ray is status into PPO actor network and output are left, right, doing nothing.

Source:
https://github.com/fatalfeel/PPO_raycast
because someone use PPO to unmanned combat air vehicle(UVAC) so I decide delete this repository.

Simulation Environment: (3D working)
https://www.mediafire.com/file/8kp1bgq5zvmlj12/raycast_env.py
https://www.mediafire.com/file/naegynukhwxlad7/best_factors.npy

Learn to pay Attention

source:
https://github.com/fatalfeel/LearnToPayAttention

paper:
https://www.robots.ox.ac.uk/~tvg/publications/2018/LearnToPayAttention_v5.pdf

2013年12月22日 星期日

Eclipse AI generate c/c++ java python on Ubuntu/Windows

official source and system minimum require:
Ubuntu 18.04 above because need gtk version >= 3.22
openjdk-11-jdk

patched source and system minimum require:
Ubuntu 16.04
openjdk-8-jdk

~check gtk version
dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'

1.
rm -rf /usr/lib/python3/dist-packages/uaclient
pip3 install opcua-client

2.
sudo apt update
sudo apt install openjdk-11-jdk

Binder on Ubuntu process to process communication

Why binder faster than socket:
Binder copy only needs one time, but pipelines, queues, sockets, D-bus all need two times
https://www.dre.vanderbilt.edu/~schmidt/cs282/PDFs/android-binder-ipc.pdf

Binder include 4 parts:
1. Driver
2. Service Manager
Register service name
3. Server
onTransact receive data from the client
4. Client

2013年12月21日 星期六

Yolov3 to OpenCV C++

Refer to
(1.) https://blog.francium.tech/custom-object-training-and-detection-with-yolov3-darknet-and-opencv-41542f2ff44e
(2.) https://learnopencv.com/training-yolov3-deep-learning-based-custom-object-detector
(3.) https://github.com/pjreddie/darknet/issues/2257
(4.) https://github.com/pjreddie/darknet/issues/1458

Start Training
1.
git clone --recursive https://github.com/pjreddie/darknet

2.
wget https://github.com/arnoldfychen/darknet/blob/master/src/convolutional_layer.c
replace ~/darknet/src/convolutional_layer.c with new one

How WIFI working from kernel to wpa_supplicant

Refer to:
1. http://fatalfeel.blogspot.com/2015/12/openocd-with-eclipse-debug-kernel-of.html
2. http://fatalfeel.blogspot.com/2013/09/debug-android-framework-and-service-in.html
3. https://www.cnblogs.com/mauricewei/p/10502300.html
4. https://zhuanlan.zhihu.com/p/344526925
5. http://www.mediafire.com/file/0adoj9isttdtod4/kernel_imx_aarch64.tar.gz

Kernel debug we  choosing jtag and wpa_supplicant choosing otg

1. rtl8723BU_WiFi module change to build in driver for debugging easier
gedit ~/OK8MM-android/vendor/nxp-opensource/kernel_imx/arch/arm64/configs/android_defconfig
CONFIG_RTL8723BU=m
//change to
CONFIG_RTL8723BU=y

2. cancel depmod module load in android
gedit ~/OK8MM-android/device/fsl/imx8m/evk_8mm/BoardConfig.mk
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_OUT)/drivers/net/wireless/realtek/rtl8723BU_WiFi/8723bu.ko
//comment to
# BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_OUT)/drivers/net/wireless/realtek/rtl8723BU_WiFi/8723bu.ko

2013年12月20日 星期五

Build and debug ipmitool for mingw64 on linux

Refer to: https://tecadmin.net/install-wine-on-ubuntu

1.
echo 'deb http://us.archive.ubuntu.com/ubuntu trusty main universe' >> /etc/apt/sources.list
sudo apt update
sudo apt install mingw32 mingw32-binutils mingw32-runtime mingw-w64
sudo apt install mingw-w64

#mingw-w64 cimpiler can add -m32 in CFLAGS for 32bits

IPMI simulator build step

/////////////////////////////////////////////////////////////
////////////////build linux kernel and rootfs////////////////
/////////////////////////////////////////////////////////////
Refer to:
http://www.linux-kvm.org/images/7/76/03x08-Juniper-Corey_Minyard-UsingIPMIinQEMU.ods.pdf
https://morris821028.github.io/2016/01/21/realtime-system-qemu
https://www.cnblogs.com/zzb-Dream-90Time/p/7111242.html

1.
apt install libncurses5-dev

2.check openipmi linux kernel version
https://sourceforge.net/p/openipmi/linux-ipmi/ci/master/tree/Makefile
VERSION = 4
PATCHLEVEL = 10
SUBLEVEL = 0

3.
git clone --recursive git://git.code.sf.net/p/openipmi/linux-ipmi
cd linux-ipmi
make ARCH=x86_64 defconfig
make ARCH=x86_64 menuconfig

2013年12月17日 星期二

PPO cross platform with libtorch C++

Prepare install:
https://fatalfeel.blogspot.com/2020/06/building-libtorch-and-numpy-in-c.html

PPO C++ source:
https://github.com/fatalfeel/PPO_libtorch

Lessons:
(1) Backpropagation Practice:
source: http://www.mediafire.com/file/fccr43arjcxfgsb/backwardcpp.tar.gz

#If no cuda, eclipse need remove follow libs:
cublas, cudnn, cudart, nvToolsExt, cufft, curand, c10_cuda, torch_cuda

Tesla told in New York Herald: I prefer to be remembered as the inventor who succeeded in abolishing war. That will be my highest pride.
http://www.teslacollection.com/tesla_articles/1898/new_york_herald/f_l_christman/tesla_declares_he_will_abolish_war
(in middle section)

Albert Einstein: The release of atom power has changed everything except our way of thinking... the solution to this problem lies in the heart of mankind. If only I had known, I should have become a watchmaker.
https://atomictrauma.wordpress.com/the-scientists/albert-einstein

Artificial Intelligence Has an Enormous Carbon Footprint
https://www.analyticsvidhya.com/blog/2022/03/the-carbon-footprint-of-ai-and-deep-learning

2013年12月16日 星期一

opencv and dlib training

Refer to:
https://github.com/mrnugget/opencv-haar-classifier-training
https://github.com/davisking/dlib/tree/master/tools/imglab
https://speech.ee.ntu.edu.tw/~hylee/mlds/2015-fall.php
https://gitee.com/Heconnor/MRF
https://www.kaggle.com/mehmetlaudatekman/support-vector-machine-object-detection

#preinstall
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DE19EB17684BA42D
apt install cmake cmake-qt-gui cmake-curses-gui
apt install libjpeg8-dev libpng12-dev libgtk2.0-dev libxext-dev libopenblas-dev liblapack-dev
apt install libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
apt install libv4l-dev zlib1g-dev
apt install ninja-build
pip3 install scikit-image

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////OpenCV/////////////////////////////////////////////////////////////
https://opencv.org/releases
download opencv-3.4.16.zip

libtorch cross compile on aarch64-linux-gnu-gcc include torchvision

Refer to:
https://github.com/pytorch/pytorch#get-the-pytorch-source
https://github.com/pytorch/pytorch/blob/master/docs/libtorch.rst
https://discuss.pytorch.org/t/compile-libtorch-c-api-from-source/81624/2
https://qiita.com/syoyo/items/360bcf15b9ee88eeeacd
https://github.com/ljk53/pytorch-android-cpp-demo
https://github.com/dpilger26/NumCpp/tree/master
https://github.com/t-kuha/mpsoc-library/wiki/How-to-build-libtorch-&-torchvision          
https://github.com/t-kuha/mpsoc-library/wiki/How-to-build-Caffe-%26-libtorch-dependencies 
https://fatalfeel.blogspot.com/2013/12/build-nrf9160dk-projects-with-zephyr-os.html      
https://fatalfeel.blogspot.com/2019/12/ai-with-cuda-install-step-and-yolov3-in.html

#install gcc compiler
sudo apt install build-essential

#install python3 version >= 3.7 need here are a lot of works.
https://fatalfeel.blogspot.com/2019/12/ai-with-cuda-install-step-and-yolov3-in.html

#install cmake 3.20.5
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DE19EB17684BA42D
sudo apt install cmake cmake-qt-gui cmake-curses-gui
sudo apt install libjpeg8-dev libpng12-dev libgtk2.0-dev libxext-dev libopenblas-dev liblapack-dev
sudo apt install libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
sudo apt install libv4l-dev zlib1g-dev
sudo apt install ninja-build

Build OpenCV with Gstreamer in JetPack

Ref: https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.1.1_Jetson.sh

//download arm64's libjasper1 libjasper-dev
https://launchpad.net/ubuntu/xenial/arm64/libjasper1/1.900.1-debian1-2.4ubuntu1.2
https://launchpad.net/ubuntu/xenial/arm64/libjasper-dev/1.900.1-debian1-2.4ubuntu1.2
gdebi ./libjasper1_1.900.1-debian1-2.4ubuntu1.2_arm64.deb
gdebi ./libjasper-dev_1.900.1-debian1-2.4ubuntu1.2_arm64.deb

2013年12月15日 星期日

Tesseract on ubuntu

refer to:
https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html

preinstall:
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DE19EB17684BA42D
apt install cmake cmake-qt-gui cmake-curses-gui
apt install automake autoconf libtool pkg-config libcurl4-gnutls-dev libjpeg8-dev libpng12-dev libtiff5-dev

1. font database
git clone --recursive https://github.com/tesseract-ocr/tessdata_best

PPO AI algorithm on PyTorch

1. Algorithm
https://spinningup.openai.com/en/latest/algorithms/ppo.html
https://zhuanlan.zhihu.com/p/108034550

2. Pytorch python source
https://github.com/fatalfeel/PPO_Pytorch (with full comment)

2013年12月7日 星期六

Slim yolov3 install step in pytorch

refer to https://arxiv.org/pdf/1907.11093.pdf
#clone ktian08-hyp branch not master branch
apt install git-coloa
run git-coloa
clone https://github.com/ultralytics/yolov3.git
actions
pull
enable rebase
origin/ktian08-hyp pull

TFTP upload to IPMI board

1. pc host
apt install tftpd-hpa
gedit /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/mnt/harddisk/upload"
TFTP_ADDRESS="192.168.59.228:69"
TFTP_OPTIONS="-c -l -s"

#-c: Allow new files to be created
#-l:  Run the server in standalone (listen) mode, rather than run from inetd.
#-s: Change  root  directory  on startup.

2013年12月3日 星期二

Install Nvidia cuda & python3.7/3.8 & Yolov3 in Pytorch

#######################################################################
#install nvidia driver + cuda 10.2 + cudnn 7.6.5
#######################################################################
1. remove old driver
sudo apt list --installed | grep cuda
sudo apt purge libcudnn7 libcudnn7-dev libcudnn7-doc
sudo rm -rf /usr/local/cuda-10.0

2. check gpu version and install driver
sudo lspci -v  #find VGA compatible controller

3. stop linux default driver if you are using
gedit /etc/modprobe.d/blacklist.conf
#necessary
blacklist nouveau
#option
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

#terminal check
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf

update-initramfs -u
reboot

2013年12月1日 星期日

Qt Widgets C++ building

refer to: 
https://www.cntofu.com/book/46/qt/ubuntubian_yi_an_zhuang_qt5__0__1.md
https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/617555
https://blog.51cto.com/u_15295315/2997065
https://www.cnblogs.com/fengyaoyao/p/10549320.html

Preinstall:
sudo add-apt-repository ppa:levi-armstrong/qt-libraries-xenial
sudo apt update
sudo apt install bison build-essential flex gperf libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev libasound2-dev libatkmm-1.6-dev \
libbz2-dev libcap-dev libcups2-dev libdrm-dev \
libgl1-mesa-dev libglu1-mesa-dev libgl1-mesa-glx libfontconfig1-dev libfreetype6-dev \
libicu-dev libnss3-dev libpci-dev libpulse-dev libssl-dev libudev-dev \
libx11-dev libx11-xcb-dev libxcb-composite0 libxcb-composite0-dev libxcb-cursor-dev \
libxcb-cursor0 libxcb-damage0 libxcb-damage0-dev libxcb-dpms0 libxcb-dpms0-dev \
libxcb-dri2-0 libxcb-dri2-0-dev libxcb-dri3-0 libxcb-dri3-dev libxcb-ewmh-dev libxcb-ewmh2 \
libxcb-glx0 libxcb-glx0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-image0 libxcb-image0-dev \
libxcb-keysyms1 libxcb-keysyms1-dev libxcb-present-dev libxcb-present0 libxcb-randr0 \
libxcb-randr0-dev libxcb-record0 libxcb-record0-dev libxcb-render-util0 \
libxcb-render-util0-dev libxcb-render0 libxcb-render0-dev libxcb-res0 libxcb-res0-dev \
libxcb-screensaver0 libxcb-screensaver0-dev libxcb-shape0 libxcb-shape0-dev libxcb-shm0 \
libxcb-shm0-dev libxcb-sync-dev libxcb-sync-dev libxcb-sync1 libxcb-util-dev \
libxcb-util0-dev libxcb-util1 libxcb-xf86dri0 \
libxcb-xf86dri0-dev libxcb-xfixes0 libxcb-xfixes0-dev libxcb-xinerama0 \
libxcb-xinerama0-dev libxcb-xkb-dev libxcb-xkb1 \
libxcb-xtest0 libxcb-xtest0-dev libxcb-xv0 libxcb-xv0-dev libxcb-xvmc0 libxcb-xvmc0-dev \
libxcb1 libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev \
libxfixes-dev libxi-dev libxrandr-dev libxrender-dev libxslt1-dev libxss-dev \
libxtst-dev libgcrypt11-dev libsigc++-2.0-dev libgtk2.0-dev perl ruby
apt install qt5-default qt59creator
~~~run /opt/qt59/bin/qtcreator

Remote desktop multi-user connection

###########server###########
1. apt remove vino (another vnc sevrer)

2. apt install x11vnc

3. click -> application -> internet -> x11vnc server
port: 5900
File transfer: UltraVnc

Rtsp server for H264 / H265 / AAC

Refer to:
https://github.com/PHZ76/RtspServer
https://github.com/ImSjt/RtspServer
https://gitee.com/marcode/RtspServer-1
https://github.com/ChristianFeldmann/h264Bitstream
https://github.com/Dillon14281118/h265bitstream
https://github.com/BobCromwell/aac-stream-analyzer

Preinstall:
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
sudo apt update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DE19EB17684BA42D
apt install cmake cmake-qt-gui cmake-curses-gui
apt install libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev libsdl1.2-dev

Android studio Eclipse jni C/C++ debug

Eclipse jni C/C++ debug provide breakpoint, watchpoint, watch value, memory value,
Arm register value, disassembly code.

Please refer this first :
http://fatalfeel.blogspot.com/2013/09/debug-android-jni-with-eclipse-gui-on.html

1. Install Ubuntu 16.04 x64 and openjdk 8
sudo apt install openjdk-8-jdk openjdk-8-jre
#check version
root@homelinux:~/CardView/Application/src/main# java -version
openjdk version "1.8.0_222"
root@homelinux:~/CardView/Application/src/main# javac -version
javac 1.8.0_222
root@homelinux:~/CardView/Application/src/main# javadoc -J-version
openjdk version "1.8.0_222"

2. Eclipse dependency
sudo apt install gtk2.0 libgtk2.0-dev

3. Android Studio 3.6.2 install to /opt/android-studio

Arduino Jtag Debug (Mega2560)

1. Prepare
#Hardware
Arduino Mega 2560
Atmel ICE
#Software
Atmel Studio 7 install
Arduino IDE install

2013年9月30日 星期一

Android Board HAL Led control

Ref.
http://www.linuxforu.com/2010/12/writing-your-first-linux-driver
http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html

http://bbs.witech.com.cn/forum.php?mod=viewthread&tid=46598&extra=page%3D1%26filter%3Dtypeid%26typeid%3D28%26typeid%3D28

1.
///set serial number on android
android2.3.4_32bit/system/core/init/init.c
//property_set("ro.serialno", serialno[0] ? serialno : "");
property_set("ro.serialno", "OK1ATV800006"); //by stone

2.
//find define mk
/xxxxxx/android2.3.4_32bit/build/core/core/envsetup.mk
TARGET_OUT := $(PRODUCT_OUT)/system
TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib

3.
//////////////HAL files reference///////////
C:\xxxxxx\android2.3.4_32bit\frameworks\base\services
C:\xxxxxx\android2.3.4_32bit\hardware\libhardware
C:\xxxxxx\android2.3_kernel_v1.01\arch\arm
C:\xxxxxx\android2.3_kernel_v1.01\drivers\char


OpenAL HRTF 3d sound on Linux & Android

source code download on 2016/06/25

https://github.com/kcat/openal-soft
also refer to
https://github.com/soundsrc/openal-soft

///////////////////////Ubuntu 14.04 linux system///////////////////////
1. preinstall
sudo apt-get install cmake
sudo apt-get install libsdl-sound1.2-dev

sudo add-apt-repository ppa:adrozdoff/ffmpeg-opti
sudo apt-get update
sudo apt-get install libavformat-ffmpeg-dev libavcodec-ffmpeg-dev libavutil-ffmpeg-dev libavfilter-ffmpeg-dev libswscale-ffmpeg-dev libswresample-ffmpeg-dev libpostproc-ffmpeg-dev