LoginSignup
7
9

More than 5 years have passed since last update.

Raspberrypi 3でUART通信する際の課題と解決方法

Last updated at Posted at 2017-07-22

Raspberrypi 3でUART通信する際の課題

Raspberrypi 2以前では使用できていたUARTがそのままでは使えない.

UARTが使えない原因

pi3のUARTはminiUARTという機能を使って実現されているが,
miniUARTのクロックはVPUとリンクしており,VPUのクロックが変わるとボーレートも変化してしまうことが原因
https://www.raspberrypi.org/documentation/configuration/uart.md

The baud rate of the mini UART is linked to the core frequency of the VPU on the VC4 GPU. This means that as the VPU frequency governor varies the core frequency, the baud rate of the UART also changes. This makes the UART of limited use in the default state. Also, when the linux console uses the mini UART (Raspberry Pi 3, Raspberry Pi Zero W), as a consequence of the UART being disabled, the console is also disabled.

※2以前ではPL011(ARMプロセッサのUART機能)を使ってUARTを実現していたが,3では新規追加されたBluetoothにPL011を割り当てており,UARTはminiUARTと呼ばれる機能を使用するようになった,らしい.

UARTを使うには

解決方法は2つあるようだ.

1. クロックを固定する
/boot/config.txtに以下の記述を追加する.
enable_uart=1
この記述によってコアクロックが250MHzに固定される(Tubo時は400MHzに自動でセットされる).
https://www.raspberrypi.org/documentation/configuration/uart.md

The Linux console can be re-enabled by adding enable_uart=1 to config.txt. This also fixes the core_freq to 250Mhz (unless force_turbo is set, when it will fixed to 400Mhz), which means that the UART baud rate stays consistent.

2. Bluetoothに割り当てていたPL011をUARTに割り当てる
先に書いておくが,この方法ではBluetoothが使えなくなる.

/boot/config.txtに以下の記述を追加する.
dtoverlay=pi3-miniuart-bt

注意点

いずれの場合においても /dev/serial0を通してUART通信することに注意.
https://www.raspberrypi.org/documentation/configuration/uart.md

The primary UART is that assigned to the Linux console, which depends on the Raspberry Pi model as described above, and can be accessed via /dev/serial0.

7
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9