LoPy 4 keep executing old code even after updating the code

  • I am using LoPy 4 with Pysense expansion board. I am using MicroWebSrv2 project. i have update some files in MicroWebSrv 2 project and then uploaded again to LoPy 4 but i am still old code is being executed. i have hard reset the Lopy 4 by >>import os >>os.fsformat('/flash') and then again i uploaded the updated code. but still, even after reset i am getting old code being executed. This is very strange. Please help

  • @aqi And can you tell by looking at the output of os.listdir() that this is the new code? If yes, try to start that code from the REPL prompt.

  • @robert-hh Thanks for your reply. I am using Atom IDE. So using Atom you can download the code which is inside the microcontroller. And also i am checking the folder structure using this command ' os.listdir()'

  • @aqi Frozen bytecode would sneak in again with the firmware. But that is only likely if you build your own firmware. if not, then there must be another path that cold code gets in again. How did you verify that the new code is loaded to your device? Do not trust any IDE for that, use simple tools.

  • @robert-hh i don't think so, because after full erase there shouldn't be anything

  • @aqi So you are talking about the MicroWebSrv2 code, which is not updated, and not about the firmware? is it possible that there is a copy of the MicroWebSrv2 code frozen in the firmware, or at other places in the file system? In that case, it the preference is defined by the search path in sys.path.

  • @robert-hh Thanks for your reply. I already used esptool.py for full erase.

    1. after that i uploaded a simple code for blinking leds and it was working fine.
    2. then i uploaded the my updated MicroWebSrv2 code but there was still this issue. i mean i am getting the old code execution while there are not old files.

  • @aqi If you mix firmware update by WIFi, a firmware loaded by USB may not get active. That is beause USB loads into the first firmware partition, while WiFi update alternates between the two partitions. So you have two options:

    • mild: Try to upload the new firmare via WiFi. You could also update any firmware and then load the new one by USB.
    • crowbar: Erase the device completely and reload using USB with the Pycom firmware updater. For a full erase use: esptool.py -p <usb port> erase_flash. You can find esptool.py for instance in the tools/fw_updater directory of the pycom repository; or just using google on the espressif site. This full erase will also delete the Lora/Sigfox ID's, which will be restored when using the pycom firmware updater.

Log in to reply

Pycom on Twitter