Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fpga_write limited to 47 bytes #493

Open
alphanumericnonsense opened this issue Jun 24, 2024 · 1 comment
Open

fpga_write limited to 47 bytes #493

alphanumericnonsense opened this issue Jun 24, 2024 · 1 comment

Comments

@alphanumericnonsense
Copy link

In trying to write to a cw305_aes_reg.v style register with CW-Lite and CW305, I'm unable to write more than 47 bytes using the target.fpga_write function below.

In CW305.py

    def fpga_write(self, addr, data):
        """Write to an address on the FPGA

        Args:
            addr (int): Address to write to
            data (list): Data to write to addr

        """
        if len(data) <= 0:
            raise ValueError("Invalid data {}".format(data))
        addr = addr << self.bytecount_size
        if self.platform in ['cw305', 'cw310', 'cw340']:
            return self._naeusb.cmdWriteMem(addr, data)
        elif 'ss2' in self.platform:
            payload = list(int.to_bytes(addr, length=4, byteorder='little'))
            payload.extend(data)
            self.ss2.send_cmd(cmd=0x23, scmd=0x57, data=payload)
            self._ss2_check_status()

which uses the following from naeusb.py

    def cmdWriteMem(self, addr : int, data):
        """
        Send command to write memory over external memory interface to FPGA. Automatically
        decides to use control-transfer or bulk-endpoint transfer based on data length.
        """
        pload = util.get_bytes_memview(data)
        if len(pload) < NAEUSB_CTRL_IO_THRESHOLD:
            self._cmd_writemem_ctrl(addr, pload)
        else:
            self._cmd_writemem_bulk(addr, pload)

        naeusb_logger.debug("FPGA_WRITE: bulk: {}, addr: {:08X}, dlen: {:08X}, response: {}"\
            .format("yes" if len(pload) >= NAEUSB_CTRL_IO_THRESHOLD else "no", addr, len(pload), data))

        return None

and

NAEUSB_CTRL_IO_THRESHOLD = 48

So something with _cmd_writemem_bulk isn't working I guess, I don't know. I tried increasing the limit from 48 to 65 to no avail.

@alex-dewar
Copy link
Contributor

Hi,

What firmware is your CW305 on? This was definitely an issue on older firmware versions, but I had thought that I'd fixed that in an earlier firmware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants