simavr icon indicating copy to clipboard operation
simavr copied to clipboard

simavr not working on Arduino FreeRTOS

Open ekazevedo opened this issue 2 years ago • 3 comments

A firmware running on a real Arduino Mega2560 did not run either on 'SimulIDE' or 'simavr'.

  • command line 'simavr -f 16000000 -m atmega2560 -ti 12 MySketch.ino.mega.hex' told me: "IRQ12 raising (enabled 1), IRQ12 calling, IRQ12 cleared" only once and stop. FreeRTOS Tick count = 1, based on watchdog, never increases.
  • I "commented" a line supposed to stop watchdog interrupts after done and now everything is working fine.

Please, see my attached patch referring to line 186 of 'sim/avr_watchdog.c'.

My workaround may not be a solution but it points out to. So, guys, more work! Please, feel free to implement the final code.

Edilson Azevedo [email protected]

ekazevedo avatar Aug 21 '22 13:08 ekazevedo

This is a strange Pull Request: the change is described as tentative, but a PR should present a change that is considered ready for integration. I suggest closing it, and creating an "Issue" if that is needed.

In any case, the change removes an essential part of the Watchdog Timer's "Interrupt and System Reset" mode, so seems almost certainly incorrect. There is no detail in the problem description, but that code should only be executed if the WDE bit is on, and FreeRTOS does not set that bit. So it seems likely that the firmware is setting it, perhaps to guard against looping with interrupts disabled. In that case it seems likely that the fix would be to turn WDIE back on in the watchdog interrupt handler.

gatk555 avatar Aug 24 '22 16:08 gatk555

I have fixed this issue with this commit in my fork of simavr.

lcgamboa avatar Aug 24 '22 16:08 lcgamboa

... and it was integrated here. While that is recent enough that it is likely not in binary distributions, OP has forked the code, so should be using the current git version. Update: the patch file does not contain that fix!

gatk555 avatar Aug 24 '22 16:08 gatk555

So, should I conclude this has already been merged a while back?

buserror avatar Aug 11 '23 13:08 buserror

Hi, all.

I applied "my" patch to my simavr and solved my problem. I had no chance to use it again up to now. Busy, I can't carefully check the code as i wish.

Thank you for your interest on this subject,

I agree to close this pull.

Edilson Azevedo [email protected]

ekazevedo avatar Aug 12 '23 02:08 ekazevedo