From db10058d27a5b4fabd56a31ad47a02c62169fd8e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 23 Feb 2015 17:09:57 -0600 Subject: [PATCH] PIC32MZ: Fix an error in the branch target of the hard-coded power up reset branch --- arch/mips/src/pic32mz/pic32mz-head.S | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/arch/mips/src/pic32mz/pic32mz-head.S b/arch/mips/src/pic32mz/pic32mz-head.S index b6f089bfdc..8ea252dce0 100644 --- a/arch/mips/src/pic32mz/pic32mz-head.S +++ b/arch/mips/src/pic32mz/pic32mz-head.S @@ -161,12 +161,14 @@ .ent __reset __reset: - .word 0x10000003 /* MIPS32: branch forward 0x10 bytes from here */ - /* MicroMIPS: ADDI32 $0, $0, 0x0007 (nop) */ - /* DO NOT change the relative branch */ - .word 0x00000000 /* NOP */ + .word 0x10000004 /* 0x0000 */ + /* MIPS32: Branch forward 0x14 bytes */ + /* MicroMIPS: ADDI32 $0, $0, 0x0007 (NOP) */ + .word 0x00000000 /* 0x0004 */ + /* MIPS32: NOP */ + /* MicroMIPS: NOP */ - /* If se get here then we are in microMIPS mode. That is because the + /* If we get here then we are in microMIPS mode. That is because the * preceding instructions are all NOP in that case and we fall through * to here. Otherwise, we branched to __reset_switch_isa */ @@ -174,17 +176,23 @@ __reset: .set micromips __reset_micromips: - la k0, __start /* Just jump to the startup initialization code */ - jr k0 - nop - /* Device not in proper ISA mode */ + /* Just jump to the startup initialization code */ + + la k0, __start /* 0x0008 */ + jr k0 /* 0x0010 */ + nop /* 0x0012 */ + + /* Device not in proper ISA mode. If we are not in microMIPS mode then + * we get here from the first instruction at __reset which will get + * interpreted as a branch to this location. + */ .align 2 .set nomicromips __reset_halt: - b __reset_halt + b __reset_halt /* 0x0014 <- Branch target */ nop .end __reset