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
d6980ad8
Unverified
Commit
d6980ad8
authored
May 19, 2019
by
Terry Ellison
Committed by
GitHub
May 19, 2019
Browse files
SDK 3.0 tranche3 (#2761)
Force libpp.a into iRAM, and backout redundant IRAM_DATA_ATTR changes
parent
45a7187a
Changes
10
Hide whitespace changes
Inline
Side-by-side
app/esp-gdbstub/gdbstub.c
View file @
d6980ad8
...
@@ -107,7 +107,7 @@ extern void xthal_set_intenable(int);
...
@@ -107,7 +107,7 @@ extern void xthal_set_intenable(int);
#define OBUFLEN 32
#define OBUFLEN 32
//The asm stub saves the Xtensa registers here when a debugging exception happens.
//The asm stub saves the Xtensa registers here when a debugging exception happens.
struct
XTensa_exception_frame_s
IRAM_DATA_ATTR
gdbstub_savedRegs
;
struct
XTensa_exception_frame_s
gdbstub_savedRegs
;
#if GDBSTUB_USE_OWN_STACK
#if GDBSTUB_USE_OWN_STACK
//This is the debugging exception stack.
//This is the debugging exception stack.
int
exceptionStack
[
256
];
int
exceptionStack
[
256
];
...
...
app/include/user_config.h
View file @
d6980ad8
...
@@ -273,14 +273,7 @@ extern void luaL_dbgbreak(void);
...
@@ -273,14 +273,7 @@ extern void luaL_dbgbreak(void);
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_STRING(x) ICACHE_STRING2(x)
#define ICACHE_STRING(x) ICACHE_STRING2(x)
#define ICACHE_STRING2(x) #x
#define ICACHE_STRING2(x) #x
#define ICACHE_RAM_ATTR \
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text." __FILE__ "." ICACHE_STRING(__LINE__))))
__attribute__((section(".iram0.text." __FILE__ "." ICACHE_STRING(__LINE__))))
#define ICACHE_FLASH_RESERVED_ATTR \
__attribute__((section(".irom.reserved." __FILE__ "." ICACHE_STRING(__LINE__)),\
used,unused,aligned(INTERNAL_FLASH_SECTOR_SIZE)))
#define IRAM_DATA_ATTR \
__attribute__((section(".iram0.data." __FILE__ "." ICACHE_STRING(__LINE__))))
#ifdef GPIO_SAFE_NO_INTR_ENABLE
#ifdef GPIO_SAFE_NO_INTR_ENABLE
#define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline))
#define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline))
#else
#else
...
...
app/lua/lauxlib.c
View file @
d6980ad8
...
@@ -918,11 +918,6 @@ static int l_check_memlimit(lua_State *L, size_t needbytes) {
...
@@ -918,11 +918,6 @@ static int l_check_memlimit(lua_State *L, size_t needbytes) {
return
(
g
->
totalbytes
>=
limit
)
?
1
:
0
;
return
(
g
->
totalbytes
>=
limit
)
?
1
:
0
;
}
}
#ifndef LUA_CROSS_COMPILER
#define REALLOC(p,o,n) (void *) this_realloc(p,o,n)
#else
#define REALLOC(p,o,n) (void *) (ptr? this_realloc(p,o,n) : c_malloc(n))
#endif
static
void
*
l_alloc
(
void
*
ud
,
void
*
ptr
,
size_t
osize
,
size_t
nsize
)
{
static
void
*
l_alloc
(
void
*
ud
,
void
*
ptr
,
size_t
osize
,
size_t
nsize
)
{
lua_State
*
L
=
(
lua_State
*
)
ud
;
lua_State
*
L
=
(
lua_State
*
)
ud
;
...
@@ -951,11 +946,10 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
...
@@ -951,11 +946,10 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
if
(
G
(
L
)
->
memlimit
>
0
&&
(
mode
&
EGC_ON_MEM_LIMIT
)
&&
l_check_memlimit
(
L
,
nsize
-
osize
))
if
(
G
(
L
)
->
memlimit
>
0
&&
(
mode
&
EGC_ON_MEM_LIMIT
)
&&
l_check_memlimit
(
L
,
nsize
-
osize
))
return
NULL
;
return
NULL
;
}
}
nptr
=
REALLOC
(
ptr
,
osize
,
nsize
);
nptr
=
(
void
*
)
this_realloc
(
ptr
,
osize
,
nsize
);
if
(
nptr
==
NULL
&&
L
!=
NULL
&&
(
mode
&
EGC_ON_ALLOC_FAILURE
))
{
if
(
nptr
==
NULL
&&
L
!=
NULL
&&
(
mode
&
EGC_ON_ALLOC_FAILURE
))
{
dbg_printf
(
"Emergency full collection
\n
"
);
/**** DEBUG ***/
luaC_fullgc
(
L
);
/* emergency full collection. */
luaC_fullgc
(
L
);
/* emergency full collection. */
nptr
=
REALLOC
(
ptr
,
osize
,
nsize
);
/* try allocation again */
nptr
=
(
void
*
)
this_realloc
(
ptr
,
osize
,
nsize
);
/* try allocation again */
}
}
return
nptr
;
return
nptr
;
}
}
...
...
app/lua/lrotable.c
View file @
d6980ad8
...
@@ -15,11 +15,6 @@
...
@@ -15,11 +15,6 @@
#define ALIGNED_STRING (__attribute__((aligned(4))) char *)
#define ALIGNED_STRING (__attribute__((aligned(4))) char *)
#endif
#endif
#ifdef LUA_CROSS_COMPILER
#undef IRAM_DATA_ATTR
#define IRAM_DATA_ATTR
#endif
#define LA_LINES 32
#define LA_LINES 32
#define LA_SLOTS 4
#define LA_SLOTS 4
//#define COLLECT_STATS
//#define COLLECT_STATS
...
@@ -50,7 +45,7 @@ typedef struct {
...
@@ -50,7 +45,7 @@ typedef struct {
unsigned
ndx
:
8
;
unsigned
ndx
:
8
;
}
cache_line_t
;
}
cache_line_t
;
static
cache_line_t
IRAM_DATA_ATTR
cache
[
LA_LINES
][
LA_SLOTS
];
static
cache_line_t
cache
[
LA_LINES
][
LA_SLOTS
];
#ifdef COLLECT_STATS
#ifdef COLLECT_STATS
unsigned
cache_stats
[
3
];
unsigned
cache_stats
[
3
];
...
...
app/lwip/core/dns.c
View file @
d6980ad8
...
@@ -222,7 +222,7 @@ static void dns_check_entries(void);
...
@@ -222,7 +222,7 @@ static void dns_check_entries(void);
/* DNS variables */
/* DNS variables */
static
struct
udp_pcb
*
dns_pcb
;
static
struct
udp_pcb
*
dns_pcb
;
static
u8_t
dns_seqno
;
static
u8_t
dns_seqno
;
static
struct
dns_table_entry
IRAM_DATA_ATTR
dns_table
[
DNS_TABLE_SIZE
];
static
struct
dns_table_entry
dns_table
[
DNS_TABLE_SIZE
];
static
ip_addr_t
dns_servers
[
DNS_MAX_SERVERS
];
static
ip_addr_t
dns_servers
[
DNS_MAX_SERVERS
];
/** Contiguous buffer for processing responses */
/** Contiguous buffer for processing responses */
//static u8_t dns_payload_buffer[LWIP_MEM_ALIGN_BUFFER(DNS_MSG_SIZE)];
//static u8_t dns_payload_buffer[LWIP_MEM_ALIGN_BUFFER(DNS_MSG_SIZE)];
...
...
app/modules/file.c
View file @
d6980ad8
...
@@ -703,6 +703,14 @@ LROT_END( file, NULL, 0 )
...
@@ -703,6 +703,14 @@ LROT_END( file, NULL, 0 )
int
luaopen_file
(
lua_State
*
L
)
{
int
luaopen_file
(
lua_State
*
L
)
{
if
(
!
vfs_mount
(
"/FLASH"
,
0
))
{
// Failed to mount -- try reformat
dbg_printf
(
"Formatting file system. Please wait...
\n
"
);
if
(
!
vfs_format
())
{
NODE_ERR
(
"
\n
*** ERROR ***: unable to format. FS might be compromised.
\n
"
);
NODE_ERR
(
"It is advised to re-flash the NodeMCU image.
\n
"
);
}
}
luaL_rometatable
(
L
,
"file.vol"
,
LROT_TABLEREF
(
file_vol
));
luaL_rometatable
(
L
,
"file.vol"
,
LROT_TABLEREF
(
file_vol
));
luaL_rometatable
(
L
,
"file.obj"
,
LROT_TABLEREF
(
file_obj
));
luaL_rometatable
(
L
,
"file.obj"
,
LROT_TABLEREF
(
file_obj
));
return
0
;
return
0
;
...
...
app/platform/platform.c
View file @
d6980ad8
...
@@ -923,7 +923,6 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
...
@@ -923,7 +923,6 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
int
platform_flash_erase_sector
(
uint32_t
sector_id
)
int
platform_flash_erase_sector
(
uint32_t
sector_id
)
{
{
NODE_DBG
(
"flash_erase_sector(%u)
\n
"
,
sector_id
);
NODE_DBG
(
"flash_erase_sector(%u)
\n
"
,
sector_id
);
system_soft_wdt_feed
();
return
flash_erase
(
sector_id
)
==
SPI_FLASH_RESULT_OK
?
PLATFORM_OK
:
PLATFORM_ERR
;
return
flash_erase
(
sector_id
)
==
SPI_FLASH_RESULT_OK
?
PLATFORM_OK
:
PLATFORM_ERR
;
}
}
...
...
app/spiffs/spiffs.c
View file @
d6980ad8
...
@@ -28,10 +28,10 @@ static spiffs fs;
...
@@ -28,10 +28,10 @@ static spiffs fs;
#define MASK_1MB (0x100000-1)
#define MASK_1MB (0x100000-1)
#define ALIGN (0x2000)
#define ALIGN (0x2000)
static
u8_t
IRAM_DATA_ATTR
spiffs_work_buf
[
LOG_PAGE_SIZE
*
2
];
static
u8_t
spiffs_work_buf
[
LOG_PAGE_SIZE
*
2
];
static
u8_t
spiffs_fds
[
sizeof
(
spiffs_fd
)
*
SPIFFS_MAX_OPEN_FILES
];
static
u8_t
spiffs_fds
[
sizeof
(
spiffs_fd
)
*
SPIFFS_MAX_OPEN_FILES
];
#if SPIFFS_CACHE
#if SPIFFS_CACHE
static
u8_t
IRAM_DATA_ATTR
myspiffs_cache
[
20
+
(
LOG_PAGE_SIZE
+
20
)
*
4
];
static
u8_t
myspiffs_cache
[
20
+
(
LOG_PAGE_SIZE
+
20
)
*
4
];
#endif
#endif
static
s32_t
my_spiffs_read
(
u32_t
addr
,
u32_t
size
,
u8_t
*
dst
)
{
static
s32_t
my_spiffs_read
(
u32_t
addr
,
u32_t
size
,
u8_t
*
dst
)
{
...
@@ -44,12 +44,18 @@ static s32_t my_spiffs_write(u32_t addr, u32_t size, u8_t *src) {
...
@@ -44,12 +44,18 @@ static s32_t my_spiffs_write(u32_t addr, u32_t size, u8_t *src) {
return
SPIFFS_OK
;
return
SPIFFS_OK
;
}
}
static
int
erase_cnt
=
-
1
;
// If set to >=0 then erasing gives a ... feedback
static
s32_t
my_spiffs_erase
(
u32_t
addr
,
u32_t
size
)
{
static
s32_t
my_spiffs_erase
(
u32_t
addr
,
u32_t
size
)
{
u32_t
sect_first
=
platform_flash_get_sector_of_address
(
addr
);
u32_t
sect_first
=
platform_flash_get_sector_of_address
(
addr
);
u32_t
sect_last
=
sect_first
;
u32_t
sect_last
=
sect_first
;
while
(
sect_first
<=
sect_last
)
while
(
sect_first
<=
sect_last
)
{
if
(
platform_flash_erase_sector
(
sect_first
++
)
==
PLATFORM_ERR
)
if
(
erase_cnt
>=
0
&&
(
erase_cnt
++
&
0xF
)
==
0
)
{
dbg_printf
(
"."
);
}
if
(
platform_flash_erase_sector
(
sect_first
++
)
==
PLATFORM_ERR
)
{
return
SPIFFS_ERR_INTERNAL
;
return
SPIFFS_ERR_INTERNAL
;
}
}
return
SPIFFS_OK
;
return
SPIFFS_OK
;
}
}
...
@@ -152,31 +158,12 @@ int myspiffs_format( void )
...
@@ -152,31 +158,12 @@ int myspiffs_format( void )
SPIFFS_unmount
(
&
fs
);
SPIFFS_unmount
(
&
fs
);
NODE_DBG
(
"Formatting: size 0x%x, addr 0x%x
\n
"
,
fs
.
cfg
.
phys_size
,
fs
.
cfg
.
phys_addr
);
NODE_DBG
(
"Formatting: size 0x%x, addr 0x%x
\n
"
,
fs
.
cfg
.
phys_size
,
fs
.
cfg
.
phys_addr
);
erase_cnt
=
0
;
int
status
=
SPIFFS_format
(
&
fs
);
erase_cnt
=
-
1
;
if
(
SPIFFS_format
(
&
fs
)
<
0
)
{
return
status
<
0
?
0
:
myspiffs_mount
(
FALSE
);
return
0
;
}
return
myspiffs_mount
(
FALSE
);
}
#if 0
void test_spiffs() {
char buf[12];
// Surely, I've mounted spiffs before entering here
spiffs_file fd = SPIFFS_open(&fs, "my_file", SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0);
if (SPIFFS_write(&fs, fd, (u8_t *)"Hello world", 12) < 0) NODE_DBG("errno %i\n", SPIFFS_errno(&fs));
SPIFFS_close(&fs, fd);
fd = SPIFFS_open(&fs, "my_file", SPIFFS_RDWR, 0);
if (SPIFFS_read(&fs, fd, (u8_t *)buf, 12) < 0) NODE_DBG("errno %i\n", SPIFFS_errno(&fs));
SPIFFS_close(&fs, fd);
NODE_DBG("--> %s <--\n", buf);
}
}
#endif
// ***************************************************************************
// ***************************************************************************
...
...
app/user/user_main.c
View file @
d6980ad8
...
@@ -92,6 +92,7 @@ static const struct defaultpt rompt IROM_PTABLE_ATTR USED_ATTR = {
...
@@ -92,6 +92,7 @@ static const struct defaultpt rompt IROM_PTABLE_ATTR USED_ATTR = {
static
uint32_t
first_time_setup
(
partition_item_t
*
pt
,
uint32_t
n
,
uint32_t
flash_size
);
static
uint32_t
first_time_setup
(
partition_item_t
*
pt
,
uint32_t
n
,
uint32_t
flash_size
);
static
void
phy_data_setup
(
partition_item_t
*
pt
,
uint32_t
n
);
static
void
phy_data_setup
(
partition_item_t
*
pt
,
uint32_t
n
);
extern
void
_ResetHandler
(
void
);
/*
/*
* The non-OS SDK prolog has been fundamentally revised in V3. See SDK EN document
* The non-OS SDK prolog has been fundamentally revised in V3. See SDK EN document
...
@@ -166,7 +167,7 @@ void user_pre_init(void) {
...
@@ -166,7 +167,7 @@ void user_pre_init(void) {
return
;
return
;
}
}
os_printf
(
"Invalid system partition table
\n
"
);
os_printf
(
"Invalid system partition table
\n
"
);
while
(
1
)
;
// Trigger WDT}
while
(
1
)
{};
}
}
/*
/*
...
@@ -266,7 +267,8 @@ static uint32_t first_time_setup(partition_item_t *pt, uint32_t n, uint32_t flas
...
@@ -266,7 +267,8 @@ static uint32_t first_time_setup(partition_item_t *pt, uint32_t n, uint32_t flas
}
}
platform_rcr_write
(
PLATFORM_RCR_PT
,
pt
,
newn
*
sizeof
(
partition_item_t
));
platform_rcr_write
(
PLATFORM_RCR_PT
,
pt
,
newn
*
sizeof
(
partition_item_t
));
while
(
1
);
// Trigger WDT; the new PT will be loaded on reboot
ets_delay_us
(
5000
);
_ResetHandler
();
// Trigger reset; the new PT will be loaded on reboot
}
}
uint32
ICACHE_RAM_ATTR
user_iram_memory_is_enabled
(
void
)
{
uint32
ICACHE_RAM_ATTR
user_iram_memory_is_enabled
(
void
)
{
...
@@ -305,18 +307,6 @@ void nodemcu_init(void) {
...
@@ -305,18 +307,6 @@ void nodemcu_init(void) {
NODE_DBG
(
"Can not init platform for modules.
\n
"
);
NODE_DBG
(
"Can not init platform for modules.
\n
"
);
return
;
return
;
}
}
#ifdef BUILD_SPIFFS
if
(
!
vfs_mount
(
"/FLASH"
,
0
))
{
// Failed to mount -- try reformat
dbg_printf
(
"Formatting file system. Please wait...
\n
"
);
if
(
!
vfs_format
())
{
NODE_ERR
(
"
\n
*** ERROR ***: unable to format. FS might be compromised.
\n
"
);
NODE_ERR
(
"It is advised to re-flash the NodeMCU image.
\n
"
);
}
}
#endif
if
(
!
task_post_low
(
task_get_id
(
start_lua
),
's'
))
if
(
!
task_post_low
(
task_get_id
(
start_lua
),
's'
))
NODE_ERR
(
"Failed to post the start_lua task!
\n
"
);
NODE_ERR
(
"Failed to post the start_lua task!
\n
"
);
}
}
...
...
ld/nodemcu.ld
View file @
d6980ad8
...
@@ -104,25 +104,20 @@ SECTIONS
...
@@ -104,25 +104,20 @@ SECTIONS
*(.entry.text)
*(.entry.text)
*(.init.literal)
*(.init.literal)
*(.init)
*(.init)
/*
/* SDK libraries that used in bootup process, interruption handling
* SDK libraries that used in bootup process, interruption handling
* and other ways where flash cache (iROM) is unavailable: */
* and other ways where flash cache (iROM) is unavailable:
*libmain.a:*(.literal .literal.* .text .text.*)
*/
*libnet80211.a:*(.literal .text)
*libmain.a:*( .literal .literal.* .text .text.*)
*libphy.a:*(.literal .text)
*libphy.a:*( .literal .literal.* .text .text.*)
*libpp.a:*(.literal .text)
*libpp.a:*( .literal .literal.* .text .text.*)
*libgcc.a:*(.literal .text)
*libgcc.a:*( .literal .literal.* .text .text.*)
/*
/* Following SDK libraries have .text sections, but not included in iRAM: */
* The following SDK libraries have .literal and .text sections, but are
/* *libat.a:*(.literal .text) - not used anywhere in NodeMCU */
* either not used in NodeMCU or are safe to execute out of in iROM:
/* *libcrypto.a:*(.literal .text) - tested that safe to keep in iROM */
* libat.a libcrypto.a libdriver.a libnet80211.a libespnow.a
/* *libdriver.a:*(.literal .text) - not used anywhere in NodeMCU */
* liblwip_536.a ibpwm.a libwpa.a ibwps.a
/* *libespnow.a:*(.literal .text) - not used anywhere in NodeMCU */
*/
/* *liblwip_536.a:*(.literal .text) - source-based library used instead */
/* *libpwm.a:*(.literal .text) - our own implementation used instead */
/* *libwpa.a:*(.literal .text) - tested that safe to keep in iROM */
/* *libwps.a:*(.literal .text) - tested that safe to keep in iROM */
*(.iram.text .iram0.text .iram0.text.*)
*(.iram.text .iram0.text .iram0.text.*)
*(.iram0.data.*)
*(.iram0.data.*)
...
@@ -260,7 +255,6 @@ SECTIONS
...
@@ -260,7 +255,6 @@ SECTIONS
/* Reserved areas, flash page aligned and last */
/* Reserved areas, flash page aligned and last */
. = ALIGN(4096);
. = ALIGN(4096);
KEEP(*(.irom.reserved .irom.reserved.*))
_irom0_text_end = ABSOLUTE(.);
_irom0_text_end = ABSOLUTE(.);
_flash_used_end = ABSOLUTE(.);
_flash_used_end = ABSOLUTE(.);
...
...
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