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

Some USB drives are not detected #9

Closed
issalig opened this issue Dec 28, 2021 · 34 comments
Closed

Some USB drives are not detected #9

issalig opened this issue Dec 28, 2021 · 34 comments

Comments

@issalig
Copy link

issalig commented Dec 28, 2021

I have been able to connect with usb drives with the following values
l usb -v | grep bEndpointAddress

WORK
bEndpointAddress 0x01 EP 1 OUT
bEndpointAddress 0x82 EP 2 IN

WORK
bEndpointAddress 0x01 EP 1 OUT
bEndpointAddress 0x81 EP 1 IN

DOES NOT WORK
bEndpointAddress 0x81 EP 1 IN
bEndpointAddress 0x02 EP 2 OUT

I checked the one that does not work under serial protocol ch376s and it works and for parallel I can read the FAT type so I assume hardware is ok and the problem is in the rom code.

I have modified the rom and I am printing the communication with ch376s for working and non working usbs.
However, this is a tedious process (modify code,flash memory with tl866, extract memory, insert into cartridge, power up, test) and I do not still have a solution. How do you do the development? From the video you sent, it looks like you are simulating it, FPGA?

Excuse for my ignorance, but given for the use case that there is only one device, I think it should be an easier way to bind it to 1. Other projects just set address to 1 0x45 0x01, then select device 1 0x13 0x01 and configuration 1 0x49 0x01

I would like to contribute to your project by fixing this bug/feature but I do not know exactly where else to look.

@issalig issalig changed the title USB drive support Some USB drives are not detected Dec 28, 2021
@S0urceror
Copy link
Owner

S0urceror commented Dec 29, 2021 via email

@issalig
Copy link
Author

issalig commented Dec 29, 2021

Wow, it is such a great development framework (mine is a poor-man framework: make, gedit, call PRINT and minipro :) ) and yes documenting is a good idea even that is the less interesting part.
So I understand that the teensy is basically and USB to parallel link for the ch376s, neat.

If you like I can send you one of the problematic usbs as well as my pcb version so that you can test it. Just give me an address and you will have it in some days. This is also my way to thank you for the project.

@S0urceror
Copy link
Owner

This shows my setup in photo's. On the left the Teensy 3.5 and on the right the Teensy 2.0. These are 5v compatible Arduino type of boards.

IMG_0229
IMG_0232

Would be great to test the problematic devices and solve the issue. This way we solve it for everyone. I am happy to share my address with you but prefer to use email for that. Send me an email to the address found on msx.org and we'll exchange details.

@S0urceror
Copy link
Owner

Back to the topic. I have a couple of questions for you:

  • Does the not working device say: "-No USB device connected", or is it just not working properly?
  • Can you send me the whole lsusb -v dump? Maybe there are more clues there.
  • You said: "I think it should be an easier way to bind it to 1. Other projects just set address to 1 0x45 0x01, then select device 1 0x13 0x01 and configuration 1 0x49 0x01". Do you mean dropping Usb Hub support and just using the device connected to the module?

@issalig
Copy link
Author

issalig commented Dec 29, 2021

  • Not working means it is not detected. It just says

    • UNAPI initialised
    • MSXUSB cartridge found
    • CH376s version: 3 (also tried with other module version 2 with same results)
    • And nothing more, it blocks here maybe in an endless loop (just the same in that in the previous image)
  • The lsusb output is in https://pastebin.com/rv2srQ7M

  • That was a naive/desperated idea given that I do not fully understand the hub scanning, and in the case of 1 usb, just hardwire it, but maybe it has no sense. I just gave some inpiration from https://pulkomandy.github.io/shinra.github.io/albireo.html which connect ch376s to an Amstrad CPC

@cristianoag
Copy link
Contributor

@issalig , I've been working with @S0urceror and had exactly the same issues you have. With his original code only one USB drive was working ok out of my 12. Then I made a small change on the code just to wait indefinitely for the CH376s interruption. S0urceror was following the specification and waiting 100 cycles for the interruption. I found out that some of the pen drives I have were a lot slower and were making the CH376 generate the interruption just after 1000 cycles. I then changed the code to loop until it gets the interruption and voila... 9 out of the 12 original set are now working ok. The other 3 are not even recognized by the CHS376.

I'm using S0urceror vNext code and changing the ch376_wait_status function. If you want to take a look on the change I made please check https://github.com/cristianoag/MSX-USB/blob/master/drivers/MsxUsbNext/generic/ch376s.c

Hope that helps.

@issalig
Copy link
Author

issalig commented Feb 4, 2022

That's great. I tried MsxusbNext and no device was recognised. Gonna check it asap.

@cristianoag
Copy link
Contributor

cristianoag commented Feb 4, 2022 via email

@S0urceror
Copy link
Owner

I've just pushed my latest MSXUSBNext updates to GitHub. Followed Cristiano's lead and removed the 100 time try-out counter as well. Beware this can lead to lock-ups when the CH376s decides to not respond at all. Let's test this in practise and see if we keep this or not.

@issalig
Copy link
Author

issalig commented Feb 5, 2022

I tried @S0urceror version which afaik currently is the same as @cristianoag and NOW it works with all my devices! Well done guys.

With a FAT12 if I select 1.Floppy disk it ends up with a "No enough memory" (which I suppose is correct)
Pressing 2 says "Full disk mode" and everything works.

imagen

@cristianoag, as I am using a MSX1 with less that 128Kb, I cannot use FAT16 (which is supported by nextor in MSX1)

I am wondering if it could be added some SRAM memory to the board. As far as I know it would only be necessary a chip like HM628512A (for 512k) and some verilog code for the mapper as it is done for the rom, right?. I am a msx noob and I still need to understand this system well. If you can point me to the right direction I will be happy to hear from you.

@cristianoag
Copy link
Contributor

cristianoag commented Feb 5, 2022 via email

@S0urceror
Copy link
Owner

S0urceror commented Feb 6, 2022 via email

@S0urceror
Copy link
Owner

S0urceror commented Feb 6, 2022 via email

@issalig
Copy link
Author

issalig commented Feb 6, 2022

That's great @S0urceror, I created a FAT16 partitiion with several (4) dsks and it works under MSX1.
@cristianoag at the beginning I did not understand how it worked, now I understand that the rom interprets dsk file. Well done!

About the delay that for some usbs is long and for others short I was thinking about a calibrarion method, I mean, start with short delay and if it does not work increase it until usb is detected (it can be a maximum of course that will say, no usb detected)
Then store this time as the device response time and use it for all the session.
What do you think?

This weekend I have no free time (I am studying for a Portuguese exam but maybe reading MSX brazilian forums could work both for studying and for procrastinating, nice! ) but in the middle of the week I hope to get some time and study the new msxusbnext development you've done is the last days and try to see if this calibration idea could work.

@S0urceror
Copy link
Owner

Just implemented CALL MOUNTDSK in BASIC. This shows the selection again and allows you to choose another disk image. Disk images are in the root folder or in the DSKS folder of the FAT16/32 formatted USB drive.

@issalig
Copy link
Author

issalig commented Feb 7, 2022

I noticed there the system was super-slow, characters appeared >500ms after the keypress. I am not sure if this is related to the delay introduced here or some problem with my machine.
https://github.com/S0urceror/MSX-USB/blob/master/drivers/MsxUsbNext/generic/ch376s.c#L58

I will look into it with more detail.

@S0urceror
Copy link
Owner

No, you shouldn't have any problems with keypresses. What I changed here is not to exit the wait routine after 100 attempts. In some cases with older USB devices this is too fast. But again that has nothing to do with keypresses.

Where you talking about keypresses in general like in DOS or BASIC? Or the response after pressing the key to select an image after the start screen?

@cristianoag
Copy link
Contributor

cristianoag commented Feb 7, 2022 via email

@issalig
Copy link
Author

issalig commented Feb 7, 2022

It is both with BASIC and MSDOS when I press a key it take a lot to appear in the screen. IDK, maybe some bad contact in the cartridge slot causes some signal. And yes, I am almost sure is just related to my machine.

@issalig
Copy link
Author

issalig commented Feb 8, 2022

Got some time and I am trying to compile msxusbnext (under linux) but for some reason when compiling msx folder I find .lk files are not generated.

Makefile dry.run shows these commands but I cannot see any specific to .lk or .ihx

$ make -n
sdasz80 -o objs/msxromcrt0.rel msxromcrt0.s 
sdcc --verbose -mz80 -c -DNODEBUG -o objs/driver.rel driver.c 
sdcc --verbose -mz80 -c -DNODEBUG -o objs/ch376s.rel ../generic/ch376s.c 	
sdcc --verbose -mz80 -c -DNODEBUG -o objs/hal.rel hal.c 
sdcc --verbose -mz80 -c -DNODEBUG -o objs/usbdisk.rel ../generic/usbdisk.c 	
sdcc -mz80 --code-loc 0x4200 --data-loc 0xc800 --no-std-crt0 -o build/driver.ihx objs/msxromcrt0.rel objs/driver.rel objs/ch376s.rel objs/hal.rel objs/usbdisk.rel 
hex2bin -e rom build/driver.ihx
sjasmplus --fullpath --raw=build/chgbnk.bin --sym=build/chgbnk.sym --lst=build/chgbnk.lst chgbnk.asm 
sjasmplus --fullpath --raw=build/extra1k.dat --sym=build/extra1k.sym --lst=build/extra1k.lst extra1k.asm
./kernel/mknexrom ./kernel/Nextor-2.1.0.base.dat ./dist/nextor.rom \
						/d:./build/driver.rom /m:./build/chgbnk.bin \
						/e:./build/extra1k.dat

The error occurs in the line sdcc -mz80 --code-loc 0x4200 --data-loc 0xc800 --no-std-crt0 -o build/driver.ihx objs/msxromcrt0.rel objs/driver.rel objs/ch376s.rel objs/hal.rel objs/usbdisk.rel

sdcc: Generating code...
sdcc: Calling assembler...
sdcc: sdasz80 -plosgffw objs/usbdisk.rel objs/usbdisk.asm
sdcc -mz80 --code-loc 0x4200 --data-loc 0xc800 --no-std-crt0 -o build/driver.ihx objs/msxromcrt0.rel objs/driver.rel objs/ch376s.rel objs/hal.rel objs/usbdisk.rel 
at 1: error 4: 'fopen' failed on file 'build/driver.lk'
make: *** [Makefile:43: build/driver.ihx] Error 1

Also I had to pass and argument, in my case true to this line because compiler reports an error.

mount_mode = usbdisk_select_dsk_file ();

@cristianoag
Copy link
Contributor

cristianoag commented Feb 8, 2022 via email

@issalig
Copy link
Author

issalig commented Feb 8, 2022

Yes, I had the build folder, but the problem is I am able to compile the linux folder but not the msx folder.
Can you try rm obj/* and make from the msx folder?

@cristianoag
Copy link
Contributor

cristianoag commented Feb 8, 2022 via email

@issalig
Copy link
Author

issalig commented Feb 8, 2022

Now it works, toolchain ready!

@cristianoag
Copy link
Contributor

cristianoag commented Feb 8, 2022 via email

@issalig
Copy link
Author

issalig commented Feb 8, 2022

So you flash the arduino with https://github.com/S0urceror/MSX-USB/blob/master/test/usb_via_arduino/src/main.parallel.cpp
And then how do you connect it to OpenMSX?

@cristianoag
Copy link
Contributor

cristianoag commented Feb 8, 2022 via email

@issalig
Copy link
Author

issalig commented Feb 8, 2022

I have downloaded OpenMSX from S0urceror and trying to compile it.
@cristianoag I am having problems with libtclcl1-dev
I install them through

sudo apt-get install  libtclcl1-dev

but then ./configure does not find them

  Tcl:              no

[EDIT] I solved libsdl2-ttf-dev looking at the log derived/x86_64-linux-opt/config/probe.log and including libfreetype-dev which is also needed.

@cristianoag
Copy link
Contributor

cristianoag commented Feb 8, 2022 via email

@issalig
Copy link
Author

issalig commented Feb 8, 2022

I am gonna move installation problems from this issue not to fill this one with other things #11

@S0urceror
Copy link
Owner

S0urceror commented Feb 9, 2022

I have just released v0.3 of MSXUSBNext for you to try. v0.3-nxt

@issalig
Copy link
Author

issalig commented Feb 10, 2022

Tested it and it works great!

@cristianoag
Copy link
Contributor

It is working ok here as well. With all my pendrives. I think we can close this one.

@S0urceror
Copy link
Owner

Good to see that MSXUSBNext alleviates most of the issues the low-level MSXUSB had with some drives. Closing this issue now.

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

3 participants