[Samsung Galaxy S23] rahulsnair:
Disclaimer

This thread is meant to those who would like to switch/update their Samsung Galaxy S23 to latest/particular version of stock firmware

Pre-Requisites

Bifrost - Here (To download latest official firmware files)

Instructions

Installation of supporting libraries

MacOS

Install homebrew and additional build tools. Replace <username> with your Mac username

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/<username>/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
brew install cmake libusb qt@5
export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/qt@5/lib"
export CPPFLAGS="-I/opt/homebrew/opt/qt@5/include"

Linux (Debian)

Install build essentials and other libraries

sudo apt install g++ make build-essential cmake libusb-1.0-0-dev qtchooser qtbase5-dev qtbase5-dev-tools zlib1g-dev

Clone Heimdall repository, check what's the latest tag, switch to latest tag. e.g.,

git clone https://git.sr.ht/~grimler/Heimdall
cd Heimdall
git tag
git checkout tags/v2.1.0

Build and install Heimdall

MacOS

cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DQt5Widgets_DIR=/opt/homebrew/opt/qt@5/lib/cmake/Qt5Widgetsexport
LIBRARY_PATH=/opt/homebrew/lib
make
sudo make install

Linux (Debian)

cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install

Heimdall is now installed. Now download the stock firmware using Bifrost (mentioned under pre-requisites). Once the download and decryption is completed, extract the zip file. You will see content similar to the following.

AP_S911BXXS6CXFC_S911BXXS6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT_meta_OS14.tar.md5

BL_S911BXXS6CXFC_S911BXXS6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5

CP_S911BXXS6CXFC_CP26917221_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5

CSC_OXM_S911BOXM6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5

HOME_CSC_OXM_S911BOXM6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5

On command line, switch to the folder where these files reside. Unpack BL, CP and AP using following commands. Please note the following file names are just for representation:

tar xf BL_S911BXXS6CXFC_S911BXXS6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5
tar xf CP_S911BXXS6CXFC_CP26917221_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5
tar xf AP_S911BXXS6CXFC_S911BXXS6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT_meta_OS14.tar.md5

Now depending on whether you wish to do an upgrade / factory reset, do one of the following. Please note the following file names are just for representation:

No Factory Reset:

tar xf HOME_CSC_OXM_S911BOXM6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5

Factory Reset:

tar xf CSC_OXM_S911BOXM6CXFC_MQB82510231_REV00_user_low_ship_MULTI_CERT.tar.md5

Now decompress all the partition files using

lz4 -dm *.lz4

You have successfully completed the necessary steps before flashing. Now boot your phone into download mode and connect the device to Mac/Laptop.

Now run the following to check if Heimdall is able to detect your phone

heimdall detect

if Heimdall says detected, depending on whether you wish to do an upgrade / factory reset, do one of the following:

Flash without factory reset :

heimdall flash --ABL abl.elf --BKSECAPP bksecapp.mbn --XBL xbl_s.melf --XBL_CONFIG xbl_config.elf \
--TZICCC tz_iccc.mbn --TZ tz.mbn --HYP hypvm.mbn --DEVCFG devcfg.mbn --AOP aop.mbn --AOP_CONFIG aop_devcfg.mbn \
--KEYMASTER keymint.mbn --QUPFW qupv3fw.elf --STORSEC storsec.mbn --APNHLOS NON-HLOS.bin --DSP dspso.bin \
--IMAGEFV imagefv.elf --UEFI uefi.elf --UEFISECAPP uefi_sec.mbn --SHRM shrm.elf --CPUCP cpucp.elf --XBL_RAMDUMP XblRamdump.elf \
--SECDATA sec.elf --APDP apdp.mbn --VBMETA vbmeta.img --TOOLSFV quest.fv --LOGDUMP testvector.fv --CATEFV QcomCate.fv \
--CORE_NHLOS_A Core_NON-HLOS.bin --HDM tz_hdm.mbn --TZ_KG tz_kg.mbn --VK vaultkeeper.mbn --BOOT boot.img --DTBO dtbo.img \
--SUPER super.img --RECOVERY recovery.img --VENDOR_BOOT vendor_boot.img --VBMETA_SYSTEM vbmeta_system.img \
--INIT_BOOT init_boot.img --VM-BOOTSYS vm-bootsys.img --MODEM modem.bin --CACHE cache.img --PRISM prism.img --OPTICS optics.img

Flash with factory reset :

heimdall flash --ABL abl.elf --BKSECAPP bksecapp.mbn --XBL xbl_s.melf --XBL_CONFIG xbl_config.elf \
--TZICCC tz_iccc.mbn --TZ tz.mbn --HYP hypvm.mbn --DEVCFG devcfg.mbn --AOP aop.mbn --AOP_CONFIG aop_devcfg.mbn \
--KEYMASTER keymint.mbn --QUPFW qupv3fw.elf --STORSEC storsec.mbn --APNHLOS NON-HLOS.bin --DSP dspso.bin \
--IMAGEFV imagefv.elf --UEFI uefi.elf --UEFISECAPP uefi_sec.mbn --SHRM shrm.elf --CPUCP cpucp.elf --XBL_RAMDUMP XblRamdump.elf \
--SECDATA sec.elf --APDP apdp.mbn --VBMETA vbmeta.img --TOOLSFV quest.fv --LOGDUMP testvector.fv --CATEFV QcomCate.fv \
--CORE_NHLOS_A Core_NON-HLOS.bin --HDM tz_hdm.mbn --TZ_KG tz_kg.mbn --VK vaultkeeper.mbn --BOOT boot.img --DTBO dtbo.img \
--SUPER super.img --RECOVERY recovery.img --VENDOR_BOOT vendor_boot.img --VBMETA_SYSTEM vbmeta_system.img \
--PERSIST persist.img --USERDATA userdata.img --MISC misc.bin --INIT_BOOT init_boot.img --VM-BOOTSYS vm-bootsys.img \
--MODEM modem.bin --CACHE cache.img --OMR omr.img --PRISM prism.img --OPTICS optics.img

Flashing with take several minutes to completed. The phone will reboot once done. Please ensure to not turn off your devices or unplug USB.

Thanks to:

Glass Echidna for developing Heimdall

Henrik Grimler for maintaining Heimdall