-
Notifications
You must be signed in to change notification settings - Fork 710
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
I'm stuck with u8g2 #364
Comments
I am using this HAL with the ESP_IDF. I am getting the same error as Marek. However I noticed that I am only getting this error when the ESP32 logging component is set to anything other than Info. When the Log level is set to Info, the code runs great. Does anyone have any idea why this is happening and what can be done to fix it? |
Hi Jim Best Regards |
Here is a turnkey project based on Neil's example:
This will compile and run as is, however if you change the log verbosity to anything other than 'Info' the example will crash and burn at the same point, and in the same way as your issue. Good luck. |
I think I have found out what the issue is and have a fix or workaround (however you want to look at it). First off, I found out the the issue only happens when I have set the ESP32 clock speed down to the slowest setting; 80Mhz. At higher clock speeds the issue goes away. The following is a snippet from the file test_SSD1306.c:
Function u8g2_esp32_hal_init is implement in the hal as follows::
As you can see, u8g2_esp32_hal_init copies the structure that is passed in by value to a local copy. My theory is that function u8g2_esp32_hal_init returns before the entire contents of the passed in structure is copied to the local structure.. When function u8g2_InitDisplay is called, it makes a callback into the hal where the structure is used to initialize the spi interface before it is fully copied. My fix/workaround is to add a delay before between when functions u8g2_esp32_hal_init and u8g2_InitDisplay is called as follows:
On my system, this make the problem go away in all cases that I have tried. One interesting observation is that placing the delay inside the function u8g2_esp32_hal_init does not work:
Perhaps vTaskDelay takes away CPU time to the structure copy operation when it is used inside the hal init function and it doesn't remove CPU time when it is used at the higher level. |
Jim, many thanks for Your valuable help. We are using u8g2 now in our project. Best Regards |
@JimGaluska Your fix did it for me as well. I spent a quarter day on this before adding |
Another thing to check: are all your struct elements properly set or cleared? I ran into a similar crash using the i2c version. I found that u8g2_esp32_i2c_byte_cb() (in u8g2_esp32_hal.c) created a struct I saw a similar fix for the SPI version in a pull request: #884 |
Thanks Adam - this was exactly the problem I had and setting |
Hi,
I would like to use 8ug2 in SPI mode. I have copied Your files into clean project but it crashes during SPI initialization. I have tried VSPI and HSPI, I'm pretty sure my PIN's are ok because this board works when I compile it for Arduino project.
On Arduino I'm using this board:
U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 0, /* dc=*/21, /* reset=*/ 5);
This is my main.c
This is output during start on VSPI and HSPI
I would be grateful if You can give my any tpis why it refuses to work ;)
It looks like an memory error:
#define ESP_ERR_NO_MEM 0x101
Best Regards
Marek
The text was updated successfully, but these errors were encountered: