Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Sep 19, 2024

Conversation

KuraZuzu
Copy link
Contributor

@KuraZuzu KuraZuzu commented Sep 13, 2024

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

dtoverlayがkernel5.16未満にも関わらず記述されていた場合に削除するよう変更
@KuraZuzu KuraZuzu requested review from ShotaAk and YusukeKato and removed request for ShotaAk September 13, 2024 05:18
Copy link
Contributor

@YusukeKato YusukeKato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

レビューしました。
コメントの確認をお願いいたします。

@YusukeKato
Copy link
Contributor

YusukeKato commented Sep 13, 2024

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

  • Ubuntu 24.04.1 LTS
  • Raspberry Pi 4B

@YusukeKato
Copy link
Contributor

YusukeKato commented Sep 13, 2024

今回の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
Copy link
Contributor

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
Copy link
Contributor Author

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 and others added 5 commits September 17, 2024 15:38
Co-authored-by: YusukeKato <YusukeKato@users.noreply.github.com>
- 変数"KERNEL_VERSION_INT"と関数"KERNEL_VERSION_INT()"が同名だったため、関数を"GET_KERNEL_VERSION_INT()"に理ネーム
- 関数"GET_KERNEL_VERSION_INT() "を現在のカーネルバージョン取得より前に定義し、自身のカーネルバージョンを整数値に変換する際に使用するよう変更
@KuraZuzu
Copy link
Contributor Author

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

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

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

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

- 今回から全ての設定がスクリプトによって自動で書き換わるため、先頭でのみこれにふれるように変更
- 32-bit OSはUbuntu 22.04でも存在するため、Raspberry Pi OSのスコープから外した
@YusukeKato
Copy link
Contributor

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

Copy link
Contributor

@YusukeKato YusukeKato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMです!

@YusukeKato YusukeKato merged commit c0907bc into master Sep 19, 2024
@YusukeKato YusukeKato deleted the feature/setting-configs branch September 19, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy