2017/9/27

reading notes : uarts in raspberry pi 3

ref:
PI 3 因為BT 的關係,所以原來的 uart console 被拿去給 bt 用了,
所以有一堆..

PI3 有兩個 uart:
  • PL011 : /dev/ttyAMA0 -- BT
  • mini UART : /dev/ttyS0 --console
Primary Console : /dev/serial0 是被指定給 console 用的,
所以指定 誰是 /dev/serial0,誰就會變 console。

miniUART 有些問題。
他的 baurate 是從 VPU 的 clk 除的。
所以跟 VPU 的頻率相關。
當使用 dvfs時,VPU 的頻率是會變的,有時候甚至會關閉,
這樣就導致 miniUART 的 baudrate 無法固定,關閉時甚至無法是用。

可以在 config.txt 中加上 enable_uart=1,
這樣,VPU 的 core_freq 就會固定 250MHz,
如果加上 force_turbo 就會固定 400MHz。

enable_uart 只跟 miniUART 有關,不會影響到 PL011

UART 和 GPIO

pi 的 kernel 是用 devicetree overlay 來處理不同 device tree 配置問題。
有兩個:
  • pi3-disable-bt : 這個會 關掉 ttyAMA0,並且把 tx, rx 接到 GPIO 14, 15 pin 上
  • pi3-miniuart-bt : 這個會讓 bt 使用 miniuart (ttyS0),一樣把 ttyAMA0 的 tx, rx 接到 GPIO 14, 15 pin 上
所以簡單(不用bt)的作法,就是在 boot/config.txt 加上
dtoverlay=pi3-disable-bt
就可以用 最旁邊的第3(GND), 4(TX), 5(RX) 做 console uart 了。


在 yocto project 中
在自己增加的 layer 中...
recipes-bsp/bootfiles/rpi-config_git.bbappend:
SRCREV = "648ffc470824c43eb0d16c485f4c24816b32cd6f"

do_deploy_append() {
    if [ -n "${ENABLE_RPI3_SERIAL_CONSOLE}" ]; then
        echo "" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
        echo "## Disable RPi3 bluetooth to enable serial console on UART0" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
        echo "dtoverlay=pi3-disable-bt" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
    fi
}

2017/9/26

another one : build yocto for rpi

這次是 這一篇

git clone -b krogoth git://git.yoctoproject.org/poky
git clone -b krogoth git://git.openembedded.org/meta-openembedded
git clone -b krogoth git://git.yoctoproject.org/meta-raspberrypi

oe-init-env build之後,到 build/conf 下 修改 local.conf..
加上:
MACHINE = "raspberrypi3"
PREFERRED_VERSION_LINUX-raspberrypi = "4.%"
DISTRO_FEATURES_remove += "x11 wayland"
DISTRO_FEATURES_append += "systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"

bblayers.conf 修改成..
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""


BBLAYERS ?= " \
  /home/charles-chang/rpi2016/sources/poky/meta \
  /home/charles-chang/rpi2016/sources/poky/meta-poky \
  /home/charles-chang/rpi2016/sources/poky/meta-yocto-bsp \
  /home/charles-chang/rpi2016/sources/meta-openembedded/meta-oe \
  /home/charles-chang/rpi2016/sources/meta-openembedded/meta-multimedia \
  /home/charles-chang/rpi2016/sources/meta-raspberrypi \
  "

BBLAYERS_NO_REMOVABLE ?= " \
  /home/charles-chang/rpi2016/sources/poky/meta \
  /home/charles-chang/rpi2016/sources/poky/meta-poky \
  "

然後 bitbake rpi-basic-image 就成工了。
build 完 dd , 可以開機。
但是 dtoverlay=pi3-disable-bt 沒作用。
uart 還是沒辦法當 console。只能用 hdmi + keyboard

Qt5 for embedded

Qt5 - embedd Linux
以前有 Qt for embedded,現在好像變成 plugin 了。
這一篇就在說明 plugin 的內容。

至於 license... 好像不清楚。
這一頁的各個 component 沒有列出..

2017/9/25

try : yocto for raspberry pi 3

先是參考 這一篇

clone git.yoctoproject.org/poky。
clone git,openembedded,org/meta-openembedded
clone github.com/meta-qt5/meta-qt5
clone git.yoctoproject.org/meta-raspberrypi
clone github.com/jumpnow/meta-rpi

作者的 meta-rpi 有提供 conf 下的 local.conf 和 bblayers.conf。
copy 過來,修改一下 bblayers.conf 裡的 path..

bitbake qt5-basic-image 出現 error:
Please use a locale setting which supports utf-8.
Python can't change the filesystem locale after loading so we need a utf-8 when python starts or things won't work.

進入 python, 用 sys.getfilesystemencoding() 看,過然,是 ANSI....
所以 follow 這一篇:
$sudo apt-get install locales
$sudo dpkg-reconfigure locales 
$sudo locale-gen en_US.UTF-8
Generating locales
 en_US.UTF-8... done
Generation complete.
$sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
$export LANG=en_US.UTF-8

然後 build 出現 error:
ERROR: bcm2835-bootfiles-20170530-r60 do_fetch: Fetcher failure for URL: 
'https://codeload.github.com/raspberrypi/firmware/tar.gz/0f315f88ac91f9be93544bfd757f8d55ca4cf099'. Checksum mismatch!
File: '/home/charles-chang/rpi-yocto/build/downloads/0f315f88ac91f9be93544bfd757f8d55ca4cf099' 
has md5 checksum c8bf818d14ee260c6d318a8ab037b1b8 when 2fe42603602158796625989c73e5088b was expected
File: '/home/charles-chang/rpi-yocto/build/downloads/0f315f88ac91f9be93544bfd757f8d55ca4cf099' 
has sha256 checksum bfeb5471762bef90fb8accb135e9cf4bb08c4a7556df42f31987bd4184f52d10 
when 79dcd9f47fbae16e9ec80f96a48e4e04c0ee2076ddbb7f73429510d812a8ef89 was expected
If this change is expected (e.g. you have upgraded to a new version without updating the checksums) then you can use 
these lines within the recipe:
SRC_URI[md5sum] = "c8bf818d14ee260c6d318a8ab037b1b8"
SRC_URI[sha256sum] = "bfeb5471762bef90fb8accb135e9cf4bb08c4a7556df42f31987bd4184f52d10"
Otherwise you should retry the download and/or check with upstream to determine if the file has become corrupted or 
otherwise unexpectedly modified.

ERROR: bcm2835-bootfiles-20170530-r60 do_fetch: Fetcher failure for URL: 
'https://codeload.github.com/raspberrypi/firmware/tar.gz/0f315f88ac91f9be93544bfd757f8d55ca4cf099'. Unable to fetch URL from any source.
ERROR: bcm2835-bootfiles-20170530-r60 do_fetch: Function failed: base_do_fetch
ERROR: Logfile of failure stored in: /home/charles-chang/rpi-yocto/build/tmp/work/raspberrypi2-poky-linux-gnueabi/bcm2835-bootfiles/20170530-r60/temp/log.do_fetch.10803
ERROR: Task (/home/charles-chang/rpi-yocto/meta-raspberrypi/recipes-bsp/bootfiles/bcm2835-bootfiles.bb:do_fetch) failed with exit code '1'
這個是 meta-rpi/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend 裡的:
RPIFW_DATE = "20170530"
SRCREV = "0f315f88ac91f9be93544bfd757f8d55ca4cf099"
SRC_URI[md5sum] = "2fe42603602158796625989c73e5088b"
SRC_URI[sha256sum] = "79dcd9f47fbae16e9ec80f96a48e4e04c0ee2076ddbb7f73429510d812a8ef89"

RPIFW_SRC_URI = "https://codeload.github.com/raspberrypi/firmware/tar.gz/${SRCREV}"
RPIFW_S = "${WORKDIR}/firmware-${SRCREV}"

PR = "r60"

do_unpack() {
    tar -C ${WORKDIR} -xzf ${DL_DIR}/${SRCREV}
}
所以到 github.com/raspberrypi/firmware/,按下release" 會到每次 release 的 tarball 頁面。
裡面沒有20170530..

最接近的是https://github.com/raspberrypi/firmware/archive/1.20170515.tar.gz 他的linkname 也不是直接 ${SRCREV}, 而是 1.${RREPFW_DATE}。
反而比較像 meta-raspberrypi/recipes-bsp/bootfiles/../common/firmware.inc:
RPIFW_DATE ?= "20170405"
RPIFW_SRC_URI ?= "https://github.com/raspberrypi/firmware/archive/1.${RPIFW_DATE}.tar.gz"
RPIFW_S ?= "${WORKDIR}/firmware-1.${RPIFW_DATE}"

SRC_URI = "${RPIFW_SRC_URI}"
SRC_URI[md5sum] = "ea82d14a7cd8cfae9b78e00d4e56bc71"
SRC_URI[sha256sum] = "2f4e5bddbac1372590db203002c35cbba3fb9d6172a93c314ee27bf05ae13bff"

PV = "${RPIFW_DATE}"

是 bbappend,所以刪掉這個bootfile.bbappend,重新build 一次...
faile 在其他地方:
| arm-poky-linux-gnueabi-strip omxplayer.bin
| make: *** [omxplayer.1] Error 52
| ERROR: Function failed: do_compile (log file is located at 
/home/charles-chang/rpi-yocto/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/omxplayer/git-r4/temp/log.do_compile.16373)
ERROR: Task (/home/charles-chang/rpi-yocto/meta-raspberrypi/recipes-multimedia/omxplayer/omxplayer_git.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3371 tasks of which 1026 didn't need to be rerun and 1 failed.
看log,看不出fail 在那裡。
bitbake omxplayer
OK
再 bitbake qt5-basic-image
OK

loopback filesystem, growable loopback device

ref:
就是做出一個loopback filesystem,是用多少,長多少,不用先 dd 一個位子出來。

2017/9/21

bitbake -- print environment variable

ref: https://douglasfranca.tech.blog/2016/12/29/yocto-printing-environments-variables/

在 bitbake 的 conf, layer, bb 等有一堆變數。
要怎麼知道這些變數在 make 得時候,是什麼內容?

用 bitbake -e recipts-name 印出所有build 內容,然後用 grep ^VARNAME= 來取出..

例如,最後 build image 的 command 是 ..
bitbake fsl-image-qt5
我想知道所有的 DISTRO_FEATURES 是?
$ bitbake -e fsl-image-qt5 | grep ^DISTRO_FEATURES=

DISTRO_FEATURES="alsa argp bluetooth ext2 irda largefile pcmcia usbgadget usbhost wifi xattr nfs zeroconf pci 3g nfc 
ipv4 ipv6 libc-backtrace libc-big-macros libc-bsd libc-cxx-tests libc-catgets libc-charsets libc-crypt libc-crypt-ufc 
libc-db-aliases libc-envz libc-fcvt libc-fmtmsg libc-fstab libc-ftraverse libc-getlogin libc-idn libc-inet-anl 
libc-libm libc-locales libc-locale-code libc-memusage libc-nis libc-nsswitch libc-rcmd libc-rtld-debug libc-spawn 
libc-streams libc-sunrpc libc-utmp libc-utmpx libc-wordexp libc-posix-clang-wchar libc-posix-regexp 
libc-posix-regexp-glibc libc-posix-wchar-io largefile opengl ptest multiarch bluez pulseaudio sysvinit bluez5 
gobject-introspection-data"

bitbake another tools - bb

ref:https://github.com/kergoth/bb

git clone 下來後 run
bb/bin/bb init
# Load bb automatically by adding
# the following to ~/.bash_profile:

eval "$(/home/charles-chang/bb/bin/bb init -)"
所以就照著他說...
姊果不能用...