this is how a mnemonic is generated from the entropy:
it’s a pretty straightforward implementation of the BIP-39 spec
as for how the entropy is gathered, here’s some code:
and here’s some accompanying explanation I typed up earlier: What library does Trezor use?
You’ll see the “external” entropy in the verbose output (as a content of EntropyAck message), and the “internal” entropy shown on the Trezor screen.
Then you can use the following script to check that the seed comes out right: trezor-firmware/python/tools/mnemonic_check.py at main · trezor/trezor-firmware · GitHub