Edinburgh Castle became a royal fortress in the 6th century.