Skip to content

WIP DNM esp32: add flash cache support #8783

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

Closed

Conversation

GautierAtWork
Copy link
Contributor

@GautierAtWork GautierAtWork commented Jul 6, 2018

Needs option CONFIG_BOOTLOADER_ESP_IDF

Closes #3722

todo:

  • Add option in Kconfig
  • Add #ifdef around changes in pinmux_esp32.c

@lpereira: an option like CONFIG_ESP32_FLASH_CACHE will be introduced. Two linker scripts will exist then: one with data cache, one without data cache. Will it be ok for you?

@codecov-io
Copy link

codecov-io commented Jul 6, 2018

Codecov Report

Merging #8783 into master will decrease coverage by 0.42%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8783      +/-   ##
==========================================
- Coverage   52.83%   52.41%   -0.43%     
==========================================
  Files         310      198     -112     
  Lines       45311    24912   -20399     
  Branches    10468     5185    -5283     
==========================================
- Hits        23942    13058   -10884     
+ Misses      16584     9754    -6830     
+ Partials     4785     2100    -2685
Impacted Files Coverage Δ
include/bluetooth/buf.h 0% <0%> (-100%) ⬇️
include/drivers/bluetooth/hci_driver.h 0% <0%> (-100%) ⬇️
subsys/random/rand32_timer.c 0% <0%> (-100%) ⬇️
include/bluetooth/hci.h 0% <0%> (-77.78%) ⬇️
drivers/console/native_posix_console.c 22.36% <0%> (-50.36%) ⬇️
boards/posix/native_posix/cmdline.c 16.21% <0%> (-45.49%) ⬇️
subsys/logging/log_output.c 2.72% <0%> (-45.06%) ⬇️
subsys/usb/usb_descriptor.c 0% <0%> (-44.59%) ⬇️
subsys/bluetooth/host/hci_core.c 2.47% <0%> (-41.43%) ⬇️
include/misc/byteorder.h 56.81% <0%> (-40.91%) ⬇️
... and 343 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f90acbf...fb03d9b. Read the comment docs.

Add flash cache support for esp32.

Signed-off-by: Gautier Seidel <[email protected]>
@nashif nashif added the DNM This PR should not be merged (Do Not Merge) label Jul 6, 2018
Copy link
Collaborator

@lpereira lpereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on the pinmux code!

I think it's fine if we have two linker scripts, at least short term. Long term, it should be better to only support building with flash cache enabled; otherwise, it's kind of hard to utilize the full potential of this SoC.

Patch LGTM, but I have a few questions.


*(.literal.*_int_handler .text.*_int_handler)
*(.literal.*_irq_spurious .text.*_irq_spurious)
*(.literal.*i2c_esp32_isr .text.*i2c_esp32_isr)
Copy link
Collaborator

@lpereira lpereira Jul 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a better idea to mark ISRs in ESP32 drivers with an __attribute__(__section__("IRAM")) or something of the sort; otherwise, for each driver for this platform, we'll need to add a line here. It would be great if we had a libdrivers.a to make this even easier.

Also, I'm curious here: say that someone writes an application using the GPIO ports, and they register a callback. Those are executed in interrupt context. If they end up calling a function that happens to not be in the flash cache, what is going to happen?

@@ -202,12 +209,23 @@ SECTIONS
*(.dynamic)
*(.gnu.version_d)
. = ALIGN(4); /* this table MUST be 4-byte aligned */

__devconfig_start = .;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are very much Zephyr-specific; don't we have linker macros for this sort of thing?

iram0_2_seg(RX): org = 0x400D0018, len = 0x330000
dram0_0_seg(RW): org = 0x3FFB0000, len = 0x50000
iram0_2_seg(RX): org = 0x400D0018, len = 0x330000-18
dram0_0_seg(RW): org = 0x3FFB0000, len = 0x2c200
Copy link
Collaborator

@lpereira lpereira Jul 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to explain what's the meaning for -18 and why the dram0_0_seg went from 0x50000 bytes to 0x2c200. I can imagine there are reasons, but linker scripts are tricky and it's best to be as clear as possible with these values.

@galak galak added the platform: ESP32 Espressif ESP32 label Jul 6, 2018
pinmux_set(NULL, pin, 0);
/* pin 6 to 11 are configured for SPI by the second stage bootloader.
* We should not change them, otherwise we can't access the flash
* anymore. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the point here is to disallow software from ever touching those pins through this driver, you probably want to put that rule into pinmux_set(), no?

Honestly, I'm not sure I see much value to this initialization loop anyway. If we have code enabled that cares about particular pin state, it will set it in its own initialization. If not, it's probably better to rely on whatever the bootloader set for us. Forcing "function zero" to be the default for everyone always is just going to cause collisions like this. Maybe just remove the loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment. The idea is to keep the ability to reconfigure these pins during run-time.

Added in board Kconfig for esp32

Signed-off-by: Gautier Seidel <[email protected]>
esp32 pinmux driver doesn't re-initialize the SPI pins if flash cache
is used.

Signed-off-by: Gautier Seidel <[email protected]>
Now two linker scripts are available: one with flash cache suport,
one without.

Signed-off-by: Gautier Seidel <[email protected]>
@aescolar
Copy link
Member

@GautierAtWork This PR seems to have been getting stale for very long.
It would seem you were waiting for some re-reviews(?) If so could you ping those?
Otherwise if you are not planning to continue working on this would you want to close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM This PR should not be merged (Do Not Merge) platform: ESP32 Espressif ESP32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable Flash Cache for ESP32
8 participants