Skip to content

Host-upload FPGA SRAM path programs zeros: xi2c_write_long clobbers its own source buffer #82

Description

@boringethan

Found during camera-fpga full-frame-readout bring-up (OpenwaterHealth/openmotion-camera-fpga#5), present in 1.8.1-rc.3 and current branches incl. feature/68.

Path: OW_FPGA_BITSTREAM blocks fill bitstream_buffer (host bitstream, CRC-checked) → OW_FPGA_PROG_SRAM reserved=0 → program_sram_fpga(cam, rom_bitstream=true, ...)fpga_program_sram (crosslink.c:396) → xi2c_write_long(hi2c, addr, cmd, 4, (uint8_t*)bitstream_buffer, bitstream_len) (crosslink.c:408).

Bug: xi2c_write_long (crosslink.c:88) begins with
memset(bitstream_buffer, 0, MAX_BITSTREAM_SIZE) then
memcpy(bitstream_buffer + cmd_len, data, data_len) — when data IS bitstream_buffer (the reserved=0 path), the memset zeroes the source before the copy, so the CrossLink receives the 0x7A command followed by zeros. The embedded-flash path (fpga_configure → ADDR_CAMERA_BITSTREAM) is unaffected because its source is flash, not the shared scratch buffer.

Also observed while working around it (informational): after any DFU session, the app's USB does not re-enumerate until a full power cycle — worth confirming whether that's expected on these boards.

Suggested fix: give xi2c_write_long its own scratch/chunk buffer (it only needs cmd_len+chunk bytes at a time — stream directly from the source with a small prefix buffer for the first chunk), or forbid data==bitstream_buffer and add a separate upload buffer.

Workaround used: DFU-rewrite the dedicated bitstream flash sectors (0x081A0000, 163489 B) and program via the stock path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions