On 16 December, 2014 - Jef Driesen wrote:
On 2014-11-21 21:28, Anton Lundin wrote:
+static dc_status_t +hw_ostc3_device_upgrade_firmware (dc_device_t *abstract, unsigned int checksum) +{
- dc_status_t rc = DC_STATUS_SUCCESS;
- hw_ostc3_device_t *device = (hw_ostc3_device_t *) abstract;
- dc_context_t *context = (abstract ? abstract->context : NULL);
- unsigned char buffer[5];
- uint32_le_array(checksum, buffer);
- // Compute a one byte checksum, so the device can validate the firmware
image.
- buffer[4] = 0x55;
- buffer[4] ^= buffer[0];
- buffer[4] = (buffer[4]<<1 | buffer[4]>>7);
- buffer[4] ^= buffer[1];
- buffer[4] = (buffer[4]<<1 | buffer[4]>>7);
- buffer[4] ^= buffer[2];
- buffer[4] = (buffer[4]<<1 | buffer[4]>>7);
- buffer[4] ^= buffer[3];
- buffer[4] = (buffer[4]<<1 | buffer[4]>>7);
Can you change this into a loop? It's already more than cryptic enough. Any idea whether this is some known checksum?
I've looked around and there are no hints in ostc-companion or the ostc3 firmware. I've asked around a bit if someone have seen it somewhere else, but as far as i know, its something home grown.
I've compacted it with a loop as you requested.
- // Now the device resets, and if everything is well, it reprograms.
- serial_sleep (device->port, 500);
- // FIXME: How should we force the application to close the device here?
Why do we need to wait here? If the device is rebooting, then the firmware update is successful, right? Since we won't get any confirmation from the ostc, what's the point of waiting here? It only blocks the caller from calling close. Or am I missing something else?
That sleep was probably just re-implemented from ostc-companion. Works just fine without it. Removed it.
What happens at this point? Does the usb-serial device node (e.g. /dev/ttyUSBx) disappear? Setting the state to REBOOTING (as you changed the FIXME in one of the other patches) prevents to do anything, except for calling close. That's probably the right thing to do, but I just wonder what's going on under the hood.
For the ostc3, the host computer sees the ftdi-chip all the time.
The FIXME here was just left because I've managed to squash the commit that removed it into the next one in the series, and thats why its removed there.
This might be different for the ostc3 (usb-serial) and sport (bluetooth), because I suspect the sport will terminate the bluetooth during the reboot, while for the ostc3 the usb-serial chip is still there.
Yepp, it terminates the connection.
So, what do you suggest, that we should change the REBOOTING state to CLOSED and close the device in hw_ostc3_device_upgrade_firmware?
I think that would be a really confusing flow.
//Anton