Skip to content

Awesome Work, and small updates #1

Description

@bm16ton

Hello, first let me say thank you! I really realy enjoyed reading your ftdi reverse breakdown. I am in awe and jealous of your skills. So i too your kernel driver, my first attempt it didnt work failed the check in probe. I immediately went to sniffing a working userland tool (should have tried more with stock code) and found a fair amount of differences, here ill list sum;

const u16 FTDI_BIT_MODE_RESET = 0x00ff;
const u16 FTDI_BIT_MODE_MPSSE = 0x02ff;

ret = usb_control_msg(
	ftdi->udev, usb_sndctrlpipe(ftdi->udev, 0),
	/* bRequest = */0x00,
	/* bRequestType = */0x40,
	/* wValue = */0x0000,
	/* wIndex =  */0x0000,
	/* data = */NULL,
	/* size = */0,
	ftdi->io_timeout);
if (ret < 0)
	return ret;

ret = usb_control_msg(
	ftdi->udev, usb_sndctrlpipe(ftdi->udev, 0),
	/* bRequest = */0x03,
	/* bRequestType = */0x40,
	/* wValue = */0x4138,
	/* wIndex =  */0x0001,
	/* data = */NULL,
	/* size = */0,
	ftdi->io_timeout);
if (ret < 0)
	return ret;

ret = usb_control_msg(
	ftdi->udev, usb_sndctrlpipe(ftdi->udev, 0),
	/* bRequest = */0x00,
	/* bRequestType = */0x40,
	/* wValue = */0x0000,
	/* wIndex =  */0x0001,
	/* data = */NULL,
	/* size = */0,
	ftdi->io_timeout);
if (ret < 0)
	return ret;

ret = usb_control_msg(
	ftdi->udev, usb_sndctrlpipe(ftdi->udev, 0),
	/* bRequest = */0x00,
	/* bRequestType = */0x40,
	/* wValue = */0x0001,
	/* wIndex =  */0x0001,
	/* data = */NULL,
	/* size = */0,
	ftdi->io_timeout);
if (ret < 0)
	return ret;

ret = usb_control_msg(
	ftdi->udev, usb_sndctrlpipe(ftdi->udev, 0),
	/* bRequest = */0x00,
	/* bRequestType = */0x40,
	/* wValue = */0x0002,
	/* wIndex =  */0x0001,
	/* data = */NULL,
	/* size = */0,
	ftdi->io_timeout);
if (ret < 0)
	return ret;

As you can see I had to change the RESET, MPSSE and wIindex also added a baudrate change (I dunno either), and still had to remove the check ftdi_mpsse_verify. I then added smbus support and blocked binding to bank B (Im using ft2232h) and everything is working great! Will add kernel mods for speed and bank A/B options and /sys entries for changing speed etc as well when I find time. I realize you probly already know but in case someone stumbles here;

PURGE RX AND TX BUFFERS

	/* bRequest = */0x00,
	/* bRequestType = */0x40,
	/* wValue = */0x0000,
	/* wIndex =  */0x0001,
	/* data = */NULL,
	/* size = */0,

PURGE RX BUFFERS

	/* bRequest = */0x00,
	/* bRequestType = */0x40,
	/* wValue = */0x0001,
	/* wIndex =  */0x0001,
	/* data = */NULL,
	/* size = */0,

PURGE TX BUFFERS

	/* bRequest = */0x00,
	/* bRequestType = */0x40,
	/* wValue = */0x0002,
	/* wIndex =  */0x0001,
	/* data = */NULL,
	/* size = */0,

Ialso get extra 2 bytes on invalid/bad commands i guess an error code. My versions is located here;
https://github.com/bm16ton/ft2232-mpsse-i2c-spi-kern-drivers
and integrated into my kernel here;
https://github.com/bm16ton/yoga-c630-linux-kernel
with hopefully more updates coming soon. Is there any reason this couldnt be submitted for mainline kernel? Again great work and thank you!

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions