.. include:: 2026-11-30 (3): Project, Hardware And Linux =========================================== Project ------- * Show refactored project structure |longrightarrow| more understandable, hopefully * Review architecture change * WhyOS intro, message queues: :ref:`2026-11-23-message-based-arch` * Door message based architecture: :ref:`fh-2026-11-24-message-based-architecture` * cmdline test: disabled; look into what exactly they test .. image:: ../2026-11-24/architecture.jpg :scale: 130% Hardware: ``bastelpi`` At Faschingbauer's Home ---------------------------------------------- .. list-table:: * * .. image:: bastelpi.jpg * .. image:: /trainings/material/soup/linux/hardware/i2c/raspi-pinout.png .. code-block:: console $ ssh -J bastelgw bastelpi 'rpicam-vid --timeout 0 --framerate 10 --libav-format matroska --width 300 --height 200 --output -' | ffplay - ^ | (jfasch.bounceme.net:2222) Onewire (DS18B20 Temperature Sensor) ------------------------------------ * :doc:`/trainings/material/soup/linux/hardware/w1/topic` .. code-block:: console $ cat /sys/bus/w1/devices/28-02131d959eaa/temperature GPIO 17 ------- .. topic:: Documentation * https://libgpiod.readthedocs.io/en/master/index.html .. code-block:: console $ gpioset --chip /dev/gpiochip0 17=1 $ gpioset --toggle 1s,1s,0 --chip /dev/gpiochip0 17=1 PWM --- .. topic:: Bootloader setup In ``/boot/firmware/config.txt``: .. code-block:: text ... dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4 ... **Administrator step** (before application is started): export PMW pins 0 and 1 that are used by application .. code-block:: console $ echo 0 > /sys/class/pwm/pwmchip0/export $ echo 1 > /sys/class/pwm/pwmchip0/export **Application startup**: in the application's "configure" phase, together with requesting GPIOs and other setup stuff. Likely done inside the motor initialization. .. code-block:: console $ echo 200000 > /sys/class/pwm/pwmchip0/pwm0/period $ echo 0 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle $ echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable .. code-block:: console $ echo 200000 > /sys/class/pwm/pwmchip0/pwm1/period $ echo 0 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle $ echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable **Blink**: only duty cycle is fiddled with from now on. .. code-block:: console $ up="0 10000 20000 30000 40000 50000 70000 90000 100000 150000 200000" $ while true; do \ for d in $up; do \ echo $d > /sys/class/pwm/pwmchip0/pwm0/duty_cycle; \ sleep 0.2; \ done \ done .. code-block:: console $ down="200000 150000 100000 90000 70000 50000 40000 30000 20000 10000 0" $ while true; do \ for d in $down; do \ echo $d > /sys/class/pwm/pwmchip0/pwm1/duty_cycle; \ sleep 0.2; \ done \ done I2C (QWIIC Button) ------------------ .. image:: ../2026-11-16/qwiic-button.jpg .. topic:: Documentation * `Sparkfun QWIIC Button `__ * `SparkFun Qwiic Button Hookup Guide `__ * :download:`QWIIC Button register map (download) <../2026-11-24/Qwiic_Button_I2C_Register_Map.pdf>` * Python source code: https://docs.sparkfun.com/qwiic_button_py/ * https://kernel.googlesource.com/pub/scm/utils/i2c-tools/i2c-tools/ I2C Tools: ``i2cdetect`` ........................ **Address**: default 0x6f .. code-block:: console $ i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6f 70: -- -- -- -- -- -- -- -- I2C Tools: ``i2cget``, ``i2cset`` ................................. **Read firmware version** Regmap |longrightarrow| two registers .. code-block:: console $ i2cget -y 1 0x6f 0x1 b # LSB 0x03 $ i2cget -y 1 0x6f 0x2 b # MSB 0x01 .. code-block:: console $ i2cget -y 1 0x6f 0x1 w # both at once 0x0103 **Read button status** *Note*: user must clear a button event that has happened .. code-block:: console $ i2cget -y 1 0x6f 0x3 b 0x03 **LED brightness** set to max (0..255) .. code-block:: console $ i2cset -y 1 0x6f 0x19 255 b **LED pulse** Granularity (pulse smoothness) 50 steps .. code-block:: console $ i2cset -y 1 0x6f 0x1a 50 b Pulse cycle time 3000ms .. code-block:: console $ i2cset -y 1 0x6f 0x1b 3000 w Off between pulses 1000ms .. code-block:: console $ i2cset -y 1 0x6f 0x1d 1000 w I2C, Programmed In C/C++: Everything Is A File .............................................. **Deprecated, But File-Ish**: using ``read()`` and ``write()`` .. literalinclude:: code/qwiic-read-firmware-two-ops.cpp :caption: :download:`code/qwiic-read-firmware-two-ops.cpp` :language: c++ **Recommended**: using combined I2C transactions .. literalinclude:: code/qwiic-read-firmware-combined-op.cpp :caption: :download:`code/qwiic-read-firmware-combined-op.cpp` :language: c++ SSH Tricks ---------- .. topic:: See also From :doc:`/trainings/material/soup/linux/ssh/index` * :doc:`/trainings/material/soup/linux/ssh/basics` * :doc:`/trainings/material/soup/linux/ssh/key-pair` * :doc:`/trainings/material/soup/linux/ssh/scp` * :doc:`/trainings/material/soup/linux/ssh/portforwarding` * :doc:`/trainings/material/soup/linux/ssh/sshfs` Jump-Host ......... .. code-block:: console $ ssh -J jfasch.bounceme.net:2222 bastelpi ``sshfs``: Mount ``jfasch.bounceme.net:2222`` ............................................. .. code-block:: console $ sshfs -p 2222 jfasch.bounceme.net: /home/jfasch/mounts/bastelgw-home/ ``sshfs``: Mount ``bastelgw``, Jumping Voa ``jfasch.bounceme.net:2222`` ....................................................................... .. code-block:: console $ sshfs -o ProxyJump=jfasch.bounceme.net:2222 bastelpi: /home/jfasch/mounts/bastelpi-home/