Comments (7)
Please post your codes somewhere, we will check about this.
from esp8266_rtos_sdk.
I fixed this problem, it's my fault.
but a new problem occurred, after I called spi_flash_write
to 0x3c, spi_flash_read
can not read the right thing.
extern char drcom_user[];
extern char drcom_pass[];
extern uint64_t drcom_mac;
void ICACHE_FLASH_ATTR
iprint_data(uint8_t* buf, uint16_t len)
{
uint16_t i;
uint8_t *ptr = buf;
for(i = 0; i < len; i++)
{
printf("%02x ", *ptr++);
}
printf(" \n");
}
void ICACHE_FLASH_ATTR
save_drcom_params(const char* username, const char* password, const char* mac)
{
printf("[*] input data: username=%s, password=%s, mac=%s\n", username, password, mac);
char buff[64] = {0};
int result = -1;
char* bar;
uint64_t foo;
strcpy(buff, username);
strcpy(buff + 33, password);
foo = strtoull(mac, &bar, 16);
*(uint64_t *)(buff + 33 + 17) = foo;
result = spi_flash_write(0x3C, (uint32*) buff, 64);
iprint_data(buff, 64);
printf("[*] write return %d %s(%d)-%s \n", result, __FILE__, __LINE__, __FUNCTION__);
}
void ICACHE_FLASH_ATTR
load_drcom_params()
{
char buff[64] = {0};
int result = -1;
result = spi_flash_read(0x3c, (uint32*)buff, 64);
iprint_data(buff, 64);
printf("[*] read result %d %s(%d)-%s \n", result, __FILE__, __LINE__, __FUNCTION__);
sprintf(drcom_user, "%s", buff);
printf("[*] drcom_user=%s success %s(%d)-%s \n", drcom_user, __FILE__, __LINE__, __FUNCTION__);
sprintf(drcom_pass, "%s", buff + 33);
printf("[*] drcom_pass=%s success %s(%d)-%s \n", drcom_pass, __FILE__, __LINE__, __FUNCTION__);
drcom_mac = *(uint64_t *)(buff + 33 + 17);
printf("[*] drcom_mac done %s(%d)-%s \n", __FILE__, __LINE__, __FUNCTION__);
}extern char drcom_user[];
extern char drcom_pass[];
extern uint64_t drcom_mac;
void ICACHE_FLASH_ATTR
iprint_data(uint8_t* buf, uint16_t len)
{
uint16_t i;
uint8_t *ptr = buf;
for(i = 0; i < len; i++)
{
printf("%02x ", *ptr++);
}
printf(" \n");
}
void ICACHE_FLASH_ATTR
save_drcom_params(const char* username, const char* password, const char* mac)
{
printf("[*] input data: username=%s, password=%s, mac=%s\n", username, password, mac);
char buff[64] = {0};
int result = -1;
char* bar;
uint64_t foo;
strcpy(buff, username);
strcpy(buff + 33, password);
foo = strtoull(mac, &bar, 16);
*(uint64_t *)(buff + 33 + 17) = foo;
result = spi_flash_write(0x3C, (uint32*) buff, 64);
iprint_data(buff, 64);
printf("[*] write return %d %s(%d)-%s \n", result, __FILE__, __LINE__, __FUNCTION__);
}
void ICACHE_FLASH_ATTR
load_drcom_params()
{
char buff[64] = {0};
int result = -1;
result = spi_flash_read(0x3c, (uint32*)buff, 64);
iprint_data(buff, 64);
printf("[*] read result %d %s(%d)-%s \n", result, __FILE__, __LINE__, __FUNCTION__);
sprintf(drcom_user, "%s", buff);
printf("[*] drcom_user=%s success %s(%d)-%s \n", drcom_user, __FILE__, __LINE__, __FUNCTION__);
sprintf(drcom_pass, "%s", buff + 33);
printf("[*] drcom_pass=%s success %s(%d)-%s \n", drcom_pass, __FILE__, __LINE__, __FUNCTION__);
drcom_mac = *(uint64_t *)(buff + 33 + 17);
printf("[*] drcom_mac done %s(%d)-%s \n", __FILE__, __LINE__, __FUNCTION__);
}
[] Now: key:username value:test[] Now: key:password value:test[] Now: key:mac value:112233445566[_] Found, value=112233445566
[_] input data: username=test, password=test, mac=112233445566
74 65 73 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 00 00 00 00 00 00 00 00 00 66 55 44 33 22 11 00 00 00 00 00 00 00 00
[] write return 0 drcom_flash.c(37)-save_drcom_params
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[] read result 0 drcom_flash.c(47)-load_drcom_params
[] drcom_user= success drcom_flash.c(49)-load_drcom_params
[] drcom_pass= success drcom_flash.c(51)-load_drcom_params
[] drcom_mac done drcom_flash.c(53)-load_drcom_params
from esp8266_rtos_sdk.
1.spi_flash_erase_sector(0x3C);
2.spi_flash_write(0x3C000, (uint32 *)buff, 64);
3.spi_flash_read(0x3C000, (uint32 *)buff, 64);
from esp8266_rtos_sdk.
Thanks it worked.
from esp8266_rtos_sdk.
Hi,
I have tried the above solution for the same task and Its not working. I am not getting any output the code is sucking in spin_flash_write. i am using SDK version 0.9.4 and my code is.
Can you please help?
char temp[128];
void ICACHE_FLASH_ATTR
save_server_params(const char* serverip, const char* port)
{
char buff[25] = {0};
int result = -1;
uint8 serverSize = sizeof(serverip);
uint8 portSize = sizeof(port);
int size = 0;
os_sprintf(temp,"[] Save data: ServerIP=%s|%d, Port=%s|%d\n", serverip, port, serverSize, portSize);
ets_uart_printf(temp);
strcpy(buff, serverip);
strcpy(buff + 17, port);
result = spi_flash_write(0x3C000, (uint32) buff, 25);
os_sprintf(temp,">> %s",buff);
ets_uart_printf(temp);
os_sprintf(temp,"[*] write return %d %s(%d)-%s \n", result, FILE, LINE, FUNCTION);
ets_uart_printf(temp);
}
void ICACHE_FLASH_ATTR
load_server_params()
{
char buff[25] = {0};
int result = -1;
char ip[16],port[5];
result = spi_flash_read(0x3C000, (uint32_)buff, 25);
os_printf(">> %s",buff);
os_sprintf(temp,"[] read result %d %s(%d)-%s \n", result, FILE, LINE, FUNCTION);
ets_uart_printf(temp);
os_sprintf(ip, "%s", buff);
ets_uart_printf(temp);
os_sprintf(temp,"[] serverIP=%s success %s(%d)-%s \n", ip, FILE, LINE, FUNCTION);
ets_uart_printf(temp);
os_sprintf(port, "%s", buff + 17);
ets_uart_printf(temp);
os_sprintf(temp,"[_] port=%s success %s(%d)-%s \n", port, FILE, LINE, FUNCTION);
ets_uart_printf(temp);
}
from esp8266_rtos_sdk.
@santanurahaman
Your buffer size should be multiples of 4 bytes, if I remember correctly..
P.S. you should post your data within YOUR CODES
, it makes easy to read.
from esp8266_rtos_sdk.
@ly0
Thanks for the reply.
The data is
serverip = 192.168.10.112
port = 8080
from esp8266_rtos_sdk.
Related Issues (20)
- How do I.. SD card using example please (GIT8266O-835)
- Linking fails on hello_world example with disabled assertions (GIT8266O-836) HOT 1
- Bootloader compilation fails when "UART for console output" is set to "none" (GIT8266O-837)
- Application doesn't work with assertion level set to "disabled" (GIT8266O-839) HOT 1
- master分支下,使用ADC例程读出来的数据过高 (GIT8266O-840)
- Do not get IP address after call esp_wifi_connect() (GIT8266O-841) HOT 1
- can't find vApplicationGetTimerTaskMemory function. (GIT8266O-843) HOT 1
- CONFIG_DISABLE_ROM_UART_PRINT leads to boot loop (GIT8266O-844)
- Error: invalid register 'intclear' for 'wsr' instruction (GIT8266O-845) HOT 1
- esp-netif interface (GIT8266O-846) HOT 1
- Compiled size (GIT8266O-847) HOT 1
- Proble Install Python Package by Using mingw32 on Windows (GIT8266O-848) HOT 3
- export.sh cannot run correctly on zsh (GIT8266O-849)
- [Bug/suggestion] Diverging baud rates in hello_world example (GIT8266O-850)
- Error in configuring ESP8266 RTOS SDK development environment on Linux??? (GIT8266O-851) HOT 7
- Segment loaded at 0x*** lands in same 64KB flash mapping as segment loaded at 0x*** (GIT8266O-852) HOT 2
- cmake error at cmakelists.txt & menuconfig errors (GIT8266O-853)
- menuconfig script fails for ncurses in Arch-Linux (GIT8266O-855) HOT 5
- 烧录protocols/mqtt/tcp的demo后报错 (GIT8266O-858)
- [Bug] `wifi: err2,exceed max time value,max val is 198A5759` (GIT8266O-859)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp8266_rtos_sdk.