說明文件

MA35D1 Update Device Tree and Check change data

MA35D1 Update Device Tree and Check change data

Update Device Tree 設定

compile 後 ,直接更換 SD 卡上的 Device Tree,不用整個SD 重新燒錄

$ bitbake linux-ma35d1 -C compile

下面是腳本,隨便放在家目錄都可以

PKGPATH=’/home/nuvoton/yocto/build/tmp-glibc/deploy/images/numaker-som-ma35d16a81/Image.dtb'

要放到對的位置

#!/bin/bash
# 宣告使用 bash shell 執行此腳本

# 檢查第一個參數($1)是否為空
if [ -z "$1" ]

then
    echo "Please input the sdcard node ex:/dev/sdx"
    # 如果參數為空,提示用戶輸入SD卡的設備路徑(例如:/dev/sdx)
    exit
    # 退出腳本
fi

# 設定設備樹二進制文件(DTB)的路徑
#PKGPATH='/home/cwhuang/MA35D1_MP_Project/build/tmp-glibc/deploy/images/numaker-som-ma35d16a81/Image.dtb'
#PKGPATH='/home/cwhuang/SSD1/yocto/NuMaker-SOM-MA35D1/build/tmp-glibc/deploy/images/numaker-som-ma35d16a81/Image.dtb'
PKGPATH='/home/nuvoton/yocto/build/tmp-glibc/deploy/images/numaker-som-ma35d16a81/Image.dtb'

# 將腳本的第一個參數(SD卡的設備路徑)賦值給 SDCARDPATH 變數
SDCARDPATH=$1

# 打印出設備樹二進制文件的路徑
echo "sdcard Package is ${PKGPATH}"

# 打印出SD卡的設備路徑
echo "sdcard node is ${SDCARDPATH}"

# 檢查設備樹二進制文件是否存在
if [ -f "${PKGPATH}" ]

then
  echo "Start downloading..."
  # 如果文件存在,則打印“開始下載...”
else
  echo "Can't find the Kernel dtb."
  # 如果文件不存在,則打印無法找到內核DTB的消息
  exit
  # 並退出腳本
fi

# 使用 dd 命令將設備樹二進制文件寫入SD卡。這裡指定了塊大小和在輸出文件中跳過的塊數量
#Refer to build/tmp-glibc/deploy/images/ma35d1-evb/nuwriter/pack-sdcard.json Image.dtb= 1024*2816 = 0x2C0000*
sudo dd if=${PKGPATH} bs=1024 seek=2816 of=${SDCARDPATH}

# 檢查 dd 命令的退出狀態
if [ "$?" -eq "0" ]

then  
   echo "Download Success."
   # 如果退出狀態為 0(表示成功),則打印"下載成功"
else
   echo "Download Failure."
   # 否則,打印"下載失敗"
   exit
   # 並退出腳本
fi

# 執行 sync 命令以確保所有數據都已經寫入SD卡
sync

執行方法如下

注意是 /dev/sdb

nuvoton@ubuntu:~$ ./update_device_tree.sh /dev/sdb
sdcard Package is /home/nuvoton/yocto/build/tmp-glibc/deploy/images/numaker-som-ma35d16a81/Image.dtb
sdcard node is /dev/sdb
Start downloading...
[sudo] password for nuvoton: 
41+1 records in
41+1 records out
42006 bytes (42 kB, 41 KiB) copied, 0.0185719 s, 2.3 MB/s
Download Success.

Update Device Tree 設定後 在MA35D1 上去檢查

以 display 這個節點為例,如下所示:

 device tree

Hexdump 或 cat 觀察數值 :

buffer-num 為例,上面device tree是 <3> ,我們 hexdump 出來 是 03 (16進位),轉成10進位就是 3 。

bits-per-pixel 為例,上面device tree是 <32> ,我們 hexdump 出來 是 20 (16進位),轉成10進位就是 32。

reset_offset_en 為例,上面device tree是 ,我們 cat 出來 就是 no

 device tree

這裡可以觀察到,最右邊的位是低位元,最左邊會是高位元。

root@numaker-som-ma35d16a81:/proc/device-tree/display@40260000# hexdump -C bits-per-pixel

root@numaker-som-ma35d16a81:/proc/device-tree/display@40260000# cat reset_offset_en

用 dtc 去 讀取 ma35d1-som-256m–5.10.140-r0-numaker-som-ma35d16a81-20231115075231.dtb

nuvoton@ubuntu:~$ sudo apt search dtc
Sorting... Done
Full Text Search... Done
ddtc/focal,focal 0.17.2 all
  Deal with ddts mails

device-tree-compiler/focal 1.5.1-1 amd64
  Device Tree Compiler for Flat Device Trees

python-dtcwt-doc/focal,focal 0.12.0-2 all
  documentation for dtcwt

python3-dtcwt/focal,focal 0.12.0-2 all
  Dual-Tree Complex Wavelet Transform library for Python 3

r-cran-waveslim/focal 1.7.5.2-1 amd64
  GNU R wavelet routines for 1-, 2- and 3-D signal processing

sbox-dtc/focal 1.11.7-1build1 amd64
  CGI chroot wrapper script for safer hosting environment

ubuntu-developer-tools-center/focal,focal 18.09+disco1 all
  transitional dummy package

nuvoton@ubuntu:~$ sudo apt-get install device-tree-compiler
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libfdt1
The following NEW packages will be installed:
  device-tree-compiler libfdt1
0 upgraded, 2 newly installed, 0 to remove and 204 not upgraded.
Need to get 265 kB of archives.
After this operation, 559 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 libfdt1 amd64 1.5.1-1 [18.8 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal/main amd64 device-tree-compiler amd64 1.5.1-1 [247 kB]
Fetched 265 kB in 2s (112 kB/s)                
Selecting previously unselected package libfdt1:amd64.
(Reading database ... 203335 files and directories currently installed.)
Preparing to unpack .../libfdt1_1.5.1-1_amd64.deb ...
Unpacking libfdt1:amd64 (1.5.1-1) ...
Selecting previously unselected package device-tree-compiler.
Preparing to unpack .../device-tree-compiler_1.5.1-1_amd64.deb ...
Unpacking device-tree-compiler (1.5.1-1) ...
Setting up libfdt1:amd64 (1.5.1-1) ...
Setting up device-tree-compiler (1.5.1-1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.7) ...

nuvoton@ubuntu:~$ dtc /home/nuvoton/yocto/build/tmp-glibc/deploy/images/numaker-som-ma35d16a81/ma35d1-som-256m--5.10.140-r0-numaker-som-ma35d16a81-20231115075231.dtb
<stdout>: Warning (unit_address_vs_reg): /i2c-gpio-0: node has a reg or ranges property, but no unit name
<stdout>: Warning (unit_address_vs_reg): /i2c-gpio-1: node has a reg or ranges property, but no unit name
<stdout>: Warning (unique_unit_address): /reserved-memory/rproc_buf@0: duplicate unit-address (also used in node /reserved-memory/display_buf@0)
<stdout>: Warning (unique_unit_address): /reserved-memory/rproc_buf@0: duplicate unit-address (also used in node /reserved-memory/vc8k_buf@0)
<stdout>: Warning (unique_unit_address): /reserved-memory/display_buf@0: duplicate unit-address (also used in node /reserved-memory/vc8k_buf@0)
<stdout>: Warning (unique_unit_address): /reserved-memory/rproc_buf@0: duplicate unit-address (also used in node /reserved-memory/gc520l_buf@0)
<stdout>: Warning (unique_unit_address): /reserved-memory/display_buf@0: duplicate unit-address (also used in node /reserved-memory/gc520l_buf@0)
<stdout>: Warning (unique_unit_address): /reserved-memory/vc8k_buf@0: duplicate unit-address (also used in node /reserved-memory/gc520l_buf@0)
/dts-v1/;

/ {
	compatible = "nuvoton,ma35d1";
	interrupt-parent = <0x01>;
	#address-cells = <0x02>;
	#size-cells = <0x02>;
	model = "Nuvoton MA35D1-SOM";

	aliases {
		ethernet0 = "/ethernet@40120000";
		ethernet1 = "/ethernet@40130000";
	};

	cpus {
		#address-cells = <0x02>;
		#size-cells = <0x00>;

		cpu@0 {
			device_type = "cpu";
			compatible = "arm,cortex-a35";
			reg = <0x00 0x00>;
			enable-method = "psci";
			next-level-cache = <0x02>;
		};

		cpu@1 {
			device_type = "cpu";
			compatible = "arm,cortex-a35";
			reg = <0x00 0x01>;
			enable-method = "psci";
			next-level-cache = <0x02>;
		};

		l2-cache0 {
			compatible = "cache";
			cache-level = <0x02>;
			phandle = <0x02>;
		};
	};

	psci {
		compatible = "arm,psci-0.2";
		method = "smc";
	};

	clock-controller@40460200 {
		compatible = "nuvoton,ma35d1-clk\0syscon\0simple-mfd";


        ...
        
comments powered by Disqus