最終更新:2023-01-17 (火) 05:12:26 (464d)  

Raspberry Pi/UART
Top / Raspberry Pi / UART

https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts

2種類ある

Raspberry Pi Zero, 1, 2 and 3

Raspberry Pi 4 and 400

プライマリUART

  • GPIO 14/15 (GPIOヘッダでは8と10)
  • Linuxコンソール

セカンダリUART

  • Bluetoothのチップに繋がってる

アサイン

  • Linux上
    Linux/dev/ttyS0?mini UART
    Linux/dev/ttyAMA0?first PL011 (UART0)
    Linux/dev/serial0?primary UART (シンボリックリンク)
    Linux/dev/serial1secondary UART (シンボリックリンク)

mini UART

メモ

  • raspi-configでも設定を変更できる
    • シリアルポート: プライマリ(ttyS0)を有効化する(デフォルトでは無効化)
    • シリアルコンソール: シリアルポートをLinuxのコンソールにする

dtoverlay

miniuart-bt

  • Bluetooth機能を切り替えて、Bluetoothモジュールとの接続にmini UART(/dev/ttyS0)を使用し、1番目のPL011(UART0)をPrimary UART(/dev/serial0)にする
  • 使用可能な最大ボーレートが低下する可能性がある
  • RPi4などでセカンダリのUART(PL011)をシリアルポート(Bluetooth/Linuxコンソール以外の用途)に使いたい場合、miniuartをBTに使うように変更する
    • force_turbo=1または、core_freq=250のいずれかを使用して、VPUコアクロックを固定周波数に設定する必要がある

disable-bt

  • Bluetoothデバイスを無効にし、1番目のPL011(UART0)をPrimary UART(/dev/serial0)にする

init_uart_clock?

  • init_uart_clock is the initial UART clock frequency. The default value is 48000000 (48MHz). Note that this clock only applies to UART0 (ttyAMA0 in Linux), and that the maximum baudrate for the UART is limited to 1/16th of the clock.
  • The default UART on the Raspberry Pi 3 and Raspberry Pi Zero is UART1 (ttyS0 in Linux), and its clock is the core VPU clock - at least 250MHz.

メモ

  • 48MHz is the current default UART clock frequency, raised from 3MHz to allow 3Mbaud for Bluetooth. 1.5 Mbaud is comfortably within the UARTs capabilities.

stty

  • pi@raspberrypi:/boot $ stty -F /dev/ttyAMA0 
    speed 3000000 baud; line = 15;
    min = 1; time = 0;
    -brkint -icrnl -imaxbel
    -opost
    -isig -icanon -iexten -echo

メモ

  • Pi3、ZeroWのminiUARTのボーレートはGPUのコアクロックに依存してしまうように設計されているので、負荷によってボーレートが変化してしまう
  • GPUのコアクロックを250MHzに固定化
    • core_freq=250
  • https://www.usagi1975.com/201907061439/

ボーレート

参考

関連