Aller au contenu

Messages recommandés

Posté(e)

Ils ont ajouté dans la version v1.0.8 via un script shell lancé en tant que service, des optimisations niveau système pour répartir la charge des MCUs sur les deux cœurs du Rockchip RK3308; modifié aussi le niceness de «l'IA»… 

Le fichier tuning.sh (~/QD_Q2/bin/tuning.sh) :

Citation

#!/bin/bash

### BEGIN INIT INFO
# Provides:       tuning
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: tunes CPU performance and process affinity
# Description:       tunes CPU performance and process affinity
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
TASKSET=/usr/bin/taskset
RENICE=/usr/bin/renice
CPUFREQSET=/usr/bin/cpufreq-set
CPUFREQINFO=/usr/bin/cpufreq-info

test -x $TASKSET || exit 0
test -x $RENICE || exit 0

set_irq_affinity() {
        TTYS4=`grep ttyS4 < /proc/interrupts | awk -F: '{print $1}' | tr -d '[:blank:]'`
        # TTYS2=`grep ttyS2 < /proc/interrupts | awk -F: '{print $1}' | tr -d '[:blank:]'`
        USB2=`grep "hcd:usb2" < /proc/interrupts | awk -F: '{print $1}' | tr -d '[:blank:]'`
        USB3=`grep "hcd:usb3" < /proc/interrupts | awk -F: '{print $1}' | tr -d '[:blank:]'`
        # USB4=`grep "hcd:usb4" < /proc/interrupts | awk -F: '{print $1}' | tr -d '[:blank:]'`

        # Split MCU IRQs evenly between CPUs 1 and 2
        echo 4 > /proc/irq/${TTYS4}/smp_affinity
        # echo 2 > /proc/irq/${TTYS2}/smp_affinity
        echo 8 > /proc/irq/${USB2}/smp_affinity
        echo 8 > /proc/irq/${USB3}/smp_affinity
        # echo 8 > /proc/irq/${USB4}/smp_affinity
}

set_affinity() {
        AFFINITY_CPUS=$1
        COMMAND_NAME=$2

        echo "Setting CPU affinity for all $COMMAND_NAME threads to CPU $AFFINITY_CPUS"
        for p in `ps -eLf | grep -i $COMMAND_NAME | grep -v grep | awk '{print $4}'`
        do
                $TASKSET -cp $AFFINITY_CPUS $p
        done
}

make_nice() {
        NICE_LEVEL=$1
        COMMAND_NAME=$2

        echo "Setting all $COMMAND_NAME threads to niceness level $NICE_LEVEL"
        for p in `ps -eLf | grep $COMMAND_NAME | grep -v grep | awk '{print $4}'`
        do
                $RENICE $NICE_LEVEL $p
        done
}

tune_up() {
        # Put CPU into Performance Mode
        # echo "Placing Printer CPU into Performance mode with fixed frequency"
        # $CPUFREQSET -g performance
        # $CPUFREQSET -d 1.10Ghz
        # $CPUFREQINFO

        # Isolate Klipper from xindi and mjpg-streamer
        echo "\nIsolating klipper from qd-q2-client, mjpg_streamer, moonraker, and nginx\n"
        set_affinity 0 /home/mks/QD_Q2/bin/client
        set_affinity 0 ustreamer
        set_affinity 0 nginx
        set_affinity 0 moonraker
        set_affinity 1-2 klippy

        set_irq_affinity

        # Set Niceness of qd-q2-client and mjpg_streamer
        echo "\nSetting niceness of qd-q2-client, mjpg_streamer, nginx\n"
        make_nice 1 /home/mks/QD_Q2/bin/client
        make_nice 1 nginx
        make_nice 2 ustreamer
}

tune_down() {
        # Put CPU into ondemand Mode
        # echo "Placing Printer CPU into default ondemand and frequency scaling mode"
        # $CPUFREQSET -g ondemand
        # $CPUFREQSET -d 408Mhz
        # $CPUFREQINFO

        # Unisolate Klipper, xindi, nginx, moonraker, and ustreamer
        echo "Resetting klipper/ustreamer/client/nginx/moonraker tuning to system default"
        set_affinity 0-3 /home/mks/QD_Q2/bin/client
        set_affinity 0-3 klippy
        set_affinity 0-3 ustreamer
        set_affinity 0-3 nginx
        set_affinity 0-3 moonraker

        echo "Resetting niceness of qd-q2-client, ustreamer, nginx to system default"
        make_nice 0 /home/mks/QD_Q2/bin/client
        make_nice 0 ustreamer
        make_nice 0 nginx
}

case "$1" in
        start)
                sleep 30        # Wait for all the main printer processes to start up
                tune_up
                ;;

        reload)
                tune_up
                ;;
        stop)
                tune_down
                ;;
        *)
                exit 0
                ;;
esac

exit 0

et le service systemd (/etc/systemd/system/makerbase-tuning.service) :

Citation

[Unit]
Description=Makerbase-Tuning
After=moonraker.service
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=3
ExecStart=bash /home/mks/QD_Q2/bin/tuning.sh start

[Install]
WantedBy=multi-user.target

En plus, mais je n'en suis pas certain, je pense que les firmwares ont été reflashé (klipper.bin et klipper_THR.bin tous deux datés du 10/10/2025).

Le service algo_app est aussi modifié :

Citation

[Unit]
Description=Start algo_app
After=network.target moonraker.service

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/usr/local/bin/algo_app/main
WorkingDirectory=/usr/local/bin/algo_app
Restart=always
RestartSec=15
MemoryHigh=200M
MemoryMax=250M
User=root
Group=root
Environment=PYTHONPATH=/usr/local/bin/algo_app
Environment=LD_LIBRARY_PATH=/usr/local/bin/algo_app/_internal/lib

Nice=19
CPUSchedulingPolicy=other
#CPUQuota=90%
CPUAffinity=3

# 确保工作目录存在并有正确的权限
ExecStartPre=/bin/mkdir -p /usr/local/bin/algo_app/video_output
ExecStartPre=/bin/mkdir -p /var/log/algo_app
ExecStartPre=/bin/chown -R root:root /usr/local/bin/algo_app
ExecStartPre=/bin/chmod -R 775 /usr/local/bin/algo_app

🙂 

 

  • J'aime 1
Posté(e)
Le 16/10/2025 at 11:22, tranbert a dit :

je pensais forcer un fliesytem check au reboot,

As-tu essayé en ajoutant à la racine du système, un fichier nommé forcefsck :

sudo touch /forcefsck

ou

sudo > /forcefsck

Extrait du /etc/init.d/checkroot.sh :

Citation

_want_force_fsck () {
        case "$(findmnt -n -o FSTYPE /)" in
        # Only ext* file systems support `-f' option to fsck. See #686895
        (ext*)
                [ -f /forcefsck ] || grep -q -s -w -i "forcefsck" /proc/cmdline
                ;;
        (*)
                return 1
                ;;
        esac
}

 

Au redémarrage suivant, une vérification forcée du système devrait avoir lieu.

🙂 

Posté(e) (modifié)
il y a 9 minutes, fran6p a dit :

Au redémarrage suivant, une vérification forcée du système devrait avoir lieu.

Ha oui bonne idée merci. Dès que j'ai fini d'imprimer les trucs pour mon fils, je teste.

Au pire, qu'est-ce qui peut se passer ? Un filesystem illisible ? Même pas peur. ☠️

(j'aurais bien aimé une console serie quand même)

Modifié (le) par tranbert
Posté(e)
il y a 6 minutes, tranbert a dit :

qu'est-ce qui peut se passer ?

Au pire : rien, au mieux : réparation du système 😉.

Lis le fichier init (checkroot.sh) pour voir ce qu'il fait 😉, j'espère simplement qu'il se lance bien, car le système d'init utilise plutôt systemd 🙄.

 

Posté(e)
il y a 57 minutes, fran6p a dit :

Au redémarrage suivant, une vérification forcée du système devrait avoir lieu.

Aurait pu...  Le fichier a disparu au reboot, mais ce n'est pas mieux... Et le log dans /var/log/fsck ne bouge pas

Warning!  /dev/mmcblk0p6 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
/dev/mmcblk0p6 contains a file system with errors, check forced.

Je vais creuser côté systemd

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant
  • Sur cette page :   0 membre est en ligne

    • Aucun utilisateur enregistré regarde cette page.
  • YouTube / Les Imprimantes 3D .fr

×
×
  • Créer...