最終更新:2024-07-16 (火) 09:13:15 (244d)  

Raspberry Pi/UART
Top / Raspberry Pi / UART

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

メモ

  • All UARTs on the Raspberry Pi are 3.3V only

コンソール

  • デフォルト: シリアルコンソールON / シリアルポートOFF
  • 一度変えるとシリアルコンソールON / シリアルポートOFFにはできない

シリアルコンソール有効

シリアルコンソール無効

抑制

  • plymouth.ignore-serial-consoles?

種類

Raspberry Pi Zero, 1, 2 and 3

Raspberry Pi 4 and 400

用途

プライマリUART

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

セカンダリUART

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

アサイン

ボード別

Linux上

mini UART

  • https://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf
  • mini UARTを使うにはVPUのクロックを固定にする必要がある
    mini UARTコアクロック動作
    プライマリ可変mini UARTは無効
    プライマリenable_uart=1を指定して固定mini UARTは有効。コアクロックは250MHz
    セカンダリ可変mini UARTは無効
    セカンダリcore_freq?=250を指定して固定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/

ボーレート

参考

関連