Donjon and dungeon are so obviously of the same origin that I was curious to know why the meanings are so different although both relate to feudal castles. What the French call donjon is what we call a keep in English, whereas the places where prisoners are kept is called oubliettes, from the verb oublier, to forget. No need to go into etymology there!
Donjon, also written dongun, doignon and dangon in the past, is from the Gallo-Roman dominiono, attested in various forms (dunjo, dungeo, domniono, domnio, etc.), in turn derived from the Latin dominus meaning “master”. It was used for the part of the castle reserved for the master and his family. It was well-protected against seiges and also included strategic food and weapon stocks. Prisoners who needed to be particularly guarded were also kept there.
It seems that the first recorded instance of the word in English near the beginning of the 14th century also meant “an underground prison cell beneath the castle keep”. But it actually seems that it is more likely that the word derives from the Frankish *dungjo, *dungjon- (“dungeon, vault, bower”), from Proto-Germanic *dungijōn, *dungō (“an enclosed space, treasury, vault”), from Proto-Indo-European *dʰengʰ- (“to cover, hide, conceal”),related to Old Saxon dung(“underground vault, cellar”), Old High German tung (“a cellar, underground living quarter”), Old English dung (“a dungeon, prison”), and Old Norse dyngja (“a detached apartment, lady’s bower”). (Thank you Wikipedia!)
So there you go, dungeon doesn’t seem to come directly from donjon at all which is disappointing somehow!