Attention is currently required from: qianfan, Angel Pons.
11 comments:
Commit Message:
It would probably be good to specify that this only supports mode 1 (vendor protocol) right now and not mode 2 (HID protocol). It would also be good to specify what settings are currently hard coded, such as the clock speed, spi mode, and that this uses CS0.
File ch347t_spi.c:
Patch Set #2, Line 34: CH347_CMD_SPI_CONTROL,
Maybe make it more clear that this controls the CS lines?
File ch347t_spi.c:
Patch Set #3, Line 30: #define CH347_MAX_DATA_READ 4096
This probably could be set to a higher value. I've tried it with a max read size of 64KiB (64*1024) and it saves about a second with a 16MiB flash chip. The read command takes in a 32 bit integer to technically this could be 4GiB, though that would be impractical due to memory constraints.
enum spi_prescaler {
SPI_BAUDRATEPRESCALER_2 = 0x00,
SPI_BAUDRATEPRESCALER_4 = 0x08,
SPI_BAUDRATEPRESCALER_8 = 0x10,
SPI_BAUDRATEPRESCALER_16 = 0x18,
SPI_BAUDRATEPRESCALER_32 = 0x20,
SPI_BAUDRATEPRESCALER_64 = 0x28,
SPI_BAUDRATEPRESCALER_128 = 0x30,
SPI_BAUDRATEPRESCALER_256 = 0x38
};
Alternatively the prescaler values could start from 1 and then the formula would be freq = 60 MHz / prescaler
enum spi_nss {
SPI_NSS_SOFT = 0x0200,
SPI_NSS_HARD = 0x0000
};
I would rename these to be clearer what it does, maybe `enum spi_cs`, `SPI_CS_SOFTWARE`, and `SPI_CS_HARDWARE`.
Patch Set #3, Line 179: buf, n + 3,
This may go over the 512 byte max packet size of the write endpoint since n can be up to 512 due to the previous code. That said, I have seen the vendor library attempt to send over 700 bytes in one packet...
Patch Set #3, Line 330: ch347t_spi_spi_send_command
The two "spi"s are redundant
libusb_release_interface(handle, 0);
libusb_attach_kernel_driver(handle, 0);
Interface 2, see comment in `ch347t_spi_init`
Mode 1 uses interface 2, and the programmer currently fails if the vendor kernel driver is loaded.
Interface 2
release_interface:
libusb_release_interface(handle, 0);
close_handle:
libusb_attach_kernel_driver(handle, 0);
Interface 2
To view, visit change 70529. To unsubscribe, or for help writing mail filters, visit settings.