Experts: Firmware flashing from internal file-system failed #12336
Replies: 6 comments 13 replies
-
Could you please give more details about your build? What hardware, port, flash size, micropython version? I know on STM that all the ISR functions are hard-coded to be in flash, including systick etc. I don't know which port you're using to know if this is likely a similar issue. Similarly on stm, the mboot bootloader has support for installing firmware from the flash filesystem already. |
Beta Was this translation helpful? Give feedback.
-
I see you're disabling WDT in your C code before flashing, but I don't see anything to disable all interrupts? I'm not sure if interrupts are going to be the problem but it might help (assuming they're not needed for the actual spiflash handling)? There's also some discussion here suggesting that WDT can't really be disabled: #8597 that being said, perhaps that function will kill the HW watchdog, and if irq's are stopped then the software one will possibly also be stopped. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot @andrewleech ! I have eventually found out why: It is because |
Beta Was this translation helpful? Give feedback.
-
Hi @andrewleech , To update firmware in place:
By default, file-system will not be touched unless you set Now, the problem is that I run out of iram0, need to drop espnow or link will fail. The strange thing is that in |
Beta Was this translation helpful? Give feedback.
-
The issue is solved in pull request #12429 |
Beta Was this translation helpful? Give feedback.
-
Hi @danicampora @dpgeorge @jimmo @peterhinch
I have been trying to flashing firmware locally from image file on internal storage, but so far no success.
I am aware that 0x40200000-0x40300000 is mapped to the 1st 1MB of flash, so running any code from this region to flash firmware is going to fail because while flashing half-way, your code gets changed and will cause crash. Not only this, while flashing, any functions that you call cannot come from this memory region. Moreover, certain interrupt handlers may re-direct to this region upon handling special events, so you must disable watchdog, disable interrupt IRQ, etc. while flashing.
Taking care of all these, I have put my code in iram1 (40100000h-40108000h) using MP_FASTCODE and view disassembly to confirm that no function calls will ever reach 0x40200000-0x40300000. I will need to call spi_flash_erase_sector, spi_flash_read, spi_flash_write and uart_tx_one_char (for verbose), all these functions come from iram1. Even for reading the firmware image file, I digged out all the sectors and sector offsets for each fragment of the file, and did not use any filesystem function calls (which are all in 0x40200000-0x40300000).
Unfortunately, I can only flash the 1st portion (0x40200000-0x40209000) which is the boot-loader, the program hangs forever once writing into the flash region that is mapped to .irom0.text section, i.e., from 0x40209000 onwards.
Can someone explain why, is there some sort of memory protection or what? My firmware code is at https://github.com/xuancong84/micropython/ , the user-level Python code is at https://github.com/xuancong84/OpenSmartLight/blob/main/micropython/update.py
Beta Was this translation helpful? Give feedback.
All reactions