2022-08-03 13:28:54 +08:00
|
|
|
import time
|
2019-12-10 02:54:48 +08:00
|
|
|
from nose.tools import assert_equal
|
|
|
|
|
2021-08-03 11:26:15 +08:00
|
|
|
from panda import Panda, DEFAULT_FW_FN, DEFAULT_H7_FW_FN, MCU_TYPE_H7
|
2022-08-03 08:05:47 +08:00
|
|
|
from .helpers import test_all_pandas, panda_connect_and_init
|
2017-07-30 22:59:14 +08:00
|
|
|
|
2022-08-03 08:05:47 +08:00
|
|
|
def check_signature(p):
|
2022-08-03 13:28:54 +08:00
|
|
|
assert not p.bootstub, "Flashed firmware not booting. Stuck in bootstub."
|
2022-08-03 08:05:47 +08:00
|
|
|
fn = DEFAULT_H7_FW_FN if p.get_mcu_type() == MCU_TYPE_H7 else DEFAULT_FW_FN
|
|
|
|
firmware_sig = Panda.get_signature_from_firmware(fn)
|
|
|
|
panda_sig = p.get_signature()
|
|
|
|
assert_equal(panda_sig, firmware_sig)
|
2019-12-10 02:54:48 +08:00
|
|
|
|
2019-08-29 03:57:42 +08:00
|
|
|
@test_all_pandas
|
2022-08-03 08:05:47 +08:00
|
|
|
@panda_connect_and_init(full_reset=False)
|
2021-11-12 13:32:51 +08:00
|
|
|
def test_a_recover(p):
|
2019-04-10 05:09:18 +08:00
|
|
|
assert p.recover(timeout=30)
|
2022-08-03 08:05:47 +08:00
|
|
|
check_signature(p)
|
2019-12-10 02:54:48 +08:00
|
|
|
|
2019-08-29 03:57:42 +08:00
|
|
|
@test_all_pandas
|
2022-08-03 08:05:47 +08:00
|
|
|
@panda_connect_and_init(full_reset=False)
|
2021-11-12 13:32:51 +08:00
|
|
|
def test_b_flash(p):
|
2022-08-03 13:28:54 +08:00
|
|
|
# test flash from bootstub
|
|
|
|
serial = p._serial
|
|
|
|
assert serial != None
|
|
|
|
p.reset(enter_bootstub=True)
|
|
|
|
p.close()
|
|
|
|
time.sleep(2)
|
|
|
|
|
|
|
|
np = Panda(serial)
|
|
|
|
assert np.bootstub
|
|
|
|
assert np._serial == serial
|
|
|
|
np.flash()
|
|
|
|
np.close()
|
|
|
|
|
|
|
|
p.reconnect()
|
|
|
|
p.reset()
|
|
|
|
check_signature(p)
|
|
|
|
|
|
|
|
# test flash from app
|
2017-07-30 22:59:14 +08:00
|
|
|
p.flash()
|
2022-08-03 08:05:47 +08:00
|
|
|
check_signature(p)
|