私的AI研究会 > RaspberryPi1
およそ1年ぶりに Raspberry Pi を再検証する。新しい OS「Bullseye」を調べる。
$ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye
これまで有効だった「Wiring Pi」は、Bullseye ベースの Rasbpberry Pi OS から提供されなくなった。
raspi-gpio は Bullseye ベース、Buster ベース、両方の Rapsberry Pi に標準インストール済み
$ raspi-gpio help WARNING! raspi-gpio set writes directly to the GPIO control registers ignoring whatever else may be using them (such as Linux drivers) - it is designed as a debug tool, only use it if you know what you are doing and at your own risk! The raspi-gpio tool is designed to help hack / debug BCM283x GPIO. Running raspi-gpio with the help argument prints this help. raspi-gpio can get and print the state of a GPIO (or all GPIOs) and can be used to set the function, pulls and value of a GPIO. raspi-gpio must be run as root. Use: raspi-gpio get [GPIO] OR raspi-gpio set <GPIO> [options] OR raspi-gpio funcs [GPIO] OR raspi-gpio raw GPIO is a comma-separated list of pin numbers or ranges (without spaces), e.g. 4 or 18-21 or 7,9-11 Note that omitting [GPIO] from raspi-gpio get prints all GPIOs. raspi-gpio funcs will dump all the possible GPIO alt funcions in CSV format or if [GPIO] is specified the alternate funcs just for that specific GPIO. Valid [options] for raspi-gpio set are: ip set GPIO as input op set GPIO as output a0-a5 set GPIO to alternate function alt0-alt5 pu set GPIO in-pad pull up pd set GPIO pin-pad pull down pn set GPIO pull none (no pull) dh set GPIO to drive to high (1) level (only valid if set to be an output) dl set GPIO to drive low (0) level (only valid if set to be an output) Examples: raspi-gpio get Prints state of all GPIOs one per line raspi-gpio get 20 Prints state of GPIO20 raspi-gpio get 20,21 Prints state of GPIO20 and GPIO21 raspi-gpio set 20 a5 Set GPIO20 to ALT5 function (GPCLK0) raspi-gpio set 20 pu Enable GPIO20 ~50k in-pad pull up raspi-gpio set 20 pd Enable GPIO20 ~50k in-pad pull down raspi-gpio set 20 op Set GPIO20 to be an output raspi-gpio set 20 dl Set GPIO20 to output low/zero (must already be set as an output) raspi-gpio set 20 ip pd Set GPIO20 to input with pull down raspi-gpio set 35 a0 pu Set GPIO35 to ALT0 function (SPI_CE1_N) with pull up raspi-gpio set 20 op pn dh Set GPIO20 to ouput with no pull and driving high
raspi-gpio | Wriring Pi | |
GPIO 全てを読む | raspi-gpio get | gpio readall |
BMC ピン 6 番を読む | raspi-gpio get 6 | gpio -g read 6 |
$ raspi-gpio get BANK0 (GPIO 0 to 27): GPIO 0: level=1 fsel=0 func=INPUT pull=UP GPIO 1: level=1 fsel=0 func=INPUT pull=UP GPIO 2: level=1 fsel=0 func=INPUT pull=UP GPIO 3: level=1 fsel=0 func=INPUT pull=UP GPIO 4: level=1 fsel=0 func=INPUT pull=UP GPIO 5: level=1 fsel=0 func=INPUT pull=UP GPIO 6: level=1 fsel=0 func=INPUT pull=UP GPIO 7: level=1 fsel=0 func=INPUT pull=UP GPIO 8: level=1 fsel=0 func=INPUT pull=UP GPIO 9: level=0 fsel=0 func=INPUT pull=DOWN GPIO 10: level=0 fsel=0 func=INPUT pull=DOWN GPIO 11: level=0 fsel=0 func=INPUT pull=DOWN GPIO 12: level=0 fsel=0 func=INPUT pull=DOWN GPIO 13: level=0 fsel=0 func=INPUT pull=DOWN GPIO 14: level=1 fsel=0 func=INPUT pull=NONE GPIO 15: level=1 fsel=0 func=INPUT pull=UP GPIO 16: level=0 fsel=0 func=INPUT pull=DOWN GPIO 17: level=0 fsel=0 func=INPUT pull=DOWN GPIO 18: level=0 fsel=0 func=INPUT pull=DOWN GPIO 19: level=0 fsel=0 func=INPUT pull=DOWN GPIO 20: level=0 fsel=0 func=INPUT pull=DOWN GPIO 21: level=0 fsel=0 func=INPUT pull=DOWN GPIO 22: level=0 fsel=0 func=INPUT pull=DOWN GPIO 23: level=0 fsel=0 func=INPUT pull=DOWN GPIO 24: level=0 fsel=0 func=INPUT pull=DOWN GPIO 25: level=0 fsel=0 func=INPUT pull=DOWN GPIO 26: level=0 fsel=0 func=INPUT pull=DOWN GPIO 27: level=0 fsel=0 func=INPUT pull=DOWN BANK1 (GPIO 28 to 45): GPIO 28: level=1 fsel=2 alt=5 func=RGMII_MDIO pull=UP GPIO 29: level=0 fsel=2 alt=5 func=RGMII_MDC pull=DOWN GPIO 30: level=0 fsel=7 alt=3 func=CTS0 pull=UP GPIO 31: level=0 fsel=7 alt=3 func=RTS0 pull=NONE GPIO 32: level=1 fsel=7 alt=3 func=TXD0 pull=NONE GPIO 33: level=1 fsel=7 alt=3 func=RXD0 pull=UP GPIO 34: level=0 fsel=7 alt=3 func=SD1_CLK pull=NONE GPIO 35: level=1 fsel=7 alt=3 func=SD1_CMD pull=UP GPIO 36: level=1 fsel=7 alt=3 func=SD1_DAT0 pull=UP GPIO 37: level=1 fsel=7 alt=3 func=SD1_DAT1 pull=UP GPIO 38: level=1 fsel=7 alt=3 func=SD1_DAT2 pull=UP GPIO 39: level=1 fsel=7 alt=3 func=SD1_DAT3 pull=UP GPIO 40: level=1 fsel=4 alt=0 func=PWM1_0 pull=NONE GPIO 41: level=1 fsel=4 alt=0 func=PWM1_1 pull=NONE GPIO 42: level=0 fsel=1 func=OUTPUT pull=UP GPIO 43: level=1 fsel=0 func=INPUT pull=UP GPIO 44: level=1 fsel=5 alt=1 func=SDA0 pull=UP GPIO 45: level=1 fsel=5 alt=1 func=SCL0 pull=UP BANK2 (GPIO 46 to 53): GPIO 46: level=0 fsel=0 func=INPUT pull=UP GPIO 47: level=0 fsel=0 func=INPUT pull=UP GPIO 48: level=0 fsel=0 func=INPUT pull=DOWN GPIO 49: level=0 fsel=0 func=INPUT pull=DOWN GPIO 50: level=0 fsel=0 func=INPUT pull=DOWN GPIO 51: level=0 fsel=0 func=INPUT pull=DOWN GPIO 52: level=0 fsel=0 func=INPUT pull=DOWN GPIO 53: level=0 fsel=0 func=INPUT pull=DOWN
Raspberry Pi 「Bullseye」では、新たなカメラドライバ「libcamera」が導入されている。
今までのおなじみの「raspistill」や「Picamera」などが置き換わり、「libcamera」としてオープンソースのカメラドライバに生まれ変わりました。
画像を撮る「raspistill」、動画を撮る「raspivid」を統合した機能を持つ。
$ libcamera-hello Made X/EGL preview window [0:28:37.207317026] [1462] INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3544-22656360 [0:28:37.275522300] [1464] WARN RPI raspberrypi.cpp:1241 Mismatch between Unicam and CamHelper for embedded data usage! [0:28:37.276291854] [1464] INFO RPI raspberrypi.cpp:1356 Registered camera /base/soc/i2c0mux/i2c@1/imx219@10 to Unicam device /dev/media3 and ISP device /dev/media0 [0:28:37.277086260] [1462] INFO Camera camera.cpp:1029 configuring streams: (0) 1640x1232-YUV420 [0:28:37.277539074] [1464] INFO RPI raspberrypi.cpp:760 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected sensor format: 1640x1232-SBGGR10_1X10 - Selected unicam format: 1640x1232-pBAA
$ libcamera-hello -t 0
$ libcamera-hello -h Valid options are: -h [ --help ] [=arg(=1)] (=0) Print this help message --version [=arg(=1)] (=0) Displays the build version number --list-cameras [=arg(=1)] (=0) Lists the available cameras attached to the system. --camera arg (=0) Chooses the camera to use. To list the available indexes, use the --list-cameras option. -v [ --verbose ] [=arg(=1)] (=0) Output extra debug and diagnostics -c [ --config ] [=arg(=config.txt)] Read the options from a file. If no filename is specified, default to config.txt. In case of duplicate options, the ones provided on the command line will be used. Note that the config file must only contain the long form options. --info-text arg (=#%frame (%fps fps) exp %exp ag %ag dg %dg) Sets the information string on the titlebar. Available values: %frame (frame number) %fps (framerate) %exp (shutter speed) %ag (analogue gain) %dg (digital gain) %rg (red colour gain) %bg (blue colour gain) %focus (focus FoM value) %aelock (AE locked status) --width arg (=0) Set the output image width (0 = use default value) --height arg (=0) Set the output image height (0 = use default value) -t [ --timeout ] arg (=5000) Time (in ms) for which program runs -o [ --output ] arg Set the output file name --post-process-file arg Set the file name for configuring the post-processing --rawfull [=arg(=1)] (=0) Force use of full resolution raw frames -n [ --nopreview ] [=arg(=1)] (=0) Do not show a preview window -p [ --preview ] arg (=0,0,0,0) Set the preview window dimensions, given as x,y,width,height e.g. 0,0,640,480 -f [ --fullscreen ] [=arg(=1)] (=0) Use a fullscreen preview window --qt-preview [=arg(=1)] (=0) Use Qt-based preview window (WARNING: causes heavy CPU load, fullscreen not supported) --hflip [=arg(=1)] (=0) Request a horizontal flip transform --vflip [=arg(=1)] (=0) Request a vertical flip transform --rotation arg (=0) Request an image rotation, 0 or 180 --roi arg (=0,0,0,0) Set region of interest (digital zoom) e.g. 0.25,0.25,0.5,0.5 --shutter arg (=0) Set a fixed shutter speed --analoggain arg (=0) Set a fixed gain value (synonym for 'gain' option) --gain arg Set a fixed gain value --metering arg (=centre) Set the metering mode (centre, spot, average, custom) --exposure arg (=normal) Set the exposure mode (normal, sport) --ev arg (=0) Set the EV exposure compensation, where 0 = no change --awb arg (=auto) Set the AWB mode (auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom) --awbgains arg (=0,0) Set explict red and blue gains (disable the automatic AWB algorithm) --flush [=arg(=1)] (=0) Flush output data as soon as possible --wrap arg (=0) When writing multiple output files, reset the counter when it reaches this number --brightness arg (=0) Adjust the brightness of the output images, in the range -1.0 to 1.0 --contrast arg (=1) Adjust the contrast of the output image, where 1.0 = normal contrast --saturation arg (=1) Adjust the colour saturation of the output, where 1.0 = normal and 0.0 = greyscale --sharpness arg (=1) Adjust the sharpness of the output image, where 1.0 = normal sharpening --framerate arg (=30) Set the fixed framerate for preview and video modes --denoise arg (=auto) Sets the Denoise operating mode: auto, off, cdn_off, cdn_fast, cdn_hq --viewfinder-width arg (=0) Width of viewfinder frames from the camera (distinct from the preview window size --viewfinder-height arg (=0) Height of viewfinder frames from the camera (distinct from the preview window size) --tuning-file arg (=-) Name of camera tuning file to use, omit this option for libcamera default behaviour --lores-width arg (=0) Width of low resolution frames (use 0 to omit low resolution stream --lores-height arg (=0) Height of low resolution frames (use 0 to omit low resolution stream --mode arg Camera mode as W:H:bit-depth:packing, where packing is P (packed) or U (unpacked) --viewfinder-mode arg Camera mode for preview as W:H:bit-depth:packing, where packing is P (packed) or U (unpacked)