Welcome, MJF, to the .org

I think you need gunpowder to be invented, and I believe they depend on one of the foundries. I don't know for certain about the latter because I never build any castle upgrades at all.

The most I will upgrade to is curtain walls, ring walls and barbicans for keeps, castles and citadels respectively. Ballista, catapult and cannon towers are, IMHO, useless as they tend to shoot at your own gatehouse during a siege, doing a lot more harm than good.