Help in understanding the address mapping

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Help in understanding the address mapping

Postby kolban » Fri Oct 14, 2016 4:48 pm

I am studying the ESP32 Technical Reference Manual but unfortunately I'm getting stuck. Specifically, I am studying the system address memory mapping and trying to relate concepts such as RAM, flash, ROM, RTC fast memory, RTC slow memory, data bus and instruction bus to the address maps. When I look at the diagrams, I see multiple arrows from distinct address ranges point to the same components.

I fully believe that the problem in comprehension exists between my ears. I'd love to use this thread as a discussion on this whole conceptual area (address mapping) and start piecing together the understanding of the distinct parts. Can anyone help?

As an example of some of my questions ... if we look at table 4 in the ESP32 Technical Reference we see a table that shows we can access flash at addresses

0x3F40 0000 to 0x3F7F FFFF - 4MBytes - read only
0x400C 2000 to 0x40BF FFFF - ~11MB - read only

How do these relate to each other? If I want to place some "reference data" in flash using esptool.py, how does the Flash address used in esptool.py relate to these addresses? If I want to write flash data from within an ESP32 app, what APIs should I use and what target address ranges should I use?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Help in understanding the address mapping

Postby WiFive » Sat Oct 15, 2016 4:15 am

To expand this into more focused questions...

What is a virtual address?
-- https://en.oxforddictionaries.com/defin ... ual_memory
What is a MMU?
-- https://en.m.wikipedia.org/wiki/Memory_management_unit
What features does the ESP32 MMU have?
--
How/when is the MMU configured?
-- 2nd stage bootloader, enable verbose log to view details
Where is configuration defined?
-- 1. partition table 2. binary image header, derived from elf sections, derived from linker scripts?
How can an absolute flash address be translated into a virtual address?
--
Where can absolute flash addresses be used?
-- spi_flash_ functions, ROM spi functions, esptool
Where can virtual mapped flash addresses be used?
-- used for data/instruction access, cache must be enabled
What are the options for writing to flash memory?
-- spi_flash_write if you want to manage erase yourself, nvs api, add a filesystem api

Experts please add your info...

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Help in understanding the address mapping

Postby ESP_Sprite » Sat Oct 15, 2016 8:39 am

The answer is that there is an MMU that basically can be configured for every 64K chunk (a page) in the address ranges you mention, to get you the data that resides at a certain 64K chunk in flash. I'm editting the technical reference chapter for the MMU right now, as soon as we release that, a lot more will become clear. I'm also working on an addition to esp-idf where you can basically say 'Give me a pointer to flash address 0x123456, I need to access a region 0x12345 bytes long' and you will automagically get a pointer pointing to that data, wherever in flash it may reside.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Help in understanding the address mapping

Postby WiFive » Sat Oct 15, 2016 9:11 am

ESP_Sprite wrote:I'm also working on an addition to esp-idf where you can basically say 'Give me a pointer to flash address 0x123456, I need to access a region 0x12345 bytes long' and you will automagically get a pointer pointing to that data, wherever in flash it may reside.
Sounds good, because as of now it looks like the only mapped regions are from within the application partition so we probably have pointers to that data already.

*not counting the nesemu which maps the whole 4MB.

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Help in understanding the address mapping

Postby ESP_Sprite » Sun Oct 16, 2016 3:45 am

Aye. Which is a PITA for a bunch of my projects, and the map-the-entire-4MB is an evil workaround, so I'd really like to get this mmu driver working in esp-idf. With a bit of luck, I can work on it next week.

Who is online

Users browsing this forum: No registered users and 135 guests