您好,我最近有个项目,希望得到帮助.
我想使用esp8266或者esp32cam连接ch375(这是usb总线芯片)的主机功能读取磁盘的数据.
甚至如果可以的话,我希望能够通过ch375的主机功能直接读取机械硬盘的数据,这样就可以通过wifi将多块硬盘联合起来,应该很有意思.
我就能拥有廉价的磁盘矩阵了(nsa和群晖主机太贵了,¥3000+)
我自己尝试根据现有api试过串口通信的方式都不行,不知道并口行不行,不过我没有找到micropython关于8*2并口通信的资料.
Note to the poster: Please use the English language for posts.
-------------------------
Hello, I have a recent project and would like to get help.
I want to use esp8266 or esp32cam to read the data from the disk by connecting to the host function of ch375 (which is a usb bus chip).
Even if I can, I would like to be able to read the data of mechanical hard disk directly through the host function of ch375, so that I can combine multiple hard disks through wifi, which should be interesting.
I will be able to have a cheap disk matrix (nsa and group-fi host is too expensive, ¥ 3000 +)
I tried to try the serial communication method according to the existing api, I do not know if the parallel port can, but I did not find micropython on the 8 * 2 parallel communication information.
Translated with www.DeepL.com/Translator (free version)
如何使用micropython连接ch375
Re: 如何使用micropython连接ch375
The ch375 has built-in USB MSC support, so what you would need to do is write a block device implementation (in Python or C) that talks to the SPI interface on the ch375. This block device could be mounted using the built-in filesystem drivers (FAT, LFS) using os.mount. Conceptually what you need to do is very similar to https://github.com/micropython/micropyt ... /sdcard.py
Re: 如何使用micropython连接ch375
Thank you very much for your answer!
I looked up the ch375 and unfortunately it doesn't support the spi protocol.
So I bought a new ch376s and it looks like there is no mature python library available.
I'll have to try to write my own, I'm probably not that good.
I looked up the ch375 and unfortunately it doesn't support the spi protocol.
So I bought a new ch376s and it looks like there is no mature python library available.
I'll have to try to write my own, I'm probably not that good.
Re: 如何使用micropython连接ch375
The web page for the chip says "In the USB host mode, the CH375 also provides serial communication mode, which is connected to the MCU/DSP/MPU through serial input, serial output and interrupt output."
Maybe it's not exactly SPI but sounds pretty close?
Re: 如何使用micropython连接ch375
I've used the CH376s briefly with MicroPython. Its Serial mode works via the UART. You send it serial commands, it sends you serial data back. This is very, very slow, but if you need to read or write small files, it's good enough. I didn't use/write a library
The other two connection methods for the CH376s - 8-bit parallel and SPI - would likely need a library to access effectively. My CH376s board is currently busy being a hard drive controller in my Apple IIe, so I can't write any example code right now
The other two connection methods for the CH376s - 8-bit parallel and SPI - would likely need a library to access effectively. My CH376s board is currently busy being a hard drive controller in my Apple IIe, so I can't write any example code right now
Re: 如何使用micropython连接ch375
Thanks scruss, sorry yes I should have said serial not SPI (no clock!).
Re: 如何使用micropython连接ch375
------------------------------------------------------------------------------------------------scruss wrote: ↑Thu Jun 23, 2022 1:41 pmI've used the CH376s briefly with MicroPython. Its Serial mode works via the UART. You send it serial commands, it sends you serial data back. This is very, very slow, but if you need to read or write small files, it's good enough. I didn't use/write a library
The other two connection methods for the CH376s - 8-bit parallel and SPI - would likely need a library to access effectively. My CH376s board is currently busy being a hard drive controller in my Apple IIe, so I can't write any example code right now
I have tried the UART communication, but no response, if you have the source code and wiring instructions, send me a reference, I would be very grateful!
I wrote a small piece of code to test the spi interface of the ch376s, following sdcard.py. The official documentation describes the pinout of the ch375 and ch376 as basically the same. I have tried switching between the software spi interface, and the general purpose GPIO interface, but it doesn't work. I even wondered if it was broken, but I bought two of them and they shouldn't both be broken. Now I suspect that there may be a problem with my wiring, I have changed a number of combinations but it does not work, please help to see if there is a problem:
esp8266 spi ch376s
D3 SCS D8
D7 SDO D6
D6 SDI D7
D5 SCK D5
GND GND
VCC 3V3
esp8266 UART ch376s
RXD TXD
TXD RXD
GND GND
VCC 3V3
from machine import Pin, SPI
cs=machine.Pin(15)
cs.init(cs.OUT, value=1)
cs(0)
spi = SPI(1, baudrate=80000000, polarity=0, phase=0)
spi.init(baudrate=100000,polarity=0,phase=0)
for i in range(16):
spi.write(b"\xff")
buf=bytearray(8)
buf[0]=0x40|0x06
buf[1] = 0 >> 24
buf[2] = 0 >> 16
buf[3] = 0 >> 8
buf[4] = 0
buf[5] = 0
spi.write(buf)
#read
tokenbuf=bytearray(1)
for i in range(100):
spi.readinto(tokenbuf,0xFF)
response=tokenbuf[0]
if not(response & 0x80):
print("is ok!")
#else:
# print(response & 0x80)
cs(1)
print("end!")