Closed kcjian closed 2 years ago
I see that you don't close your probes when you encounter errors. Do you know if the failing process encountered any pynrfjprog errors?
It might be usefull to make sure that probe.close() is always closed. For example by using a context handler:
def run(self):
if self.burn_modem:
try:
lock.acquire()
with HighLevel.IPCDFUProbe(api, int(self.d_name), HighLevel.CoProcessor.CP_MODEM) as modem_probe:
lock.release()
try:
print(self.d_name, ':Burning modem firmware ')
err = update_fw(self.d_name, self.modem_file, modem_probe)
if err:
return
print(self.d_name, ':Burning modem firmware completed ')
except:
print(self.d_name, ":Burning modem firmware error ")
return
except:
print(self.d_name, ":init modem_Jlink error")
lock.release()
return
if self.burn_app:
try:
lock.acquire()
with HighLevel.DebugProbe(api, int(self.d_name)) as app_probe:
lock.release()
try:
print(self.d_name, ':Burning app firmware')
err = program_app(self.d_name, self.app_file, app_probe)
if err:
return
print(self.d_name, ':Burning app firmware completed')
except:
print(self.d_name, ":Burning app firmware error ")
except:
print(self.d_name, ":init app_Jlink error")
lock.release()
return
Or like this:
def run(self):
if self.burn_modem:
with lock.acquire():
try:
modem_probe = HighLevel.IPCDFUProbe(api, int(self.d_name), HighLevel.CoProcessor.CP_MODEM)
except:
print(self.d_name, ":init modem_Jlink error")
return
try:
print(self.d_name, ':Burning modem firmware ')
err = update_fw(self.d_name, self.modem_file, modem_probe)
if err:
return
print(self.d_name, ':Burning modem firmware completed ')
except:
print(self.d_name, ":Burning modem firmware error ")
return
finally:
modem_probe.close()
if self.burn_app:
with lock.acquire():
try:
app_probe = HighLevel.DebugProbe(api, int(self.d_name))
except:
print(self.d_name, ":init app_Jlink error")
return
try:
print(self.d_name, ':Burning app firmware')
err = program_app(self.d_name, self.app_file, app_probe)
if err:
return
print(self.d_name, ':Burning app firmware completed')
except:
print(self.d_name, ":Burning app firmware error ")
return
finally:
modem_probe.close()
try:
app_probe = HighLevel.DebugProbe(api, int(self.d_name))
except:
print(self.d_name, ":init app_Jlink error")
return
finally:
lock.release()
try:
print(self.d_name, ':Burning app firmware')
err = program_app(self.d_name, self.app_file, app_probe)
if err:
return
print(self.d_name, ':Burning app firmware completed')
app_probe.close()
except:
print(self.d_name, ":Burning app firmware error ")
Closing due to inactivity
I started ten threads, burned ten jlinks, and repeatedly tested them.
in operationThread:
After a period of time, the program would crash. There was only one log in PyCharm:
process finished with exit code 134 (interrupted by signal 6: sigabrt)
But Mac will pop up a dialog, part of which is shown as follows
The complete log is as follows pynrfjprog_log.txt
I don't know if I'm not using it right or if there's something wrong with this library. Now our burning software can't run stably for a long time (sometimes it will crash soon). I hope to get your help.