snagboot 3.0__tar.gz → 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {snagboot-3.0/src/snagboot.egg-info → snagboot-3.1.0}/PKG-INFO +9 -5
- {snagboot-3.0 → snagboot-3.1.0}/README.md +7 -3
- {snagboot-3.0 → snagboot-3.1.0}/pyproject.toml +2 -1
- {snagboot-3.0 → snagboot-3.1.0/src/snagboot.egg-info}/PKG-INFO +9 -5
- {snagboot-3.0 → snagboot-3.1.0}/src/snagboot.egg-info/SOURCES.txt +6 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagboot.egg-info/requires.txt +3 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/config.py +1 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/fastboot.py +21 -3
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/gui-requirements.txt +0 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/gui.py +6 -5
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/android_sparse_file/utils.py +124 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/bmaptools/BmapCopy.py +1 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/bmaptools/Filemap.py +3 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/dfu.py +9 -4
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/fastboot.py +17 -12
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/fastboot_uboot.py +9 -10
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/ums.py +19 -18
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/50-snagboot.rules +6 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/__init__.py +1 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/cli.py +6 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/config.py +3 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/firmware.py +75 -10
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/rom_container.py +43 -19
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/zynqmp_fw.py +5 -1
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/dfu.py +2 -6
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/fastboot.py +107 -45
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/hid.py +20 -6
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/imx_sdp.py +23 -3
- snagboot-3.1.0/src/snagrecover/protocols/openocd.py +150 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/imx.py +9 -5
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/stm32mp.py +40 -5
- snagboot-3.1.0/src/snagrecover/recoveries/th1520.py +15 -0
- snagboot-3.1.0/src/snagrecover/recoveries/zynq7000.py +30 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/supported_socs.yaml +6 -0
- snagboot-3.1.0/src/snagrecover/templates/imx95-dart-mx95.yaml +2 -0
- snagboot-3.1.0/src/snagrecover/templates/th1520-beaglev-ahead.yaml +2 -0
- snagboot-3.1.0/src/snagrecover/templates/zynq7000-generic.yaml +8 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/utils.py +8 -0
- {snagboot-3.0 → snagboot-3.1.0}/LICENSE +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/MANIFEST.in +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/setup.cfg +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagboot.egg-info/dependency_links.txt +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagboot.egg-info/entry_points.txt +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagboot.egg-info/top_level.txt +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/board.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagBoard.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagBoardID.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagBoardList.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagConfigEntry.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagConfigField.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagConfigTab.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagMainWindow.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagPanelItem.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagTabButton.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/SnagUnpauseButton.qml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/boards.png +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/lab_penguins.ico +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/lab_penguins.png +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/qmldir +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/qml/save.png +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/session.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagfactory/utils.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/android_sparse_file/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/android_sparse_file/sparse.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/bmaptools/BmapCreate.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/bmaptools/BmapHelpers.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/bmaptools/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagflash/cli.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/am335x_usb_setup.sh +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/am335x_fw.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/amlogic_fw.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/bcm.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/fat.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/imx_fw.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/ivt.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/qcom_fw.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/sama5_fw.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/samba_applet.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/sunxi_fw/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/sunxi_fw/fel-to-spl-thunk.S +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/sunxi_fw/fel-to-spl-thunk.bin +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/sunxi_fw/mmu.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/sunxi_fw/soc_info.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/firmware/sunxi_fw/sunxi_fw.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/prompt.ps1 +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/amlogic.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/bcm.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/bootp.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/fel.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/hab_constants.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/memory_ops.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/qcom_sahara.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/protocols/sambamon.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/__init__.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/am335x.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/am62lx.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/am6x.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/amlogic.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/bcm.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/keembay.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/qcom.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/rzn1.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/sama5.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/stm32_flashlayout.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/sunxi.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/recoveries/zynqmp.py +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/am335x-beaglebone-black.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/am62x-beagle-play.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/am62x-phyboard-lyra.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/am654x-evm.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/amlogic_G12x_SM1.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/amlogic_GXx_AXG.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/bcm2711.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/bcm2712.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx28-evk.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx6-colibri-imx6ull.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx6-var-som-mx6.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx7-colibri-imx7d.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx8-dart-mx8m-mini.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx8mp-phyboard-pollux.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx8qm-mek.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx91-phyboard-segin.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/imx93-evk.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/iq9075-evk.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/j721e-evm.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/keembay-generic.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/rzn1d-snarc.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/sama5-sama5d2xplained.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/sama5-sama5d3xplained.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/sama5-sama5d4xplained.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/stm32mp-stm32mp257f-ev1.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/stm32mp1-stm32mp135f-dk.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/stm32mp1-stm32mp157f-dk2.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/sunxi-orangepi-pc.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/templates/zynqmp-generic.yaml +0 -0
- {snagboot-3.0 → snagboot-3.1.0}/src/snagrecover/usb.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: snagboot
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Summary: Generic recovery and reflashing tool for embedded platforms
|
|
5
5
|
Author-email: Romain Gantois <romain.gantois@bootlin.com>
|
|
6
6
|
License-Expression: GPL-2.0-only
|
|
@@ -21,14 +21,16 @@ Requires-Dist: crccheck>=1.3.0
|
|
|
21
21
|
Requires-Dist: pylibfdt>=1.7.2.post1
|
|
22
22
|
Requires-Dist: packaging>=24.2
|
|
23
23
|
Requires-Dist: backports.zstd; python_version < "3.14"
|
|
24
|
+
Requires-Dist: libusb; platform_system == "Windows"
|
|
24
25
|
Provides-Extra: gui
|
|
25
26
|
Requires-Dist: PySide6>=6.8.2; extra == "gui"
|
|
26
|
-
Requires-Dist: PySide6_Addons>=6.8.2; extra == "gui"
|
|
27
27
|
Requires-Dist: PySide6_Essentials>=6.8.2; extra == "gui"
|
|
28
28
|
Dynamic: license-file
|
|
29
29
|
|
|
30
30
|
# Snagboot
|
|
31
31
|
|
|
32
|
+
[](https://www.bestpractices.dev/projects/14233)
|
|
33
|
+
|
|
32
34
|
Snagboot intends to be an open-source and generic replacement to the
|
|
33
35
|
vendor-specific, sometimes proprietary, tools used to recover and/or reflash
|
|
34
36
|
embedded platforms. Examples of such tools include STM32CubeProgrammer, SAM-BA
|
|
@@ -51,17 +53,19 @@ Snagboot currently supports the following families of System-On-Chips (SoCs):
|
|
|
51
53
|
* [Allwinner sunxi](https://linux-sunxi.org/) A10, A10S, A13, A20, A23, A31, A33, A63, A64, A80, A83T, AF1C100S, H2+, R8, R16, R40, R329, R528, T113-S3, V3S, V5S, V536, V831, V853
|
|
52
54
|
* [STMicroelectronics](http://st.com/) [STM32MP1](https://www.st.com/en/microcontrollers-microprocessors/stm32mp1-series.html) and [STM32MP2](https://www.st.com/en/microcontrollers-microprocessors/stm32mp2-series.html)
|
|
53
55
|
* [Microchip](https://www.microchip.com/) [SAMA5](https://www.microchip.com/en-us/products/microprocessors/32-bit-mpus/sama5)
|
|
54
|
-
* [NXP](https://www.nxp.com/) [i.MX6](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-6-processors:IMX6X_SERIES), [i.MX7](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-7-processors:IMX7-SERIES), [i.MX8](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors:IMX8-SERIES), [i.MX91](https://www.nxp.com/products/i.MX91), [i.MX93](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93)
|
|
55
|
-
* [Texas Instruments](https://www.ti.com) [AM335x](https://www.ti.com/product/AM3358), [AM62x](https://www.ti.com/product/AM625), [AM62Lx](https://www.ti.com/product/AM62L), [AM64x](https://www.ti.com/product/AM6442), [AM654x](https://www.ti.com/product/AM6548)
|
|
56
|
-
* [Xilinx/AMD](https://www.amd.com/) [Zynq UltraScale+ MPSoC](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-ultrascale-plus-mpsoc.html)
|
|
56
|
+
* [NXP](https://www.nxp.com/) [i.MX6](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-6-processors:IMX6X_SERIES), [i.MX7](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-7-processors:IMX7-SERIES), [i.MX8](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors:IMX8-SERIES), [i.MX91](https://www.nxp.com/products/i.MX91), [i.MX93](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93), [i.MX95](https://www.nxp.com/products/i.MX95)
|
|
57
|
+
* [Texas Instruments](https://www.ti.com) [AM335x](https://www.ti.com/product/AM3358), [AM62x](https://www.ti.com/product/AM625), [AM62Lx](https://www.ti.com/product/AM62L), [AM64x](https://www.ti.com/product/AM6442), [AM654x](https://www.ti.com/product/AM6548), [DRA821U](https://www.ti.com/product/DRA821U), [TDA4VM](https://www.ti.com/product/TDA4VM), [AM67](https://www.ti.com/product/AM67), [AM68](https://www.ti.com/product/AM68), [AM69](https://www.ti.com/product/AM69)
|
|
58
|
+
* [Xilinx/AMD](https://www.amd.com/) [Zynq UltraScale+ MPSoC](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-ultrascale-plus-mpsoc.html) [Zynq 7000 SoCs](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-7000.html)
|
|
57
59
|
* [Intel](https://www.intel.com/) Keembay
|
|
58
60
|
* [Broadcom](https://www.broadcom.com/) BCM2711 and BCM2712, used in [Raspberry Pi 4 & 5](https://www.raspberrypi.com/documentation/computers/processors.html)
|
|
59
61
|
* [AMLogic](https://www.amlogic.com/#Products) series: G12A (eg S905D2), G12B (eg A311D), SM1 (eg S905D3) and series: GXL (eg S905D), GXM (eg S912), GXBB (eg S905), AXG (eg A113D)
|
|
60
62
|
* [Renesas](https://www.renesas.com/en/products/microcontrollers-microprocessors/rz-mpus) RZ/N1 series
|
|
61
63
|
* [Qualcomm](https://www.qualcomm.com/) [IQ9075](https://www.qualcomm.com/internet-of-things/products/iq9-series/iq-9075)
|
|
64
|
+
* [T-Head](https://www.t-head.cn/) TH1520, tested on [BeagleV-Ahead](https://www.beagleboard.org/boards/beaglev-ahead)
|
|
62
65
|
|
|
63
66
|
Please check [supported_socs.yaml](https://github.com/bootlin/snagboot/blob/main/src/snagrecover/supported_socs.yaml)
|
|
64
67
|
or run `snagrecover --list-socs` for a more precise list of supported SoCs.
|
|
65
68
|
|
|
66
69
|
Documentation: https://snagboot.readthedocs.io
|
|
70
|
+
To report a security vulnerability: [SECURITY.md](https://github.com/bootlin/snagboot/blob/main/SECURITY.md)
|
|
67
71
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Snagboot
|
|
2
2
|
|
|
3
|
+
[](https://www.bestpractices.dev/projects/14233)
|
|
4
|
+
|
|
3
5
|
Snagboot intends to be an open-source and generic replacement to the
|
|
4
6
|
vendor-specific, sometimes proprietary, tools used to recover and/or reflash
|
|
5
7
|
embedded platforms. Examples of such tools include STM32CubeProgrammer, SAM-BA
|
|
@@ -22,17 +24,19 @@ Snagboot currently supports the following families of System-On-Chips (SoCs):
|
|
|
22
24
|
* [Allwinner sunxi](https://linux-sunxi.org/) A10, A10S, A13, A20, A23, A31, A33, A63, A64, A80, A83T, AF1C100S, H2+, R8, R16, R40, R329, R528, T113-S3, V3S, V5S, V536, V831, V853
|
|
23
25
|
* [STMicroelectronics](http://st.com/) [STM32MP1](https://www.st.com/en/microcontrollers-microprocessors/stm32mp1-series.html) and [STM32MP2](https://www.st.com/en/microcontrollers-microprocessors/stm32mp2-series.html)
|
|
24
26
|
* [Microchip](https://www.microchip.com/) [SAMA5](https://www.microchip.com/en-us/products/microprocessors/32-bit-mpus/sama5)
|
|
25
|
-
* [NXP](https://www.nxp.com/) [i.MX6](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-6-processors:IMX6X_SERIES), [i.MX7](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-7-processors:IMX7-SERIES), [i.MX8](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors:IMX8-SERIES), [i.MX91](https://www.nxp.com/products/i.MX91), [i.MX93](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93)
|
|
26
|
-
* [Texas Instruments](https://www.ti.com) [AM335x](https://www.ti.com/product/AM3358), [AM62x](https://www.ti.com/product/AM625), [AM62Lx](https://www.ti.com/product/AM62L), [AM64x](https://www.ti.com/product/AM6442), [AM654x](https://www.ti.com/product/AM6548)
|
|
27
|
-
* [Xilinx/AMD](https://www.amd.com/) [Zynq UltraScale+ MPSoC](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-ultrascale-plus-mpsoc.html)
|
|
27
|
+
* [NXP](https://www.nxp.com/) [i.MX6](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-6-processors:IMX6X_SERIES), [i.MX7](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-7-processors:IMX7-SERIES), [i.MX8](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors:IMX8-SERIES), [i.MX91](https://www.nxp.com/products/i.MX91), [i.MX93](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93), [i.MX95](https://www.nxp.com/products/i.MX95)
|
|
28
|
+
* [Texas Instruments](https://www.ti.com) [AM335x](https://www.ti.com/product/AM3358), [AM62x](https://www.ti.com/product/AM625), [AM62Lx](https://www.ti.com/product/AM62L), [AM64x](https://www.ti.com/product/AM6442), [AM654x](https://www.ti.com/product/AM6548), [DRA821U](https://www.ti.com/product/DRA821U), [TDA4VM](https://www.ti.com/product/TDA4VM), [AM67](https://www.ti.com/product/AM67), [AM68](https://www.ti.com/product/AM68), [AM69](https://www.ti.com/product/AM69)
|
|
29
|
+
* [Xilinx/AMD](https://www.amd.com/) [Zynq UltraScale+ MPSoC](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-ultrascale-plus-mpsoc.html) [Zynq 7000 SoCs](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-7000.html)
|
|
28
30
|
* [Intel](https://www.intel.com/) Keembay
|
|
29
31
|
* [Broadcom](https://www.broadcom.com/) BCM2711 and BCM2712, used in [Raspberry Pi 4 & 5](https://www.raspberrypi.com/documentation/computers/processors.html)
|
|
30
32
|
* [AMLogic](https://www.amlogic.com/#Products) series: G12A (eg S905D2), G12B (eg A311D), SM1 (eg S905D3) and series: GXL (eg S905D), GXM (eg S912), GXBB (eg S905), AXG (eg A113D)
|
|
31
33
|
* [Renesas](https://www.renesas.com/en/products/microcontrollers-microprocessors/rz-mpus) RZ/N1 series
|
|
32
34
|
* [Qualcomm](https://www.qualcomm.com/) [IQ9075](https://www.qualcomm.com/internet-of-things/products/iq9-series/iq-9075)
|
|
35
|
+
* [T-Head](https://www.t-head.cn/) TH1520, tested on [BeagleV-Ahead](https://www.beagleboard.org/boards/beaglev-ahead)
|
|
33
36
|
|
|
34
37
|
Please check [supported_socs.yaml](https://github.com/bootlin/snagboot/blob/main/src/snagrecover/supported_socs.yaml)
|
|
35
38
|
or run `snagrecover --list-socs` for a more precise list of supported SoCs.
|
|
36
39
|
|
|
37
40
|
Documentation: https://snagboot.readthedocs.io
|
|
41
|
+
To report a security vulnerability: [SECURITY.md](https://github.com/bootlin/snagboot/blob/main/SECURITY.md)
|
|
38
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: snagboot
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Summary: Generic recovery and reflashing tool for embedded platforms
|
|
5
5
|
Author-email: Romain Gantois <romain.gantois@bootlin.com>
|
|
6
6
|
License-Expression: GPL-2.0-only
|
|
@@ -21,14 +21,16 @@ Requires-Dist: crccheck>=1.3.0
|
|
|
21
21
|
Requires-Dist: pylibfdt>=1.7.2.post1
|
|
22
22
|
Requires-Dist: packaging>=24.2
|
|
23
23
|
Requires-Dist: backports.zstd; python_version < "3.14"
|
|
24
|
+
Requires-Dist: libusb; platform_system == "Windows"
|
|
24
25
|
Provides-Extra: gui
|
|
25
26
|
Requires-Dist: PySide6>=6.8.2; extra == "gui"
|
|
26
|
-
Requires-Dist: PySide6_Addons>=6.8.2; extra == "gui"
|
|
27
27
|
Requires-Dist: PySide6_Essentials>=6.8.2; extra == "gui"
|
|
28
28
|
Dynamic: license-file
|
|
29
29
|
|
|
30
30
|
# Snagboot
|
|
31
31
|
|
|
32
|
+
[](https://www.bestpractices.dev/projects/14233)
|
|
33
|
+
|
|
32
34
|
Snagboot intends to be an open-source and generic replacement to the
|
|
33
35
|
vendor-specific, sometimes proprietary, tools used to recover and/or reflash
|
|
34
36
|
embedded platforms. Examples of such tools include STM32CubeProgrammer, SAM-BA
|
|
@@ -51,17 +53,19 @@ Snagboot currently supports the following families of System-On-Chips (SoCs):
|
|
|
51
53
|
* [Allwinner sunxi](https://linux-sunxi.org/) A10, A10S, A13, A20, A23, A31, A33, A63, A64, A80, A83T, AF1C100S, H2+, R8, R16, R40, R329, R528, T113-S3, V3S, V5S, V536, V831, V853
|
|
52
54
|
* [STMicroelectronics](http://st.com/) [STM32MP1](https://www.st.com/en/microcontrollers-microprocessors/stm32mp1-series.html) and [STM32MP2](https://www.st.com/en/microcontrollers-microprocessors/stm32mp2-series.html)
|
|
53
55
|
* [Microchip](https://www.microchip.com/) [SAMA5](https://www.microchip.com/en-us/products/microprocessors/32-bit-mpus/sama5)
|
|
54
|
-
* [NXP](https://www.nxp.com/) [i.MX6](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-6-processors:IMX6X_SERIES), [i.MX7](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-7-processors:IMX7-SERIES), [i.MX8](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors:IMX8-SERIES), [i.MX91](https://www.nxp.com/products/i.MX91), [i.MX93](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93)
|
|
55
|
-
* [Texas Instruments](https://www.ti.com) [AM335x](https://www.ti.com/product/AM3358), [AM62x](https://www.ti.com/product/AM625), [AM62Lx](https://www.ti.com/product/AM62L), [AM64x](https://www.ti.com/product/AM6442), [AM654x](https://www.ti.com/product/AM6548)
|
|
56
|
-
* [Xilinx/AMD](https://www.amd.com/) [Zynq UltraScale+ MPSoC](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-ultrascale-plus-mpsoc.html)
|
|
56
|
+
* [NXP](https://www.nxp.com/) [i.MX6](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-6-processors:IMX6X_SERIES), [i.MX7](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-7-processors:IMX7-SERIES), [i.MX8](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors:IMX8-SERIES), [i.MX91](https://www.nxp.com/products/i.MX91), [i.MX93](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93), [i.MX95](https://www.nxp.com/products/i.MX95)
|
|
57
|
+
* [Texas Instruments](https://www.ti.com) [AM335x](https://www.ti.com/product/AM3358), [AM62x](https://www.ti.com/product/AM625), [AM62Lx](https://www.ti.com/product/AM62L), [AM64x](https://www.ti.com/product/AM6442), [AM654x](https://www.ti.com/product/AM6548), [DRA821U](https://www.ti.com/product/DRA821U), [TDA4VM](https://www.ti.com/product/TDA4VM), [AM67](https://www.ti.com/product/AM67), [AM68](https://www.ti.com/product/AM68), [AM69](https://www.ti.com/product/AM69)
|
|
58
|
+
* [Xilinx/AMD](https://www.amd.com/) [Zynq UltraScale+ MPSoC](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-ultrascale-plus-mpsoc.html) [Zynq 7000 SoCs](https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-7000.html)
|
|
57
59
|
* [Intel](https://www.intel.com/) Keembay
|
|
58
60
|
* [Broadcom](https://www.broadcom.com/) BCM2711 and BCM2712, used in [Raspberry Pi 4 & 5](https://www.raspberrypi.com/documentation/computers/processors.html)
|
|
59
61
|
* [AMLogic](https://www.amlogic.com/#Products) series: G12A (eg S905D2), G12B (eg A311D), SM1 (eg S905D3) and series: GXL (eg S905D), GXM (eg S912), GXBB (eg S905), AXG (eg A113D)
|
|
60
62
|
* [Renesas](https://www.renesas.com/en/products/microcontrollers-microprocessors/rz-mpus) RZ/N1 series
|
|
61
63
|
* [Qualcomm](https://www.qualcomm.com/) [IQ9075](https://www.qualcomm.com/internet-of-things/products/iq9-series/iq-9075)
|
|
64
|
+
* [T-Head](https://www.t-head.cn/) TH1520, tested on [BeagleV-Ahead](https://www.beagleboard.org/boards/beaglev-ahead)
|
|
62
65
|
|
|
63
66
|
Please check [supported_socs.yaml](https://github.com/bootlin/snagboot/blob/main/src/snagrecover/supported_socs.yaml)
|
|
64
67
|
or run `snagrecover --list-socs` for a more precise list of supported SoCs.
|
|
65
68
|
|
|
66
69
|
Documentation: https://snagboot.readthedocs.io
|
|
70
|
+
To report a security vulnerability: [SECURITY.md](https://github.com/bootlin/snagboot/blob/main/SECURITY.md)
|
|
67
71
|
|
|
@@ -84,6 +84,7 @@ src/snagrecover/protocols/hab_constants.py
|
|
|
84
84
|
src/snagrecover/protocols/hid.py
|
|
85
85
|
src/snagrecover/protocols/imx_sdp.py
|
|
86
86
|
src/snagrecover/protocols/memory_ops.py
|
|
87
|
+
src/snagrecover/protocols/openocd.py
|
|
87
88
|
src/snagrecover/protocols/qcom_sahara.py
|
|
88
89
|
src/snagrecover/protocols/sambamon.py
|
|
89
90
|
src/snagrecover/recoveries/__init__.py
|
|
@@ -100,6 +101,8 @@ src/snagrecover/recoveries/sama5.py
|
|
|
100
101
|
src/snagrecover/recoveries/stm32_flashlayout.py
|
|
101
102
|
src/snagrecover/recoveries/stm32mp.py
|
|
102
103
|
src/snagrecover/recoveries/sunxi.py
|
|
104
|
+
src/snagrecover/recoveries/th1520.py
|
|
105
|
+
src/snagrecover/recoveries/zynq7000.py
|
|
103
106
|
src/snagrecover/recoveries/zynqmp.py
|
|
104
107
|
src/snagrecover/templates/am335x-beaglebone-black.yaml
|
|
105
108
|
src/snagrecover/templates/am62x-beagle-play.yaml
|
|
@@ -118,6 +121,7 @@ src/snagrecover/templates/imx8mp-phyboard-pollux.yaml
|
|
|
118
121
|
src/snagrecover/templates/imx8qm-mek.yaml
|
|
119
122
|
src/snagrecover/templates/imx91-phyboard-segin.yaml
|
|
120
123
|
src/snagrecover/templates/imx93-evk.yaml
|
|
124
|
+
src/snagrecover/templates/imx95-dart-mx95.yaml
|
|
121
125
|
src/snagrecover/templates/iq9075-evk.yaml
|
|
122
126
|
src/snagrecover/templates/j721e-evm.yaml
|
|
123
127
|
src/snagrecover/templates/keembay-generic.yaml
|
|
@@ -129,4 +133,6 @@ src/snagrecover/templates/stm32mp-stm32mp257f-ev1.yaml
|
|
|
129
133
|
src/snagrecover/templates/stm32mp1-stm32mp135f-dk.yaml
|
|
130
134
|
src/snagrecover/templates/stm32mp1-stm32mp157f-dk2.yaml
|
|
131
135
|
src/snagrecover/templates/sunxi-orangepi-pc.yaml
|
|
136
|
+
src/snagrecover/templates/th1520-beaglev-ahead.yaml
|
|
137
|
+
src/snagrecover/templates/zynq7000-generic.yaml
|
|
132
138
|
src/snagrecover/templates/zynqmp-generic.yaml
|
|
@@ -70,6 +70,7 @@ class FastbootTask:
|
|
|
70
70
|
fb_addr = self.require_global("fb-buffer-addr")
|
|
71
71
|
fb_size = self.get_global("fb-buffer-size")
|
|
72
72
|
self.target_device = self.require_global("target-device")
|
|
73
|
+
self.usb_wait_timeout = self.get_global("usb-wait-timeout")
|
|
73
74
|
|
|
74
75
|
self.cmds = [
|
|
75
76
|
f"set fb-addr {fb_addr}",
|
|
@@ -79,7 +80,10 @@ class FastbootTask:
|
|
|
79
80
|
if fb_size is not None:
|
|
80
81
|
self.cmds.append(f"set fb-size {fb_size}")
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
is_mmc_target = self.target_device.startswith("mmc")
|
|
84
|
+
is_ufs_target = self.target_device.startswith("ufs")
|
|
85
|
+
|
|
86
|
+
if not is_mmc_target and not is_ufs_target:
|
|
83
87
|
self.eraseblk_size = self.require_global("eraseblk-size")
|
|
84
88
|
self.cmds.append(f"set eraseblk-size {self.eraseblk_size}")
|
|
85
89
|
|
|
@@ -125,6 +129,7 @@ class FastbootTask:
|
|
|
125
129
|
"port": self.port,
|
|
126
130
|
"fastboot_cmd": [],
|
|
127
131
|
"interactive_cmds": self.cmds,
|
|
132
|
+
"usb_wait_timeout": self.usb_wait_timeout,
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
self.args = FastbootArgs(args)
|
|
@@ -157,7 +162,10 @@ class FastbootMTDTask(FastbootTask):
|
|
|
157
162
|
def __init__(self, config: dict, num: int, globals: dict):
|
|
158
163
|
super().__init__(config, num, globals)
|
|
159
164
|
|
|
160
|
-
|
|
165
|
+
is_mmc_target = self.target_device.startswith("mmc")
|
|
166
|
+
is_ufs_target = self.target_device.startswith("ufs")
|
|
167
|
+
|
|
168
|
+
if is_mmc_target or is_ufs_target:
|
|
161
169
|
raise SnagFactoryConfigError(
|
|
162
170
|
f"the '{self.name}' task is only supported on mtd backends"
|
|
163
171
|
)
|
|
@@ -202,7 +210,8 @@ class FastbootMMCTask(FastbootTask):
|
|
|
202
210
|
|
|
203
211
|
if not self.target_device.startswith("mmc"):
|
|
204
212
|
raise SnagFactoryConfigError(
|
|
205
|
-
f"the '{self.name}' task is only supported on mmc backends"
|
|
213
|
+
f"the '{self.name}' task is only supported on mmc backends. "
|
|
214
|
+
f"For 'ufs' backends, use the 'run' task with raw commands."
|
|
206
215
|
)
|
|
207
216
|
|
|
208
217
|
self.device_num = int(self.target_device[-1])
|
|
@@ -239,6 +248,15 @@ class FastbootTaskRun(FastbootTask):
|
|
|
239
248
|
|
|
240
249
|
|
|
241
250
|
class FastbootTaskFlash(FastbootTask):
|
|
251
|
+
def __init__(self, config: dict, num: int, globals: dict):
|
|
252
|
+
super().__init__(config, num, globals)
|
|
253
|
+
|
|
254
|
+
if self.target_device.startswith("ufs"):
|
|
255
|
+
raise SnagFactoryConfigError(
|
|
256
|
+
f"the '{self.name}' task is not supported on 'ufs' backends. "
|
|
257
|
+
f"Use the 'run' task instead."
|
|
258
|
+
)
|
|
259
|
+
|
|
242
260
|
def get_cmds(self):
|
|
243
261
|
for entry in self.config:
|
|
244
262
|
part = entry.get("part", "")
|
|
@@ -8,11 +8,6 @@ import importlib.resources
|
|
|
8
8
|
import packaging.requirements
|
|
9
9
|
import packaging.version
|
|
10
10
|
|
|
11
|
-
from PySide6.QtGui import QIcon, QGuiApplication
|
|
12
|
-
from PySide6.QtQml import QQmlEngine, QQmlComponent
|
|
13
|
-
from PySide6.QtCore import QObject, Slot, QUrl, QTimer
|
|
14
|
-
from PySide6.QtQml import QmlElement
|
|
15
|
-
from PySide6.QtQuick import QQuickItem
|
|
16
11
|
import signal
|
|
17
12
|
import functools
|
|
18
13
|
|
|
@@ -50,6 +45,12 @@ for req in gui_reqs:
|
|
|
50
45
|
print(f"underlying cause: {dep_error}")
|
|
51
46
|
sys.exit(1)
|
|
52
47
|
|
|
48
|
+
from PySide6.QtGui import QIcon, QGuiApplication
|
|
49
|
+
from PySide6.QtQml import QQmlEngine, QQmlComponent
|
|
50
|
+
from PySide6.QtCore import QObject, Slot, QUrl, QTimer
|
|
51
|
+
from PySide6.QtQml import QmlElement
|
|
52
|
+
from PySide6.QtQuick import QQuickItem
|
|
53
|
+
|
|
53
54
|
import time
|
|
54
55
|
import yaml
|
|
55
56
|
from math import ceil
|
|
@@ -23,12 +23,15 @@
|
|
|
23
23
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
24
24
|
|
|
25
25
|
import logging
|
|
26
|
+
import os
|
|
26
27
|
|
|
27
28
|
from snagflash.android_sparse_file.sparse import (
|
|
28
29
|
AndroidSparseFile,
|
|
29
30
|
AndroidChunkHeader,
|
|
30
31
|
SPARSE_CHUNKHEADER_LEN,
|
|
31
32
|
SPARSE_FILEHEADER_LEN,
|
|
33
|
+
DEFAULT_BLOCK_SIZE,
|
|
34
|
+
MAGIC,
|
|
32
35
|
CHUNK_TYPE_DONTCARE,
|
|
33
36
|
CHUNK_TYPE_RAW,
|
|
34
37
|
CHUNK_TYPE_FILL,
|
|
@@ -56,6 +59,46 @@ def chunk_type_name(chunk_type):
|
|
|
56
59
|
return CHUNK_TYPE_NAMES.get(chunk_type, f"UNKNOWN(0x{chunk_type:04X})")
|
|
57
60
|
|
|
58
61
|
|
|
62
|
+
def is_sparse_file(path):
|
|
63
|
+
"""
|
|
64
|
+
Check whether the file at 'path' is a valid Android sparse image, by
|
|
65
|
+
inspecting its magic cookie (first 4 bytes, little-endian).
|
|
66
|
+
"""
|
|
67
|
+
with open(path, "rb") as f:
|
|
68
|
+
magic_bytes = f.read(4)
|
|
69
|
+
if len(magic_bytes) < 4:
|
|
70
|
+
return False
|
|
71
|
+
magic = int.from_bytes(magic_bytes, byteorder="little")
|
|
72
|
+
return magic == MAGIC
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ZeroPaddedReader:
|
|
76
|
+
"""
|
|
77
|
+
Wraps a raw binary file object so that read(n) always returns exactly n
|
|
78
|
+
bytes, zero-padding the final short read at true EOF.
|
|
79
|
+
|
|
80
|
+
This lets a raw (non-sparse) file be fed directly into
|
|
81
|
+
process_raw_chunk(), which normally expects to read exact,
|
|
82
|
+
block-aligned payloads out of a real Android sparse file. Raw files are
|
|
83
|
+
usually not a multiple of block_size, so the final block must be
|
|
84
|
+
zero-padded up to the block boundary. Once EOF has been reached, any
|
|
85
|
+
further reads return all zero bytes, as a safety net.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
def __init__(self, fd):
|
|
89
|
+
self.fd = fd
|
|
90
|
+
self.eof = False
|
|
91
|
+
|
|
92
|
+
def read(self, n):
|
|
93
|
+
if self.eof:
|
|
94
|
+
return b"\x00" * n
|
|
95
|
+
data = self.fd.read(n)
|
|
96
|
+
if len(data) < n:
|
|
97
|
+
self.eof = True
|
|
98
|
+
data += b"\x00" * (n - len(data))
|
|
99
|
+
return data
|
|
100
|
+
|
|
101
|
+
|
|
59
102
|
class SplitFragmentState:
|
|
60
103
|
"""
|
|
61
104
|
Holds the accumulated state for the sparse fragment currently being built
|
|
@@ -446,3 +489,84 @@ def split_streaming(path, dest, bufsize):
|
|
|
446
489
|
|
|
447
490
|
finally:
|
|
448
491
|
sparse_file.close()
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def split_streaming_raw(path, dest, bufsize, block_size=DEFAULT_BLOCK_SIZE):
|
|
495
|
+
"""
|
|
496
|
+
Generator that yields one split sparse file at a time, built from a raw
|
|
497
|
+
(non-sparse) binary image, for immediate processing.
|
|
498
|
+
|
|
499
|
+
The raw file is treated as a single logical CHUNK_TYPE_RAW region
|
|
500
|
+
spanning the whole image. This synthetic chunk is split into
|
|
501
|
+
bufsize-limited sparse fragments by reusing the exact same
|
|
502
|
+
process_raw_chunk()/flush_fragment() machinery used by split_streaming()
|
|
503
|
+
for real sparse files, so the resulting fragments have the same
|
|
504
|
+
guarantees:
|
|
505
|
+
|
|
506
|
+
- Every fragment's sparse header reports the full logical block count
|
|
507
|
+
of the entire raw image (not just the blocks it contains).
|
|
508
|
+
- Every fragment starts with a DONT_CARE prefix covering blocks already
|
|
509
|
+
flushed in earlier fragments, and ends with a DONT_CARE suffix
|
|
510
|
+
covering blocks that will be flushed in later fragments.
|
|
511
|
+
- Each fragment (header + prefix + RAW payload + suffix) never exceeds
|
|
512
|
+
bufsize bytes.
|
|
513
|
+
|
|
514
|
+
If the raw file size is not a multiple of block_size, the final block
|
|
515
|
+
is transparently zero-padded up to the block boundary (the padding only
|
|
516
|
+
exists in the generated sparse payload, the source file is untouched).
|
|
517
|
+
|
|
518
|
+
Args:
|
|
519
|
+
path: Path to input raw binary file
|
|
520
|
+
dest: Path for temporary output file (will be reused for each split)
|
|
521
|
+
bufsize: Maximum size for each output file
|
|
522
|
+
block_size: Sparse image block size in bytes (default: DEFAULT_BLOCK_SIZE)
|
|
523
|
+
|
|
524
|
+
Yields:
|
|
525
|
+
Path to each split file (same path, but content changes each iteration)
|
|
526
|
+
"""
|
|
527
|
+
file_size = os.path.getsize(path)
|
|
528
|
+
total_blks = (file_size + block_size - 1) // block_size # ceil division
|
|
529
|
+
|
|
530
|
+
# Pre-flight validation: ensure bufsize can hold at least one block with all headers
|
|
531
|
+
min_required = (
|
|
532
|
+
SPARSE_FILEHEADER_LEN # 28 bytes: file header
|
|
533
|
+
+ 2 * SPARSE_CHUNKHEADER_LEN # 24 bytes: prefix + one data chunk header
|
|
534
|
+
+ block_size # At least one block of data
|
|
535
|
+
+ SPARSE_CHUNKHEADER_LEN # 12 bytes: suffix reserve
|
|
536
|
+
)
|
|
537
|
+
if bufsize <= min_required:
|
|
538
|
+
raise IOError(
|
|
539
|
+
f"Buffer size {bufsize} too small. Need at least {min_required} bytes "
|
|
540
|
+
f"to fit one {block_size}-byte block with headers"
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
blocks_done = 0
|
|
544
|
+
state = SplitFragmentState()
|
|
545
|
+
|
|
546
|
+
logger.debug(
|
|
547
|
+
f"Starting streaming raw split: total_blocks={total_blks}, block_size={block_size}"
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
# Synthesize a single RAW chunk header covering the entire raw image
|
|
551
|
+
header = AndroidChunkHeader()
|
|
552
|
+
header.type = CHUNK_TYPE_RAW
|
|
553
|
+
header.size = total_blks
|
|
554
|
+
|
|
555
|
+
with open(path, "rb") as raw_fd:
|
|
556
|
+
input_fd = ZeroPaddedReader(raw_fd)
|
|
557
|
+
|
|
558
|
+
raw_gen = process_raw_chunk(
|
|
559
|
+
input_fd, header, state, blocks_done, bufsize, block_size, dest, total_blks
|
|
560
|
+
)
|
|
561
|
+
while True:
|
|
562
|
+
try:
|
|
563
|
+
flushed_fragment = next(raw_gen)
|
|
564
|
+
yield flushed_fragment
|
|
565
|
+
except StopIteration as stop:
|
|
566
|
+
blocks_done = stop.value
|
|
567
|
+
break
|
|
568
|
+
|
|
569
|
+
# Final flush: emit any remaining staged chunks as the last fragment
|
|
570
|
+
frag = flush_fragment(state, dest, block_size, total_blks)
|
|
571
|
+
if frag:
|
|
572
|
+
yield frag
|
|
@@ -189,7 +189,7 @@ class Bmap(object):
|
|
|
189
189
|
self._f_bmap_path = None
|
|
190
190
|
|
|
191
191
|
self._f_image = image
|
|
192
|
-
self._image_path = image
|
|
192
|
+
self._image_path = getattr(image, "name", "compressed image")
|
|
193
193
|
|
|
194
194
|
# The bmap file checksum type and length
|
|
195
195
|
self._cs_type = None
|
|
@@ -100,7 +100,9 @@ class _FilemapBase(object):
|
|
|
100
100
|
self._open_image_file()
|
|
101
101
|
|
|
102
102
|
try:
|
|
103
|
-
|
|
103
|
+
image.seek(0, os.SEEK_END)
|
|
104
|
+
self.image_size = image.tell()
|
|
105
|
+
image.seek(0, os.SEEK_SET)
|
|
104
106
|
except IOError as err:
|
|
105
107
|
raise Error(
|
|
106
108
|
"cannot get information about file '%s': %s" % (self._f_image.name, err)
|
|
@@ -36,7 +36,7 @@ from usb.core import Device
|
|
|
36
36
|
|
|
37
37
|
def dfu_detach(dev: Device, altsetting: int = 0):
|
|
38
38
|
logger.info("Sending DFU detach command...")
|
|
39
|
-
dfu_cmd = dfu.DFU(dev
|
|
39
|
+
dfu_cmd = dfu.DFU(dev)
|
|
40
40
|
dfu_cmd.get_status()
|
|
41
41
|
dfu_cmd.detach(altsetting)
|
|
42
42
|
logger.info("Done")
|
|
@@ -48,7 +48,7 @@ def dfu_download(dev: Device, altsetting: int, path: str):
|
|
|
48
48
|
size = len(blob)
|
|
49
49
|
logger.info(f"Downloading {path} to altsetting {altsetting}...")
|
|
50
50
|
logger.debug(f"DFU config altsetting:{altsetting} size:0x{size:x} path:{path}")
|
|
51
|
-
dfu_cmd = dfu.DFU(dev
|
|
51
|
+
dfu_cmd = dfu.DFU(dev)
|
|
52
52
|
dfu_cmd.get_status()
|
|
53
53
|
dfu_cmd.download_and_run(blob, altsetting, 0, size, show_progress=True)
|
|
54
54
|
dfu_cmd.get_status()
|
|
@@ -83,8 +83,13 @@ def dfu_cli(args):
|
|
|
83
83
|
altsetting = 0
|
|
84
84
|
if args.dfu_config:
|
|
85
85
|
for dfu_config in args.dfu_config:
|
|
86
|
-
(
|
|
87
|
-
|
|
86
|
+
(partname, sep, path) = dfu_config.partition(":")
|
|
87
|
+
try:
|
|
88
|
+
altsetting = int(partname)
|
|
89
|
+
except ValueError:
|
|
90
|
+
altsetting = dfu.search_partid(dev, partname)
|
|
91
|
+
if altsetting is None:
|
|
92
|
+
cli_error(f"u-boot does not support partition '{partname}")
|
|
88
93
|
dfu_download(dev, altsetting, path)
|
|
89
94
|
if not args.dfu_keep or args.dfu_detach or args.dfu_reset:
|
|
90
95
|
dfu_detach(dev, altsetting)
|
|
@@ -27,22 +27,16 @@ from snagrecover.utils import (
|
|
|
27
27
|
cli_error,
|
|
28
28
|
access_error,
|
|
29
29
|
prettify_usb_addr,
|
|
30
|
+
USB_RETRIES,
|
|
31
|
+
USB_INTERVAL,
|
|
30
32
|
)
|
|
31
33
|
import sys
|
|
32
34
|
import logging
|
|
35
|
+
from math import ceil
|
|
33
36
|
|
|
34
37
|
logger = logging.getLogger("snagflash")
|
|
35
38
|
|
|
36
39
|
from snagflash.fastboot_uboot import SnagflashFastbootUboot
|
|
37
|
-
import warnings
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def fb_interactive_deprecation():
|
|
41
|
-
warnings.warn(
|
|
42
|
-
"Using interactive mode with the '-P fastboot' option is deprecated and will be removed in a future release! Please use the '-P fastboot-uboot' option instead!",
|
|
43
|
-
FutureWarning,
|
|
44
|
-
stacklevel=1,
|
|
45
|
-
)
|
|
46
40
|
|
|
47
41
|
|
|
48
42
|
def fastboot_ready_check(dev):
|
|
@@ -79,7 +73,13 @@ def fastboot(args):
|
|
|
79
73
|
if usb_addr is None:
|
|
80
74
|
access_error("USB Fastboot", args.port)
|
|
81
75
|
|
|
82
|
-
|
|
76
|
+
usb_wait_timeout = getattr(args, "usb_wait_timeout", None)
|
|
77
|
+
if usb_wait_timeout is None:
|
|
78
|
+
retries = USB_RETRIES
|
|
79
|
+
else:
|
|
80
|
+
retries = max(0, ceil(usb_wait_timeout / USB_INTERVAL) - 1)
|
|
81
|
+
|
|
82
|
+
dev = get_usb(usb_addr, retries=retries, ready_check=fastboot_ready_check)
|
|
83
83
|
dev.default_timeout = int(args.timeout)
|
|
84
84
|
|
|
85
85
|
fast = fb.Fastboot(dev, timeout=dev.default_timeout)
|
|
@@ -114,6 +114,7 @@ def fastboot(args):
|
|
|
114
114
|
"oem_bootbus",
|
|
115
115
|
"reset",
|
|
116
116
|
"flash_sparse",
|
|
117
|
+
"flash_image",
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
for cmd in args.fastboot_cmd:
|
|
@@ -138,7 +139,9 @@ def fastboot(args):
|
|
|
138
139
|
|
|
139
140
|
if args.interactive_cmdfile is not None:
|
|
140
141
|
if args.protocol == "fastboot":
|
|
141
|
-
|
|
142
|
+
cli_error(
|
|
143
|
+
"Using the '-I' option with the 'fastboot' protocol is no longer supported! Please use 'fastboot-uboot'"
|
|
144
|
+
)
|
|
142
145
|
|
|
143
146
|
session = SnagflashFastbootUboot(fast)
|
|
144
147
|
logger.info(f"running commands from file {args.interactive_cmdfile}")
|
|
@@ -149,7 +152,9 @@ def fastboot(args):
|
|
|
149
152
|
|
|
150
153
|
if args.interactive:
|
|
151
154
|
if args.protocol == "fastboot":
|
|
152
|
-
|
|
155
|
+
cli_error(
|
|
156
|
+
"Using the '-i' option with the 'fastboot' protocol is no longer supported! Please use 'fastboot-uboot'"
|
|
157
|
+
)
|
|
153
158
|
|
|
154
159
|
if session is None:
|
|
155
160
|
session = SnagflashFastbootUboot(fast)
|
|
@@ -6,6 +6,7 @@ import random
|
|
|
6
6
|
import os
|
|
7
7
|
import sys
|
|
8
8
|
from math import ceil
|
|
9
|
+
import shlex
|
|
9
10
|
|
|
10
11
|
logger = logging.getLogger("snagflash")
|
|
11
12
|
|
|
@@ -235,21 +236,19 @@ paths-relative-to: controls how relative image paths in flash commands are resol
|
|
|
235
236
|
|
|
236
237
|
self.get_fb_size()
|
|
237
238
|
|
|
238
|
-
|
|
239
|
-
path = path.strip('"').strip('"')
|
|
240
|
-
rest = rest.strip(" ")
|
|
239
|
+
token_args = shlex.split(args)
|
|
241
240
|
|
|
241
|
+
path = token_args[0]
|
|
242
242
|
path = self.resolve_path(path)
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
offset = token_args[1]
|
|
245
|
+
offset = int(offset, 0)
|
|
246
|
+
|
|
247
|
+
if len(token_args) > 2:
|
|
248
|
+
part = shlex.join(token_args[2:])
|
|
247
249
|
else:
|
|
248
|
-
offset = rest
|
|
249
250
|
part = None
|
|
250
251
|
|
|
251
|
-
offset = int(offset, 0)
|
|
252
|
-
|
|
253
252
|
logger.info(f"Flashing file {path}")
|
|
254
253
|
|
|
255
254
|
target = self.request_env("target")
|
|
@@ -423,7 +422,7 @@ paths-relative-to: controls how relative image paths in flash commands are resol
|
|
|
423
422
|
fast.oem_run(f"mmc dev {device_num}")
|
|
424
423
|
part_start = 0
|
|
425
424
|
elif "hwpart" in part:
|
|
426
|
-
hwpart,
|
|
425
|
+
hwpart, hwpart_num = shlex.split(part)
|
|
427
426
|
hwpart_num = int(hwpart_num.strip(" "))
|
|
428
427
|
logger.debug(f"setting MMC device to {device_num} {hwpart_num}")
|
|
429
428
|
fast.oem_run(f"mmc dev {device_num} {hwpart_num}")
|