TUTORIEL COMPLET : COMPILATION DU PATCH I2S POUR RADXA ZERO 3W (NOYAU 6.18) ============================================================================== Ce guide vous permet de recompiler le pilote officiel 'rockchip_i2s_tdm.c' (1436 lignes) avec le correctif forçant le format onde carrée (I2S standard) et l'activation du Runtime PM. Part one ====================================================================== TUTORIEL OFFICIEL : FIXATION I2S RADXA ZERO 3W (NOYAU 6.18.45) ====================================================================== ÉTAPES DE COMPILATION DU VRAI PILOTE COMPLET AVEC LE PATCH DE L'ONDE CARRÉE ---------------------------------------------------------------------- Étape 1 : Préparation du système et installation des dépendances ---------------------------------------------------------------------- Connectez-vous en SSH à votre Radxa Zero 3W et exécutez ces commandes : apt update && apt install -y build-essential linux-headers-current-rockchip64 mkdir -p /root/build_audio_perfect cd /root/build_audio_perfect ---------------------------------------------------------------------- Étape 2 : Téléchargement du VRAI code source officiel complet ---------------------------------------------------------------------- Copiez et collez ce bloc entier dans votre terminal. L'utilisation des guillemets et de variables empêche la console SSH de couper l'adresse : URL_C="https://raw.githubusercontent.com/torvalds/linux/v6.18/sound/soc/rockchip/rockchip_i2s_tdm.c" URL_H="https://raw.githubusercontent.com/torvalds/linux/v6.18/sound/soc/rockchip/rockchip_i2s_tdm.h" curl -sL "$URL_C" -o rockchip_i2s_tdm.c curl -sL "$URL_H" -o rockchip_i2s_tdm.h Afin de vérifier que le téléchargement a réussi et que le fichier contient le vrai pilote complet de 1500 lignes, tapez : wc -l rockchip_i2s_tdm.c ---------------------------------------------------------------------- Étape 3 : Application du Patch chirurgical (Onde Carrée I2S) ---------------------------------------------------------------------- Exécutez cette commande automatique pour injecter le forçage des registres I2S standard à l'endroit idéal dans la fonction hw_params : sed -i '/if (i2s_tdm->clk_trcm == TRCM_TXONLY)/i \tif (slots == 2) {\n\t\tregmap_update_bits(i2s_tdm->regmap, I2S_TXCR, I2S_TXCR_TDM_MODE_MASK, I2S_TXCR_TDM_MODE_I2S);\n\t\tregmap_update_bits(i2s_tdm->regmap, I2S_RXCR, I2S_RXCR_TDM_MODE_MASK, I2S_TXCR_TDM_MODE_I2S);\n\t\tlrck_div = slots * slot_width;\n\t}\n' rockchip_i2s_tdm.c ---------------------------------------------------------------------- Étape 4 : Création du Makefile (via nano) ---------------------------------------------------------------------- Ouvrez l'éditeur de texte nano : nano Makefile Copiez et collez le bloc suivant. ATTENTION : Les lignes sous "all:" et "clean:" DOIVENT impérativement commencer par une TABULATION (Touche Tab) ! obj-m += snd-soc-rockchip-i2s-tdm.o snd-soc-rockchip-i2s-tdm-objs := rockchip_i2s_tdm.o all: make -C /lib/modules/6.18.45-current-rockchip64/build M=/root/build_audio_perfect modules clean: make -C /lib/modules/6.18.45-current-rockchip64/build M=/root/build_audio_perfect clean Sauvegardez et quittez : CTRL+O, Entrée, puis CTRL+X. ---------------------------------------------------------------------- Étape 5 : Compilation et Installation Prioritaire ---------------------------------------------------------------------- Exécutez ces commandes pour compiler le pilote officiel modifié et l'enregistrer dans la zone prioritaire (updates) de votre noyau : make mkdir -p /lib/modules/6.18.45-current-rockchip64/updates/ cp snd-soc-rockchip-i2s-tdm.ko /lib/modules/6.18.45-current-rockchip64/updates/ depmod -a Redémarrez enfin votre Radxa Zero 3W : reboot ====================================================================== FIN DU TUTORIEL ====================================================================== Part two ------------------------------------------------------------------------------ ÉTAPE 1 : PRÉPARATION ET NETTOYAGE DU RÉPERTOIRE ------------------------------------------------------------------------------ Connectez-vous en SSH à votre Radxa Zero 3W et exécutez : mkdir -p /root/build_audio_perfect cd /root/build_audio_perfect make clean 2>/dev/null || true rm -f rockchip_i2s_tdm.c ------------------------------------------------------------------------------ ÉTAPE 2 : TÉLÉCHARGEMENT DU CODE SOURCE OFFICIEL COMPLET ------------------------------------------------------------------------------ Exécutez ce bloc pour récupérer le pilote de 1436 lignes sans coupure d'URL : URL_C="https://raw.githubusercontent.com/torvalds/linux/v6.18/sound/soc/rockchip/rockchip_i2s_tdm.c" curl -sL "$URL_C" -o rockchip_i2s_tdm.c Vérification de la taille du fichier (doit afficher 1436) : wc -l rockchip_i2s_tdm.c ------------------------------------------------------------------------------ ÉTAPE 3 : APPLICATION DU PATCH DANS NANO ------------------------------------------------------------------------------ Ouvrez le fichier avec Nano : nano rockchip_i2s_tdm.c 1. Utilisez CTRL+W et cherchez : rockchip_i2s_tdm_hw_params 2. Descendez tout en bas de cette fonction (juste avant la ligne 'return rockchip_i2s_io_multiplex(substream, dai);'). 3. Insérez le bloc suivant : /* ================================================================= */ /* INTERCEPTION MAJEURE ET ALIGNEMENT ALGORITHMIQUE DES HORLOGES */ /* ================================================================= */ if (params_channels(params) == 2) { /* 1. Force le format onde carrée standard I2S (Phillips) */ regmap_update_bits(i2s_tdm->regmap, I2S_TXCR, I2S_TXCR_TFS_MASK, I2S_TXCR_TFS_I2S); regmap_update_bits(i2s_tdm->regmap, I2S_RXCR, I2S_RXCR_TFS_MASK, I2S_TXCR_TFS_I2S); /* 2. Synchro matérielle stricte : Fusion physique du RX sur le TX */ regmap_update_bits(i2s_tdm->regmap, I2S_CKR, I2S_CKR_TRCM_MASK, I2S_CKR_TRCM_TXONLY); /* 3. Forçage du ratio BCLK strict à 64fs pour le mode 32 bits */ regmap_update_bits(i2s_tdm->regmap, I2S_CKR, I2S_CKR_BJD_MASK, I2S_CKR_BJD_DISABLE); /* 4. Repositionnement de la racine MCLK à 11.2896 MHz pour le 44.1 kHz */ if (!IS_ERR(i2s_tdm->mclk_tx)) { clk_set_rate(i2s_tdm->mclk_tx, 11289600); } if (!IS_ERR(i2s_tdm->mclk_rx)) { clk_set_rate(i2s_tdm->mclk_rx, 11289600); } } /* ================================================================= */ 4. Cherchez ensuite la fonction : rockchip_i2s_tdm_probe (tout en bas du fichier). 5. Trouvez la ligne suivante : pm_runtime_enable(&pdev->dev); 6. Remplacez-la par ces deux lignes pour forcer le réveil électrique continu : /* ================================================================= */ /* ALIMENTATION CONTINU ET RE-ROUTAGE PARENT MATÉRIEL DES CLOCKS */ /* ================================================================= */ pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_get_noresume(&pdev->dev); /* Maintien éveillé permanent */ /* Fusionne l'arbre des horloges RX et TX dès le chargement du pilote */ if (!IS_ERR(i2s_tdm->mclk_rx) && !IS_ERR(i2s_tdm->mclk_tx)) { struct clk *parent_tx = clk_get_parent(i2s_tdm->mclk_tx); if (parent_tx) { clk_set_parent(i2s_tdm->mclk_rx, parent_tx); } } /* ================================================================= */ 7. Sauvegardez et quittez (CTRL+O, Entrée, CTRL+X). ------------------------------------------------------------------------------ ÉTAPE 4 : CRÉATION DU MAKEFILE ------------------------------------------------------------------------------ Ouvrez Nano pour créer le Makefile : nano Makefile Collez le contenu exact suivant (attention, les lignes 'make' doivent commencer par une vraie TABULATION) : obj-m += snd-soc-rockchip-i2s-tdm.o snd-soc-rockchip-i2s-tdm-objs := rockchip_i2s_tdm.o all: make -C /lib/modules/6.18.45-current-rockchip64/build M=/root/build_audio_perfect modules clean: make -C /lib/modules/6.18.45-current-rockchip64/build M=/root/build_audio_perfect clean Sauvegardez et quittez (CTRL+O, Entrée, CTRL+X). ------------------------------------------------------------------------------ ÉTAPE 5 : COMPILATION ET DÉPLOIEMENT PRIORITAIRE ------------------------------------------------------------------------------ Exécutez les commandes de build et d'installation : make mkdir -p /lib/modules/6.18.45-current-rockchip64/updates/ cp snd-soc-rockchip-i2s-tdm.ko /lib/modules/6.18.45-current-rockchip64/updates/ depmod -a reboot ------------------------------------------------------------------------------ ÉTAPE 6 : TEST DE LA BROCHE 35 AU REDÉMARRAGE ------------------------------------------------------------------------------ Une fois la Radxa redémarrée avec sa carte Waveshare branchée : 1. Vérifiez le statut d'alimentation (doit être 'active') : cat /sys/bus/platform/devices/*.i2s/power/runtime_status 2. Lancez le flux de test ALSA : speaker-test -D hw:PCM5122I2S -c 2 -r 44100 -F S32_LE -t pink & 3. Pour contrôler les horloges cat /sys/kernel/debug/clk/clk_summary | grep -E 'i2s3|i2s3_2ch|aclk_i2s3'