servo_micro: Increase maximum I2C-over-USB write and read sizes.
BRANCH=none
TEST=This makes block_write_size up to 254B in iteflash work,
and makes 256B verification reads work.
#define CONFIG_USB_I2C
#define CONFIG_I2C
#define CONFIG_I2C_MASTER
+/*
+ * iteflash requires 256 byte reads for verifying ITE EC firmware. Without this
+ * the limit is CONFIG_I2C_CHIP_MAX_READ_SIZE which is 255 for STM32F0 due to an
+ * 8 bit field, per src/platform/ec/include/config.h comment.
+ */
+#define CONFIG_I2C_XFER_LARGE_READ
#define I2C_PORT_MASTER 0
+/*
+ * As of 2018-11-27 the default for both is 60 bytes. These larger values allow
+ * for reflashing of ITE EC chips over I2C
+ * (https://issuetracker.google.com/79684405) in reasonably speedy fashion. If
+ * the EC firmware defaults are ever raised significantly, consider removing
+ * these overrides.
+ *
+ * As of 2018-11-27 the actual maximum write size supported by the I2C-over-USB
+ * protocol is (1<<12)-1, and the maximum read size supported is
+ * (1<<15)-1. However compile time assertions require that these values be
+ * powers of 2 after overheads are included. Thus, the write limit set here
+ * /should/ be (1<<12)-4 and the read limit should be (1<<15)-6, however those
+ * ideal limits are not actually possible because servo_micro lacks sufficient
+ * spare memory for them. With symmetrical limits, the maximum that currently
+ * fits is (1<<11)-4 write limit and (1<<11)-6 read limit, leaving 1404 bytes of
+ * RAM available.
+ *
+ * However even with a sufficiently large write value here, the maximum that
+ * actually works as of 2018-12-03 is 255 bytes. Additionally, ITE EC firmware
+ * image verification requires exactly 256 byte reads. Thus the only useful
+ * powers-of-2-minus-overhead limits to set here are (1<<9)-4 writes and
+ * (1<<9)-6 reads, leaving 6012 bytes of RAM available, down from 7356 bytes of
+ * RAM available with the default 60 byte limits.
+ */
+#undef CONFIG_USB_I2C_MAX_WRITE_COUNT
+#undef CONFIG_USB_I2C_MAX_READ_COUNT
+#define CONFIG_USB_I2C_MAX_WRITE_COUNT ((1<<9) - 4)
+#define CONFIG_USB_I2C_MAX_READ_COUNT ((1<<9) - 6)
+
/*
* Allow dangerous commands all the time, since we don't have a write protect
* switch.
