Resetautorun not working on ItsyBitsy M4?


#1

Hi

I notice that (save-image 'name) seems to flash in the onboard dataflash , since it can be loaded back with (load-image)
The thing I notice is that it’s not autorunning my program
After a reset the memory stays empty .

I’m using the 2.4 lisp for itsybitsy m4
BTW there are also 3071 cells defined , but it must be much more IMHO since it has 192KB of ram…

Kind regards,

Ronny


#2

Hi Ronny,

Both of these problems should be fixed in 2.4b; please try that and let me know how you get on.

David


#3

Hi David

Sorry to tell you that autorun still doesn’t work.
The memory stays empty at 20479 after a reset , so nothing is loaded.
I’ve uncommented resetautorun , I assume thats correct ?

Ronny


#5

I confirm that this is not working as intended. I hope to have a fix soon.

David


#6

Please try inserting the following line in the definition for autorunimage():

if (!FlashSetup()) error(PSTR("No DataFlash found."));

after the existing line;

#elif defined(ARDUINO_METRO_M4) || defined(ARDUINO_ITSYBITSY_M4) || defined(ARDUINO_FEATHER_M4)

and recompile (with #define resetautorun uncommented).

Now if you define:

(defun go () (print "Hello!"))

and do:

(save-image 'go)

it should print Hello! on reset.


#7

Hi David !

First of all , thanks for your efforts on making this working.

The results :

The code you suggested works perfectly :-) , so you could make it a 2.4c version …

However I have this remark to you :

In setup ()
there’s is this code :

Serial.begin(9600);
while (!Serial);
initworkspace();
initenv();
initsleep();
pfstring(PSTR("uLisp 2.4 "), pserial); pln(pserial);

I noticed on the mkrzero , and also on the itsibitsy that when you are autorunning with NO serial connection to the computer , that "while (!serial) will stall the software.
This because on native usb boards , as on the 2 mentioned boards , the serial connection will never be available.
And therefore the autorun will not work. Don’t understand me wrong , your solution for autorunning was needed , because I knew that this problem existed , but I bypassed the problem with an external serial to usb connection.
So an extra solution could be something like this …

Serial.begin(9600);
#if defined (resetautorun)
#else
while (!Serial);
#endif
initworkspace();
initenv();
initsleep();
pfstring(PSTR("uLisp 2.4 "), pserial); pln(pserial);

So conlusion :
your solution is perfectly , but maybe the while (! serial) could also be corrected ???)

Hope you like it , and again thanks for the quick solution.

Looking forward to a 2.4c version …

Kind regards
Ronny Suy


#8

Hi Ronny,

Thanks for the feedback, and the suggestion about while (!Serial). I’ll have to think about why that was there in the first place, and whether it’s needed at all.

Regards, David


#9

Hi David

No problem !
As far as my memory goes it was only needed for some ‘older’ boards.
If I’m correct its not mandatory anymore.

But correct me if I’m wrong

Ronny


#10

I’ve been testing Serial on an ItsyBitsy M4, and while (!Serial) seems to be necessary to wait for the Serial to initialise:

void setup() {
  Serial.begin(9600);
  while (!Serial);
}

void loop() {
  for (int x=1; x<1000; x++) {
    Serial.println(x);
    delay(1000);
  }
}

Without it this starts printing at 5.


#11

So perhaps the solution is to leave while (!Serial) there, but make it time out after 5 seconds with:

int start = millis();
while (millis() - start < 5000) { if (Serial) break; }

#12

Hi David

Will this solution also work when no serial is connected ? because that I think is the real problem with while (!serial).

Regards,

Ronny


#13

I’m pretty sure it will, because after 5 seconds it will carry on regardless. If you’d like to try it replace the line:

  while (!Serial);

with:

int start = millis();
while (millis() - start < 5000) { if (Serial) break; }

in setup().


#14

Hi David

I already did the tests and it works perfectly , with or without serial connection !

Thanks !

Ronny


#15

Great, thanks! I’ll adopt that for the next version,
David