Go into iTunes with the phone connected to your pc/iMac
Back up your device
https://developer.apple.com/ios/download/
My device is model a1533 (listed on back of iphone)
Select your model and it starts the download:
Hold Alt/Option (on a Mac - it's Shift on a PC) and click the Restore iPhone button on the device's Summary tab (next to Check for Update)