-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conflicts between USB and IO modules vs M5 libraries #11
Comments
More testing, no final conclusion yet. Dealing with the USBHost issue first. I was able to get the USB Host working well on the Core Basic using the M5Stack lib. Further I put the buttons and app loop into FreeRTOS tasks joining the USBHost.task. Changed all delay() to vTaskDelay(). Added in some defines for CoreS3 to switch I2C and SPI pins and the M5.begin()/M5.Power(). The newer libs use auto cfg = M5.config() + M5.begin(cfg). Put some stack size probes in and adjusted each stack size to give at least 2000 words extra from the lowest free space I observed during run time. If any task gets below 1000 words free stack space a very noticeable debug line will print on the serial. I can switch freely between BT and USBHost no problem so far. I disconnect BT (not end it) when switching to host. Further new logic will force a radio address search when the search button is pressed. Switching modes will use the last address used if 'auto_address' var is set to 0. 1 forces a new search in every condition. I observed the polling rates in and outside of the RTOS task and tweaked some delays, generally reducing them to minimal values. Some printouts staged will show a visual timely for each scheduling. The major reason for moving the main app loop to a RTOS task is because I observed:
In summary, compatibility seems a bit of a mess. I miss my Teensy4 world. |
Made further progress. Can run USB Host on the Core2 with the M5Core2.h and get USB to run as long as the Basic. M5Unified.h kills off USB Host promptly. Talking over i2c to the IO module kills off USB Host, hangs the process. Modified the pins assignments in the USB host library, no change. USB Host works OK on an early version of the program before the graphics and IO module were added. Given how M5.Unified acts so different than M5Core2.h, it feels like the CS and INT pins may not be handled correctly as they are different for each model. I do not think the CoreS3 talks to the IO module or runs I2C scan, but I can see the factory program scan the I2C bus OK. |
Now have the CoreS3, Core2 and Core Basic all working with the IO module, SD card, graphics and partly, buttons (of various methods). All of these CPUs models fail to operate with the USB V1.2 module when there is any IO and graphics activity. The FreeRTOS USB Host task appears to be alive in some part evidenced by pulling the USB cable out and the disconnect event fires off. However the app_loop and main loop appear halted or hung. My working assumption is a broken or missed event related to SPI communications. I would not be surprised if it was using the wrong pins at times, or worse, not managing access to SPI bus, possibly busting other process's SPI operations putting them into a wait state. There may be USB data there, but no way to extract it. USB Host works on an older version of code before IO module or graphics. Add either, and things hang in short order. The fact it can work for a random time further suggests it is a SPI bus timing/access issue. |
Found that USBHost will run for a very long time, over a day, IF I run it in the foreground with no optional timeout parameters. It will respond to radio side issued messages and let the main loop run one time so the display gets updated, but then after all other functions are blocked - buttons, polling. If I add a timeout, say 5ms, or 1ms, it will let the main loop run every 5 or 1ms one time. It eventually hangs. It makes sense it would do this waiting for events if it was run as a task in FreeRTOS, but that always results in a lockup in short order when combined with other things like graphics and IO. Tried different SPI bus frequency settings, no improvement. |
I have managed to see the 4-In/8-Out and the USB Host modules work with a Core3-Se finally, using the examples. Am using the M5Core3.h lib. If USB and IO stay stable, I may add the BLE code to the existing BT Classic and shift to the Core3. I ordered a Core2 to test with.
I have run into a challenge getting the USB host v1.2 module to work the M5Unified library. It works with M5Stack lib (sometimes). I think it works best with no M5 lib. For reasons I cannot pin down the USB host may lock up after a minute or less, or it can run forever I have seen it run days but some seemingly unrelated changes I go to test USB and it does not work right anymore. I am thinking it has something to do with the FREERTOS underneath TinyUSB lib. The example do not use any M5Stack or M5Unified lib. I have older and newer versions of the full program, the older one works, but have not identified why, they look identical. Reminds me of the ancient days when non-printable characters in the editor broke builds.
The IO module does not seem to work with the M5Stack, thus the need to move to the M5Unified lib, which then breaks USB Host. Like the USB, the examples do not use the M5xxx libs.
Maybe can skip the M5xxx libs and get graphics through another lib like M5GFX.h. This has been frustrating and time consuming to nail down. The Core2/3 may be an exit plan if they work.
The text was updated successfully, but these errors were encountered: