Addition of extra error checking in APM firmware uploading, and properly handling the errors