aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-12-14 15:37:14 -0500
committerPaul Selkirk <paul@psgd.org>2017-12-14 15:37:14 -0500
commitb35b87ea14016760786319a23b87792f1e1041de (patch)
treebe8030ae1d0fb995e09503c818526ba8f805d6a5 /projects/hsm
parent03b14b4cd4a214a92e3968ff33a13c2086896864 (diff)
Revert a clean up 'fix' which actually broke FPGA upload.
Diffstat (limited to 'projects/hsm')
-rw-r--r--projects/hsm/mgmt-fpga.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/projects/hsm/mgmt-fpga.c b/projects/hsm/mgmt-fpga.c
index b535b1d..af7ba11 100644
--- a/projects/hsm/mgmt-fpga.c
+++ b/projects/hsm/mgmt-fpga.c
@@ -64,8 +64,13 @@ static HAL_StatusTypeDef _flash_write_callback(uint8_t *buf, size_t len)
if ((res = fpgacfg_erase_sector(dfu_offset / FPGACFG_SECTOR_SIZE)) != CMSIS_HAL_OK)
return res;
- res = fpgacfg_write_data(dfu_offset, buf, len);
- dfu_offset += len;
+ /* fpgacfg_write_data (a thin wrapper around n25q128_write_data)
+ * requires the offset and length to be page-aligned. The last chunk
+ * will be short, so we pad it out to the full chunk size.
+ */
+ len = len;
+ res = fpgacfg_write_data(dfu_offset, buf, BITSTREAM_UPLOAD_CHUNK_SIZE);
+ dfu_offset += BITSTREAM_UPLOAD_CHUNK_SIZE;
return res;
}