Commit c14393550404003f0fe248af20617b9a402d6242
authorMichel Pollet <buserror@gmail.com>
Tue, 16 Jun 2015 18:05:21 +0000 (19:05 +0100)
committerMichel Pollet <buserror@gmail.com>
Tue, 16 Jun 2015 18:05:21 +0000 (19:05 +0100)
This allows the AVR to soft reset into the bootloader for example.

A watchdog reset will re-run the bootloader with the correct flag.

Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
simavr/sim/sim_avr.c
simavr/sim/sim_avr.h

index 4b612d6ada2402f204227c51a93e0116832ddbef..b2b2cf0840402481f3b8131b0731c3490b5fa30a 100644 (file)
@@ -124,7 +124,7 @@ void avr_reset(avr_t * avr)
        for(int i = 0x20; i <= MAX_IOs; i++)
                avr->data[i] = 0;
        _avr_sp_set(avr, avr->ramend);
-       avr->pc = 0;
+       avr->pc = avr->reset_pc;        // Likely to be zero
        for (int i = 0; i < 8; i++)
                avr->sreg[i] = 0;
        avr_interrupt_reset(avr);
index aad19b5b3bb097a4da28b0e723c7e982514e06e8..038b893c7aa352ee0a300a9a1223785e02157d44 100644 (file)
@@ -232,6 +232,11 @@ typedef struct avr_t {
         * It CAN be a little confusing, so concentrate, young grasshopper.
         */
        avr_flashaddr_t pc;
+       /*
+        * Reset PC, this is the value used to jump to at reset time, this
+        * allow support for bootloaders
+        */
+       avr_flashaddr_t reset_pc;
 
        /*
         * callback when specific IO registers are read/written.