Giter Site home page Giter Site logo

Comments (7)

 avatar commented on July 17, 2024

Please post your codes somewhere, we will check about this.

from esp8266_rtos_sdk.

ly0 avatar ly0 commented on July 17, 2024

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.

 avatar commented on July 17, 2024

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.

ly0 avatar ly0 commented on July 17, 2024

Thanks it worked.

from esp8266_rtos_sdk.

santanurahaman avatar santanurahaman commented on July 17, 2024

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.

ly0 avatar ly0 commented on July 17, 2024

@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.

santanurahaman avatar santanurahaman commented on July 17, 2024

@ly0
Thanks for the reply.

The data is
serverip = 192.168.10.112
port = 8080

from esp8266_rtos_sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.