What is the history of breathing?

Humans can breathe either through the nose or the mouth. Tradeoffs ensue. A clogged nose, say from a cold, doesn’t turn off life, but food can easily slip into the windpipe and choke a person.

How did this develop? Do other mammals all have two air entrances? If so, what earlier classes have a combined breathing apparatus? If none do, when did it start in mammals?

Mouth breathing came first. The nostrils were just depressions with smellifying sensors. They became connected in the lobe-fin fishes that were our ancestors.

The jaw evolved as a modification of the first set of gills which was initially used to force water through for breathing and only later coopted into a feeding structure. If you want to trace the history back even further.

According to this article, Evolution of the Mammalian Nose, breathing through the nose while sleeping is highly beneficial to mammals, and found across all mammals.

Looks like a number of adaptations were needed to get the current design. They apparently appear in cynodonts, from the above link.

It is not until the early Triassic that the first steps leading to a mammalian type nose appear. …

The next advance in nasal structure occurred in an ill defined and paraphyletic group referred here to simply as mammaliforms, that existed at the beginning of the end of the Triassic and beginning of the Jurassic.

But then it gets murky, because no early mammal fossils include well-preserved nasal functions.

This break in the fossil record begs the obvious question, when did these final steps take place?