最終更新: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にはできない
シリアルコンソール有効
- console=tty1 console=serial0,115200
- enable_uart=1
シリアルコンソール無効
抑制
- plymouth.ignore-serial-consoles?
種類
- 2種類ある
Raspberry Pi Zero, 1, 2 and 3
Raspberry Pi 4 and 400
- 4つPL011が増えている
用途
プライマリUART
- GPIO 14/15 (GPIOヘッダでは8と10)
- Linuxコンソール
セカンダリUART
- Bluetoothのチップに繋がってる
アサイン
ボード別
Model first PL011 (UART0) mini UART Raspberry Pi Zero primary secondary Raspberry Pi Zero W secondary (Bluetooth) primary Raspberry Pi 3 secondary (Bluetooth) primary Raspberry Pi 4 secondary (Bluetooth) primary
Linux上
Linux/dev/ttyS0 mini UART Linux/dev/ttyAMA0? first PL011 (UART0) Linux/dev/serial0 primary UART (シンボリックリンク) Linux/dev/serial1 secondary UART (シンボリックリンク)
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/
ボーレート
- The PL011 uses the ~48MHz uart clock as a base, which results in a maximum achievable baudrate of 3Mbit/sec (48MHz/16)
https://forums.raspberrypi.com/viewtopic.php?t=226881