• **ERROR: Prompt not detected - upload failed. Trying to recover...

        ...,key,{mode:'ECB'}),j=0;j<16;j++)dcryp­t[j]+=crypt[j]/256;for(...
    

    **
    Pico v1.85
    Trying out AES in ECB mode as a random number generator and got an error.
    Did I do something dumb?

    //AES2.js
    //How random is it?
    var plain=new Int8Array(16);
    var key=new Int8Array(16);
    var crypt=new Int8Array(16);
    var dcrypt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]­;
    var i;
    var j;
    var k;
    for(i=0;i<16;i++){
      plain[i]=0;
      key[i]=1;
      dcrypt[i]=0;
    }//nexti
    for(k=0;k<256;k++){
     plain[1]=k;
     for(i=0;i<256;i++){
      plain[0]=i;
      crypt=AES.encrypt(plain,key,{mode:'ECB'}­);
      for(j=0;j<16;j++)dcrypt[j]+=(crypt[j]/25­6);
     }//nexti
    }//nextk
    for(j=0;j<16;j++)console.log(dcrypt[j]/2­56);
    
    

    The Output

    >echo(0);
    ERROR: Prompt not detected - upload failed. Trying to recover...
            ...,key,{mode:'ECB'}),j=0;j<16;j++)dcryp­t[j]+=crypt[j]/256;for(...
                                          ^
    debug>echo(1);
    In debug mode: Expected a simple ID, type 'help' for more info.
    debug>echo(1)
    In debug mode: Expected a simple ID, type 'help' for more info.
    debug>c
    127.84310913085
    127.69502258300
    127.16555786132
    127.92999267578
    127.30929565429
    127.41572570800
    127.00732421875
    127.69149780273
    127.79350280761
    127.83537292480
    127.17370605468
    127.31027221679
    127.58242797851
    127.05628967285
    
    
  • The issue is just that your code is taking longer to execute than expected.

    Usually, the code you upload should execute as fast as possible, and then you should do any calculations in callback functions - ideally making them execute quickly.

    So if you do:

    function go() {
    var plain=new Int8Array(16);
    var key=new Int8Array(16);
    var crypt=new Int8Array(16);
    var dcrypt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]­­;
    var i;
    var j;
    var k;
    for(i=0;i<16;i++){
      plain[i]=0;
      key[i]=1;
      dcrypt[i]=0;
    }//nexti
    for(k=0;k<256;k++){
     plain[1]=k;
     for(i=0;i<256;i++){
      plain[0]=i;
      crypt=AES.encrypt(plain,key,{mode:'ECB'}­­);
      for(j=0;j<16;j++)dcrypt[j]+=(crypt[j]/25­­6);
     }//nexti
    }//nextk
    for(j=0;j<16;j++)console.log(dcrypt[j]/2­­56);
    }
    setTimeout(go, 500);
    

    It'll work fine. Or you could just call go() from the left-hand side after upload

  • Thanks.

  • To peek into what's going on on upload, take a look at this conversation about simple explanation how to (upload and) save code that espruino runs on start?.

  • My esp32 seems to be bricked. Each time I boot, it spits out the text from the attached file and finishes with HALTING. I have tried re-flashing the chip, but the code causing the issue is still on there. Is there a way to clear out the code section of the chip?


    1 Attachment

  • Erase_flash got me back on track! But my real issue remains, why does adding setWatch cause my chip to go into an unusable state?

    Sorry for the double post from the Gitter board.

  • ...did you have a setWatch in root level?... 'never' put 'active/sensitive' things into the root level, 'always' put it into a startup function that is called in onInit() or with setTimeout() as last line in upload. With that you prevent getting your Espruino active before it has finished uploading.

  • Good advise, thank you!
    Any thoughts on getting a setWatch to work? Since posting I have been querying the pins on an interval of 10ms.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

ERROR: Prompt not detected - upload failed. Trying to recover...

Posted by Avatar for ClearMemory041063 @ClearMemory041063

Actions