{"id":347,"date":"2025-04-10T18:19:42","date_gmt":"2025-04-10T18:19:42","guid":{"rendered":"https:\/\/tolva.fr\/?p=347"},"modified":"2025-04-10T18:19:42","modified_gmt":"2025-04-10T18:19:42","slug":"quelques-mots-sur-les-fichiers-de-mise-a-jour-android","status":"publish","type":"post","link":"https:\/\/tolva.fr\/index.php\/2025\/04\/10\/quelques-mots-sur-les-fichiers-de-mise-a-jour-android\/","title":{"rendered":"Quelques mots sur les fichiers de mise \u00e0 jour Android"},"content":{"rendered":"\n<p>Dans l&rsquo;article pr\u00e9c\u00e9dent on a vu que rooter un t\u00e9l\u00e9phone Android avec magisk impliquait de t\u00e9l\u00e9charger le firmware du t\u00e9l\u00e9phone avant d&rsquo;en modifier une partie.<\/p>\n\n\n\n<p>Mais que contient ce firmware au juste ?<\/p>\n\n\n\n<p>Pour donner quelques \u00e9l\u00e9ments de r\u00e9ponse, t\u00e9l\u00e9chargeons-le firmware d&rsquo;un pixel 7A (sur <a href=\"https:\/\/developers.google.com\" data-type=\"link\" data-id=\"https:\/\/developers.google.com\">https:\/\/developers.google.com<\/a>) et examinons son contenu.<\/p>\n\n\n\n<p>Le firmware en question se pr\u00e9sente sous la forme d&rsquo;un fichier zip d&rsquo;un point moins de 3Go que l&rsquo;on peut d\u00e9compresser :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:~\/articles\/android_root_magisk$ ls -l *zip\n-rw-r--r-- 1 thomas thomas 2971991323 16 mars   2024 lynx-ap1a.240305.019.a1-factory-7f7dfec6.zip<\/code><\/pre>\n\n\n\n<p>Une fois d\u00e9compress\u00e9, on trouve deux fichiers img, des scripts et un autre zip :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1$ ls -l\ntotal 2919252\n-rw-r--r-- 1 thomas thomas   14663432 22 f\u00e9vr.  2024 bootloader-lynx-lynx-14.4-11290827.img\n-rw-r--r-- 1 thomas thomas        993 22 f\u00e9vr.  2024 flash-all.bat\n-rwxr-xr-x 1 thomas thomas       1110 22 f\u00e9vr.  2024 flash-all.sh\n-rwxr-xr-x 1 thomas thomas       1057 22 f\u00e9vr.  2024 flash-base.sh\n-rw-r--r-- 1 thomas thomas 2892830617 22 f\u00e9vr.  2024 image-lynx-ap1a.240305.019.a1.zip\n-rw-r--r-- 1 thomas thomas   81797260 22 f\u00e9vr.  2024 radio-lynx-g5300q-231218-240202-b-11396366.img<\/code><\/pre>\n\n\n\n<p>Regardons le script <code>flash-all.sh<\/code> pour se faire une id\u00e9e du r\u00f4le de ces diff\u00e9rents fichiers :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>(...)\nfastboot flash bootloader bootloader-lynx-lynx-14.4-11290827.img\nfastboot reboot-bootloader\nsleep 5\nfastboot flash radio radio-lynx-g5300q-231218-240202-b-11396366.img\nfastboot reboot-bootloader\nsleep 5\nfastboot -w update image-lynx-ap1a.240305.019.a1.zip<\/code><\/pre>\n\n\n\n<p>Un petit coup d&rsquo;oeil au <code>help<\/code> de <code>fastboot<\/code> nous apprend que <\/p>\n\n\n\n<p><code>fastboot flash &lt;partition> &lt;fichier><\/code><\/p>\n\n\n\n<p> \u00e9crit le fichier <code>&lt;fichier><\/code> sur la partition <code>&lt;partition><\/code>.<\/p>\n\n\n\n<p>Ainsi, ce script met \u00e0 jour la partition <code>bootloader<\/code> avec le fichier <\/p>\n\n\n\n<p><code>bootloader-lynx-lynx-14.4-11290827.img<\/code>, <\/p>\n\n\n\n<p>la partition <code>radio<\/code> avec <\/p>\n\n\n\n<p><code>radio-lynx-g5300q-231218-240202-b-11396366.img<\/code>, <\/p>\n\n\n\n<p>puis les autres partitions avec le contenu de <\/p>\n\n\n\n<p><code>image-lynx-ap1a.240305.019.a1.zip<\/code>.<\/p>\n\n\n\n<p>D\u00e9zippons maintenant <code>image-lynx-ap1a.240305.019.a1.zip<\/code> :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1$ ls -l\ntotal 8436988\n-rw-r--r-- 1 thomas thomas    1646592  1 janv.  2009 abl.img\n-rw-r--r-- 1 thomas thomas        168  1 janv.  2009 android-info.txt\n-rw-r--r-- 1 thomas thomas      12288  1 janv.  2009 bl1.img\n-rw-r--r-- 1 thomas thomas     536576  1 janv.  2009 bl2.img\n-rw-r--r-- 1 thomas thomas      94208  1 janv.  2009 bl31.img\n-rw-r--r-- 1 thomas thomas   67108864  1 janv.  2009 boot.img\n-rw-r--r-- 1 thomas thomas   14663432 22 f\u00e9vr.  2024 bootloader-lynx-lynx-14.4-11290827.img\n-rw-r--r-- 1 thomas thomas   16777216  1 janv.  2009 dtbo.img\n-rw-r--r-- 1 thomas thomas        407  1 janv.  2009 fastboot-info.txt\n-rw-r--r-- 1 thomas thomas        993 22 f\u00e9vr.  2024 flash-all.bat\n-rwxr-xr-x 1 thomas thomas       1110 22 f\u00e9vr.  2024 flash-all.sh\n-rwxr-xr-x 1 thomas thomas       1057 22 f\u00e9vr.  2024 flash-base.sh\n-rw-r--r-- 1 thomas thomas     315392  1 janv.  2009 gsa.img\n-rw-r--r-- 1 thomas thomas 2892830617 22 f\u00e9vr.  2024 image-lynx-ap1a.240305.019.a1.zip\n-rw-r--r-- 1 thomas thomas    8388608  1 janv.  2009 init_boot.img\n-rw-r--r-- 1 thomas thomas    2392064  1 janv.  2009 ldfw.img\n-rw-r--r-- 1 thomas thomas   81797120  1 janv.  2009 modem.img\n-rw-r--r-- 1 thomas thomas      40960  1 janv.  2009 pbl.img\n-rw-r--r-- 1 thomas thomas 3270004736  1 janv.  2009 product.img\n-rw-r--r-- 1 thomas thomas    1048576  1 janv.  2009 pvmfw.img\n-rw-r--r-- 1 thomas thomas   81797260 22 f\u00e9vr.  2024 radio-lynx-g5300q-231218-240202-b-11396366.img\n-rw-r--r-- 1 thomas thomas       5184  1 janv.  2009 super_empty.img\n-rw-r--r-- 1 thomas thomas     348160  1 janv.  2009 system_dlkm.img\n-rw-r--r-- 1 thomas thomas  276996096  1 janv.  2009 system_ext.img\n-rw-r--r-- 1 thomas thomas  946470912  1 janv.  2009 system.img\n-rw-r--r-- 1 thomas thomas   18255872  1 janv.  2009 system_other.img\n-rw-r--r-- 1 thomas thomas    6967296  1 janv.  2009 tzsw.img\n-rw-r--r-- 1 thomas thomas      12288  1 janv.  2009 vbmeta.img\n-rw-r--r-- 1 thomas thomas       8192  1 janv.  2009 vbmeta_system.img\n-rw-r--r-- 1 thomas thomas       4096  1 janv.  2009 vbmeta_vendor.img\n-rw-r--r-- 1 thomas thomas   67108864  1 janv.  2009 vendor_boot.img\n-rw-r--r-- 1 thomas thomas   53944320  1 janv.  2009 vendor_dlkm.img\n-rw-r--r-- 1 thomas thomas  762724352  1 janv.  2009 vendor.img\n-rw-r--r-- 1 thomas thomas   67108864  1 janv.  2009 vendor_kernel_boot.img<\/code><\/pre>\n\n\n\n<p>L&rsquo;essentiel des fichiers obtenus sont des fichiers img, d&rsquo;autres images de partition, donc.<\/p>\n\n\n\n<p>\u00c0 ce stade il est int\u00e9ressant de regardons ce que dit la documentation<\/p>\n\n\n\n<p>(<a href=\"https:\/\/source.android.com\/docs\/core\/architecture\/partitions?hl=fr\" data-type=\"link\" data-id=\"https:\/\/source.android.com\/docs\/core\/architecture\/partitions?hl=fr\">https:\/\/source.android.com\/docs\/core\/architecture\/partitions?hl=fr<\/a>) sur les partitions standards d&rsquo;un syst\u00e8me android :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>La partition <code>boot<\/code>, qui contient une image noyau.<\/li>\n\n\n\n<li>La partition <code>init_boot<\/code>, qui contient un ramdisk initial (comparable \u00e0 l&rsquo;initramfs sur une machine Linux). Cette partition n&rsquo;existait pas avant Android 13, le ramdisk \u00e9tant alors inclus dans la partition <code>boot<\/code>.<\/li>\n\n\n\n<li>La partition <code>system<\/code>, qui contient le syst\u00e8me Android.<\/li>\n\n\n\n<li>La partition <code>radio<\/code>, contenant l&rsquo;image radio du terminal.<\/li>\n<\/ul>\n\n\n\n<p>Cette liste est loin d&rsquo;\u00eatre exhaustive.<\/p>\n\n\n\n<p>Une grande partie des fichiers img sont des syst\u00e8mes de fichiers ext2, ou bien des fichiers bootimg :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1$ file *\nabl.img:                                        MPEG-4 LOAS\nandroid-info.txt:                               ASCII text\nbl1.img:                                        data\nbl2.img:                                        data\nbl31.img:                                       data\nboot.img:                                       Android bootimg, kernel\nbootloader-lynx-lynx-14.4-11290827.img:         data\ndtbo.img:                                       data\nfastboot-info.txt:                              ASCII text\nflash-all.bat:                                  DOS batch file, ASCII text\nflash-all.sh:                                   POSIX shell script, ASCII text executable\nflash-base.sh:                                  POSIX shell script, ASCII text executable\ngsa.img:                                        data\nimage-lynx-ap1a.240305.019.a1.zip:              Zip archive data, at least v2.0 to extract\ninit_boot.img:                                  Android bootimg\nldfw.img:                                       data\nmodem.img:                                      POSIX tar archive (GNU)\npbl.img:                                        data\nproduct.img:                                    Linux rev 1.0 ext2 filesystem data, UUID=02451e5a-f7eb-5fb1-abde-8e2050760baf, volume name \"product\" (extents) (large files) (huge files)\npvmfw.img:                                      Android bootimg, kernel\nradio-lynx-g5300q-231218-240202-b-11396366.img: data\nsuper_empty.img:                                data\nsystem_dlkm.img:                                Linux rev 1.0 ext2 filesystem data, UUID=84fcdd28-c7df-5da1-8a4e-a6a463236cad, volume name \"system_dlkm\" (extents) (large files) (huge files)\nsystem_ext.img:                                 Linux rev 1.0 ext2 filesystem data, UUID=325c0af1-f051-5882-bd0f-3b06c21874ca, volume name \"system_ext\" (extents) (large files) (huge files)\nsystem.img:                                     Linux rev 1.0 ext2 filesystem data, UUID=4b7c82c5-b85c-542a-8564-855173ebc983 (extents) (large files) (huge files)\nsystem_other.img:                               Linux rev 1.0 ext2 filesystem data, UUID=22b4799e-cbd3-536a-b6b1-90ae8580012e, volume name \"system\" (extents) (large files) (huge files)\ntzsw.img:                                       JSON data\nvbmeta.img:                                     data\nvbmeta_system.img:                              data\nvbmeta_vendor.img:                              data\nvendor_boot.img:                                data\nvendor_dlkm.img:                                Linux rev 1.0 ext2 filesystem data, UUID=8ca5a762-6bce-50ac-86ed-73386405c80c, volume name \"vendor_dlkm\" (extents) (large files) (huge files)\nvendor.img:                                     Linux rev 1.0 ext2 filesystem data, UUID=7c64135c-a38f-5da1-a0a6-5b42ab72c07f, volume name \"vendor\" (extents) (large files) (huge files)\nvendor_kernel_boot.img:                         data<\/code><\/pre>\n\n\n\n<p>D\u00e9plions quelques-uns des images de partition pour voir ce qu&rsquo;elles contiennent :<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Partitions boot et init_boot<\/strong><\/h4>\n\n\n\n<p>Le fichier <code>boot.img<\/code> est un Android bootimg qui contient un noyau :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1$ file boot.img \nboot.img: Android bootimg, kernel\nthomas@ankou:~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1$ ls -l boot.img \n-rw-r--r-- 1 thomas thomas 67108864  1 janv.  2009 boot.img<\/code><\/pre>\n\n\n\n<p>Le fichier <code>init_boot.img<\/code> est lui aussi fichier Android bootimg :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1$ file init_boot.img \ninit_boot.img: Android bootimg\nthomas@ankou:~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1$ ls -l init_boot.img \n-rw-r--r-- 1 thomas thomas 8388608  1 janv.  2009 init_boot.img<\/code><\/pre>\n\n\n\n<p>Pour <em>d\u00e9plier<\/em> <code>boot.img<\/code> et <code>init_boot.img<\/code>, nous allons utiliser le projet <\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/LineageOS\/android_system_tools_mkbootimg\" data-type=\"link\" data-id=\"https:\/\/github.com\/LineageOS\/android_system_tools_mkbootimg\">https:\/\/github.com\/LineageOS\/android_system_tools_mkbootimg<\/a>:<\/p>\n\n\n\n<p>Comment cet outil fonctionne-t-il ? :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop$ .\/android_system_tools_mkbootimg\/unpack_bootimg.py \nusage: unpack_bootimg.py &#91;-h] --boot_img BOOT_IMG &#91;--out OUT] &#91;--format {info,mkbootimg}] &#91;-0]\nunpack_bootimg.py: error: the following arguments are required: --boot_img<\/code><\/pre>\n\n\n\n<p>On r\u00e9alise un unpack du fichier <code>boot.img<\/code> dans le r\u00e9pertoire <code>output<\/code> :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop$ .\/android_system_tools_mkbootimg\/unpack_bootimg.py --boot ~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1\/boot.img --out .\/output\/\nboot magic: ANDROID!\nkernel_size: 24954449\nramdisk size: 0\nos version: None\nos patch level: None\nboot image header version: 4\ncommand line args: \nboot.img signature size: 0<\/code><\/pre>\n\n\n\n<p>Le r\u00e9pertoire <code>output<\/code> contient un fichier <code>ramdisk<\/code> vide et un fichier <code>kernel<\/code> :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop$ ls -l output\/\ntotal 24372\n-rw-r--r-- 1 thomas thomas 24954449 11 mars  20:03 kernel\n-rw-r--r-- 1 thomas thomas        0 11 mars  20:03 ramdisk<\/code><\/pre>\n\n\n\n<p>Obtenir un r\u00e9pertoire contenant un ramdisk vide est coh\u00e9rent avec ce que la documentation expliquait \u00e0 propos de la partition <code>boot<\/code>.<\/p>\n\n\n\n<p>Examinons le contenu du r\u00e9pertoire :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop$ file output\/*\noutput\/kernel:  LZ4 compressed data (v0.1-v0.9)\noutput\/ramdisk: empty<\/code><\/pre>\n\n\n\n<p>Le fichier <code>kernel<\/code> est compress\u00e9 avec LZ4. D\u00e9compressons-le :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output$ lz4 -d kernel kernel.uncompressed\nkernel               : decoded 51685888 bytes<\/code><\/pre>\n\n\n\n<p>Le fichier obtenu est, on s&rsquo;y attendait, une image noyau :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output$ file kernel.uncompressed \nkernel.uncompressed: Linux kernel ARM64 boot executable Image, little-endian, 4K pages<\/code><\/pre>\n\n\n\n<p>R\u00e9alisons maintenant l&rsquo;unpack de <code>init_boot.img<\/code> :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop$ .\/android_system_tools_mkbootimg\/unpack_bootimg.py --boot ~\/articles\/android_root_magisk\/lynx-ap1a.240305.019.a1\/init_boot.img --out .\/output\/\nboot magic: ANDROID!\nkernel_size: 0\nramdisk size: 2332279\nos version: None\nos patch level: None\nboot image header version: 4\ncommand line args: \nboot.img signature size: 0<\/code><\/pre>\n\n\n\n<p>Inversement \u00e0 <code>boot.img<\/code>, et comme attendu, il contient un fichier <code>kernel<\/code> vide et un fichier <code>ramdisk<\/code> :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop$ ls -l output\/\ntotal 2280\n-rw-r--r-- 1 thomas thomas       0 11 mars  20:22 kernel\n-rw-r--r-- 1 thomas thomas 2332279 11 mars  20:22 ramdisk<\/code><\/pre>\n\n\n\n<p>Comme auparavant, ce fichier ramdisk contient des donn\u00e9es compress\u00e9es avec LZ4 :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop$ file output\/*\noutput\/kernel:  empty\noutput\/ramdisk: LZ4 compressed data (v0.1-v0.9)<\/code><\/pre>\n\n\n\n<p>D\u00e9compressons-le :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output$ lz4 -d ramdisk ramdisk.uncompressed\nramdisk              : decoded 4398080 bytes<\/code><\/pre>\n\n\n\n<p>On obtient une archive cpio :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output$ file ramdisk.uncompressed \nramdisk.uncompressed: ASCII cpio archive (SVR4 with no CRC)<\/code><\/pre>\n\n\n\n<p>Que l&rsquo;on d\u00e9compresse \u00e9galement :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output$ sudo cpio -i -F ramdisk.uncompressed \n8590 blocs<\/code><\/pre>\n\n\n\n<p>Examinons le contenu du ramdisk :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output$ ls\ndebug_ramdisk  dev  first_stage_ramdisk  init  kernel  metadata  mnt  proc  ramdisk  ramdisk.uncompressed  second_stage_resources  sys  system<\/code><\/pre>\n\n\n\n<p>Hormis les fichiers <code>ramdisk<\/code>, <code>ramdisk.uncompressed<\/code> et <code>kernel<\/code>, on obtient un syst\u00e8me de fichier minimaliste de d\u00e9marrage :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output$ ls -l\ntotal 9732\ndrwxr-xr-x 2 root   root      4096 11 mars  20:49 debug_ramdisk\ndrwxr-xr-x 2 root   root      4096 11 mars  20:49 dev\ndrwxr-xr-x 9 root   root      4096 11 mars  20:49 first_stage_ramdisk\n-rwxr-x--- 1 root   root   3192656 11 mars  20:49 init\n-rw-r--r-- 1 thomas thomas       0 11 mars  20:22 kernel\ndrwxr-xr-x 2 root   root      4096 11 mars  20:49 metadata\ndrwxr-xr-x 2 root   root      4096 11 mars  20:49 mnt\ndrwxr-xr-x 2 root   root      4096 11 mars  20:49 proc\ndrwxr-xr-x 2 root   root      4096 11 mars  20:49 second_stage_resources\ndrwxr-xr-x 2 root   root      4096 11 mars  20:49 sys\ndrwxr-xr-x 4 root   root      4096 11 mars  20:49 system<\/code><\/pre>\n\n\n\n<p>Voici l&rsquo;arborescence de ce ramdisk :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/plop\/output# sudo tree\n.\n\u251c\u2500\u2500 debug_ramdisk\n\u251c\u2500\u2500 dev\n\u2502   \u251c\u2500\u2500 console\n\u2502   \u251c\u2500\u2500 null\n\u2502   \u2514\u2500\u2500 urandom\n\u251c\u2500\u2500 first_stage_ramdisk\n\u2502   \u251c\u2500\u2500 debug_ramdisk\n\u2502   \u251c\u2500\u2500 dev\n\u2502   \u251c\u2500\u2500 metadata\n\u2502   \u251c\u2500\u2500 mnt\n\u2502   \u251c\u2500\u2500 proc\n\u2502   \u251c\u2500\u2500 second_stage_resources\n\u2502   \u2514\u2500\u2500 sys\n\u251c\u2500\u2500 init\n\u251c\u2500\u2500 metadata\n\u251c\u2500\u2500 mnt\n\u251c\u2500\u2500 proc\n\u251c\u2500\u2500 second_stage_resources\n\u251c\u2500\u2500 sys\n\u2514\u2500\u2500 system\n    \u251c\u2500\u2500 bin\n    \u2502   \u251c\u2500\u2500 snapuserd -> snapuserd_ramdisk\n    \u2502   \u2514\u2500\u2500 snapuserd_ramdisk\n    \u2514\u2500\u2500 etc\n        \u251c\u2500\u2500 init\n        \u2502   \u2514\u2500\u2500 snapuserd.rc\n        \u2514\u2500\u2500 ramdisk\n            \u2514\u2500\u2500 build.prop<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Quelques mots sur init et le d\u00e9marrage<\/strong><\/h4>\n\n\n\n<p>Jetons un coup d&rsquo;oeil \u00e0 la page <\/p>\n\n\n\n<p><a href=\"https:\/\/android.googlesource.com\/platform\/system\/core\/+\/master\/init\/README.md\" data-type=\"link\" data-id=\"https:\/\/android.googlesource.com\/platform\/system\/core\/+\/master\/init\/README.md\">https:\/\/android.googlesource.com\/platform\/system\/core\/+\/master\/init\/README.md<\/a>,<\/p>\n\n\n\n<p>qui pr\u00e9cise le r\u00f4le des fichiers *rc et donne quelques explications sur la cin\u00e9matique du boot.<\/p>\n\n\n\n<p>TL;DR :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>init<\/code> est le premier processus ex\u00e9cut\u00e9 lors du d\u00e9marrage.<\/li>\n\n\n\n<li>En r\u00e9alit\u00e9, sur un Android r\u00e9cent, 3 <code>init<\/code> diff\u00e9rents sont ex\u00e9cut\u00e9s :\n<ul class=\"wp-block-list\">\n<li>Le premier <code>init<\/code> (contenu dans la partition <code>init_boot<\/code>) r\u00e9alise quelques op\u00e9rations essentielles (montage de <code>\/proc<\/code>, <code>\/dev<\/code>, et montage de la partition <code>system<\/code> sur <code>\/<\/code>)<\/li>\n\n\n\n<li>Le deuxi\u00e8me <code>init<\/code> (conenu dans la partition <code>system<\/code>) est ex\u00e9cut\u00e9 avec l&rsquo;argument <code>selinux_setup<\/code><\/li>\n\n\n\n<li>Le troisi\u00e8me <code>init<\/code>, ex\u00e9cut\u00e9 avec l&rsquo;argument <code>second_stage<\/code>, finalise le d\u00e9marrage<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u00c0 chaque fois qu&rsquo;<code>init<\/code> est lanc\u00e9, certaines des op\u00e9rations qu&rsquo;il r\u00e9alise sont d\u00e9clar\u00e9es dans des fichiers <code>.rc<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Partition system<\/strong><\/h4>\n\n\n\n<p>Montons system.img :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/test\/system$ sudo mount -o loop,ro system.img .\/mnt\/<\/code><\/pre>\n\n\n\n<p>Listons son contenu :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/test\/system\/mnt$ ls -ln\ntotal 120\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 acct\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 apex\nlrw-r--r--.  1    0    0    11  1 janv.  2009 bin -&gt; \/system\/bin\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 bootstrap-apex\nlrw-r--r--.  1    0    0    50  1 janv.  2009 bugreports -&gt; \/data\/user_de\/0\/com.android.shell\/files\/bugreports\nlrw-r--r--.  1    0    0    11  1 janv.  2009 cache -&gt; \/data\/cache\ndr-xr-xr-x.  2    0    0  4096  1 janv.  2009 config\nlrw-r--r--.  1    0    0    17  1 janv.  2009 d -&gt; \/sys\/kernel\/debug\ndrwxrwx--x.  2 1000 1000  4096  1 janv.  2009 data\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 data_mirror\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 debug_ramdisk\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 dev\nlrw-r--r--.  1    0    0    11  1 janv.  2009 etc -&gt; \/system\/etc\nlrwxr-x---.  1    0 2000    16  1 janv.  2009 init -&gt; \/system\/bin\/init\n-rwxr-x---.  1    0 2000   468  1 janv.  2009 init.environ.rc\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 linkerconfig\ndrwx------.  2    0    0 16384  1 janv.  2009 lost+found\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 metadata\ndrwxr-xr-x.  2    0 1000  4096  1 janv.  2009 mnt\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 odm\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 odm_dlkm\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 oem\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 postinstall\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 proc\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 product\nlrw-r--r--.  1    0    0    21  1 janv.  2009 sdcard -&gt; \/storage\/self\/primary\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 second_stage_resources\ndrwxr-x--x.  2    0 1028  4096  1 janv.  2009 storage\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 sys\ndrwxr-xr-x. 12    0    0  4096  1 janv.  2009 system\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 system_dlkm\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 system_ext\ndrwxr-xr-x.  2    0 2000  4096  1 janv.  2009 vendor\ndrwxr-xr-x.  2    0    0  4096  1 janv.  2009 vendor_dlkm<\/code><\/pre>\n\n\n\n<p>On retrouve la m\u00eame arborescence \u00e0 la racine du t\u00e9l\u00e9phone :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>lynx:\/ # ls -ln \/\ntotal 84\ndrwxr-xr-x   2 0    0     4096 2009-01-01 01:00 acct\ndrwxr-xr-x  81 0    0     1660 2025-03-21 21:23 apex\nlrw-r--r--   1 0    0       11 2009-01-01 01:00 bin -&gt; \/system\/bin\ndrwxr-xr-x   9 0    0      220 2025-03-21 21:23 bootstrap-apex\nlrw-r--r--   1 0    0       50 2009-01-01 01:00 bugreports -&gt; \/data\/user_de\/0\/com.android.shell\/files\/bugreports\nlrw-r--r--   1 0    0       11 2009-01-01 01:00 cache -&gt; \/data\/cache\ndrwxr-xr-x   4 0    0        0 2025-03-21 21:23 config\nlrw-r--r--   1 0    0       17 2009-01-01 01:00 d -&gt; \/sys\/kernel\/debug\ndrwxrwx--x  49 1000 1000  4096 2025-03-21 21:23 data\ndrwx------   8 0    1000   160 2025-03-21 21:23 data_mirror\ndrwx--x--x   3 0    0      200 2025-03-21 21:23 debug_ramdisk\ndrwxr-xr-x  24 0    0     6280 2025-03-21 21:23 dev\nlrw-r--r--   1 0    0       11 2009-01-01 01:00 etc -&gt; \/system\/etc\nlrwxr-x---   1 0    2000    16 2009-01-01 01:00 init -&gt; \/system\/bin\/init\n-rwxr-x---   1 0    2000   468 2009-01-01 01:00 init.environ.rc\ndrwxr-xr-x  19 0    0      420 2025-03-21 21:23 linkerconfig\ndrwx------   2 0    0    16384 2009-01-01 01:00 lost+found\ndrwxr-xr-x  13 0    0     4096 2024-06-28 01:09 metadata\ndrwxr-xr-x  15 0    1000   320 2025-03-21 21:23 mnt\ndrwxr-xr-x   2 0    0     4096 2009-01-01 01:00 odm\ndrwxr-xr-x   2 0    0     4096 2009-01-01 01:00 odm_dlkm\ndrwxr-xr-x   2 0    0     4096 2009-01-01 01:00 oem\ndrwxr-xr-x   2 0    0     4096 2009-01-01 01:00 postinstall\ndr-xr-xr-x 919 0    0        0 1970-01-01 01:00 proc\ndrwxr-xr-x  15 0    0     4096 2009-01-01 01:00 product\nlrw-r--r--   1 0    0       21 2009-01-01 01:00 sdcard -&gt; \/storage\/self\/primary\ndrwxr-xr-x   2 0    0     4096 2009-01-01 01:00 second_stage_resources\ndrwx--x---   4 2000 9997    80 2025-03-21 21:23 storage\ndr-xr-xr-x  13 0    0        0 1970-01-01 01:00 sys\ndrwxr-xr-x  12 0    0     4096 2009-01-01 01:00 system\ndrwxr-xr-x   4 0    0     4096 2009-01-01 01:00 system_dlkm\ndrwxr-xr-x  11 0    0     4096 2009-01-01 01:00 system_ext\ndrwxrwx--x   2 2000 2000    60 2025-03-22 14:04 tmp\ndrwxr-xr-x  13 0    2000  4096 2009-01-01 01:00 vendor\ndrwxr-xr-x   5 0    0     4096 2009-01-01 01:00 vendor_dlkm<\/code><\/pre>\n\n\n\n<p>Conclusion : <\/p>\n\n\n\n<p>Le contenu de la partition system, mont\u00e9e \u00e0 la racine, est le contenu du fichier system.img<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Partition vendor<\/strong><\/h4>\n\n\n\n<p>\u00c0 ce stade, tout le monde aura compris l&rsquo;id\u00e9e :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>thomas@ankou:\/tmp\/test\/vendor\/mnt$ ls -l\ntotal 84\ndrwxr-xr-x.  2 root 2000  4096  1 janv.  2009 apex\ndrwxr-x--x.  4 root 2000  4096  1 janv.  2009 bin\n-rw-------.  1 root root  9808  1 janv.  2009 build.prop\ndrwxr-xr-x. 20 root 2000  4096  1 janv.  2009 etc\ndrwxr-xr-x.  7 root 2000  4096  1 janv.  2009 firmware\ndrwxr-xr-x.  3 root 2000  4096  1 janv.  2009 framework\ndrwxr-xr-x.  7 root 2000  8192  1 janv.  2009 lib\ndrwxr-xr-x.  7 root 2000 16384  1 janv.  2009 lib64\ndrwx------.  2 root root 16384  1 janv.  2009 lost+found\ndrwxr-xr-x.  3 root 2000  4096  1 janv.  2009 odm\ndrwxr-xr-x.  3 root 2000  4096  1 janv.  2009 odm_dlkm\ndrwxr-xr-x.  2 root 2000  4096  1 janv.  2009 overlay<\/code><\/pre>\n\n\n\n<p>\u00c0 comparer \u00e0 :<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide has-small-font-size\"><code>lynx:\/vendor # ls -ln\ntotal 92\ndrwxr-xr-x  2 0 2000  4096 2009-01-01 01:00 apex\ndrwxr-x--x  4 0 2000  4096 2009-01-01 01:00 bin\n-rw-------  1 0 0     9815 2009-01-01 01:00 build.prop\ndrwxr-xr-x 20 0 2000  4096 2009-01-01 01:00 etc\ndrwxr-xr-x  7 0 2000  4096 2009-01-01 01:00 firmware\ndrwxr-xr-x  3 0 2000  4096 2009-01-01 01:00 framework\ndrwxr-xr-x  7 0 2000 12288 2009-01-01 01:00 lib\ndrwxr-xr-x  7 0 2000 20480 2009-01-01 01:00 lib64\ndrwx------  2 0 0    16384 2009-01-01 01:00 lost+found\ndrwxr-xr-x  3 0 2000  4096 2009-01-01 01:00 odm\ndrwxr-xr-x  3 0 2000  4096 2009-01-01 01:00 odm_dlkm\ndrwxr-xr-x  2 0 2000  4096 2009-01-01 01:00 overlay<\/code><\/pre>\n\n\n\n<p>L\u00e0 aussi, le contenu de \/vendor est quasi-identique au contenu de vendor.img<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Conclusions<\/strong><\/h4>\n\n\n\n<p>D\u00e9cortiquer une image firmware d&rsquo;un t\u00e9l\u00e9phone Android permet de mieux comprendre ce qui se produit lorsque l&rsquo;on met \u00e0 jour le firmware avec fastboot, mais aussi de se faire une id\u00e9e du contenu des partitions d&rsquo;un t\u00e9l\u00e9phone.<\/p>\n\n\n\n<p>Toutefois, unpacker les fichiers de l&rsquo;image pour les comparer aux partitions n&rsquo;explique pas le r\u00f4le de tous les fichiers qu&rsquo;elle contient (par exemple les fichiers vbmeta_*, dtbo.img) : Il y a encore du travail !<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dans l&rsquo;article pr\u00e9c\u00e9dent on a vu que rooter un t\u00e9l\u00e9phone Android avec magisk impliquait de t\u00e9l\u00e9charger le firmware du t\u00e9l\u00e9phone avant d&rsquo;en modifier une partie. Mais que contient ce firmware au juste ? Pour donner quelques \u00e9l\u00e9ments de r\u00e9ponse, t\u00e9l\u00e9chargeons-le firmware d&rsquo;un pixel 7A (sur https:\/\/developers.google.com) et examinons son contenu. Le firmware en question se [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-347","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts\/347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/comments?post=347"}],"version-history":[{"count":3,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":350,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts\/347\/revisions\/350"}],"wp:attachment":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/media?parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/categories?post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/tags?post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}