RPI2 Ready To Go !?

樹莓派 2 B 已經發行一個月了,在《春雷早發︰樹莓派 2 Model B ︰早鳥篇》裡談到的 GPIO 問題大體都解決了。  kernel 也已經更新至︰

pi@raspberrypi ~ $ cat /proc/version 
Linux version 3.18.7-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015

現下最大的麻煩大概是

Pi 2 is much more picky than B+ when it comes to memory cards and throws mmcblk0 errors randomly when rebooting #372

就作者測試所知,這個問題也許出在『 kernel 』﹐因為同一片 SD card 如果用 Debian 8 少有問題,然而在 raspbian 上卻會發生

RPI2 Boot issues

。假使你有幸碰到,最簡單的解決方案就是

嘗試多開幾次機!!或者在『 /boot/config.txt 』上加上一行

kernel=kernel7.img

直接告訴 start.elf 使用 arm v7 的 kernel ,據聞這可以增加開機成功率!?或許再更新 raspberrypi/firmware

pi@raspberrypi ~ $ sudo rpi-update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8107  100  8107    0     0  14692      0 --:--:-- --:--:-- --:--:-- 26067
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Backing up firmware
 *** Backing up modules 3.18.7-v7+
 *** Downloading specific firmware revision (this will take a few minutes)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168    0   168    0     0    144      0 --:--:--  0:00:01 --:--:--   197
100 43.4M  100 43.4M    0     0   451k      0  0:01:38  0:01:38 --:--:--  467k
 *** Updating firmware
 *** Updating kernel modules
 *** depmod 3.18.8-v7+
 *** depmod 3.18.8+
 *** Updating VideoCore libraries
 *** Using HardFP libraries
 *** Updating SDK
 *** Running ldconfig
 *** Storing current firmware revision
 *** Deleting downloaded files
 *** Syncing changes to disk
 *** If no errors appeared, your firmware was successfully updated to 6f1db5b734a8cf5217cafd983b1ff9c84c1c5013
 *** A reboot is needed to activate the new firmware

pi@raspberrypi ~ $ sudo reboot

Broadcast message from root@raspberrypi (pts/0) (Wed Mar  4 17:07:55 2015):
The system is going down for reboot NOW!

pi@raspberrypi ~ $ cat /proc/version 
Linux version 3.18.8-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #764 SMP PREEMPT Tue Mar 3 15:22:38 GMT 2015

彷彿不管用??

是否勇敢進入『 RPI BCM2708 Parameters 』調適的世界︰

# 嘗試批配 SD 卡宣稱之 high speed mode emmc_clock_freq 

pi@raspberrypi ~ $ cat /proc/cmdline 
dma.dmachans=0x7f35 bcm2708_fb.fbwidth=640 bcm2708_fb.fbheight=480 bcm2709.boardrev=0xa01041 bcm2709.serial=0xfc60130d smsc95xx.macaddr=B8:27:EB:60:13:0D bcm2708_fb.fbswap=1 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  sdhci-bcm2708.emmc_clock_freq=480000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 cgroup_enable=memory elevator=deadline rootwait splash quiet plymouth.ignore-serial-consoles

 

說不定會有意料之外的驚奇!!

 

 

 

 

大樹底下好乘涼 ︰ 《拜樹頭》 ? ※成而不居

百花齊放

百花齊放

百家爭鳴

百家爭鳴

鏡花緣‧第三回》徐英公傳檄起義兵 駱主簿修書寄良友

百花仙子笑道:「小仙今拜南極仙翁為師,若論高手,大約除了敝老師就要輪到小仙,豈可與從前一例看待。--就下十盤我也不懼!且命貴仙女暖酒安枰,我兩人好一飲一著,分個高下。」麻姑道:「仙姑休得誇強,到了終局,你才知利害,那才後悔不該同我對局哩!」百花仙子道:「仙姑今日如果得勝,小仙聞得下界高手甚多,我去凡間訪求明師,就便將弈秋請來,看你可怕?」麻姑道:「那弈秋老先生,連孟夫子都佩服的,我如何不怕!但仙姑『下凡訪師』這句話,未免動了紅塵之念,將來只怕下界有人聘你去做棋中高手哩。」

一面說笑,隨命仙女擺設酒肴,安排棋局,登時各逞心思,對著起來。百花仙子只顧在此著棋,那知下界帝王忽有御旨命他百花齊放

在一篇名為《 Device trees everywhere 》的文章裡,談及了二零零五年五月時,  IBM 的 Benjamin Herrenschmidt 建置了一套新的『設備樹』之 linux kernel 啟動機制,即使一個沒有『 OF 』 Open Firmware 的系統,也可以使用『設備樹』得到好處。此事記載於 Linux 《 booting-without-of.txt 》 文件之中,那時 ── May 18, 2005: Rev 0.1 – Initial draft, no chapter III yet. ── ,到了

November 21, 2005: Rev 0.5

– Additions/generalizations for 32-bit
– Changed to reflect the new arch/powerpc structure
– Added chapter VI

此刻的差異實在說並不大。『術語』與『架構』延襲至今,正是深入理解『 /proc/device-tree 』、『 The DT block format 』、『 Required content of the device tree 』以及一些『建議』的基礎『文本』。俗話講︰『十年磨一劍』,正此之謂耶??

雖說『設備樹』是種系統連接『硬體裝置』的簡易『描述語言』 ,但要三言兩語講清楚它與『第一啟動』 BIOS 韌體或是『 Boot Loader 』與『 kernel os 』之裝置『驅動程式』間的關係,其實很不容易。因此這裡也只能借花獻佛,請讀者自讀《 Device Tree for DUMMIES 》的了。

□︰ phandle 是什麼阿?
○︰ p + Handle 的吧!
□︰能說文解字嗎?
○︰ Handle 把柄, p (ointer) 乃指標是也!
□︰有些八卦呢??
○︰音譯成『ㄈㄟㄢ ㄉㄡ』才八卦哩!!

vray-bsp-tree-acceleration-structure

象棋‧仙人指路

既然『設備樹』 與『檔案樹』都是『樹狀結構』,系統開機後用『 /proc/device-tree 』來表現啟始 dtb 之結果,正是一一對應︰

設備根節點 Device Root  \Longleftrightarrow /proc/device-tree 目錄

設備節點 Device Node  \Longleftrightarrow 子目錄

設備屬性 Device Property  \Longleftrightarrow 檔案

# 設備樹鏈結至 /sys/firmware/devicetree/base
ls -la /proc/device-tree
lrwxrwxrwx 1 root root 29  3月  2 15:56 /proc/device-tree -> /sys/firmware/devicetree/base

# 與 fdt 同構
cd /proc/device-tree
ls -l

總計 0
-r--r--r--  1 root root  4  3月  2 15:55 #address-cells
drwxr-xr-x  2 root root  0  3月  2 15:55 aliases
drwxr-xr-x  7 root root  0  3月  2 15:55 axi
drwxr-xr-x  2 root root  0  3月  2 15:55 chosen
drwxr-xr-x  4 root root  0  3月  2 15:55 clocks
-r--r--r--  1 root root 13  3月  2 15:55 compatible
drwxr-xr-x  6 root root  0  3月  2 15:55 cpus
drwxr-xr-x  2 root root  0  3月  2 15:55 display
-r--r--r--  1 root root  4  3月  2 15:55 interrupt-parent
drwxr-xr-x  2 root root  0  3月  2 15:55 memory
-r--r--r--  1 root root  8  3月  2 15:55 memreserve
-r--r--r--  1 root root 23  3月  2 15:55 model
-r--r--r--  1 root root  1  3月  2 15:55 name
drwxr-xr-x  2 root root  0  3月  2 15:55 __overrides__
-r--r--r--  1 root root  4  3月  2 15:55 #size-cells
drwxr-xr-x 10 root root  0  3月  2 15:55 soc
drwxr-xr-x  2 root root  0  3月  2 15:55 sound
drwxr-xr-x  2 root root  0  3月  2 15:55 __symbols__
drwxr-xr-x  2 root root  0  3月  2 15:55 system
drwxr-xr-x  2 root root  0  3月  2 15:55 timer

這雖然說是了解 Linux FDT 建制很好的辦法, 然而

# 不是 ASCII 碼
cat \#address-cells 
□

# 不符數據內容
hexdump \#address-cells 
0000000 0000 0100                              
0000004

# 字串 OK
cat compatible 
brcm,bcm2709

,所以也不是容易的事。要是

# 產生當下 /proc/device-tree
dtc -I fs -O dtb -o runtime.dtb /proc/device-tree
Warning (avoid_default_addr_size): Relying on default #address-cells value for /axi/vc_mem
Warning (avoid_default_addr_size): Relying on default #size-cells value for /axi/vc_mem

# 總覽
fdtdump runtime.dtb
/dts-v1/;
// magic:		0xd00dfeed
// totalsize:		0x1ce3 (7395)
// off_dt_struct:	0x38
// off_dt_strings:	0x1948
// off_mem_rsvmap:	0x28
// version:		17
// last_comp_version:	16
// boot_cpuid_phys:	0xf00
// size_dt_strings:	0x39b
// size_dt_struct:	0x1910

/ {
    model = "Raspberry Pi 2 Model B";
    compatible = "brcm,bcm2709";
    memreserve = <0x3b000000 0x0000001c>;
    #address-cells = <0x00000001>;
    #size-cells = <0x00000001>;
    interrupt-parent = <0x00000001>;
    axi {
...

# 閱讀
fdtget runtime.dtb -l /
axi
soc
cpus
display
sound
timer
chosen
clocks
memory
system
__symbols__
aliases
__overrides__

fdtget runtime.dtb -p /
model
compatible
memreserve
#address-cells
#size-cells
interrupt-parent

fdtget runtime.dtb / \#address-cells
1

 

 

─── 也許在這逐鹿中原之時,快就是好!! ───

 

 

 

大樹底下好乘涼 ︰ 《拜樹頭》 ? ※ 碩果不食

碩果不食

□︰今已有兩極四方,恐入八卦矣!

○︰所為何事?

□︰圍城而不攻?是何故耶??

○︰是所謂碩果不食。能上不能下?窮之災!囧之禍乎??

○︰《易》有剝極來復之道!!

與時並進者遭遇『困難』,面對『未知』是再自然不過的事。如之何『求解』正砥礪著學者的『百折不撓』之精神。『九天九地』的探尋,難到不會有『一陽來復』之時?深體自由軟體者之心??

假使仔細閱讀《 Device Tree on ARCH_BCM2708 》,留心一下『那個人』── notro ── 與『那個時間』── on Jul 30, 2014 ──,也許我們不只對樹莓派『裝置樹』有更多的了解,更能明白許多的貢獻其來有自,正所謂『德不孤,必有鄰』乎!!

此處將僅簡單說說幾個工具程式,以及簡介它們的用法。

常用縮寫︰

DT 】︰  Device Tree
FDT 】︰ Flattended Device Tree: a DT representation used in the dtb blob.
.dtb 】︰ Device Tree Binary
.dts 】︰ Device Tree Source
.dtsi 】︰ Device Tree Source Include
dtc 】︰ Device Tree Compiler

 

# dtc 的用法說明

pi@raspberrypi ~ dtc -h Usage: dtc [options] <input file>  Options: -[qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv@]   -q, --quiet                 	Quiet: -q suppress warnings, -qq errors, -qqq all   -I, --in-format <arg>       	Input formats are: 		dts - device tree source text 		dtb - device tree blob 		fs  - /proc/device-tree style directory   -o, --out <arg>             	Output file   -O, --out-format <arg>      	Output formats are: 		dts - device tree source text 		dtb - device tree blob 		asm - assembler source   -V, --out-version <arg>     	Blob version to produce, defaults to %d (for dtb and asm output)   -d, --out-dependency <arg>  	Output dependency file   -R, --reserve <arg>         	tMake space for <number> reserve map entries (for dtb and asm output)   -S, --space <arg>           	Make the blob at least <bytes> long (extra space)   -p, --pad <arg>             	Add padding to the blob of <bytes> long (extra space)   -b, --boot-cpu <arg>        	Set the physical boot cpu   -f, --force                 	Try to produce output even if the input tree has errors   -i, --include <arg>         	Add a path to search for include files   -s, --sort                  	Sort nodes and properties before outputting (useful for comparing trees)   -H, --phandle <arg>         	Valid phandle formats are: 		legacy - "linux,phandle" properties only 		epapr  - "phandle" properties only 		both   - Both "linux,phandle" and "phandle" properties   -W, --warning <arg>         	Enable/disable warnings (prefix with "no-")   -E, --error <arg>           	Enable/disable errors (prefix with "no-")   -@, --symbols <arg>         	Symbols and Fixups support   -h, --help                  	Print this help and exit   -v, --version               	Print version and exit  # 範例︰解碼當下使用裝置樹 dtc -I fs -O dts -o runtime.dts /proc/device-tree    # fdtdump 的用法說明 pi@raspberrypi ~ fdtdump -h
Usage: fdtdump [options] 

Options: -[dshV]
  -d, --debug   Dump debug information while decoding the file
  -s, --scan    Scan for an embedded fdt in file
  -h, --help    Print this help and exit
  -V, --version Print version and exit

# 範例︰顯示 dtb 內容
fdtdump /boot/overlays/lirc-rpi-overlay.dtb



# fdtget 的用法說明
pi@raspberrypi ~ fdtget -h Usage: read values from device tree 	fdtget   [ ]... 	fdtget -p   [ ]...  Each value is printed on a new line. 	s=string, i=int, u=unsigned, x=hex 	Optional modifier prefix: 		hh or b=byte, h=2 byte, l=4 byte (default)  Options: -[t:pld:hV]   -t, --type     Type of data   -p, --properties    List properties for each node   -l, --list          List subnodes for each node   -d, --default  Default value to display when the property is missing   -h, --help          Print this help and exit   -V, --version       Print version and exit  # 範例︰讀取預設 bcm2709-rpi-2-b.dtb 的 spi 狀態︰ fdtget /boot/bcm2709-rpi-2-b.dtb /soc/spi@7e204000 status  disabled  # 如果 config.txt 有 dtparam=spi=on ,假使檢查 runtime dtc -I fs -O dtb -o runtime.dtb /proc/device-tree fdtget runtime.dtb /soc/spi@7e204000 status  okay    # fdtput 的用法說明 pi@raspberrypi ~ fdtput -h
Usage: write a property value to a device tree
	fdtput 
   [...]
	fdtput -c 
 [...]

The command line arguments are joined together into a single value.
	s=string, i=int, u=unsigned, x=hex
	Optional modifier prefix:
		hh or b=byte, h=2 byte, l=4 byte (default)

Options: -[cpt:vhV]
  -c, --create     Create nodes if they don't already exist
  -p, --auto-path  Automatically create nodes as needed for the node path
  -t, --type  Type of data
  -v, --verbose    Display each value decoded from command line
  -h, --help       Print this help and exit
  -V, --version    Print version and exit

# 範例︰
cp /boot/bcm2709-rpi-2-b.dtb .
fdtput --type s bcm2709-rpi-2-b.dtb /soc/spi@7e204000 status "okay"
fdtget bcm2709-rpi-2-b.dtb /soc/spi@7e204000 status

 

 

 

 

大樹底下好乘涼 ︰ 《拜樹頭》 ? ※ Q&A !

Baitou_Mountain_Tianchi

長白山‧天池

飲水思源

北周‧庾信徵調曲 六

正陽和氣萬類繁,君王道合天地尊。
黎人耕植於義圃,君子翱翔於禮園。
落其實者思其樹,飲其流者懷其源。
咎繇為謀不仁遠,士會為政群盜棄。
克寬則昆蟲內向,彰信則殊俗宅心。
浮橋有月支抱馬,上苑有烏孫學琴。
赤玉則南海輸贐,白環則西山獻琛。
無勞鑿空於大夏,不待蹶角於蹛林。

在大變動時候,通常『問題』和『答案』至少一樣重要,甚至於更重要。許多『零碎資訊』拼湊出『藍圖』,或許正是『逆流朔源』的大好時機!因此也許該閱讀論壇的這個『文本』︰

I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

by PhilE » Wed Jan 21, 2015 4:45 pm
The most recent Raspbian release, with Pi 2 support, switches to a new kernel (3.18), and includes a configuration change to enable Device Tree support by default. This has caused some previously working things to mysteriously stop working, but with a few configuration changes normal service should be resumed. I’ll tell you how to do that in a moment, but first a short history lesson. Skip forward to “TL;DR: Yeah, yeah, but how do I fix it?” if you don’t care.
……
So DT is officially a “Thing”, but why should Raspberry Pi use it? The change is primarily a practical one. Until now, supporting some peripheral cards has required the addition of “struct platform_device” objects to the board support code. These are usually conditionally compiled based on the kernel configuration options, but in order to prevent regular users from having to compile their own kernel these options are turned on in the standard builds. As a result, at boot time many (typically unwanted) modules are loaded unless they added to the blacklist (which prevents the automatic loading but still allows subsequent manual loading). Insufficient blacklisting could lead to nasty contention for GPIO pins, usually experienced after a kernel update since the blacklist file (/etc/modprobe.d/raspi-blacklist.conf) isn’t a part of the kernel and hence doesn’t automatically get updated.

Device Tree turns this system on its head, by replacing those “struct platform_device”s with nodes in the DT, allowing users to control which devices are enabled and hence which modules get loaded. Adding a new device driver module to the kernel doesn’t automatically result in a module being loaded – the appropriate nodes must also be added to the DT.

TL;DR: Yeah, yeah, but how do I fix it?……

要是帶著『思源之心』慎思 Q&A ……

I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

by PhilE » Mon Feb 09, 2015 1:27 pm

We need a bit more information:
1) Which version are you running now? What does `uname -a` say?

2) Does /proc/device-tree exist?

3) Have you read the above and enabled the SPI interface? I would guess so, if it gets that far before failing, but I’d like confirmation.

4) Does disabling device tree (add “device_tree=” to your config.txt and reboot) make a difference?

5) What is connected to your SPI interface?

 

是否能窺探『先機』於萬一??