Chat freely about anything...

User avatar
By de1m
#52721 Hi all,
I would write the wifi config to flash and read this after reboot.
I've found a read/write example and it's working

Code: Select allstatic void ICACHE_FLASH_ATTR test() {
   os_printf("SDK version:%s\n", system_get_sdk_version());

    uint32 temp[4]={122323, 13, 14, 15};
    uint32 temp1[4]={0};

    int i = spi_flash_erase_sector(0x8c);
    os_printf("spi_flash_erase_sector: %d\n", i);
    int o = spi_flash_write(0x8c000, temp, sizeof(temp));
    os_printf("spi_flash_write: %d\n", o);

    int p = spi_flash_read(0x8c000, temp1, sizeof(temp1));
    os_printf("spi_flash_read: %d\n", p);

    os_printf("read :%x, %x, %x, %x\n", temp1[0], temp1[1], temp1[2], temp1[3]);
}

Output:
SDK version:1.5.4(baaeaebb)
spi_flash_erase_sector: 0
spi_flash_write: 0
spi_flash_read: 0
read :1ddd3, d, e, f


Now, I've written this
Code: Select allstatic void ICACHE_FLASH_ATTR test() {
   os_printf("SDK version:%s\n", system_get_sdk_version());

    struct wConf{
       char ssid[32];
       char passwd[64];
    };

    struct wConf wifiApConf;

    os_memcpy(wifiApConf.ssid, "CO2", 3);
    os_memcpy(wifiApConf.passwd, "co2passwd", 64);

    uint32 ssidAp[32];

    int i = spi_flash_erase_sector(0x8c);
    os_printf("spi_flash_erase_sector: %d\n", i);
    int o = spi_flash_write(0x8c00, (uint32 *)&wifiApConf.ssid, 3);
    os_printf("spi_flash_write: %d\n", o);
    int p = spi_flash_read(0x8c00, (uint32 *)&ssidAp[0],4);
    os_printf("spi_flash_read: %d\n", p);
    os_printf("result: %s\n", ssidAp);
}

Output:
SDK version:1.5.4(baaeaebb)
spi_flash_erase_sector: 0
spi_flash_write: 0
spi_flash_read: 0
result: \0x01\0x08\0x10


I think, that the result "\0x01\0x08\0x10" is not correct?

Can someone write me a example for this?
User avatar
By ian
#69201 Phil - we are somewhat off topic but maybe that's not such a bad thing. I see several posts here which are quite obviously from students looking for 'quick' answers to their work. Blatant advertising of 'dissertation writing' sites should be blocked. I am with you on this.
User avatar
By RichardS
#69349 They are SPAMMERS, I deleted 100's of ESSAY writing message and signatures.... over the last few months....

Keep reporting and I will keep deleting.

RichardS