詳細はOpenPLCハット作成を参照だが、
GPIO14とGPIO15は、デフォルトではUART TXD, RXDに割り付けられており、
ブート中TXDはOutput w/ Highドライブ、RXDはInput w/内蔵プルアップとなり、
Raspberry Pi OS起動後に両方ともInput w/内蔵プルダウンとなる。
RXD側は外部プルダウン抵抗で対応できるけど、
TXD側は対応できないため、ブート中のGPIO設定を変更したい。
ラズパイ公式に記載されてるdt-blob.binを作成する方法を試してみる。
Contents
ファームウェアバージョン確認
2014年7月15日以降のファームウェアでこの方法、user-provided Device Tree blob fileでのデフォルトのピン設定、が有効とのこと。
|
1 2 3 4 |
$ vcgencmd version Aug 24 2020 18:52:38 Copyright (c) 2012 Broadcom version 8d19c1935e67d8ac2fe87c639d4e8b8ef250813b (clean) (release) (start) |
2020年8月24日版のファームウェアなので使える。
Device Tree blobファイル作成
GitのExampleファイルを参考に作成する。
このファイルには全てのラズパイモデル分が入ってるため、
自分の使用しているモデルのみ抜き出すことにする。
ラズパイモデル確認
以下のようにコマンドで確認できる。
|
1 2 |
$ cat /proc/device-tree/model Raspberry Pi 3 Model B Rev 1.2 |
Pi 3 Model B rev 1.2なので、pins_3b2のみをコピーして作成する。
dtsファイル作成
dt-blob.dtsファイルにGitのExampleファイルの内容をコピーしていく。
修正するのはpin@p14とpin@p15のみ。
GPIO以外のピン情報はラズパイ公式の回路図には記載されていないのでわからない。公開予定もない模様。
Exampleファイル:
|
1 2 |
pin@p14 { function = "uart0"; termination = "no_pulling"; drive_strength_mA = < 8 >; }; // TX uart0 pin@p15 { function = "uart0"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // RX uart0 |
これをコメントアウトすべきか、function=inputまたはoutputにするか迷う。
Exampleファイルにはpin@defaultが以下のように設定されているのでコメントアウトで良い気がする。
|
1 2 3 4 5 6 |
pin@default { polarity = "active_high"; termination = "pull_down"; startup_state = "inactive"; function = "input"; }; // pin |
まずはコメントアウトしてdt-blob.binを作成して確認してみる。
以下が全文。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
/dts-v1/; / { videocore { pins_3b2 { // Pi 3 Model B rev 1.2 pin_config { pin@default { polarity = "active_high"; termination = "pull_down"; startup_state = "inactive"; function = "input"; }; // pin //pin@p14 { function = "uart0"; termination = "no_pulling"; drive_strength_mA = < 8 >; }; // TX uart0 //pin@p15 { function = "uart0"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // RX uart0 pin@p34 { function = "input"; termination = "pull_up"; drive_strength_mA = < 8 >; }; pin@p35 { function = "input"; termination = "pull_up"; drive_strength_mA = < 8 >; }; pin@p36 { function = "input"; termination = "pull_up"; drive_strength_mA = < 8 >; }; pin@p37 { function = "input"; termination = "pull_up"; drive_strength_mA = < 8 >; }; pin@p38 { function = "input"; termination = "pull_up"; drive_strength_mA = < 8 >; }; pin@p39 { function = "input"; termination = "pull_up"; drive_strength_mA = < 8 >; }; pin@p40 { function = "pwm"; termination = "no_pulling"; drive_strength_mA = < 16 >; }; // Right audio pin@p41 { function = "pwm"; termination = "no_pulling"; drive_strength_mA = < 16 >; }; // Left audio pin@p42 { function = "gp_clk"; termination = "pull_down"; }; // ETH_CLK - Ethernet 25MHz output pin@p43 { function = "gp_clk"; termination = "pull_down"; }; // WIFI_CLK - Wifi 32kHz output pin@p44 { function = "input"; termination = "pull_up"; }; // I2C 0 SDA pin@p45 { function = "input"; termination = "pull_up"; }; // I2C 0 SCL pin@p46 { function = "input"; termination = "pull_up"; }; // SMPS_SCL pin@p47 { function = "input"; termination = "pull_up"; }; // SMPS_SDA pin@p48 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CLK pin@p49 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CMD pin@p50 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D0 pin@p51 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D1 pin@p52 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D2 pin@p53 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D3 pin@p128 { function = "output"; termination = "no_pulling"; }; // BT_ON pin@p129 { function = "output"; termination = "no_pulling"; }; // WL_ON pin@p130 { function = "output"; termination = "no_pulling"; }; // ACT_LED pin@p131 { function = "output"; termination = "no_pulling"; startup_state = "active"; }; // LAN_RUN pin@p132 { function = "input"; termination = "no_pulling"; polarity = "active_low"; }; // Hotplug pin@p133 { function = "output"; termination = "no_pulling"; }; // Camera shutdown pin@p134 { function = "output"; termination = "no_pulling"; }; // Camera LED pin@p135 { function = "input"; termination = "no_pulling"; polarity = "active_low"; }; // Power low }; // pin_config pin_defines { pin_define@HDMI_CONTROL_ATTACHED { type = "external"; number = <4>; }; pin_define@NUM_CAMERAS { type = "internal"; number = <1>; }; pin_define@CAMERA_0_I2C_PORT { type = "internal"; number = <0>; }; pin_define@CAMERA_0_SDA_PIN { type = "internal"; number = <44>; }; pin_define@CAMERA_0_SCL_PIN { type = "internal"; number = <45>; }; pin_define@CAMERA_0_SHUTDOWN { type = "external"; number = <5>; }; pin_define@CAMERA_0_UNICAM_PORT { type = "internal"; number = <1>; }; pin_define@CAMERA_0_LED { type = "external"; number = <6>; }; pin_define@FLASH_0_ENABLE { type = "absent"; }; pin_define@FLASH_0_INDICATOR { type = "absent"; }; pin_define@FLASH_1_ENABLE { type = "absent"; }; pin_define@FLASH_1_INDICATOR { type = "absent"; }; pin_define@POWER_LOW { type = "external"; number = <7>; }; pin_define@LEDS_DISK_ACTIVITY { type = "external"; number = <2>; }; pin_define@LAN_RUN { type = "external"; number = <3>; }; pin_define@LAN_RUN_BOOT { type = "internal"; number = <29>; }; pin_define@BT_ON { type = "external"; number = <0>; }; pin_define@WL_ON { type = "external"; number = <1>; }; pin_define@SMPS_SDA { type = "internal"; number = <46>; }; pin_define@SMPS_SCL { type = "internal"; number = <47>; }; pin_define@ETH_CLK { type = "internal"; number = <42>; }; pin_define@WL_LPO_CLK { type = "internal"; number = <43>; }; pin_define@USB_LIMIT_1A2 { type = "absent"; }; pin_define@SIO_1V8_SEL { type = "absent"; }; pin_define@PWML { type = "internal"; number = <41>; }; pin_define@PWMR { type = "internal"; number = <40>; }; pin_define@SAFE_MODE { type = "absent"; }; pin_define@SD_CARD_DETECT { type = "absent"; }; pin_define@ID_SDA { type = "internal"; number = <0>; }; pin_define@ID_SCL { type = "internal"; number = <1>; }; pin_define@DISPLAY_I2C_PORT { type = "internal"; number = <0>; }; pin_define@DISPLAY_SDA { type = "internal"; number = <44>; }; pin_define@DISPLAY_SCL { type = "internal"; number = <45>; }; }; // pin_defines }; // pins }; }; |
dt-blob.bin作成
dtcコマンドで作成
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
$ sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob.dts /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@default: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p34: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p35: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p36: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p37: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p38: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p39: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p40: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p41: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p42: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p43: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p44: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p45: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p46: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p47: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p48: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p49: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p50: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p51: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p52: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p53: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p128: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p129: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p130: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p131: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p132: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p133: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p134: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_config/pin@p135: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@HDMI_CONTROL_ATTACHED: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@NUM_CAMERAS: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@CAMERA_0_I2C_PORT: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@CAMERA_0_SDA_PIN: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@CAMERA_0_SCL_PIN: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@CAMERA_0_SHUTDOWN: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@CAMERA_0_UNICAM_PORT: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@CAMERA_0_LED: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@FLASH_0_ENABLE: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@FLASH_0_INDICATOR: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@FLASH_1_ENABLE: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@FLASH_1_INDICATOR: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@POWER_LOW: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@LEDS_DISK_ACTIVITY: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@LAN_RUN: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@LAN_RUN_BOOT: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@BT_ON: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@WL_ON: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@SMPS_SDA: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@SMPS_SCL: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@ETH_CLK: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@WL_LPO_CLK: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@USB_LIMIT_1A2: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@SIO_1V8_SEL: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@PWML: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@PWMR: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@SAFE_MODE: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@SD_CARD_DETECT: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@ID_SDA: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@ID_SCL: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@DISPLAY_I2C_PORT: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@DISPLAY_SDA: node has a unit name, but no reg property /boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_3b2/pin_defines/pin_define@DISPLAY_SCL: node has a unit name, but no reg property |
すごい数のwarningが出てるけどまずは無視。
リブートして確認。
成功
ブート中にGPIO14がHighになることはなくなった。
正常にOpenPLCも動作しているし問題なさそう。
One Reply to “ブート中のGPIO設定変更”
[…] らめていたが、ブート中のピン設定は変更できた。詳細についてはブート中のGPIO設定変更を参照。 […]