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

ESP32 PSRAM behaves erratically if flashed using 80Mhz flash mode #1566

Open
daagaak opened this issue May 19, 2024 · 3 comments
Open

ESP32 PSRAM behaves erratically if flashed using 80Mhz flash mode #1566

daagaak opened this issue May 19, 2024 · 3 comments

Comments

@daagaak
Copy link

daagaak commented May 19, 2024

I've been experiencing some erratic behaviour in my ESP32 trying to enable PSRAM on my WROOM-E module (confirmed to have an 8MB PSRAM module).

Attempting to synthesize this down to a broken test case, I generated a new esp-template project, and replaced the heap section with:

fn init_heap(p: PSRAM) {
    esp_hal::psram::init_psram(p);
    unsafe {
        ALLOCATOR.init(
            esp_hal::psram::psram_vaddr_start() as *mut u8,
            esp_hal::psram::PSRAM_BYTES,
        );
    }
}

And changed the init_heap call to be:

    init_heap(peripherals.PSRAM);

This actually works as expected when you espflash with the default settings. However, if you bump up the flash speed to 80mhz with -f 80mhz then I've seen it either:

  • Hang during PSRAM init
  • Throw a LoadProhibited during PSRAM init
  • Throw a IllegalInstruction during PSRAM init.

I think this is because the esp32 HAL PSRAM code assumes that you're running in 40mhz Flash/40mhz PSRAM mode:

 345⋮    │        let mode = PsramCacheSpeed::PsramCacheF40mS40m; // How to make this configurable
@MabezDev
Copy link
Member

I think this is because the esp32 HAL PSRAM code assumes that you're running in 40mhz Flash/40mhz PSRAM mode:

Could you try changing this locally in esp-hal and seeing if with the correct mode it works?

@daagaak
Copy link
Author

daagaak commented May 20, 2024

Yes is does. I've been running with it set (unconditionally) to PsramCacheF80S80 since yesterday and it seems to work reliably.

@bjoernQ
Copy link
Contributor

bjoernQ commented May 21, 2024

I think the comment // How to make this configurable is the key thing - we could use (another) cargo-feature for it but ideally, we should have #1111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

3 participants