frame

NodeMCU V2 not virtualizing after Zerynth 2.0 install

Hello,
The board is recognized but upon virtualizing I get the messages:
[info] Starting device registration
[error] Can't burn bootloader!


However, I am unable to find any logs explaining the error in detail. Even with procmon the only log I could find when trying to virtualize was:
C:\Windows\ModemLogs\ModemLog_Standard 56000 bps Modem.txt

I did check to make sure any esp libraries were installed in Zerynth, as was required for me to virtualize in 1.0,  but that did not help. 

Is there any way to dig into this and figure out what is going on?

Comments

  • Hello Ray and thanks for the report.

    First simple check would be clicking the info button (the one to the right of the Virtualization button) and verify that the port field is not "None". Which version of Windows are you using?
    Giacomo Baldi
    Zerynth Head of Software Development
  • It is showing COM3 and I am running Windows 10. The serial monitor seems to work and I can enter commands at least until I restart the unit. Then I have to reopen Zerynth in order to use the serial monitor again. 
    I've also tried flashing to the lua firmware as I was running an arduino blynk sketch on it before. And I've tried booting the mcu up into flash mode (holding down gpio0) and launching Zerynth and trying to virtualize. 

    I did notice a tmp.bin is created in the tmp directory, is this the VM bin; if so can I manually flash it?
  • mmm...
    something weird must be happening in the nodemcu device code.

    To get a quick and dirty log of the problem you can edit the file C:\users\your-username\zerynth2\dist\r2.0.4\devices\nodemcu2\nodemcu2.py

    at line 43 just add a print for the output of esptool:

            res,out,err = proc.runcmd("python",tools["esptool"],"--port",self.port,"write_flash","--flash_freq","40m","--flash_mode","dio","--flash_size","4m","--verify", "0x00000",romf, "0x20000", iromf, "0x3fc000",bromf,hex(prom_addr),promf)
            print(out) # add this line
            fs.del_tempfile(romf)
            fs.del_tempfile(iromf)

    it should appear in the system log and give some clue
    Giacomo Baldi
    Zerynth Head of Software Development
  • Thanks. I couldn't seem to get the proper indent level with notepad++, so I had to make the modification after Zerynth is launched or else it won't detect the mcu. Here is the output (I've already tried "forget device" several times):
    [info] Starting device registration
    [error] Can't burn bootloader!
    [warning] inconsistent use of tabs and spaces in indentation (nodemcu2.py, line 44)
    [error] Can't find device zs:nodemcu2:e7a4bc050dddcfcc95a52881d92f1d4634052f87
    When I tried in IDLE, I think I was able to get the indent sorted out, with the following output and Zerynth detecting the device without changing the code while running:
    [info] Starting device registration
    esptool.py v1.2-dev
    Connecting...
    A fatal error occurred: Failed to connect to ESP8266

    I do notice that the TX LED does flash when attempting this. 
  • Giacomo, 

    I was able to resolve this issue by replacing the esptool.py (updating from 1.2 to 1.3) in \sys\esptool. Not sure why it worked in Zerynth1  but not in 2. A possible regression perhaps?

    Thanks,
    Ray
  • I may have spoken too soon. Upon uploading a project I ran into this:
    [info] Got header: d2c500002000800e94000b00000a026a
    [error] No answer to probe

    Going to try holding gpi0 down. 
  • Ok so obviously holding GPI0 down isn't going to let the VM run on the MCU.
    After trying again, the "got header" message appears as semi-gibberish:
    [info] Got header: 2onl`N{n sr po r  "n| Bon (truncated){cb $bc #p$l|$cnNolld  $$l{ldon't use rtc mem data
    [info] Got header: ocbb l cr$r$
    [info] Probe sent
    [error] No answer to probe

    This prompted me to play around with the baud rate. Adding the baud rate manually doesn't seem to make a difference in the nodemcu2.py. What I did notice, was that using putty to connect to com3, that at 115200, the output seems very close to the gibberish output (l▒▒l▒▒l▒▒▒{ldon't use rtc mem data), but at 76800, data appears to look correct (a bunch of hex then OS SDK ver: 1.4.0(c599790) compiled @ Mar  1 2016 17:25:17).

    I also did try reverting the esptool back to 1.2 but that didn't seem to help. Maybe something wrong with the baud matching?

  • GiacomoGiacomo Member
    edited January 28
    Hello Ray,

    You are right, the gibberish is at 76800 baud, the weird default baud of the esp8226 firmware. However it is reset to 115200 as soon as the VM starts. So, some gibberish at start is "normal" behaviour.

    The "Got Header" prints out everything received from the esp waiting for a correct VM Header in order to start the uplink phase.

    Regarding tabs in .py files, just use 4 spaces instead of a tab and you should be ok for all ztc code files.

    Esptool has been slightly modified in order to make it compatible with Python 3.5 (the version used by the ZTC), strange that it keeps working after you upgraded it...I'll check it asap. 

    The GPIO0 thing "should" not be needed for the nodecmu since the usb is configured in such a way that, on certain serial signals, the esp is reset and put in boot mode automatically (by esptool).

    However, can you confirm you have been able to register the nodemcu? Registering amount to flashing a simple bootloader to the nodemcu, a process very similar to virtualization...so it is weird that registration worked and virtualization didn't. After registration you need to create a VM and flash it. I am asking because the output you mentioned (d2c500002000800e94000b00000a026a) smells like the output from the registration bootloader that it is not a working VM and can't accept bytecode.

    On a side note, can you also confirm you have version r2.0.4?

    Let us know!

    Giacomo Baldi
    Zerynth Head of Software Development
  • Hi,

    I had the same problem and solved it like this:

    1.) I added the line
    print(out)
    to C:\users\your-username\zerynth2\dist\r2.0.4\devices\nodemcu2\nodemcu2.py like Ray Holden suggested above.

    2.) The output was:
      File "C:\Users\<my user name>\zerynth2\sys\python\lib\site-packages\serial\serialwin32.py", line 304, in flush
        time.sleep(0.05)
    NameError: name 'time' is not defined
    3.) I took a look at it and found out: the time module is only imported if the sendBreak function is called, but it is also used in the flush function on line 300.

    4.) I added on the top of the file:
    import ctypes
    import time # add this line
    from serial import win32
    and it worked.

  • Ray Holden Member
    edited January 28
    Registration and virtualization worked fine for me after the modifications I noted above:
    [info] Starting Virtualization...
    esptool.py v1.3
    Connecting....
    Running Cesanta flasher stub...
    [truncated]
    WARNING: Unlikely to work as data goes beyond end of flash. Hint: Use --flash_size
    [truncated again]
    Verifying 0x400 (1024) bytes @ 0x0006f000 in flash against C:\Users\RHold\zerynth2\tmp\tmpv_6gk0... [info] Virtualization Ok
    Device Virtualized
    I noticed the warning but it didn't seem to throw any errors. When I start the project uplink, the mcu does seem to reset and ftdi led flashes for a while (VM initialization?) What I did notice, is that "No answer to probe" occurs before the led flashing stops... so maybe a timeout value that is too low?
    [info] Compilation Ok
    [info] Searching for device e7a4bc050dddcfcc95a52881d92f1d4634052f87 with alias zs:nodemcu2:e7a4bc050dd
    [truncated got header gibberish] [info] Got header: oBBp cc l c$r$ [error] No answer to probe
    (not sure what's going on with the code block above... looks fine when formatting and editing :-/ )

    taking a look at uplinker.py, I noticed that it doesn't output "probe sent". Going off of my timeout hunch, I modified this line in uplinker.py:
        while time.perf_counter()-starttime<8: #bumped up a little bit from 5 to compensate
    After this change, uplinker seems to get past the probe stage, but I can't figure out if there is a timeout in the uplink stage to compensate for "too late reset"
    [info] Probe sent
    [info] Got header: r2.0.4 T4kpTrnrRdWWT9NkiK88Gg nodemcu2 d2c500002000800e94000b00000a026a ZERYNTH
    [error] Something wrong during the probing phase: too late reset?

    thanks
  • Ok, so I tried this in two new VMs, Ubuntu works fine after adding the user to the dialup group.

    On my new Win10 VM, I get something new:

     [info] Starting device registration
    Traceback (most recent call last):
      File "C:\Users\ray\zerynth2\dist\r2.0.4\ztc\ztc.py", line 109, in
        cli()
      File "C:\Users\ray\zerynth2\sys\python\lib\site-packages\click\core.py", line 716, in __call__
        return self.main(*args, **kwargs)
      File "C:\Users\ray\zerynth2\sys\python\lib\site-packages\click\core.py", line 696, in main
        rv = self.invoke(ctx)
      File "C:\Users\ray\zerynth2\sys\python\lib\site-packages\click\core.py", line 1060, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "C:\Users\ray\zerynth2\sys\python\lib\site-packages\click\core.py", line 1060, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "C:\Users\ray\zerynth2\sys\python\lib\site-packages\click\core.py", line 889, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "C:\Users\ray\zerynth2\sys\python\lib\site-packages\click\core.py", line 534, in invoke
        return callback(*args, **kwargs)
      File "C:\Users\ray\zerynth2\dist\r2.0.4\ztc\devices\devcmd.py", line 249, in register
        res,out = tgt.burn([ base64.standard_b64decode(x) for x in reg["bin"]],info)
      File "C:\Users\ray\zerynth2\dist\r2.0.4\devices\nodemcu2\nodemcu2.py", line 42, in burn
        res,out,err = proc.runcmd("python",tools["esptool"],"--port",self.port,"write_flash","--flash_freq","40m","--flash_mode","dio","--flash_size","4m","--verify", "0x00000",romf, "0x20000", iromf, "0x3fc000",bromf,hex(prom_addr),promf)
      File "C:\Users\ray\zerynth2\dist\r2.0.4\ztc\base\proc.py", line 26, in runcmd
        return self.run(cmdval,*args,outfn=outfn)
      File "C:\Users\ray\zerynth2\dist\r2.0.4\ztc\base\proc.py", line 31, in run
        cmd = cmd+" "+(" ".join(args))
    TypeError: sequence item 2: expected str instance, NoneType found


  • thanks @"Ray Holden"  and @wese3112 ,

    nice catches!

    I will do some testing on a fresh Windows 10 install and release a fix asap.




    Giacomo Baldi
    Zerynth Head of Software Development
Sign In or Register to comment.

ZERYNTH Community

@ 2016 Zerynth.com, all rights reserved.