Petalinux2018.3によるzynq-7000ブート用SDカード作成 のバックアップソース(No.5)

更新

[[公開メモ]]

* Petalinux 2018.3 を使って zynq-7000 用のブートSDカードを作る [#xf4d6dda]

[[電気回路/zynq/Petalinux2018.3環境を整える]] の続き。

以前、Petalinux 2016.4 でやった [[電気回路/zynq/Petalinux のビルド#aabc4100]] および [[電気回路/zynq/Petalinux のカスタマイズ#p4f8f224]] を新しいバージョンでやり直すことになる。

#contents

ターゲットは z-turn board で、これまで以下のような記事を書いていた。

#ls2(電気回路/z-turn,compact)

Petalinux により標準でサポートされている環境ではない(BSP が提供されていない)ので、
いろいろ調べながらやることになる。

* プロジェクトの作成 [#o40aac7b]

z-turn ボードに対応する BSP は配布されていないので、
zynq の汎用テンプレートを使ってプロジェクトを作る。
(BSP が配布されているシステムであればプロジェクト作成時に BSP を指定する)

プロジェクトルートに .gitignore が作られるので、
それをそのまま使うことで git による管理が基本的には可能となる。

ただし、現時点で petalinux の git 対応は完全ではないため、
プロジェクトを共有するには BSP を使った方が良い、との注意もあった。

 LANG:console
 $ cd
 $ mkdir petalinux
 $ cd petalinux
 $ petalinux-create -t project --template zynq -n zturn_v2018.3
  INFO: Create project: zturn_v2018.3
  INFO: New project successfully created in /home/takeuchi/petalinux/zturn_v2018.3
 $ cd zturn_v2018.3
 $ ls -a
  ./  ../  .gitignore  .petalinux/  config.project  project-spec/
 $ cat .gitignore
  */*/config.old
  */*/rootfs_config.old
  build/
  images/linux/
  pre-built/linux/
  .petalinux/*
  !.petalinux/metadata
  *.o
  *.jou
  *.log
  project-spec/meta-plnx-generated/
  /components/plnx_workspace
 $ git init
  Initialized empty Git repository in /home/takeuchi/petalinux/zturn_v2018.3/.git/
 $ git add .
 $ git config --global user.email "osamu@big.jp"
 $ git config --global user.name "Osamu Takeuchi"
 $ git commit -m "newly created"
  [master (root-commit) 441cd0f] newly created
   22 files changed, 997 insertions(+)

config.project と project-spec/ とがプロジェクトの本体になる。

* vivado のハードウェア設定を取り込みつつ基本の設定 [#o3495afb]

[[vivado のハードウェア設定を出力する>電気回路/zynq/Petalinux のビルド#a82e50cc]] の手順で 
vivado 2018.3 を使って system.hdf を作成して、zturn_v2018.3/hw_platform/system.hdf に置いた。
(.hdf ファイルの実体は hw_platform ディレクトリ内の主要ファイルを .zip 形式でまとめたもの)

 LANG:console
 $ ls hw_platform/
  system.hdf
 $ petalinux-config --get-hw-description=hw_platform
  INFO: Getting hardware description...
  [INFO] generating Kconfig for project
  [INFO] menuconfig project
  (設定画面が現れる → とりあえず何も変更せずに Exit して設定を保存する)
  configuration written to /home/takeuchi/petalinux/zturn_v2018.3/project-spec/configs/config
  
  *** End of the configuration.
  *** Execute 'make' to start the build or try 'make help'.
  
  [INFO] sourcing bitbake
  [INFO] generating plnxtool conf
  [INFO] generating meta-plnx-generated layer
  [INFO] generating machine configuration
  [INFO] generating bbappends for project . This may take time !
  [INFO] generating u-boot configuration files
  [INFO] generating kernel configuration files
  [INFO] generating kconfig for Rootfs
  [INFO] oldconfig rootfs
  [INFO] generating petalinux-user-image.bb
 $ git diff
 $

とりあえず何も変更せずに Exit したところ、
git 先生は何も変っていないとおっしゃる・・・ほんとに?

 LANG:console
 $ ls
  build/  components/  config.project  hw_platform/  project-spec/
 $ ls build/
  bitbake-cookerdaemon.log  cache/  conf/  config.log  misc/  sstate-cache/  tmp/

./build に config.log やら conf/ やらできてますが無視するわけ???

.gitignore はもう少しちゃんと見直すべきっぽい。

** 罫線の表示がおかしい [#t90ff50a]

設定画面が現れたのだけれど・・・そのままだと罫線部分が文字化けする。

&ref(petalinux-config1.png,,50%);

https://islandcnt.exblog.jp/16849117/ の "-YaSTのライン化け-" にあるように、
PuTTY の設定で Charactor set を use font encording にすればいいらしい。

&ref(petalinux-config2.png,,50%);

ただこれだと LANG=ja_JP.UTF-8 での日本語表示がおかしくなる。

http://totech.hateblo.jp/entry/2014/09/22/071012 にあるように 
ja_JP.sjis ロケールを追加して、

 LANG:console
 $ sudo localedef -f SHIFT_JIS -i ja_JP ja_JP.SJIS
  character map `SHIFT_JIS' is not ASCII compatible, locale not ISO C compliant
 $ export LANG=ja_JP.sjis
  takeuchi@petalinux2019-3:~/petalinux/zturn_v2018.3$ ls -l
  合計 28
  drwxrwxr-x 7 takeuchi takeuchi 4096  3月 15 20:38 build
  drwxrwxr-x 3 takeuchi takeuchi 4096  3月 15 20:31 components
  -rw-r--r-- 1 takeuchi takeuchi  248  3月 15 20:14 config.project
  drwxrwxr-x 2 takeuchi takeuchi 4096  3月 15 20:30 hw_platform
  drwxr-xr-x 6 takeuchi takeuchi 4096  3月 15 20:36 project-spec

のようにすれば文字化けはなくなるのだけれど・・・今時 Linux ターミナルで
SJIS 使うのはどうなのかと。

LANG=C で進めるか、その都度 PuTTY の設定を変える方がよいのかもしれない。

* ロケール問題再び? [#rfb10738]

ああそうか、そもそも [[電気回路/zynq/Petalinux のビルド#y0c5addb]] で痛い目に遭ったように、
Petalinux 自体が LANG=C 以外だとおかしな事になるんだった。

この問題は今も続いているようで、

 LANG:console
 $ export LANG=ja_JP.sjis
 $ petalinux-build -c kernel
  [INFO] building kernel
  [INFO] sourcing bitbake
  INFO: bitbake virtual/kernel
  Please use a locale setting which supports UTF-8 (such as LANG=en_US.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.
  ERROR: Failed to build kernel

のように、自ら検出してエラーを出してくれるようになっていた。

あれ?エラーメッセージを読むと UTF-8 なら問題ないと書いてある???

というかむしろ、

 LANG:console
 $ export LANG=C
 $ petalinux-build -c kernel
  [INFO] building kernel
  [INFO] sourcing bitbake
  INFO: bitbake virtual/kernel
  Please use a locale setting which supports UTF-8 (such as LANG=en_US.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.
  ERROR: Failed to build kernel

LANG=C だと UTF-8 が処理できないのでダメらしい。

* 暗号化ファイルシステムの問題 [#haea0979]

ということは、LANG=ja_JP.UTF-8 なら問題ない?

 LANG:console
 $ export LANG=ja_JP.UTF-8
 $ petalinux-build -c kernel
  [INFO] building kernel
  [INFO] sourcing bitbake
  INFO: bitbake virtual/kernel
  ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
      Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
      Following is the list of potential problems / advisories:
  
      Failed to create a file with a long name in TMPDIR. Please use a filesystem that does not unreasonably limit filename length.
  Failed to create a file with a long name in SSTATE_DIR. Please use a filesystem that does not unreasonably limit filename length.
 
  Summary: There was 1 ERROR message shown, returning a non-zero exit code.
 ERROR: Failed to build kernel

今度は長いファイル名を使えないのがダメと言われた。

うわーこれきついや。

仕方がないので [[ホームディレクトリ暗号化の解除>電気回路/zynq/Petalinux2018.3環境を整える#e1dacfc9]]
の手順で暗号化を解除した。

すると、

 LANG:console
 $ source /opt/petalinux_2018.3/settings.sh
 $ petalinux-build -c kernel
  [INFO] building kernel
  [INFO] sourcing bitbake
  INFO: bitbake virtual/kernel
  Parsing recipes:   5%

のようにビルドが進むようになった。



* エラー出た [#x53811ae]
 LANG:console
 $ petalinux-build -c kernel
  [INFO] building kernel
  [INFO] sourcing bitbake
  INFO: bitbake virtual/kernel
  Loading cache: 100% |############################################| Time: 0:00:03
  Loaded 3444 entries from dependency cache.
  Parsing recipes: 100% |##########################################| Time: 0:00:31
  Parsing of 2569 .bb files complete (2532 cached, 37 parsed). 3445 targets, 149 skipped, 0 masked, 0 errors.
  NOTE: Resolving any missing task queue dependencies
  Initialising tasks: 100% |#######################################| Time: 0:00:21
  Checking sstate mirror object availability: 100% |###############| Time: 0:00:46
  NOTE: Executing SetScene Tasks
  NOTE: Executing RunQueue Tasks
  WARNING: petalinux-user-image-1.0-r0 do_rootfs: [log_check] petalinux-user-image: found 1 warning message in the logfile:
  [log_check] warning: %post(sysvinit-inittab-2.88dsf-r10.plnx_zynq7) scriptlet failed, exit status 1
  
  ERROR: fsbl-2018.3+gitAUTOINC+56f3da2afb-r0 do_configure: Function failed: do_configure (log file is located at /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/temp/log.do_configure.5645)
  ERROR: Logfile of failure stored in: /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/temp/log.do_configure.5645
  Log data follows:
  | DEBUG: Executing shell function do_configure
  | MISC_ARG is  -yamlconf /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/fsbl.yaml
  | APP_ARG is  -app "Zynq FSBL"
  | Using xsct from: /opt/petalinux_2018.3/tools/xsct/SDK/2018.3/bin/xsct
  | cmd is: xsct -sdx -nodisp /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/app.tcl -ws /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/build -pname fsbl -rp /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/git -processor ps7_cortexa9_0 -hdf /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/deploy/images/plnx-zynq7/Xilinx-plnx-zynq7.hdf -arch 32  -app "Zynq FSBL"  -yamlconf /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/fsbl.yaml
  | INFO: [Hsi 55-1698] elapsed time for repository loading 0 seconds
  | Opening the hardware design, this may take few seconds.
  | ERROR: [Hsi 55-1606] Unable to find ps7 init files in the directory /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/build/fsbl_plat/_platform/dsa.
  | INFO: create bsp using fsbl_domain
  | Creating app at: /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/build
  | ERROR: [Hsi 55-1606] Unable to find ps7 init files in the directory /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/build/fsbl_plat/_platform/dsa.
  | ERROR: [Hsi 55-1438] Error running generate_app.
  | ERROR: [Common 17-39] 'hsi::generate_app' failed due to earlier errors.
  |
  |     while executing
  | "::hsi::generate_app -app $hsitemplate"
  |     (procedure "app" line 323)
  |     invoked from within
  | "app create -name $params(pname) -lang c -template $params(app) -plnx"
  |     invoked from within
  | "if { $params(ws) ne "" } {
  |       #Local Work Space available
  |       if { $params(pname) ne "" } {
  |               # hwpname/bspname is empty then default it to pname+_hwproj/b..."
  |     (file "/home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/app.tcl" line 139)
  | WARNING: exit code 1 from a shell command.
  | ERROR: Function failed: do_configure (log file is located at /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/temp/log.do_configure.5645)
  ERROR: Task (/opt/petalinux_2018.3/components/yocto/source/arm/layers/meta-xilinx-tools/recipes-bsp/fsbl/fsbl_git.bb:do_configure) failed with exit code '1'
  NOTE: Tasks Summary: Attempted 2330 tasks of which 2115 didn't need to be rerun and 1 failed.
  
  Summary: 1 task failed:
    /opt/petalinux_2018.3/components/yocto/source/arm/layers/meta-xilinx-tools/recipes-bsp/fsbl/fsbl_git.bb:do_configure
  Summary: There was 1 WARNING message shown.
  Summary: There was 1 ERROR message shown, returning a non-zero exit code.
  ERROR: Failed to build kernel
 $ grep sysvinit-inittab-2.88dsf-r10.plnx_zynq7 build/tmp/log/cooker/plnx-zynq7/*.log
  build/tmp/log/cooker/plnx-zynq7/20190318111654.log:[log_check] warning: %post(sysvinit-inittab-2.88dsf-r10.plnx_zynq7) scriptlet failed, exit status 1
  build/tmp/log/cooker/plnx-zynq7/console-latest.log:[log_check] warning: %post(sysvinit-inittab-2.88dsf-r10.plnx_zynq7) scriptlet failed, exit status 1
 $ grep -3 WARNING build/tmp/log/cooker/plnx-zynq7/console-latest.log
  NOTE: recipe udev-extraconf-1.1-r0: task do_package_write_rpm: Succeeded
  NOTE: Running task 2302 of 2350 (/home/takeuchi/petalinux/zturn_v2018.3/project-spec/meta-plnx-generated/recipes-core/images/petalinux-user-image.bb:do_rootfs)
  NOTE: recipe petalinux-user-image-1.0-r0: task do_rootfs: Started
  WARNING: petalinux-user-image-1.0-r0 do_rootfs: [log_check] petalinux-user-image: found 1 warning message in the logfile:
  [log_check] warning: %post(sysvinit-inittab-2.88dsf-r10.plnx_zynq7) scriptlet failed, exit status 1
  
  NOTE: recipe petalinux-user-image-1.0-r0: task do_rootfs: Succeeded
 $ less build/tmp/buildstats/20190318111736/petalinux-user-image-1.0-r0/do_rootfs
  Event: TaskStarted
  Started: 1552909796.05
  petalinux-user-image-1.0-r0: do_rootfs
  Elapsed time: 109.67 seconds
  utime: 263
  stime: 63
  cutime: 5102
  cstime: 4180
  IO write_bytes: 43159552
  IO read_bytes: 205795328
  IO cancelled_write_bytes: 14962688
  IO wchar: 64986714
  IO rchar: 477055882
  IO syscr: 285327
  IO syscw: 194109
  rusage ru_utime: 2.6360000000000001
  rusage ru_stime: 0.63600000000000001
  rusage ru_maxrss: 117760
  rusage ru_minflt: 42270
  rusage ru_majflt: 0
  rusage ru_inblock: 1320
  rusage ru_oublock: 1896
  rusage ru_nvcsw: 746
  rusage ru_nivcsw: 32773
  Child rusage ru_utime: 51.020000000000003
  Child rusage ru_stime: 41.808
  Child rusage ru_maxrss: 115216
  Child rusage ru_minflt: 1252772
  Child rusage ru_majflt: 207
  Child rusage ru_inblock: 400624
  Child rusage ru_oublock: 82400
  Child rusage ru_nvcsw: 55524
  Child rusage ru_nivcsw: 149096
  Status: PASSED
  Ended: 1552909905.73
 $ grep sysvinit-inittab build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/petalinux-user-image/1.0-r0/temp/log.do_rootfs
   sysvinit-inittab                plnx_zynq7      2.88dsf-r10      oe-repo 7.5 k
   sysvinit-inittab-lic            plnx_zynq7      2.88dsf-r10      oe-repo  12 k
    Installing       : sysvinit-inittab-2.88dsf-r10.plnx_zynq7             69/122
    Running scriptlet: sysvinit-inittab-2.88dsf-r10.plnx_zynq7             69/122
  warning: %post(sysvinit-inittab-2.88dsf-r10.plnx_zynq7) scriptlet failed, exit status 1
    Installing       : sysvinit-inittab-lic-2.88dsf-r10.plnx_zynq7        117/122
    Verifying        : sysvinit-inittab-2.88dsf-r10.plnx_zynq7             79/122
    Verifying        : sysvinit-inittab-lic-2.88dsf-r10.plnx_zynq7         94/122
    sysvinit-inittab-lic.plnx_zynq7 2.88dsf-r10
    sysvinit-inittab.plnx_zynq7 2.88dsf-r10
  Non-fatal POSTIN scriptlet failure in rpm package sysvinit-inittab
  Non-fatal POSTIN scriptlet failure in rpm package sysvinit-inittab
  NOTE: Saving postinstall script of sysvinit-inittab
  NOTE: Delayed package scriptlet: 100-sysvinit-inittab
  [log_check] warning: %post(sysvinit-inittab-2.88dsf-r10.plnx_zynq7) scriptlet failed, exit status 1
 $ ls /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/temp/run.do_configure
  /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/temp/run.do_configure
 $ ls /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/build/fsbl_plat/_platform/dsa
  Xilinx-plnx-zynq7.dsa  Xilinx-plnx-zynq7.hdf

うーん、do_rootfs の warning は Non-fatal と言っているし、とりあえず無視してよさそう?

do_configure の ERROR: [Hsi 55-1606] Unable to find ps7 init files in the directory /home/takeuchi/petalinux/zturn_v2018.3/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/fsbl/2018.3+gitAUTOINC+56f3da2afb-r0/build/fsbl_plat/_platform/dsa. が build が止った原因っぽいけれど、"Unable to find ps7 init files" で Google ってもそれらしい記事はなく、何が足りないと言っているのかよく分からない。

* 設定 [#ne1acba3]

Counter: 12742 (from 2010/06/03), today: 1, yesterday: 0