In 423, in order to defend itself from Rouran’s invasions, Northern Wei built a Great Wall from Chicheng to the east and Wuyuan to the West, and established Huaihuang (, in present Zhangbei), Rouxuan (, in present Shangyi), Woye (, in present Wuyuan County, Inner Mongolia) as two of the Six Frontier Towns. Later on, Yuyi (, in present Chicheng and Guyuan ) was added. In 523, an uprising happened in Huaihuang, thus starting the Rebellion of Six Frontier Towns, an anti-Sinicization movement among northern peoples. In 525, Du Luozhou () led Shanggu Uprising, leading to many similar uprising to respond, including Gao Huan's. Next year, Du Luozhou broke through Juyong Pass and occupied You Prefecture.