2018/12/28

STM32 Boot Mode

STM32 Boot mode 很有趣,經由 Boot0/1 pin 可以選擇由內部 flash 或是內部 boot rom 開機。
----------------------------------
| BOOT1  | BOOT0 |  Boot Mode    |
----------------------------------
|   x    |   0   | Main Flash    |
----------------------------------
|   0    |   1   | System Memory |
----------------------------------
|   1    |   1   | Embedded SRAM |
----------------------------------
若是選擇由 boot rom 開機,有一個 default download channel 流程,依序檢查下列download path 是否有動作..
  • UART1.3
  • CAN
  • USB
所以不需要額外的 download channel config pin

對應 USB download的 pc tool 是 dfu-tools


STM32F4 Discovery Board

要進入 dfu mode 的話。因為 板子 boot1 , boot0 都是 pull-low
所以要是想進入dfu mode (System Memory) 的話,就要把 BOOT0 設為 High
在 discovery board 上,boot0 的 pin 腳剛好在 VDD 旁邊。
所以只要用 JMP 把這兩個 pin ( BOOT0, VDD) 短路就可以了。

2018/12/27

stm32f4 discovery board, test run in debian.

stlink 沒有 package,要從 source code build
build 文件參考 Compiling

大概就是...需要 build-essential, cmake, libusb-1.0-0-dev , libgtk-3-dev(if stlink-gui)

ref:
發現 debian 有..stlink-tools,package 頁面,列出的主頁面就是texane/stlink
所以大概是一樣的。

所以就 apt-get install slink-tools 就可以

cross-compile 用 gcc-arm-none-eabi 這個 package 就可以。
debian 的 arm-none-eabi-gdb 在 gdb-arm-none-eabi 這個 package 中。

所以合起來,toolchain and download utility 就是.
  • stlink-tools
  • gcc-arm-none-eabi
  • gdb-arm-none-eabi

Test build and run.

libopencm3 的 example 來測試就可以,
git clone https://gitub.com/libopencm3/libopencm3-examples.git
cd libopencm3-examples
git submodule init
git submodule update
然後就可以直接 make..


ref:how to compile and burn the code to stm32 chip on linux ubuntu

很奇怪的是,用 package 的版本,TrueStudio 沒辦法正確invoke。
follow github 版本 make, install 之後,TrueStudio 就可以正卻進入 debug mode..
git clone git@github.com:texane/stlink.git
cd stlink
make release
cd build/Release
然後 sudo make install
log:
[ 23%] Built target stlink-static
[ 46%] Built target stlink
[ 53%] Built target st-info
[ 63%] Built target st-flash
[ 76%] Built target st-util
[ 86%] Built target flash
[ 93%] Built target sg
[100%] Built target usb
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libstlink.so.1.5.1
-- Installing: /usr/local/lib/libstlink.so.1
-- Installing: /usr/local/lib/libstlink.so
-- Installing: /usr/local/lib/libstlink.a
-- Installing: /usr/local/bin/st-flash
-- Set runtime path of "/usr/local/bin/st-flash" to ""
-- Installing: /usr/local/bin/st-info
-- Set runtime path of "/usr/local/bin/st-info" to ""
-- Installing: /etc/modprobe.d/stlink_v1.conf
-- Installing: /etc/udev/rules.d/49-stlinkv1.rules
-- Installing: /etc/udev/rules.d/49-stlinkv2-1.rules
-- Installing: /etc/udev/rules.d/49-stlinkv2.rules
-- Installing: /etc/udev/rules.d/49-stlinkv3.rules
-- Installing: /usr/local/bin/st-util
-- Set runtime path of "/usr/local/bin/st-util" to ""
-- Installing: /usr/local/lib/pkgconfig/stlink.pc
-- Installing: /usr/local/include/stlink.h
-- Installing: /usr/local/include/stlink/backend.h
-- Installing: /usr/local/include/stlink/chipid.h
-- Installing: /usr/local/include/stlink/commands.h
-- Installing: /usr/local/include/stlink/flash_loader.h
-- Installing: /usr/local/include/stlink/logging.h
-- Installing: /usr/local/include/stlink/mmap.h
-- Installing: /usr/local/include/stlink/reg.h
-- Installing: /usr/local/include/stlink/sg.h
-- Installing: /usr/local/include/stlink/usb.h
-- Installing: /usr/local/include/stlink/version.h
-- Installing: /usr/local/share/man/man1/st-util.1
-- Installing: /usr/local/share/man/man1/st-flash.1
-- Installing: /usr/local/share/man/man1/st-info.1
因為 rules 有改變,所以如果不要重新開機,要叫 udev reload:
#udevadm control --reload-rules
#udevadm trigger

TrueStudio 的 Debug Configuration 選 :
  • Debug Probe: ST-LINK
  • Audostart local GDB server
  • Hostname or IP adress : localhost
  • Port Number: 61234
-- all are the default value of 'ST-LINK' option

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,所以 沒辦法試...