-
Notifications
You must be signed in to change notification settings - Fork 166
Slow reading at compiler version 5.x #190
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
Comments
I've read the thread you've linked and your patch seems reasonable enough. You're probably right that it affects other devices so I'm thinking of something like that: diff --git a/components/retro-go/rg_storage.c b/components/retro-go/rg_storage.c
index c36806c9..79436878 100644
--- a/components/retro-go/rg_storage.c
+++ b/components/retro-go/rg_storage.c
@@ -16,6 +16,7 @@
#endif
#ifdef ESP_PLATFORM
+#include <esp_idf_version.h>
#include <esp_vfs_fat.h>
#endif
@@ -81,6 +82,17 @@ void rg_storage_init(void)
slot_config.host_id = RG_STORAGE_SDSPI_HOST;
slot_config.gpio_cs = RG_GPIO_SDSPI_CS;
+ // If we're using esp-idf >= 5.0 and the SPI bus is not shared, we must keep the SD card selected
+ // to work around slow accesses. (https://github.com/espressif/esp-idf/issues/10493)
+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
+ if (RG_STORAGE_SDSPI_HOST != RG_SCREEN_HOST && RG_GPIO_SDSPI_CS != GPIO_NUM_NC)
+ {
+ gpio_set_direction(RG_GPIO_SDSPI_CS, GPIO_MODE_OUTPUT);
+ gpio_set_level(RG_GPIO_SDSPI_CS, 0);
+ slot_config.gpio_cs = GPIO_NUM_NC;
+ }
+ #endif
+
esp_vfs_fat_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 4, No changes needed in
That's a very good question. It wasn't intentionally removed, I must have done something with git. I will have to look into it... |
You don't have to look which version of the compiler is used. It also works good on the older compiler version. Some person says the loading of the files are also much faster. I think it would be better like i have done at my source. the code like
If you don't modify the config it runs like it is, but if you say GPIO_NUM_NC it don't use CS. With the optinal parameter CS_ORIG you can say which pin you want to set low to always enable the cs. Only devs they want to use this function can enable and disable them over the config file. |
We have the problem when development the brutzelboy that the speed of reading files or the startup with the compiler version 5.x is very slow. Very slow means a normal gameboy game needs about 2 minutes to load. With the compiler verson 4.x the speed is ok, but not very fast.
After simple debugging the code i found out that the read function is very slow. it needs about 2-3 secounds to read one block.
Then i search for any problems with reading from sd card at expressif esp32. I found this link.
espressif/esp-idf#10493
It describe that the fseek function is very slow. If you read the article expressif say they can't find any lost of speed. If the person change the pin from GPIO4 to GPIO13 it works again.
If this is a problem of the hardware, compiler or documentation i don't know, but there is a simple workaround.
Out hardware is ready and we don't want to change anythink on the hardware. So the CS signal you only need if you have more then one device on the spi bus. Most of the schematics has only one device on each spi bus.
I wrote a wirkaround that the cs line is alwas low and active. After compiling it with a 5.x compiler i got .. more speed then before with a 4.x compiled version. We say about 30 up to 50% faster loading.
My code changes:
In retro-go\components\retro-go\rg_storage.c
and retro-go\components\retro-go\targets\brutzelboy\config.h
It's possible that all devices have this problem.
@ducalex why is brutzelboy anymore in the repro?
The text was updated successfully, but these errors were encountered: