He was raised in Yunnan, China. In 1381 Yunnan was reconquered by Ming dynasty forces, and he was captured, castrated, and sent into the army. By 1390, under the command of the prince of Yan, he had distinguished himself as a junior officer—skilled in war and diplomacy and having made influential friends at court.