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

USB host support #42

Open
karoria opened this issue Jul 12, 2022 · 10 comments
Open

USB host support #42

karoria opened this issue Jul 12, 2022 · 10 comments

Comments

@karoria
Copy link
Contributor

karoria commented Jul 12, 2022

Hi @terjeio
I was wondering if I can activate native USB host of teensy4.1 and use it as secondary source to read programs from a usb pen drive in addition to sd card. I hope it should be easy. I use PIO for compilation. Can you guide me through the process on which library to include for it and how to host its space alongwith sd on server (including ftp).
Thanks in advance and a big salute for whatever you have done for the DIY CNC community.
Regards,
Ravi

@terjeio
Copy link
Contributor

terjeio commented Jul 13, 2022

It seems the SD card library already supports USB drives. I guess sdcard.c needs to be changed to mount the USB drive instead of the SD card to make it work. More changes is likely needed to make it work alogside the SD card.

@karoria
Copy link
Contributor Author

karoria commented Jul 13, 2022

Ok. Will try it. Thanks.

@karoria
Copy link
Contributor Author

karoria commented Sep 17, 2022

Hi @terjeio sorry I couldn't find what needs to be changed in sdcard.c to mount USB drive instead of SD card. Will you please point me?

@terjeio
Copy link
Contributor

terjeio commented Sep 17, 2022

I believe it is the device name set here.

Perhaps this snippet from one of the uSDFS examples is a clue for what to use?

#if TEST_DRV == 0
  const char *Dev = "0:/";  // SPI
#elif TEST_DRV == 1
  const char *Dev = "1:/";  // SDHC
#elif TEST_DRV == 2
  const char *Dev = "2:/";  // USB
#endif

@karoria
Copy link
Contributor Author

karoria commented Sep 18, 2022

Thanks for hint. I got the definition in driver.c changed it to 2:/ and USB opens through FTP. But there are some weird files along with. I have formatted it with FAT32 but the www directory has some different name like WW~1 I think it should be related to FS or FTP permissions. my webUI doesn't open inspite I have put the www directory in root of USB drive.

@terjeio
Copy link
Contributor

terjeio commented Sep 18, 2022

the www directory has some different name like WW~1

Long filename support is not enabled for FatFs for some reason?

You may also try WebDAV via WinSCP - this does not keep track of current working directory that may mess things up with ftp.

my webUI doesn't open inspite I have put the www directory in root of USB drive.

What about ESP3D WebUI - same?
And do you use the webui backend?
If so then you may try WEBUI_ENABLE 2 instead of 1 to force the v2 protocol - if set to 1 I try to auto detect which one to use. Also be aware that the webui backend is in a somewhat fluid state now due to v3 support beeing finalized.
Oh, and your webui code is gzipped (index.html.gz)?

@karoria
Copy link
Contributor Author

karoria commented Sep 19, 2022

I am not using ESP3D webUI. But will check with it. I am using grblTouch which is not gzipped, so simple to work with. I also don't use any webUI backend (actually I don't understand what do you mean by backend) but I can surely tell you that I have not used any of the code which is inside ESP3D webUI. Will try with Luc's webUI and post the results here as I get time.

@terjeio
Copy link
Contributor

terjeio commented Sep 19, 2022

(actually I don't understand what do you mean by backend)

Ok, this may explain it - I have removed support for fetching index.html from the www directory if no backend is present. You will have to move it too the root directory or implement a mini backend the redirects the request.

A backend is code that processes http requests in different ways depending on the url provided, it is set up by registering url handlers with the http server. It may also register a file redirector with the server that get called when a file is not found - this can be used to look up the file elsewhere in the filing system.

The iMXRT1062 driver has gotten littlefs support, this is for storing files in flash. You may use this to store the grblTouch code, with file redirection you can check if the code is present on the sdcard, if not fall back to littlefs.

@karoria
Copy link
Contributor Author

karoria commented Sep 19, 2022

Ok. That sounds interesting. Actually I am using server.c but my code is little older and there may be lots of changes by you. Will play around with your suggestions. BTW, will you point me on how to save my grblTouch web app to flash? I can see the path you have mentioned in server.c is /embedded for it.

@terjeio
Copy link
Contributor

terjeio commented Sep 19, 2022

BTW, will you point me on how to save my grblTouch web app to flash? I can see the path you have mentioned in server.c is /embedded for it.

The actual file system path is /littlefs - the /embedded file system path is read-only and files are stored in a .c file. The WebUI index.html.gz stored in this file is for updating the WebUI image in littlefs, either when index.html.gz is not found in the / or /www directories or when http:///forcefallback=yes is opened. All this is handled via file redirection in server.c - and you may redirect whatever filenames you want.

With WinSCP I open /littlefs mount via WebDAV by specifying /littlefs as the remote directory in advanced settings.

image

ftp access to mounts other than the root mount is not yet working - I'll fix this later.

A bit more complicated than before I know, but the http server daemon is a lot more flexible now.

If storing grblTouch in flash you really should minimize the javascript and gzip the result- you will save a lot of flash that way. It might not even be possible to store it in flash if not doing so.

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