Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
0420b6d7
Commit
0420b6d7
authored
Jan 02, 2015
by
HuangRui
Browse files
Add definition of NODE_STORE_TYPEDEF_ATTR and NODE_STORE_ATTR.
parent
1b9479a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/include/user_config.h
View file @
0420b6d7
...
@@ -35,7 +35,8 @@
...
@@ -35,7 +35,8 @@
#define NODE_ERR
#define NODE_ERR
#endif
/* NODE_ERROR */
#endif
/* NODE_ERROR */
#define NODE_STORE_ATTR __attribute__((aligned(4),packed))
#define NODE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define NODE_STORE_ATTR __attribute__((aligned(4)))
#define CLIENT_SSL_ENABLE
#define CLIENT_SSL_ENABLE
#define GPIO_INTERRUPT_ENABLE
#define GPIO_INTERRUPT_ENABLE
...
...
app/platform/flash_api.c
View file @
0420b6d7
...
@@ -7,12 +7,10 @@
...
@@ -7,12 +7,10 @@
#include "flash_api.h"
#include "flash_api.h"
#include "spi_flash.h"
#include "spi_flash.h"
#include "c_stdio.h"
SPIFlashInfo
*
ICACHE_FLASH_ATTR
SPIFlashInfo
*
ICACHE_FLASH_ATTR
flash_get_info
(
void
)
flash_get_info
(
void
)
{
{
static
SPIFlashInfo
spi_flash_info
__attribute__
((
aligned
(
4
)))
;
static
SPIFlashInfo
spi_flash_info
NODE_STORE_ATTR
;
static
bool
is_spi_flash_info_initialized
=
false
;
static
bool
is_spi_flash_info_initialized
=
false
;
// Make the code more fast
// Make the code more fast
if
(
!
is_spi_flash_info_initialized
)
if
(
!
is_spi_flash_info_initialized
)
...
@@ -20,7 +18,8 @@ flash_get_info(void)
...
@@ -20,7 +18,8 @@ flash_get_info(void)
SPIRead
(
0
,
&
spi_flash_info
,
sizeof
(
spi_flash_info
));
SPIRead
(
0
,
&
spi_flash_info
,
sizeof
(
spi_flash_info
));
is_spi_flash_info_initialized
=
true
;
is_spi_flash_info_initialized
=
true
;
}
}
return
&
spi_flash_info
;
// return (SPIFlashInfo *)(0x40200000);
return
&
spi_flash_info
;
}
}
uint8_t
ICACHE_FLASH_ATTR
uint8_t
ICACHE_FLASH_ATTR
...
@@ -75,8 +74,7 @@ flash_set_size(uint8_t size)
...
@@ -75,8 +74,7 @@ flash_set_size(uint8_t size)
// Dangerous, here are dinosaur infested!!!!!
// Dangerous, here are dinosaur infested!!!!!
// Reboot required!!!
// Reboot required!!!
// If you don't know what you're doing, your nodemcu may turn into stone ...
// If you don't know what you're doing, your nodemcu may turn into stone ...
c_printf
(
"
\n
Set size!!! %d
\n
"
,
size
);
uint8_t
data
[
SPI_FLASH_SEC_SIZE
]
NODE_STORE_ATTR
;
uint8_t
data
[
SPI_FLASH_SEC_SIZE
]
__attribute__
((
aligned
(
4
)));
SPIRead
(
0
,
data
,
sizeof
(
data
));
SPIRead
(
0
,
data
,
sizeof
(
data
));
SPIFlashInfo
*
p_spi_flash_info
=
(
SPIFlashInfo
*
)(
data
);
SPIFlashInfo
*
p_spi_flash_info
=
(
SPIFlashInfo
*
)(
data
);
p_spi_flash_info
->
size
=
size
;
p_spi_flash_info
->
size
=
size
;
...
@@ -195,19 +193,9 @@ flash_init_data_default(void)
...
@@ -195,19 +193,9 @@ flash_init_data_default(void)
// Dangerous, here are dinosaur infested!!!!!
// Dangerous, here are dinosaur infested!!!!!
// Reboot required!!!
// Reboot required!!!
// It will init system data to default!
// It will init system data to default!
uint8_t
flash_init_data
[
128
]
__attribute__
((
aligned
(
4
)))
=
{
0x05
,
0x00
,
0x04
,
0x02
,
0x05
,
0x05
,
0x05
,
0x02
,
0x05
,
0x00
,
0x04
,
0x05
,
0x05
,
0x04
,
0x05
,
0x05
,
0x04
,
0xFE
,
0xFD
,
0xFF
,
0xF0
,
0xF0
,
0xF0
,
0xE0
,
0xE0
,
0xE0
,
0xE1
,
0x0A
,
0xFF
,
0xFF
,
0xF8
,
0x00
,
0xF8
,
0xF8
,
0x52
,
0x4E
,
0x4A
,
0x44
,
0x40
,
0x38
,
0x00
,
0x00
,
0x01
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xE1
,
0x0A
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x93
,
0x43
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
SPIEraseSector
((
flash_get_sec_num
()
-
4
));
SPIEraseSector
((
flash_get_sec_num
()
-
4
));
SPIWrite
((
flash_get_sec_num
()
-
4
)
*
SPI_FLASH_SEC_SIZE
,
flash_init_data
,
sizeof
(
flash_init_data
)
);
SPIWrite
((
flash_get_sec_num
()
-
4
)
*
SPI_FLASH_SEC_SIZE
,
0x10000
-
SPI_FLASH_SEC_SIZE
+
(
0
),
128
);
return
true
;
return
true
;
}
}
...
...
app/platform/flash_api.h
View file @
0420b6d7
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define __FLASH_API_H__
#define __FLASH_API_H__
#include "ets_sys.h"
#include "ets_sys.h"
#include "user_config.h"
#include "user_config.h"
typedef
struct
typedef
struct
{
{
uint8_t
unknown0
;
uint8_t
unknown0
;
...
@@ -28,7 +29,7 @@ typedef struct
...
@@ -28,7 +29,7 @@ typedef struct
SIZE_16MBIT
=
3
,
SIZE_16MBIT
=
3
,
SIZE_32MBIT
=
4
,
SIZE_32MBIT
=
4
,
}
size
:
4
;
}
size
:
4
;
}
NODE_STORE_ATTR
SPIFlashInfo
;
}
NODE_STORE_
TYPEDEF_
ATTR
SPIFlashInfo
;
SPIFlashInfo
*
flash_get_info
(
void
);
SPIFlashInfo
*
flash_get_info
(
void
);
uint8_t
flash_get_size
(
void
);
uint8_t
flash_get_size
(
void
);
...
...
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