This is an automated email from the ASF dual-hosted git repository.

kasjer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 738d6881c bsp/olimex-pic32: Start no-bootloader image with MCLR pulse
738d6881c is described below

commit 738d6881c1f167d9853c141b61e3215b4c807d40
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Oct 14 10:36:20 2026 +0200

    bsp/olimex-pic32: Start no-bootloader image with MCLR pulse
    
    When application is built with MCU_NO_BOOTLOADER_BUILD it is placed
    in boot flash and started directly from reset. J-Link reset and go
    issued at the end of the programming session leaves such image in a
    state where the first context switch never happens: os_start()
    returns, interrupts are not delivered and neither console nor USB
    work. Same image starts correctly after plain MCLR reset.
    
    For no-bootloader builds skip reset and go in programming session and
    pulse MCLR from separate J-Link session that does not connect to the
    target. Bootloader and application builds still use reset and go.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/bsp/olimex-pic32-emz64/download.sh  | 17 +++++++++++++++--
 hw/bsp/olimex-pic32-hmz144/download.sh | 17 +++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/hw/bsp/olimex-pic32-emz64/download.sh 
b/hw/bsp/olimex-pic32-emz64/download.sh
index 358f28767..e1b5e2671 100755
--- a/hw/bsp/olimex-pic32-emz64/download.sh
+++ b/hw/bsp/olimex-pic32-emz64/download.sh
@@ -46,9 +46,22 @@ else
     cp ${BIN_BASENAME}.img ${BIN_BASENAME}.bin
     echo "loadfile ${BIN_BASENAME}.bin 0x1d000000" >> script
   fi
-  echo "r" >> script
-  echo "g" >> script
+  if [ "$MYNEWT_VAL_MCU_NO_BOOTLOADER_BUILD" != "1" ]; then
+    echo "r" >> script
+    echo "g" >> script
+  fi
   echo "q" >> script
 
   JLink${COMSPEC:+.}Exe  -AutoConnect 1 -Device PIC32MZ2048EFH064 -If ICSP 
-speed 12000 -CommandFile script
+
+  if [ "$MYNEWT_VAL_MCU_NO_BOOTLOADER_BUILD" == "1" ]; then
+    # Application started from boot flash by debugger reset and go does
+    # not run (first context switch never happens). Pulse MCLR without
+    # connecting to the target instead.
+    echo "r0" > script
+    echo "sleep 200" >> script
+    echo "r1" >> script
+    echo "q" >> script
+    JLink${COMSPEC:+.}Exe -Device PIC32MZ2048EFH064 -If ICSP -CommandFile 
script
+  fi
 fi
diff --git a/hw/bsp/olimex-pic32-hmz144/download.sh 
b/hw/bsp/olimex-pic32-hmz144/download.sh
index e07725999..597987ae1 100755
--- a/hw/bsp/olimex-pic32-hmz144/download.sh
+++ b/hw/bsp/olimex-pic32-hmz144/download.sh
@@ -41,9 +41,22 @@ else
     cp ${BIN_BASENAME}.img ${BIN_BASENAME}.bin
     echo "loadfile ${BIN_BASENAME}.bin 0x1d000000" >> script
   fi
-  echo "r" >> script
-  echo "g" >> script
+  if [ "$MYNEWT_VAL_MCU_NO_BOOTLOADER_BUILD" != "1" ]; then
+    echo "r" >> script
+    echo "g" >> script
+  fi
   echo "q" >> script
 
   JLink${COMSPEC:+.}Exe  -AutoConnect 1 -Device PIC32MZ2048EFM144 -If ICSP 
-speed 12000 -CommandFile script
+
+  if [ "$MYNEWT_VAL_MCU_NO_BOOTLOADER_BUILD" == "1" ]; then
+    # Application started from boot flash by debugger reset and go does
+    # not run (first context switch never happens). Pulse MCLR without
+    # connecting to the target instead.
+    echo "r0" > script
+    echo "sleep 200" >> script
+    echo "r1" >> script
+    echo "q" >> script
+    JLink${COMSPEC:+.}Exe -Device PIC32MZ2048EFM144 -If ICSP -CommandFile 
script
+  fi
 fi

Reply via email to