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
715ff5b7
Commit
715ff5b7
authored
Dec 31, 2014
by
HuangRui
Browse files
NodeMCU firmware can auto detect flash size now.
parent
72f60d3e
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/include/user_config.h
View file @
715ff5b7
...
...
@@ -3,10 +3,11 @@
#define NODE_VERSION "NodeMcu 0.9.4"
#define BUILD_DATE "build 20141230"
#define FLASH_512K
//
#define FLASH_512K
// #define FLASH_1M
// #define FLASH_2M
// #define FLASH_4M
#define FLASH_AUTOSIZE
// #define DEVELOP_VERSION
#define FULL_VERSION_FOR_USER
...
...
app/platform/cpu_esp8266.h
View file @
715ff5b7
...
...
@@ -5,6 +5,7 @@
#include "spi_flash.h"
#include "pin_map.h"
#include "user_config.h"
#include "flash_api.h"
// Number of resources (0 if not available/not implemented)
#define NUM_GPIO GPIO_PIN_NUM
#define NUM_SPI 1
...
...
@@ -24,6 +25,8 @@
#define FLASH_SEC_NUM 0x200
#elif defined(FLASH_4M)
#define FLASH_SEC_NUM 0x400
#elif defined(FLASH_AUTOSIZE)
#define FLASH_SEC_NUM (flash_get_sec_num())
#else
#define FLASH_SEC_NUM 0x80
#endif
...
...
app/platform/flash_api.c
0 → 100644
View file @
715ff5b7
/******************************************************************************
* Flash api for NodeMCU
*******************************************************************************/
#include "user_config.h"
#include "flash_api.h"
#include "spi_flash.h"
SPIFlashInfo
*
ICACHE_FLASH_ATTR
flash_get_info
()
{
static
SPIFlashInfo
spi_flash_info
;
static
bool
is_spi_flash_info_initialized
=
false
;
// Make the code more fast
if
(
!
is_spi_flash_info_initialized
)
{
SPIRead
(
0
,
&
spi_flash_info
,
sizeof
(
spi_flash_info
));
is_spi_flash_info_initialized
=
true
;
}
return
&
spi_flash_info
;
}
uint32_t
ICACHE_FLASH_ATTR
flash_get_size_byte
()
{
static
uint32_t
flash_size
=
0
;
// Make the code more fast
if
(
flash_size
==
0
)
{
SPIFlashInfo
*
p_spi_flash_info
=
flash_get_info
();
switch
(
p_spi_flash_info
->
size
)
{
case
SIZE_2MBIT
:
// 2Mbit, 256kByte
flash_size
=
256
*
1024
;
break
;
case
SIZE_4MBIT
:
// 4Mbit, 512kByte
flash_size
=
512
*
1024
;
break
;
case
SIZE_8MBIT
:
// 8Mbit, 1MByte
flash_size
=
1
*
1024
*
1024
;
break
;
case
SIZE_16MBIT
:
// 16Mbit, 2MByte
flash_size
=
2
*
1024
*
1024
;
break
;
case
SIZE_32MBIT
:
// 32Mbit, 4MByte
flash_size
=
4
*
1024
*
1024
;
break
;
default:
// Unknown flash size, fall back mode.
flash_size
=
512
*
1024
;
break
;
}
}
return
flash_size
;
}
uint16_t
ICACHE_FLASH_ATTR
flash_get_sec_num
()
{
static
uint16_t
result
=
0
;
// Make the code more fast
if
(
result
==
0
)
{
result
=
flash_get_size_byte
()
/
SPI_FLASH_SEC_SIZE
;
}
return
result
;
}
\ No newline at end of file
app/platform/flash_api.h
0 → 100644
View file @
715ff5b7
#ifndef __FLASH_API_H__
#define __FLASH_API_H__
#include "ets_sys.h"
typedef
struct
__attribute__
((
packed
))
{
uint8_t
unknown0
;
uint8_t
unknown1
;
enum
{
MODE_QIO
=
0
,
MODE_QOUT
=
1
,
MODE_DIO
=
2
,
MODE_DOUT
=
15
,
}
mode
:
8
;
enum
{
SPEED_40MHZ
=
0
,
SPEED_26MHZ
=
1
,
SPEED_20MHZ
=
2
,
SPEED_80MHZ
=
15
,
}
speed
:
4
;
enum
{
SIZE_4MBIT
=
0
,
SIZE_2MBIT
=
1
,
SIZE_8MBIT
=
2
,
SIZE_16MBIT
=
3
,
SIZE_32MBIT
=
4
,
}
size
:
4
;
}
SPIFlashInfo
;
uint32_t
flash_get_size_byte
();
uint16_t
flash_get_sec_num
();
#endif // __FLASH_API_H__
app/user/user_main.c
View file @
715ff5b7
...
...
@@ -48,6 +48,8 @@ extern void spiffs_mount();
// extern void test_spiffs();
// extern int test_romfs();
// extern uint16_t flash_get_sec_num();
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
...
...
@@ -104,7 +106,7 @@ void user_init(void)
// lua_main( 2, lua_argv );
// char* lua_argv[] = { (char *)"lua", (char *)"-e", (char *)"pwm.setup(0,100,50) pwm.start(0) pwm.stop(0)", NULL };
// lua_main( 3, lua_argv );
// NODE_DBG("Flash sec num: 0x%x\n", flash_get_sec_num());
task_init
();
system_os_post
(
USER_TASK_PRIO_0
,
SIG_LUA
,
's'
);
}
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