電気回路/zynq/Device Tree Overlay のバックアップソース(No.1)

更新

[[公開メモ]]

* リブートしなくても Device Tree を変更できるらしい [#f4a6ef00]

http://qiita.com/ikwzm/items/ec514e955c16076327ce

さらに、FPGA のロードまで Linux の起動後に行うようにすれば、
Linux のリブートの必要なくロジックの書き換え&利用が可能になります。

PetaLinux で利用可能な Xilinx Linux Kernel 4.6.0 では、
menuconfig からチェックを付けるだけでこの機能が使えるようになります。
[[電気回路/zynq/Petalinux のカスタマイズ#u43d03eb]]

ということで、試してみます。

* 情報 [#vff0dbb9]

dtc に -@ を付けて、unresolved reference を許可できる話など~
https://www.raspberrypi.org/documentation/configuration/device-tree.md

* dtbocfg のビルド [#e7739276]

ビルドにカーネルソースを必要とするので、PetaLinux のクロスコンパイル環境を
使ってビルドしました。

 $ cd ~/z-turn
 $ git clone https://github.com/ikwzm/dtbocfg.git
 $ cd dtbocfg
 $ ls
  Makefile  Readme.md  dtbocfg.c  dtbocfg.rb
 $ cat Makefile
  ARCH            := arm
  KERNEL_SRC_DIR  ?= /lib/modules/$(shell uname -r)/build
  ifeq ($(shell uname -m | sed -e s/arm.*/arm/),arm)
  else
    CROSS_COMPILE  ?= arm-linux-gnueabihf-
  endif
  
  obj-m := dtbocfg.o
  
  all:
          make -C $(KERNEL_SRC_DIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules
  
  clean:
          make -C $(KERNEL_SRC_DIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) clean
 $ petalinux-setup
 $ arm-linux-gnueabihf-gcc --version
  arm-linux-gnueabihf-gcc (Linaro GCC 5.2-2015.11-2) 5.2.1 20151005
  Copyright (C) 2015 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 $ ls ~/z-turn/zturn-v2016.4/kernel-source
  COPYING        Makefile        block     include  modules.builtin  sound
  CREDITS        Module.symvers  certs     init     modules.order    tools
  Documentation  README          crypto    ipc      net              usr
  Kbuild         REPORTING-BUGS  drivers   kernel   samples          virt
  Kconfig        System.map      firmware  lib      scripts          vmlinux
  MAINTAINERS    arch            fs        mm       security         vmlinux.o
 $ make KERNEL_SRC_DIR=~/z-turn/zturn-v2016.4/kernel-source
  make -C /home/osamu/z-turn/zturn-v2016.4/kernel-source ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- M=/home/osamu/z-turn/dtbocfg modules
  make[1]: ディレクトリ '/home/osamu/z-turn/zturn-v2016.4/kernel-source' に入ります
    CC [M]  /home/osamu/z-turn/dtbocfg/dtbocfg.o
    Building modules, stage 2.
    MODPOST 1 modules
    CC      /home/osamu/z-turn/dtbocfg/dtbocfg.mod.o
    LD [M]  /home/osamu/z-turn/dtbocfg/dtbocfg.ko
  make[1]: ディレクトリ '/home/osamu/z-turn/zturn-v2016.4/kernel-source' から出ます
 $ ls
  Makefile        Readme.md  dtbocfg.ko     dtbocfg.mod.o  dtbocfg.rb
  Module.symvers  dtbocfg.c  dtbocfg.mod.c  dtbocfg.o      modules.order
 $ sudo cp dtbocfg.ko 

* 環境 [#od018e4e]

[[電気回路/zynq/Petalinux のカスタマイズ#u43d03eb]] でビルドしたカーネルと、
PetaLinux で作られた標準の .dtb を使って z-turn ボードを起動します。

 LANG:console
 $ uname -a
  Linux xenial-zynq 4.6.0-xilinx #1 SMP PREEMPT Fri Feb 24 07:17:45 JST 2017 armv7l armv7l armv7l GNU/Linux
 $ git clone https://github.com/ikwzm/dtbocfg.git
 $ cd dtbocfg/
 $ ls
  Makefile  Readme.md  dtbocfg.c  dtbocfg.rb
 $

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