audioscience / avdecc-lib

Simple C++ library for implementing IEEE1722.1 (AVB Device Enumeration, Discovery and Control)
MIT License
78 stars 45 forks source link

AECP in-progress responses in firmware upgrade should be polled rather than checked once #303

Open larry-xmos opened 7 years ago

larry-xmos commented 7 years ago

Firmware upgrade fails in erase step if end station is taking some time to erase its non-volatile memory:

$ upgrade upgrade.bin
Erasing image...

[NOTIFICATION] (RESPONSE_RECEIVED, 0x2297fffe80081b, START_OPERATION, ENTITY, 0, IN_PROGRESS, 0x1)

[LOG] ERROR (RESPONSE_RECEIVED, 0x2297fffe80081b, START_OPERATION, ENTITY, 0, 36, IN_PROGRESS)
Error: Erase failed.

cmd_line::cmd_firmware_upgrade does a START_OPERATION command and calls get_last_resp_status once to get status. This seems to simply wait for the first response packet to arrive and return its status field.

My XMOS end station takes about 3 seconds to erase its flash and will send IN_PROGRESS responses every 120ms and finally a SUCCESS at the end (see process_aem_cmd_start_abort_operation in https://github.com/xmos/lib_tsn/blob/master/lib_tsn/src/1722_1/avb_1722_1_aecp.c).

Also, I noticed cmd_firmware_upgrade uses hardcoded 3 for AEM_MEMORY_OBJECT_OPERATION_ERASE.

andrew-elder commented 7 years ago

@larry-xmos - thanks for the error report. Patches and pull-requests welcomed!

franczc commented 7 years ago

@andrew-elder, @larry-xmos: We experienced the same issue and had resolved it in our internal repository. I'll work to get the fix pushed upstream in a day or two.