STM32 custom bootloader: how to verify the firmware?
What you're probably looking for is a checksum or a hash of the entire application image. 

Say you'd be using CRC32 since the chip may already have hardware support for it.


After compiling the firmware, you create the checksum for it and store it in a separate file. 
Transfer both these files onto the filesystem.
The bootloader then reads the firmware image, creating the checksum once again.
If the generated and stored checksums match, then you're good to go.


Sorry if I understood the question incorrectly.