DA14531 Further secondary bootloader optimization for large image files

ID: LPCBARESDK-780

Status: Open

First reported: 6.0.14.1114

Fixed in: TBD

Description

The secondary bootloader is used to replace the ROM bootloader for application that requires different boot pins than used in the ROM bootloader. You can refer to the AN-B-072: DA14531 Booting from OTP and Serial Interfaces. The secondary bootloader available in the SDK 6.0.16 6.0.16.1144\utilities\secondary_bootloader fails to boot images larger than 30.75 KB.

#define MAX_CODE_LENGTH             (0x7B00)

Workaround

Apply this patch:

diff --git a/utilities/secondary_bootloader/includes/uart_booter.h b/utilities/secondary_bootloader/includes/uart_booter.h
index 1f3d623..d4d7d0b 100644
--- a/utilities/secondary_bootloader/includes/uart_booter.h
+++ b/utilities/secondary_bootloader/includes/uart_booter.h
@@ -16,8 +16,8 @@
 #define _UART_BOOTER_H

 #if defined (__DA14531__)
-#define MAX_CODE_LENGTH             (0x7B00)
-#define SYSRAM_COPY_BASE_ADDRESS    (0x500)
+#define MAX_CODE_LENGTH             (0x9200)
+#define SYSRAM_COPY_BASE_ADDRESS    (0x300)
 #else
 #define MAX_CODE_LENGTH             (0x12000)
 #define SYSRAM_COPY_BASE_ADDRESS    (0x2000)
diff --git a/utilities/secondary_bootloader/src/uart_booter.c b/utilities/secondary_bootloader/src/uart_booter.c
index 52a7aa2..7c9542b 100644
--- a/utilities/secondary_bootloader/src/uart_booter.c
+++ b/utilities/secondary_bootloader/src/uart_booter.c
@@ -157,6 +157,7 @@ int FwDownload(void)
     code = (char*) (SYSRAM_COPY_BASE_ADDRESS);          // set pointer to SYSRAM
     for (i = 0; i < fw_size; i++)                       // copy code from UART to RAM
     {
+        SetWord16(WATCHDOG_REG, 0xFF);
         if (0 == uart_receive_byte(&recv_byte))
         {
             return -6; // receive code byte
@@ -262,6 +263,7 @@ int FwDownloadOneWireUART(void)
     code = (char*) (SYSRAM_COPY_BASE_ADDRESS);          // set pointer to SYSRAM
     for (i = 0; i < fw_size; i++)                       // copy code from UART to RAM
     {
+        SetWord16(WATCHDOG_REG, 0xFF);
         if (0 == uart_receive_byte(&recv_byte))
         {
             return -6; // receive code byte
diff --git a/utilities/secondary_bootloader/startup/bootloader_531.sct b/utilities/secondary_bootloader/startup/bootloader_531.sct
index 324f8dd..62612e5 100644
--- a/utilities/secondary_bootloader/startup/bootloader_531.sct
+++ b/utilities/secondary_bootloader/startup/bootloader_531.sct
@@ -1,12 +1,12 @@
-LR_1 0x07FC0000 0x00008000 {    ; load region size_region
-    ER_1 +0 0x00000500 {        ; load address = execution address
+LR_1 0x07FC0000 0x00009500 {    ; load region size_region
+    ER_1 +0 0x00000300 {        ; load address = execution address
         *.o (RESET, +First)
         *(InRoot$$Sections)
         startup_DA14531.o
         system_DA14531.o
     }

-    ER_2 0x07FC8000 0x3000 {    ; push it to the end of SysRAM
+    ER_2 0x07FC9500 0x2000 {    ; push it to the end of SysRAM
         .ANY (+RO)
         .ANY (+RW +ZI)
         .ANY (STACK)