Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
d84a24fc
Commit
d84a24fc
authored
Dec 08, 2015
by
Johny Mattsson
Committed by
Johny Mattsson
Dec 12, 2015
Browse files
Proper cached-flash to phys address translation.
parent
c4e8b04f
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/platform/common.c
View file @
d84a24fc
...
...
@@ -149,7 +149,7 @@ uint32_t platform_flash_get_first_free_block_address( uint32_t *psect )
uint32_t
start
,
end
,
sect
;
NODE_DBG
(
"_flash_used_end:%08x
\n
"
,
(
uint32_t
)
_flash_used_end
);
if
(
_flash_used_end
>
0
){
// find the used sector
sect
=
flashh_find_sector
(
(
uint32_t
)
_flash_used_end
-
INTERNAL_FLASH_MAPPED_ADDRESS
-
1
,
NULL
,
&
end
);
sect
=
flashh_find_sector
(
platform_flash_mapped2phys
(
(
uint32_t
)
_flash_used_end
-
1
)
,
NULL
,
&
end
);
if
(
psect
)
*
psect
=
sect
+
1
;
return
end
+
1
;
...
...
app/platform/cpu_esp8266.h
View file @
d84a24fc
...
...
@@ -68,4 +68,9 @@
#define flash_read spi_flash_read
#endif // defined(FLASH_SAFE_API)
#define CACHE_FLASH_CTRL_REG 0x3ff0000c
#define CACHE_FLASH_ACTIVE 0x00000100
#define CACHE_FLASH_MAPPED0 0x02000000
#define CACHE_FLASH_MAPPED1 0x00010000
#endif // #ifndef __CPU_ESP8266_H__
app/platform/platform.c
View file @
d84a24fc
...
...
@@ -579,3 +579,14 @@ int platform_flash_erase_sector( uint32_t sector_id )
system_soft_wdt_feed
();
return
flash_erase
(
sector_id
)
==
SPI_FLASH_RESULT_OK
?
PLATFORM_OK
:
PLATFORM_ERR
;
}
uint32_t
platform_flash_mapped2phys
(
uint32_t
mapped_addr
)
{
uint32_t
cache_ctrl
=
READ_PERI_REG
(
CACHE_FLASH_CTRL_REG
);
if
(
!
(
cache_ctrl
&
CACHE_FLASH_ACTIVE
))
return
-
1
;
bool
b0
=
(
cache_ctrl
&
CACHE_FLASH_MAPPED0
)
?
1
:
0
;
bool
b1
=
(
cache_ctrl
&
CACHE_FLASH_MAPPED1
)
?
1
:
0
;
uint32_t
meg
=
(
b1
<<
1
)
|
b0
;
return
mapped_addr
-
INTERNAL_FLASH_MAPPED_ADDRESS
+
meg
*
0x100000
;
}
app/platform/platform.h
View file @
d84a24fc
...
...
@@ -237,6 +237,16 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size );
uint32_t
platform_flash_get_num_sectors
(
void
);
int
platform_flash_erase_sector
(
uint32_t
sector_id
);
/**
* Translated a mapped address to a physical flash address, based on the
* current flash cache mapping.
* @param mapped_addr Address to translate (>= INTERNAL_FLASH_MAPPED_ADDRESS)
* @return the corresponding physical flash address, or -1 if flash cache is
* not currently active.
* @see Cache_Read_Enable.
*/
uint32_t
platform_flash_mapped2phys
(
uint32_t
mapped_addr
);
// *****************************************************************************
// Allocator support
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment