Most of the hardware wallets have a github give at lease a basic way of compiling their firmware.
Picking on foundation devices
https://github.com/Foundation-Devices/passport2That will get you to the point that you can see what you are installing on your hardware wallet IS what they are giving you.
As for what the firmware itself does. You would have to dive into a lot of programming knowledge to see exactly what it is doing.
That is actually more difficult because what might be seemingly benign code may actually be doing something subtly wrong.
If it is an actual mistake or deliberate is for another discussion.
-Dave