RaspberryPiMouse icon indicating copy to clipboard operation
RaspberryPiMouse copied to clipboard

スクリプトによるRaspberry Pi設定の自動化

Open KuraZuzu opened this issue 1 year ago • 3 comments

What does this implement/fix?

デバイスドライバをビルドする前に必要な設定(ソースファイルのダウンロードとインストール)を自動で行うスクリプトを追加します。

従来の/boot/firmware/config.txtを手動で修正していた手順を、本PRで追加するスクリプトで行うため、カーネルヘッダーのインストール以外はRaspberry Pi OSUbuntu Serverの両方で手順が統一されます。

Does this close any currently open issues?

しません。

How has this been tested?

環境

Raspberry Pi 3Bと4Bに対してそれぞれ以下の環境全てを用意しテストし、サンプルプログラム全ての動作を確認しました。

  • Ubuntu Server 22.04 (32-bit)
  • Ubuntu Server 22.04 (64-bit)
  • Ubuntu Server 24.04 (64-bit)
  • Raspberry Pi OS (32-bit)
  • Raspberry Pi OS (64-bit)

手順

  1. 各種OSのimageが書き込まれたSDカードをRaspberry Pi 3B/4Bに挿し込み、Raspberry Pi Mouse V3を組み立てます。
  2. ディスプレイとキーボード、マウスを接続して起動します。
  3. ターミナルを開いて以下のコマンドを実行し、Raspberry Pi 3B/4Bの設定をします。
$ sudo apt update
$ sudo apt upgrade
$ git clone -b feature/setting-configs https://github.com/rt-net/RaspberryPiMouse.git
$ cd RaspberryPiMouse/utils
$ ./set_configs.bash 
  1. Raspberyr Pi 3B/4Bを再起動します
  2. ターミナルでカーネルヘッダーをインストールします(Ubuntu ServerとRaspberry Pi OSによってコマンドが違います)
# Ubuntu Server の場合
$ sudo apt install linux-headers-$(uname -r) build-essential

# Raspberry Pi OSの場合
$ sudo apt install raspberrypi-kernel-headers build-essential 
  1. 以下のコマンドを実行してデバイスドライバをビルドします
$ cd RaspberryPiMouse/utils
$ ./build_install.bash
  1. サンプルプログラムを実行して動作を確認します(動作内容
$ cd ../SampleProgram
$ bash step1.sh
// ...
$ bash step6.sh

Any other comments?

今回の変更に合わせ、Raspberry Pi Mouseのチュートリアル内のソースファイルのダウンロードとインストールを修正する必要があります。

Checklists

  • [x] I have read the CONTRIBUTING guidelines.
  • [x] I have checked to ensure there aren't other open Pull Requests for the same change.

KuraZuzu avatar Sep 13 '24 05:09 KuraZuzu

下記の環境でサンプルが動作することを確認しました。

  • Ubuntu 24.04.1 LTS
  • Raspberry Pi 4B

YusukeKato avatar Sep 13 '24 09:09 YusukeKato

今回のPRの変更内容に関係するかは不明ですが、./build_install.bash時に下記のようにwarningが出たので問題がないか(修正が必要か)の確認をお願いしたいです。

ubuntu@ubuntu:~/RaspberryPiMouse/utils$ ./build_install.bash 
build_install_header_from_apt_raspi4.bash
make -C /usr/src/linux-headers-6.8.0-1010-raspi M=/home/ubuntu/RaspberryPiMouse/src/drivers V=0 clean
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-1010-raspi'
make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-1010-raspi'
make -C /usr/src/linux-headers-6.8.0-1010-raspi M=/home/ubuntu/RaspberryPiMouse/src/drivers V=0 modules
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-1010-raspi'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: aarch64-linux-gnu-gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0
  You are using:           gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0
  CC [M]  /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.o
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:1140:6: warning: no previous prototype for ‘update_signed_count’ [-Wmissing-prototypes]
 1140 | void update_signed_count(struct rtcnt_device_info *dev_info, int rtcnt_count)
      |      ^~~~~~~~~~~~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:1176:6: warning: no previous prototype for ‘reset_signed_count’ [-Wmissing-prototypes]
 1176 | void reset_signed_count(struct rtcnt_device_info *dev_info, int rtcnt_count)
      |      ^~~~~~~~~~~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c: In function ‘mcp3204_get_value’:
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:1907:14: warning: unused variable ‘str’ [-Wunused-variable]
 1907 |         char str[128];
      |              ^~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c: At top level:
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:2387:5: warning: no previous prototype for ‘dev_init_module’ [-Wmissing-prototypes]
 2387 | int dev_init_module(void)
      |     ^~~~~~~~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:2544:6: warning: no previous prototype for ‘dev_cleanup_module’ [-Wmissing-prototypes]
 2544 | void dev_cleanup_module(void)
      |      ^~~~~~~~~~~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:1954:13: warning: ‘spi_remove_device’ defined but not used [-Wunused-function]
 1954 | static void spi_remove_device(struct spi_master *master, unsigned int cs)
      |             ^~~~~~~~~~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:335:26: warning: ‘mcp3204_driver’ defined but not used [-Wunused-variable]
  335 | static struct spi_driver mcp3204_driver = {
      |                          ^~~~~~~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:95:12: warning: ‘spi_chip_select’ defined but not used [-Wunused-variable]
   95 | static int spi_chip_select = 0;
      |            ^~~~~~~~~~~~~~~
/home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.c:94:12: warning: ‘spi_bus_num’ defined but not used [-Wunused-variable]
   94 | static int spi_bus_num = 0;
      |            ^~~~~~~~~~~
  MODPOST /home/ubuntu/RaspberryPiMouse/src/drivers/Module.symvers
  CC [M]  /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.mod.o
  LD [M]  /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.ko
  BTF [M] /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.ko
Skipping BTF generation for /home/ubuntu/RaspberryPiMouse/src/drivers/rtmouse.ko due to unavailability of vmlinux
make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-1010-raspi'

YusukeKato avatar Sep 13 '24 09:09 YusukeKato

README上のCI結果のバッジの修正をお願いしたいです。 おそらく下記の修正でCI結果が「failing」から「passing」に変更されると思います。

修正前↓

![CI](https://github.com/rt-net/RaspberryPiMouse/workflows/CI/badge.svg?branch=master)

修正後↓

[![CI](https://github.com/rt-net/RaspberryPiMouse/actions/workflows/driver-cross-build.yml/badge.svg)](https://github.com/rt-net/RaspberryPiMouse/actions/workflows/driver-cross-build.yml)

YusukeKato avatar Sep 13 '24 09:09 YusukeKato

README上のCI結果のバッジの修正をお願いしたいです。 おそらく下記の修正でCI結果が「failing」から「passing」に変更されると思います。

修正前↓

![CI](https://github.com/rt-net/RaspberryPiMouse/workflows/CI/badge.svg?branch=master)

修正後↓

[![CI](https://github.com/rt-net/RaspberryPiMouse/actions/workflows/driver-cross-build.yml/badge.svg)](https://github.com/rt-net/RaspberryPiMouse/actions/workflows/driver-cross-build.yml)

修正しました。

KuraZuzu avatar Sep 17 '24 06:09 KuraZuzu

今回のPRの変更内容に関係するかは不明ですが、./build_install.bash時に下記のようにwarningが出たので問題がないか(修正が必要か)の確認をお願いしたいです。

動作としては問題ないです。今回は直さなくても良いかなというのが私の意見です。

これらのwarningはデバイスツリーによる動作(カーネル5.16以上)のとき、SPIのマスターをサーチする処理にイレギュラーな方法を用いて大きな分岐が起こっていることに起因します。これらのwarningを消すためにはたくさんのカーネルバージョン分岐を設ける必要があるため、コードの可読性を更に下げ、修正にも時間がかかってしまいます。これらのwarningを直す手間を、純粋なデバイスツリーでの動作するコードへのリファクタリングに回したほうが良いのではないかと考えています。

ですが、確かに開発に慣れていない人がビルド時に大量に出るwarningを見ると不安になると思うので修正するというのも全然ありだとは思っています。

KuraZuzu avatar Sep 17 '24 09:09 KuraZuzu

warningの件、承知しました。 一応Issueを立てておきます。

YusukeKato avatar Sep 19 '24 01:09 YusukeKato