Development Installing GSI by repacking super.img on SM-A127F and SM-A325F (Linux)

Search This thread

foopy5samsung

Member
Jun 21, 2022
16
5
Then how come the OEM unlocking option is unavailable.... If you have ever flashed stock firmware before, maybe you flashed the wrong one? That could cause OEM unlocking option to be unavailable.
 
  • Like
Reactions: uluruman

Sands207

Senior Member
Oct 13, 2014
1,312
682
Maine
Samsung Galaxy A32 5G
Then how come the OEM unlocking option is unavailable.... If you have ever flashed stock firmware before, maybe you flashed the wrong one? That could cause OEM unlocking option to be unavailable.
It's been unavailable since I bought the phone directly from Tmobile. I've tried every solution out there and no build for my phone regardless of carrier in the US or Canada on android 11 or 12 has the option to OEM Unlock available. I've built ROMs myself right here on Xda and flashed many Samsung devices using both odin and heimdall so I know it's not me this time. I'm just wondering if I try an latest build Android 12 GSI with this tool if I can get past vbmeta errors when flashing on my end on my end among other things?
 

uluruman

Senior Member
Oct 23, 2021
248
40
It's been unavailable since I bought the phone directly from Tmobile. I've tried every solution out there and no build for my phone regardless of carrier in the US or Canada on android 11 or 12 has the option to OEM Unlock available. I've built ROMs myself right here on Xda and flashed many Samsung devices using both odin and heimdall so I know it's not me this time. I'm just wondering if I try an latest build Android 12 GSI with this tool if I can get past vbmeta errors when flashing on my end on my end among other things?
If OEM is not unlocked you cannot get past the Verified Boot protection, even to flash a GSI. I just wonder how is that possible you can flash any other country's stock firmware and not get the OEM unlock option? Or you can't flash? Did you try the NPB firmware (Nepal/Butan, that's my favorite) and did Factory Reset without letting the system to boot after that? Flashing with NAND erase and repartitioning would also be helpful.

OEM unlock sets some secret bit somewhere, maybe via a GPIO pin. It's interesting if anyone tried to find out how exactly it is done, disassemble the stock firmware, hook oscilloscope to pins, etc.
 
Last edited:
  • Like
Reactions: Sands207

map7

Member
Dec 9, 2021
13
0
Will the heimdall_flash_stock.sh script work for a Galaxy Note20 Ultra 5G (SM-N986B C2S exynos)?
 

uluruman

Senior Member
Oct 23, 2021
248
40
v1.15.2 released: Added the Ctrl+C trap in heimdall_flash_stock.sh, so now the temporarily renamed files are correctly renamed back in case of flashing being aborted with Ctrl+C. Upgraded Heimdall with the git pull requests, but it seems those still do not cure the relatively rare issue when flashing specific files gets completely stuck at some point.
 

map7

Member
Dec 9, 2021
13
0
I downloaded the stock image for my phone and when running the heimdall_flash_stock.sh with the zip file I get the following error;

Checking the PIT file format...
PIT file seems to be incorrect. Exiting...

I've got a Samsung NOTE 20 Ultra 5G and I'm in Australia and I think the phone is Telstra as it came with those apps, the bit/binary SW Rev number is 4. I've tried a 5 as it said to try the latest.

repacksuper/heimdall_flash_stock.sh N986BXXU5GWA5_N986BOXM5GWA5_TEL.zip

Should I try with the heimdall_flash.sh and pass in my pit file?
 

map7

Member
Dec 9, 2021
13
0
@physwizz I did have TWRP on there, but now when I boot I get the following error:

DEBORE ON_FAIL_PARTITION_ID

I can still get the downloading page though if I reboot and hold volup+voldown+plug usb in PC.
 

physwizz

Senior Member
Sep 16, 2013
3,860
861
Sydney
@physwizz I did have TWRP on there, but now when I boot I get the following error:

DEBORE ON_FAIL_PARTITION_ID

I can still get the downloading page though if I reboot and hold volup+voldown+plug usb in PC.
Flash patched ap or stock recovery and then go here.

 

map7

Member
Dec 9, 2021
13
0
Flash patched ap or stock recovery and then go here.


I think I have the correct stock image but I'm not completely sure. I've got the Bit/SW Rev = 4, and it's a SM-N986B Telstra phone from Australia. So I think that is one of these stock images https://samfw.com/firmware/SM-N986B/TEL/bit/4/av/all

So I've downloaded that and are you suggesting I untar & unlz4 then flash the recovery only like so?

Code:
sudo heimdall flash --RECOVERY recovery.img
 

uluruman

Senior Member
Oct 23, 2021
248
40
I downloaded the stock image for my phone and when running the heimdall_flash_stock.sh with the zip file I get the following error;

Checking the PIT file format...
PIT file seems to be incorrect. Exiting...

I've got a Samsung NOTE 20 Ultra 5G and I'm in Australia and I think the phone is Telstra as it came with those apps, the bit/binary SW Rev number is 4. I've tried a 5 as it said to try the latest.

repacksuper/heimdall_flash_stock.sh N986BXXU5GWA5_N986BOXM5GWA5_TEL.zip

Should I try with the heimdall_flash.sh and pass in my pit file?
Thanks for reporting this! I have fixed this problem, you can try heimdall_flash_stock.sh again.

v1.15.3 released: The "file" tool used to identify PIT files was replaced with direct reading of the file header as the first method proved to be unreliable.
 

physwizz

Senior Member
Sep 16, 2013
3,860
861
Sydney
I think I have the correct stock image but I'm not completely sure. I've got the Bit/SW Rev = 4, and it's a SM-N986B Telstra phone from Australia. So I think that is one of these stock images https://samfw.com/firmware/SM-N986B/TEL/bit/4/av/all

So I've downloaded that and are you suggesting I untar & unlz4 then flash the recovery only like so?

Code:
sudo heimdall flash --RECOVERY recovery.img
Yeah that should work.
Greetings from south West Sydney
 

map7

Member
Dec 9, 2021
13
0
Yeah that should work.
Greetings from south West Sydney

It gets a lot further but it bombs out whilst flashing the img files at different stages every time I try;

1st time;
Code:
repacksuper/heimdall_flash_stock.sh samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip

Checking the zip file...
Identified as zip archive

Unzipping the AP section...
AP section file: AP_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT_meta_OS13.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT_meta_OS13.tar.md5

Unzipping the BL section...
BL section file: BL_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5

Unzipping the CP section...
CP section file: CP_N986BXXU5GVL2_CP23419976_QB60212932_REV01_user_low_ship_MULTI_CERT.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP_N986BXXU5GVL2_CP23419976_QB60212932_REV01_user_low_ship_MULTI_CERT.tar.md5

Unzipping the CSC section...
CSC section file: CSC_OXM_N986BOXM5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC_OXM_N986BOXM5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5

Unpacking the AP tar...
boot.img.lz4
recovery.img.lz4
dtbo.img.lz4
super.img.lz4
userdata.img.lz4
vbmeta.img.lz4
vbmeta_samsung.img.lz4
dqmdbg.img.lz4
misc.bin.lz4
meta-data/
meta-data/fota.zip

Unpacking the BL tar...
sboot.bin.lz4
up_param.bin.lz4
ldfw.img.lz4
tzsw.img.lz4
tzar.img.lz4
keystorage.bin.lz4
ssp.img.lz4
uh.bin.lz4
vbmeta.img.lz4
harx.bin.lz4

Unpacking the CP tar...
modem.bin.lz4
modem_debug.bin.lz4

Unpacking the CSC tar...
C2S_EUR_OPEN.pit
cache.img.lz4
omr.img.lz4
prism.img.lz4
optics.img.lz4
meta-data/
meta-data/fota.zip

Checking the PIT file format...
Identified as PIT by file signature "76983412"

Decompressing files...
Checking "dtbo.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dtbo.img
Samfw.com_SM-N986B_O : decoded 8388608 bytes                                  
Checking "vbmeta_samsung.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta_samsung.img
Samfw.com_SM-N986B_O : decoded 3664 bytes                                    
Checking "dqmdbg.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dqmdbg.img
Samfw.com_SM-N986B_O : decoded 53360 bytes                                    
Checking "vbmeta.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta.img
Samfw.com_SM-N986B_O : decoded 9936 bytes                                    
Checking "super.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/super.img
Samfw.com_SM-N986B_O : decoded 9222371252 bytes                              
Checking "misc.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/misc.bin
Samfw.com_SM-N986B_O : decoded 520976 bytes                                  
Checking "boot.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/boot.img
Samfw.com_SM-N986B_O : decoded 61865984 bytes                                
Checking "userdata.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/userdata.img
Samfw.com_SM-N986B_O : decoded 1120363048 bytes                              
Checking "recovery.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/recovery.img
Samfw.com_SM-N986B_O : decoded 69009408 bytes                                
Checking "vbmeta.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/vbmeta.img
Samfw.com_SM-N986B_O : decoded 9936 bytes                                    
Checking "tzar.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzar.img
Samfw.com_SM-N986B_O : decoded 7340816 bytes                                  
Checking "harx.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/harx.bin
Samfw.com_SM-N986B_O : decoded 3145728 bytes                                  
Checking "ldfw.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ldfw.img
Samfw.com_SM-N986B_O : decoded 6291456 bytes                                  
Checking "up_param.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/up_param.bin
Samfw.com_SM-N986B_O : decoded 4608000 bytes                                  
Checking "ssp.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ssp.img
Samfw.com_SM-N986B_O : decoded 496640 bytes                                  
Checking "tzsw.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzsw.img
Samfw.com_SM-N986B_O : decoded 1572864 bytes                                  
Checking "uh.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/uh.bin
Samfw.com_SM-N986B_O : decoded 89624 bytes                                    
Checking "sboot.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/sboot.bin
Samfw.com_SM-N986B_O : decoded 4194304 bytes                                  
Checking "keystorage.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/keystorage.bin
Samfw.com_SM-N986B_O : decoded 524288 bytes                                  
Checking "modem.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem.bin
Samfw.com_SM-N986B_O : decoded 65473968 bytes                                
Checking "modem_debug.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem_debug.bin
Samfw.com_SM-N986B_O : decoded 5242880 bytes                                  
Checking "optics.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/optics.img
Samfw.com_SM-N986B_O : decoded 5070984 bytes                                  
Checking "cache.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/cache.img
Samfw.com_SM-N986B_O : decoded 78044 bytes                                    
Checking "omr.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/omr.img
Samfw.com_SM-N986B_O : decoded 53360 bytes                                    
Checking "prism.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/prism.img
Samfw.com_SM-N986B_O : decoded 1215943020 bytes                              

Detecting partition names...
"vbmeta.img" goes into "VBMETA"
Skipping "userdata.img" (unsafe)
"dqmdbg.img" goes into "DQMDBG"
"dtbo.img" goes into "DTBO"
"super.img" goes into "SUPER"
"boot.img" goes into "BOOT"
"recovery.img" goes into "RECOVERY"
Skipping "misc.bin" (unsafe)
"vbmeta_samsung.img" goes into "VBMETA_SAMSUNG"
Skipping "vbmeta.img" (duplicate partition name "VBMETA")
"tzsw.img" goes into "TZSW"
"harx.bin" goes into "HARX"
"ssp.img" goes into "SSP"
"keystorage.bin" goes into "KEYSTORAGE"
"uh.bin" goes into "UH"
"sboot.bin" goes into "BOOTLOADER"
"up_param.bin" goes into "UP_PARAM"
"ldfw.img" goes into "LDFW"
"tzar.img" goes into "TZAR"
"modem.bin" goes into "RADIO"
"modem_debug.bin" goes into "CP_DEBUG"
"optics.img" goes into "OPTICS"
"omr.img" goes into "OMR"
Skipping "cache.img" (unsafe)
"prism.img" goes into "PRISM"

Now get into the Download mode:
A. If the phone is currently turned off, hold down BOTH the Volume Up and Down
   buttons and connect the USB cable to PC while keeping them pressed
B. If the phone is currently booted, first connect the USB cable to PC, then do
   the reboot but as soon as the screen goes black immediately hold down BOTH
   the Volume Up and Down buttons
When the phone is in the Download mode (teal screen), continue to the
"Downloading..." page following the instructions on the screen (usually it is
done by pressing the Volume Up button).

Are you now in the download mode? Y/n

Detecting device...
Device detected

Flashing all partitions...
Flushing disk cache (this may take some time)
Heimdall v1.4.2

Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Uploading RADIO
100%
RADIO upload successful

Uploading OPTICS
100%
OPTICS upload successful

Uploading CP_DEBUG
100%
CP_DEBUG upload successful

Uploading UH
100%
UH upload successful

Uploading BOOTLOADER
75%
ERROR: Failed to send file part packet!
ERROR: BOOTLOADER upload failed!

Ending session...
ERROR: Failed to send end session packet!
Releasing device interface...

Heimdall exit code: 123

Heimdall was unable to upload firmware.
You have to resort to Odin for Windows. Sorry.
Exiting...

2nd time

Code:
repacksuper/heimdall_flash_stock.sh samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip

Checking the zip file...
Identified as zip archive

Unzipping the AP section...
It seems like the AP section was already unzipped before.
Skip it? Y/n

Unzipping the BL section...
It seems like the BL section was already unzipped before.
Skip it? Y/n

Unzipping the CP section...
It seems like the CP section was already unzipped before.
Skip it? Y/n

Unzipping the CSC section...
It seems like the CSC section was already unzipped before.
Skip it? Y/n

Unpacking the AP tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/userdata.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dqmdbg.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dtbo.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/super.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/boot.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/recovery.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/misc.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta_samsung.img
Reuse them? Y/n

Unpacking the BL tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/vbmeta.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzsw.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/harx.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ssp.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/keystorage.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/uh.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/sboot.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/up_param.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ldfw.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzar.img
Reuse them? Y/n

Unpacking the CP tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem_debug.bin
Reuse them? Y/n

Unpacking the CSC tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/optics.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/omr.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/cache.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/C2S_EUR_OPEN.pit
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/prism.img
Reuse them? Y/n

Checking the PIT file format...
Identified as PIT by file signature "76983412"

Decompressing files...
Checking "vbmeta.img" format: seems uncompressed. Accepting as is.
Checking "userdata.img" format: seems uncompressed. Accepting as is.
Checking "dqmdbg.img" format: seems uncompressed. Accepting as is.
Checking "dtbo.img" format: seems uncompressed. Accepting as is.
Checking "super.img" format: seems uncompressed. Accepting as is.
Checking "boot.img" format: seems uncompressed. Accepting as is.
Checking "recovery.img" format: seems uncompressed. Accepting as is.
Checking "misc.bin" format: seems uncompressed. Accepting as is.
Checking "vbmeta_samsung.img" format: seems uncompressed. Accepting as is.
Checking "vbmeta.img" format: seems uncompressed. Accepting as is.
Checking "tzsw.img" format: seems uncompressed. Accepting as is.
Checking "harx.bin" format: seems uncompressed. Accepting as is.
Checking "ssp.img" format: seems uncompressed. Accepting as is.
Checking "keystorage.bin" format: seems uncompressed. Accepting as is.
Checking "uh.bin" format: seems uncompressed. Accepting as is.
Checking "sboot.bin" format: seems uncompressed. Accepting as is.
Checking "up_param.bin" format: seems uncompressed. Accepting as is.
Checking "ldfw.img" format: seems uncompressed. Accepting as is.
Checking "tzar.img" format: seems uncompressed. Accepting as is.
Checking "modem.bin" format: seems uncompressed. Accepting as is.
Checking "modem_debug.bin" format: seems uncompressed. Accepting as is.
Checking "optics.img" format: seems uncompressed. Accepting as is.
Checking "omr.img" format: seems uncompressed. Accepting as is.
Checking "cache.img" format: seems uncompressed. Accepting as is.
Checking "prism.img" format: seems uncompressed. Accepting as is.

Detecting partition names...
"vbmeta.img" goes into "VBMETA"
Skipping "userdata.img" (unsafe)
"dqmdbg.img" goes into "DQMDBG"
"dtbo.img" goes into "DTBO"
"super.img" goes into "SUPER"
"boot.img" goes into "BOOT"
"recovery.img" goes into "RECOVERY"
Skipping "misc.bin" (unsafe)
"vbmeta_samsung.img" goes into "VBMETA_SAMSUNG"
Skipping "vbmeta.img" (duplicate partition name "VBMETA")
"tzsw.img" goes into "TZSW"
"harx.bin" goes into "HARX"
"ssp.img" goes into "SSP"
"keystorage.bin" goes into "KEYSTORAGE"
"uh.bin" goes into "UH"
"sboot.bin" goes into "BOOTLOADER"
"up_param.bin" goes into "UP_PARAM"
"ldfw.img" goes into "LDFW"
"tzar.img" goes into "TZAR"
"modem.bin" goes into "RADIO"
"modem_debug.bin" goes into "CP_DEBUG"
"optics.img" goes into "OPTICS"
"omr.img" goes into "OMR"
Skipping "cache.img" (unsafe)
"prism.img" goes into "PRISM"

Now get into the Download mode:
A. If the phone is currently turned off, hold down BOTH the Volume Up and Down
   buttons and connect the USB cable to PC while keeping them pressed
B. If the phone is currently booted, first connect the USB cable to PC, then do
   the reboot but as soon as the screen goes black immediately hold down BOTH
   the Volume Up and Down buttons
When the phone is in the Download mode (teal screen), continue to the
"Downloading..." page following the instructions on the screen (usually it is
done by pressing the Volume Up button).

Are you now in the download mode? Y/n

Detecting device...
Device detected

Flashing all partitions...
Flushing disk cache (this may take some time)
Heimdall v1.4.2

Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Uploading UH
100%
UH upload successful

Uploading OMR
100%
OMR upload successful

Uploading LDFW
100%
LDFW upload successful

Uploading BOOT
10%
ERROR: Failed to send file part packet!
ERROR: BOOT upload failed!

Ending session...
ERROR: Failed to send end session packet!
Releasing device interface...

Heimdall exit code: 123

Heimdall was unable to upload firmware.
You have to resort to Odin for Windows. Sorry.
Exiting...

Greetings from Melbourne's North :)
 

uluruman

Senior Member
Oct 23, 2021
248
40
It gets a lot further but it bombs out whilst flashing the img files at different stages every time I try;

1st time;
Code:
repacksuper/heimdall_flash_stock.sh samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip

Checking the zip file...
Identified as zip archive

Unzipping the AP section...
AP section file: AP_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT_meta_OS13.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT_meta_OS13.tar.md5

Unzipping the BL section...
BL section file: BL_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL_N986BXXU5GWA5_N986BXXU5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5

Unzipping the CP section...
CP section file: CP_N986BXXU5GVL2_CP23419976_QB60212932_REV01_user_low_ship_MULTI_CERT.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP_N986BXXU5GVL2_CP23419976_QB60212932_REV01_user_low_ship_MULTI_CERT.tar.md5

Unzipping the CSC section...
CSC section file: CSC_OXM_N986BOXM5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5
Archive:  samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip
  inflating: Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC_OXM_N986BOXM5GWA5_MQB61003468_REV01_user_low_ship_MULTI_CERT.tar.md5

Unpacking the AP tar...
boot.img.lz4
recovery.img.lz4
dtbo.img.lz4
super.img.lz4
userdata.img.lz4
vbmeta.img.lz4
vbmeta_samsung.img.lz4
dqmdbg.img.lz4
misc.bin.lz4
meta-data/
meta-data/fota.zip

Unpacking the BL tar...
sboot.bin.lz4
up_param.bin.lz4
ldfw.img.lz4
tzsw.img.lz4
tzar.img.lz4
keystorage.bin.lz4
ssp.img.lz4
uh.bin.lz4
vbmeta.img.lz4
harx.bin.lz4

Unpacking the CP tar...
modem.bin.lz4
modem_debug.bin.lz4

Unpacking the CSC tar...
C2S_EUR_OPEN.pit
cache.img.lz4
omr.img.lz4
prism.img.lz4
optics.img.lz4
meta-data/
meta-data/fota.zip

Checking the PIT file format...
Identified as PIT by file signature "76983412"

Decompressing files...
Checking "dtbo.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dtbo.img
Samfw.com_SM-N986B_O : decoded 8388608 bytes                              
Checking "vbmeta_samsung.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta_samsung.img
Samfw.com_SM-N986B_O : decoded 3664 bytes                                
Checking "dqmdbg.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dqmdbg.img
Samfw.com_SM-N986B_O : decoded 53360 bytes                                
Checking "vbmeta.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta.img
Samfw.com_SM-N986B_O : decoded 9936 bytes                                
Checking "super.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/super.img
Samfw.com_SM-N986B_O : decoded 9222371252 bytes                          
Checking "misc.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/misc.bin
Samfw.com_SM-N986B_O : decoded 520976 bytes                              
Checking "boot.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/boot.img
Samfw.com_SM-N986B_O : decoded 61865984 bytes                            
Checking "userdata.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/userdata.img
Samfw.com_SM-N986B_O : decoded 1120363048 bytes                          
Checking "recovery.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/recovery.img
Samfw.com_SM-N986B_O : decoded 69009408 bytes                            
Checking "vbmeta.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/vbmeta.img
Samfw.com_SM-N986B_O : decoded 9936 bytes                                
Checking "tzar.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzar.img
Samfw.com_SM-N986B_O : decoded 7340816 bytes                              
Checking "harx.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/harx.bin
Samfw.com_SM-N986B_O : decoded 3145728 bytes                              
Checking "ldfw.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ldfw.img
Samfw.com_SM-N986B_O : decoded 6291456 bytes                              
Checking "up_param.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/up_param.bin
Samfw.com_SM-N986B_O : decoded 4608000 bytes                              
Checking "ssp.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ssp.img
Samfw.com_SM-N986B_O : decoded 496640 bytes                              
Checking "tzsw.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzsw.img
Samfw.com_SM-N986B_O : decoded 1572864 bytes                              
Checking "uh.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/uh.bin
Samfw.com_SM-N986B_O : decoded 89624 bytes                                
Checking "sboot.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/sboot.bin
Samfw.com_SM-N986B_O : decoded 4194304 bytes                              
Checking "keystorage.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/keystorage.bin
Samfw.com_SM-N986B_O : decoded 524288 bytes                              
Checking "modem.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem.bin
Samfw.com_SM-N986B_O : decoded 65473968 bytes                            
Checking "modem_debug.bin.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem_debug.bin
Samfw.com_SM-N986B_O : decoded 5242880 bytes                              
Checking "optics.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/optics.img
Samfw.com_SM-N986B_O : decoded 5070984 bytes                              
Checking "cache.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/cache.img
Samfw.com_SM-N986B_O : decoded 78044 bytes                                
Checking "omr.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/omr.img
Samfw.com_SM-N986B_O : decoded 53360 bytes                                
Checking "prism.img.lz4" format: LZ4 compressed. Decompressing...
Decoding file Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/prism.img
Samfw.com_SM-N986B_O : decoded 1215943020 bytes                          

Detecting partition names...
"vbmeta.img" goes into "VBMETA"
Skipping "userdata.img" (unsafe)
"dqmdbg.img" goes into "DQMDBG"
"dtbo.img" goes into "DTBO"
"super.img" goes into "SUPER"
"boot.img" goes into "BOOT"
"recovery.img" goes into "RECOVERY"
Skipping "misc.bin" (unsafe)
"vbmeta_samsung.img" goes into "VBMETA_SAMSUNG"
Skipping "vbmeta.img" (duplicate partition name "VBMETA")
"tzsw.img" goes into "TZSW"
"harx.bin" goes into "HARX"
"ssp.img" goes into "SSP"
"keystorage.bin" goes into "KEYSTORAGE"
"uh.bin" goes into "UH"
"sboot.bin" goes into "BOOTLOADER"
"up_param.bin" goes into "UP_PARAM"
"ldfw.img" goes into "LDFW"
"tzar.img" goes into "TZAR"
"modem.bin" goes into "RADIO"
"modem_debug.bin" goes into "CP_DEBUG"
"optics.img" goes into "OPTICS"
"omr.img" goes into "OMR"
Skipping "cache.img" (unsafe)
"prism.img" goes into "PRISM"

Now get into the Download mode:
A. If the phone is currently turned off, hold down BOTH the Volume Up and Down
   buttons and connect the USB cable to PC while keeping them pressed
B. If the phone is currently booted, first connect the USB cable to PC, then do
   the reboot but as soon as the screen goes black immediately hold down BOTH
   the Volume Up and Down buttons
When the phone is in the Download mode (teal screen), continue to the
"Downloading..." page following the instructions on the screen (usually it is
done by pressing the Volume Up button).

Are you now in the download mode? Y/n

Detecting device...
Device detected

Flashing all partitions...
Flushing disk cache (this may take some time)
Heimdall v1.4.2

Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Uploading RADIO
100%
RADIO upload successful

Uploading OPTICS
100%
OPTICS upload successful

Uploading CP_DEBUG
100%
CP_DEBUG upload successful

Uploading UH
100%
UH upload successful

Uploading BOOTLOADER
75%
ERROR: Failed to send file part packet!
ERROR: BOOTLOADER upload failed!

Ending session...
ERROR: Failed to send end session packet!
Releasing device interface...

Heimdall exit code: 123

Heimdall was unable to upload firmware.
You have to resort to Odin for Windows. Sorry.
Exiting...

2nd time

Code:
repacksuper/heimdall_flash_stock.sh samfw_stock_rom_android_13/Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac.zip

Checking the zip file...
Identified as zip archive

Unzipping the AP section...
It seems like the AP section was already unzipped before.
Skip it? Y/n

Unzipping the BL section...
It seems like the BL section was already unzipped before.
Skip it? Y/n

Unzipping the CP section...
It seems like the CP section was already unzipped before.
Skip it? Y/n

Unzipping the CSC section...
It seems like the CSC section was already unzipped before.
Skip it? Y/n

Unpacking the AP tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/userdata.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dqmdbg.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/dtbo.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/super.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/boot.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/recovery.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/misc.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/AP/vbmeta_samsung.img
Reuse them? Y/n

Unpacking the BL tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/vbmeta.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzsw.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/harx.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ssp.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/keystorage.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/uh.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/sboot.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/up_param.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/ldfw.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/BL/tzar.img
Reuse them? Y/n

Unpacking the CP tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem.bin
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CP/modem_debug.bin
Reuse them? Y/n

Unpacking the CSC tar...
Found unpacked files:
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/optics.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/omr.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/cache.img
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/C2S_EUR_OPEN.pit
Samfw.com_SM-N986B_OPS_N986BXXU5GWA5_fac/CSC/prism.img
Reuse them? Y/n

Checking the PIT file format...
Identified as PIT by file signature "76983412"

Decompressing files...
Checking "vbmeta.img" format: seems uncompressed. Accepting as is.
Checking "userdata.img" format: seems uncompressed. Accepting as is.
Checking "dqmdbg.img" format: seems uncompressed. Accepting as is.
Checking "dtbo.img" format: seems uncompressed. Accepting as is.
Checking "super.img" format: seems uncompressed. Accepting as is.
Checking "boot.img" format: seems uncompressed. Accepting as is.
Checking "recovery.img" format: seems uncompressed. Accepting as is.
Checking "misc.bin" format: seems uncompressed. Accepting as is.
Checking "vbmeta_samsung.img" format: seems uncompressed. Accepting as is.
Checking "vbmeta.img" format: seems uncompressed. Accepting as is.
Checking "tzsw.img" format: seems uncompressed. Accepting as is.
Checking "harx.bin" format: seems uncompressed. Accepting as is.
Checking "ssp.img" format: seems uncompressed. Accepting as is.
Checking "keystorage.bin" format: seems uncompressed. Accepting as is.
Checking "uh.bin" format: seems uncompressed. Accepting as is.
Checking "sboot.bin" format: seems uncompressed. Accepting as is.
Checking "up_param.bin" format: seems uncompressed. Accepting as is.
Checking "ldfw.img" format: seems uncompressed. Accepting as is.
Checking "tzar.img" format: seems uncompressed. Accepting as is.
Checking "modem.bin" format: seems uncompressed. Accepting as is.
Checking "modem_debug.bin" format: seems uncompressed. Accepting as is.
Checking "optics.img" format: seems uncompressed. Accepting as is.
Checking "omr.img" format: seems uncompressed. Accepting as is.
Checking "cache.img" format: seems uncompressed. Accepting as is.
Checking "prism.img" format: seems uncompressed. Accepting as is.

Detecting partition names...
"vbmeta.img" goes into "VBMETA"
Skipping "userdata.img" (unsafe)
"dqmdbg.img" goes into "DQMDBG"
"dtbo.img" goes into "DTBO"
"super.img" goes into "SUPER"
"boot.img" goes into "BOOT"
"recovery.img" goes into "RECOVERY"
Skipping "misc.bin" (unsafe)
"vbmeta_samsung.img" goes into "VBMETA_SAMSUNG"
Skipping "vbmeta.img" (duplicate partition name "VBMETA")
"tzsw.img" goes into "TZSW"
"harx.bin" goes into "HARX"
"ssp.img" goes into "SSP"
"keystorage.bin" goes into "KEYSTORAGE"
"uh.bin" goes into "UH"
"sboot.bin" goes into "BOOTLOADER"
"up_param.bin" goes into "UP_PARAM"
"ldfw.img" goes into "LDFW"
"tzar.img" goes into "TZAR"
"modem.bin" goes into "RADIO"
"modem_debug.bin" goes into "CP_DEBUG"
"optics.img" goes into "OPTICS"
"omr.img" goes into "OMR"
Skipping "cache.img" (unsafe)
"prism.img" goes into "PRISM"

Now get into the Download mode:
A. If the phone is currently turned off, hold down BOTH the Volume Up and Down
   buttons and connect the USB cable to PC while keeping them pressed
B. If the phone is currently booted, first connect the USB cable to PC, then do
   the reboot but as soon as the screen goes black immediately hold down BOTH
   the Volume Up and Down buttons
When the phone is in the Download mode (teal screen), continue to the
"Downloading..." page following the instructions on the screen (usually it is
done by pressing the Volume Up button).

Are you now in the download mode? Y/n

Detecting device...
Device detected

Flashing all partitions...
Flushing disk cache (this may take some time)
Heimdall v1.4.2

Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Uploading UH
100%
UH upload successful

Uploading OMR
100%
OMR upload successful

Uploading LDFW
100%
LDFW upload successful

Uploading BOOT
10%
ERROR: Failed to send file part packet!
ERROR: BOOT upload failed!

Ending session...
ERROR: Failed to send end session packet!
Releasing device interface...

Heimdall exit code: 123

Heimdall was unable to upload firmware.
You have to resort to Odin for Windows. Sorry.
Exiting...

Greetings from Melbourne's North :)
Alas, Heimdall sometimes fails at some files, and I can't fix it because C/C++ programming is beyond me. Recently I've backported all the git pull requests I could find which theoretically could remedy this issue but none helped. So only Odin remains.

For some firmware Heimdall works flawlessly, for example A127FXXU4AUK1, A127FXXU7CVL2, A325FXXU2AUJ4, A325FXXU2CVK3 (for A12 and A32), but not A325FXXU2BVH1 or A325FXXU2BVD6. I absolutely cannot tell why it gets stuck at some files from some particular firmware. May be it's still some weird libusb issue, but I think it's all was fixed long ago, it's something in the Odin protocol.
 

axy_david

Senior Member
Nov 5, 2010
183
16
1675461140778.png

WSL Ubuntu 18.04, as a workaround i use 7z ZS to extract the super
 

uluruman

Senior Member
Oct 23, 2021
248
40
v1.15.6 released: Fixed compatibility issues with systems where /bin/sh is Bash, such as ArchLinux

Tried heimdall_flash_stock.sh on my brother's ArchLinux and discovered that some things are completely messed-up. Fixed it now. So not every /bin/sh the same /bin/sh and probably not really Bourne-compatible at all :oops:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    repacksuper
    ===========

    Copyleft uluruman 2021-2022

    (for LINUX/WSL only)

    This is the minimalistic set of tools + a script for Linux for the automated
    ground-up repacking and flashing of the Samsung Galaxy super.img, replacing
    the stock Android system with something much less intrusive and obtrusive
    (e.g. LineageOS). Or just some other GSI (Generic System Image).

    Additional included scripts (since v1.1) simplify flashing of stock firmware or
    separate image files under Linux using Heimdall.

    Theoretically should work for any Samsung A-series phones, and may be even for
    some others. Tested on SM-A127F/DSN made in India and Vietnam and SM-A325F/DS
    made in India, on Debian Linux 11 x64. There are reports of successful flashing
    of SM-A127M, SM-A032M and SM-A226B.


    Why this method?
    ----------------

    Repacking of super.img is the only method which allows changing of the phone's
    operating system without screwing up the Verified Boot (VB) protection
    mechanism. Keeping the VB allows you to be sure that everything besides the
    platform was indeed compiled by Samsung and wasn't tampered with, no matter from
    where you downloaded your stock firmware.

    The other reason is that although there are alternative methods of changing the
    OS, for phones with dynamic partitioning and no working version of TWRP
    available they may be even more complicated than repacking of super.img
    externally by this script.


    Requirements
    ------------

    Install the following tools from the official repositories of your Linux distro:
    simg2img xz-utils lz4 unzip gzip jq file


    Basic instructions
    ------------------

    repacksuper.sh: main script for changing your phone's operating system
    heimdall_flash_stock.sh: script for flashing stock firmware under Linux

    heimdall_flash.sh: script for flashing any custom image file under Linux
    Just run a script without any arguments to see help.


    Extra tools used (x64 binaries and sources included)
    ----------------------------------------------------


    Additional notes
    ----------------

    The included binaries for the lpunpack, lpmake and Heimdall were compiled for
    the x86_64 architecture. If your PC architecture is different (e.g. x86 32-bit
    or ARM) you have to compile these tools yourself. The full source code is
    included (or otherwise available on GitHub).


    0.9: Initial release

    0.91: Non-sparse new system is now correctly moved into the super dir

    0.91a: Bug in the new system file format checking fixed

    0.91b: Better support for spaces in paths

    0.92: Added checking for system requirements and an optional parameter for
    setting of the final tar archive name.

    0.92a: Fixed file ownership issues inside the tar distribution archive

    0.93: Added support for SM-A325F. Several minor improvements.

    0.94: Added support for gzip-packed GSI images. Packing into .tar is now done
    without question if the command line parameter is given. Tar parameter
    now can include the full path. Without the full path the default tar
    location is now the same as the GSI. Several other minor changes.

    1.0: Finally added working native Linux flashing using Heimdall (HUGE thanks
    to amo13 and Benjamin Dobell). Two new options: using empty product.img
    and silent (non-interactive) mode. Colored text. Bugfixes and minor
    changes.

    1.01: Option to specify the SUPER partition name manually (needed for flashing
    SM-A127F with Heimdall). Now it is possible to place output .img and .tar
    files in any directory and give them any name. Text terminology a bit
    clarified, help text expanded. Done many internal optimizations,
    additional sanity checks and minor changes.

    1.02: Support for SM-A032F/M and similar firmwares with non-packed super.img.
    Support for firmwares with/without additional partitions. Support for
    arbitrary partition group names. Very experimental option to use empty
    system_ext.img for additional privacy (applicable to some phone models/
    regions). Lots of minor fixes.

    1.03: Multiple .img files are now supported in GSI archive files (one of them
    should be system.img in that case), e.g. Android AOSP zip files are now
    supported directly. The logic of flashing with Heimdall now includes more
    complex cases, such as flashing in two steps with a reboot. Unnecessary
    code in GZ unpacking removed. Some other small fixes and optimizations.

    1.1: New scripts heimdall_flash_stock.sh and heimdall_flash.sh added.
    Lots of refactoring in repacksuper.sh (because of that there may be some
    bugs left), improved and clarified UI logic, changes in where the files are
    now placed (see help for details), direct work with stock Zip firmware
    files, lots of minor changes.

    1.11: Colored text now should be correctly displayed in almost any shell that
    supports it except if it's explicitly disabled with NO_COLOR.

    1.11.1: heimdall_flash.sh now can flash Super partitions unconditionally in one
    step when using both the -s parameter and manually specifying parition
    name (e.g. SUPER for SM-A127F).

    1.12: The heimdall_flash_stock.sh script was significantly upgraded with lots of
    new features. Now it theoretically allows upgrading of stock firmware
    without erasing user data, keeping the GSI and custom recovery, etc.
    (although it's not that straightforward, read the help for details).
    A couple of fixes in the other scripts.

    1.12.1: changed unlz4 to lz4 -d, as some distros don't have the needed symlink

    1.13: In repacksuper.sh support added for the Vendor DLKM and ODM DLKM
    partitions, as well as the experimental -v option to add or replace Vendor
    DLKM with a custom image. A couple of minor fixes.

    1.14: Greatly improved logic of heimdall_flash.sh, now it's possible to specify
    both or either custom partition name and custom file name, and acquiring
    PIT from device is done only when it's needed. Versioning scheme of the
    scripts was unified: the script that was updated receives the updated
    version number of the whole pack, the rest retain the old numbers.

    1.15: up_param_tool.sh script was added: it allows altering of the boot
    sequence images (logo, "not official" warning, etc.), as well as the
    Recovery and Download internal graphics. Happy hacking, but please pay
    attention to the warning displayed after extracting the JPEG files.
    A couple of minor fixes in the other scripts.

    1.15.1: Bug with failing LZ4 uncompression fixed in repacksuper.sh and
    heimdall_flash_stock.sh.

    1.15.2: Added the Ctrl+C trap in heimdall_flash_stock.sh, so now the temporarily
    renamed files are correctly renamed back in case of flashing being
    aborted with Ctrl+C. Upgraded Heimdall with the git pull requests, but
    it seems those still do not cure the relatively rare issue when flashing
    specific files gets completely stuck at some point.

    1.15.3: The "file" tool used to identify PIT files was replaced with direct
    reading of the file header as the first method proved to be unreliable.

    1.15.4: Fixed a bug in heimdall_flash.sh (missing g flag in sed)

    1.15.5: Fixed the compatibility issue with the older LZ4 compressors

    1.15.6: Fixed compatibility issues with systems where /bin/sh is Bash, such as
    ArchLinux

    1.15.7: repacksuper.sh: fixed using the existing "repacksuper" dir as source,
    also in this mode you can now specify "-" as new system image to reuse
    everything inside the "super" subdir. New experimental -w parameter.
    All scripts: the Ctrl+C trap now switched on and off the correct way.
    Several other fixes.

    During the script run you can see several "Invalid sparse file format at header
    magic" warnings, just ignore them.

    For some firmware files Heimdall may not work at all (freeze indefinitely or
    exit with an error), in that case you have to resort to Odin. In many cases
    Heimdall freezes when uploading files for some time, but that does not mean it
    is completely frozen, just be patient.

    In LineageOS, Dot OS and some other GSIs I tried on SM-127F the touch screen
    remains not responsive for about 6 seconds after waking up. The problem is not
    present at least with SM-127F/DSN phones made in India, but present at least in
    those made in Vietnam. Another problem in the most, if not all, GSIs is that the
    MTP USB file transfer does not work (at least on Linux) because of the "wrong"
    (Samsung's instead of Google's) default MPT driver used by the kernel.

    Both of the aforementioned problems can be solved by installing the fixed and

    recompiled kernel.

    For the last problem alternative solutions include using apps such as
    Warpinator, Syncthing or ftpd.

    When choosing a GSI to install I really don't recommend using ones which include
    GApps and therefore use any of the Google services. Don't let corporations
    gather your data. You bought the phone and from now on it should be all yours,
    with all of its data, like a PC in the good old days. You own your device, and
    nobody has the right to stick their nose into how you use your phone, gather any
    statistics and push you any ads. You always have a choice to turn down
    privacy-unfriendly stuff, the price of that "inconvenience" is actually
    ridiculous. From my point of view, there is simply no point in using non-stock
    systems if they are still littered with the privacy-unfriendly bloatware.

    For the step-by-step guide (slightly outdated) read this and this post. Also be sure to read this post concerning the importance of optics.img. Concerning the up_param_tool.sh be sure to read this post.

    The included binaries for the lpunpack, lpmake and Heimdall were compiled for the x86_64 architecture. If your PC architecture is different (e.g. x86 32-bit or ARM) you have to compile these tools yourself. The full source code is included (or otherwise available on GitHub).
    2
    One more important thing: if, for example, you're using the Nepalese firmware as the basis for your GSI, while you reside in the UK, you may still need to download your actual regional firmware as well. Inside the CSC part of the firmware there is a file called optics.img which contains the lists of the cellular provider carrier data specific to your region, otherwise you (probably) will be limited in number of service providers available.

    You can extract and flash optics.img separately this way:
    1. download and unzip the full stock firmware for your region of residence
    2. unpack optics.img.lz4 from the CSC_OMC_ODM tar.md5 file using the standard tar utility (e.g. tar -f CSC_OMC_ODM_A325FODM2AUJ3_CL22736284_QB44664166_REV00_user_low_ship_MULTI_CERT.tar.md5 -x optics.img.lz4)
    3. now unpack it using lz4: unlz4 optics.img.lz4
    4. pack .img into tar: tar cf optics_native.tar optics.img
    5. flash it using Odin into the CSC slot
    You can do it at any time after installing the GSI, and you have to do it only once (unless you flash the full stock firmware or the CSC slot separately, of course).
    1
    I should test this for a127f
    1
    Thanks A LOT, this works! I am finally able to run LineageOS on my phone!

    For Windows 10+ users: WSL runs this script just fine with a few additional steps.
    1. Install WSL 2 and any Linux distribution from Microsoft Store
    2. Run the distribution to finish setup
    3. Install the required packages from the post (sudo apt install for Ubuntu/Debian)
    4. Shift + Right Click in the folder where you have the script, the AP and the GSI packages
    5. Open Linux shell there
    6. Unpack & run script as stated in its help

    Voila!
    1
    Updated the second post with the list of latest known stable firmware and LineageOS combinations, and the fully re-worked list of recommendations.