Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266 espfs.c espFsInit() flashAddress calculated incorrectly for user2.bin OTA #53

Open
isavitsky opened this issue Nov 3, 2019 · 0 comments

Comments

@isavitsky
Copy link

When system boots into user2.bin in espFsInit() the flashAddress is been always calculated to user1.bin location in the following prtion of code in espfs.c:

	if((uint32_t)flashAddress > 0x40000000) {
		flashAddress = (void*)((uint32_t)flashAddress-FLASH_BASE_ADDR);
	}

The following part of code can be added after the above to correct this:

    uint32_t shift;
    if ( system_get_userbin_addr() > 0x01000 )
    { // user2.bin
        uint8_t map = system_get_flash_size_map();
        switch ( map )
        {
            case FLASH_SIZE_4M_MAP_256_256:
                shift = 256*1024; // 256kB
                break;
            case FLASH_SIZE_8M_MAP_512_512:
            case FLASH_SIZE_16M_MAP_512_512:
            case FLASH_SIZE_32M_MAP_512_512:
                shift = 512*1024; // 512kB
                break;
            case FLASH_SIZE_16M_MAP_1024_1024:
            case FLASH_SIZE_32M_MAP_1024_1024:
            case FLASH_SIZE_64M_MAP_1024_1024:
            case FLASH_SIZE_128M_MAP_1024_1024:
                shift = 1024*1024; // 1MB
                break;
            default:
                shift = 512*1024;
        }
        flashAddress = (void *)((uint32_t)flashAddress + shift);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant