Skip to content

Commit

Permalink
fix: Added the transfer of the start address to the link script
Browse files Browse the repository at this point in the history
Signed-off-by: Taras Drozdovskyi <[email protected]>
  • Loading branch information
tdrozdovsky committed Dec 19, 2024
1 parent b2f12b0 commit 7cfd8f5
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion arch/cortex-m23/m2351/src/m2351_badge/nonsecure/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ mtower_ns$(EXEEXT): $(OBJS_NS)
$(Q) $(MAKE) -C $(TOPDIR)/freertos/ TOPDIR="$(TOPDIR)" FREE_RTOS_ARCH=ARM_V8M libFreeRTOS_ns.a
$(Q) $(MAKE) -C ../../StdDriver/src/ TOPDIR="$(TOPDIR)" libm2351_StdDriver_ns.a
@echo "LD: mTower_ns$(EXEEXT)"
$(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL33) -Tnonsecure.ld $(OBJS_NS) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl33.elf
$(Q) $(CC) $(CFLAGS) -Wl,--defsym,START_ADDRESS_BL33=$(CONFIG_START_ADDRESS_BL33) -Tnonsecure.ld $(OBJS_NS) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl33.elf
# $(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL33) -Tnonsecure.ld $(OBJS_NS) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl33.elf
$(Q) $(OBJCOPY) -S -O binary $(OBJDIR)/bl33.elf $(OBJDIR)/bl33.bin

clean:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions of Non-secure region */
MEMORY
{
/* FLASH (rx) : ORIGIN = 0x10040000, LENGTH = 0x40000 */
FLASH (rx) : ORIGIN = START_ADDRESS_BL33, LENGTH = 0x40000
RAM (rwx) : ORIGIN = 0x30008000, LENGTH = 0x10000
}

Expand Down
7 changes: 4 additions & 3 deletions arch/cortex-m23/m2351/src/m2351_badge/secure/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ CFLAGS += -I../../Device/Nuvoton/M2351/Include
CFLAGS += -I$(TOPDIR)/tee_client/public
CFLAGS += -I$(TOPDIR)/tee_client/libteec/include/freertos
CFLAGS += -I$(TOPDIR)/tee/lib/libutee/include

CFLAGS += -I$(TOPDIR)/tee/lib/libutils/ext/include
CFLAGS += -I$(TOPDIR)/tee/lib/libutils/isoc/include
CFLAGS += -I$(TOPDIR)/tee/include
Expand Down Expand Up @@ -84,9 +83,11 @@ mtower_s$(EXEEXT): $(OBJS_S)
$(Q) $(MAKE) -C $(TOPDIR)/common/ TOPDIR="$(TOPDIR)" WORLD=secure liballoc_s.a
$(Q) $(MAKE) -C $(TOPDIR)/crypto/ TOPDIR="$(TOPDIR)" WORLD=secure libcrypt_s.a
@echo "CC: mTower_s$(EXEEXT)"
$(Q) $(CC) $(CFLAGS) -mcmse -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl32.elf
$(Q) $(CC) $(CFLAGS) -mcmse -Wl,--defsym,START_ADDRESS_BL32=$(CONFIG_START_ADDRESS_BL32) -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl32.elf
$(Q) $(CC) $(CFLAGS) -Wl,--defsym,START_ADDRESS_BL32=$(CONFIG_START_ADDRESS_BL32),--unresolved-symbols=ignore-all,--out-implib=$(OBJDIR)/libnsc$(LIBEXT),--cmse-implib -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS)
# $(Q) $(CC) $(CFLAGS) -mcmse -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl32.elf
# $(Q) $(CC) $(CFLAGS) -Wl,--unresolved-symbols=ignore-all -Wl,--section-start=.gnu.sgstubs=0x3f000 -Wl,--out-implib=$(OBJDIR)/libnsc$(LIBEXT) -Wl,--cmse-implib $(OBJS_S) $(LIBPATHS) $(LIBS)
$(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Wl,--unresolved-symbols=ignore-all -Wl,--out-implib=$(OBJDIR)/libnsc$(LIBEXT) -Wl,--cmse-implib -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS)
# $(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Wl,--unresolved-symbols=ignore-all -Wl,--out-implib=$(OBJDIR)/libnsc$(LIBEXT) -Wl,--cmse-implib -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS)
$(Q) rm -f a.out
$(Q) $(OBJCOPY) -S -O binary $(OBJDIR)/bl32.elf $(OBJDIR)/bl32.bin
$(Q) cp -f $(OBJDIR)/libnsc$(LIBEXT) $(TOPDIR)/lib/
Expand Down
3 changes: 0 additions & 3 deletions arch/cortex-m23/m2351/src/m2351_badge/secure/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ int32_t Secure_LED_On(uint32_t num)
PA11 = 0;
PD11 = 0;
PD10 = 0;

// PA10 = 0;
PB0 = 0;

return 0;
Expand All @@ -246,7 +244,6 @@ int32_t Secure_LED_Off(uint32_t num)
PA11 = 1;
PD11 = 1;
PD10 = 1;
// PA10 = 1;
PB0 = 1;

return 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/cortex-m23/m2351/src/m2351_badge/secure/secure.ld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
MEMORY
{
/* FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x80000 */ /* 512k */
FLASH (rx) : ORIGIN = START_ADDRESS_BL32, LENGTH = 0x80000 /* 512k */
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x18000 /* 160k */
FLASH_NCS (rx) : ORIGIN = 0x0003F000, LENGTH = 0x00000400
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ mtower_ns$(EXEEXT): $(OBJS_NS)
$(Q) $(MAKE) -C $(TOPDIR)/freertos/ TOPDIR="$(TOPDIR)" FREE_RTOS_ARCH=ARM_V8M libFreeRTOS_ns.a
$(Q) $(MAKE) -C ../../StdDriver/src/ TOPDIR="$(TOPDIR)" libm2351_StdDriver_ns.a
@echo "LD: mTower_ns$(EXEEXT)"
$(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL33) -Tnonsecure.ld $(OBJS_NS) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl33.elf
$(Q) $(CC) $(CFLAGS) -Wl,--defsym,START_ADDRESS_BL33=$(CONFIG_START_ADDRESS_BL33) -Tnonsecure.ld $(OBJS_NS) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl33.elf
# $(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL33) -Tnonsecure.ld $(OBJS_NS) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl33.elf
$(Q) $(OBJCOPY) -S -O binary $(OBJDIR)/bl33.elf $(OBJDIR)/bl33.bin

clean:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@
#include "M2351.h"
#include "version.h"
#include "config.h"
#include "printf.h"

/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

#include "printf.h"

/* Demo application include. */

/* Pre-processor Definitions. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions of Non-secure region */
MEMORY
{
/* FLASH (rx) : ORIGIN = 0x10040000, LENGTH = 0x40000 */
FLASH (rx) : ORIGIN = START_ADDRESS_BL33, LENGTH = 0x40000
RAM (rwx) : ORIGIN = 0x30008000, LENGTH = 0x10000
}

Expand Down
6 changes: 4 additions & 2 deletions arch/cortex-m23/m2351/src/numaker_pfm_m2351/secure/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ mtower_s$(EXEEXT): $(OBJS_S)
$(Q) $(MAKE) -C $(TOPDIR)/common/ TOPDIR="$(TOPDIR)" WORLD=secure liballoc_s.a
$(Q) $(MAKE) -C $(TOPDIR)/crypto/ TOPDIR="$(TOPDIR)" WORLD=secure libcrypt_s.a
@echo "CC: mTower_s$(EXEEXT)"
$(Q) $(CC) $(CFLAGS) -mcmse -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl32.elf
$(Q) $(CC) $(CFLAGS) -mcmse -Wl,--defsym,START_ADDRESS_BL32=$(CONFIG_START_ADDRESS_BL32) -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl32.elf
$(Q) $(CC) $(CFLAGS) -Wl,--defsym,START_ADDRESS_BL32=$(CONFIG_START_ADDRESS_BL32),--unresolved-symbols=ignore-all,--out-implib=$(OBJDIR)/libnsc$(LIBEXT),--cmse-implib -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS)
# $(Q) $(CC) $(CFLAGS) -mcmse -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS) -o $(OBJDIR)/bl32.elf
# $(Q) $(CC) $(CFLAGS) -Wl,--unresolved-symbols=ignore-all -Wl,--section-start=.gnu.sgstubs=0x3f000 -Wl,--out-implib=$(OBJDIR)/libnsc$(LIBEXT) -Wl,--cmse-implib $(OBJS_S) $(LIBPATHS) $(LIBS)
$(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Wl,--unresolved-symbols=ignore-all -Wl,--out-implib=$(OBJDIR)/libnsc$(LIBEXT) -Wl,--cmse-implib -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS)
# $(Q) $(CC) $(CFLAGS) -Wl,--section-start=.text=$(CONFIG_START_ADDRESS_BL32) -Wl,--unresolved-symbols=ignore-all -Wl,--out-implib=$(OBJDIR)/libnsc$(LIBEXT) -Wl,--cmse-implib -Tsecure.ld $(OBJS_S) $(LIBPATHS) $(LIBS)
$(Q) rm -f a.out
$(Q) $(OBJCOPY) -S -O binary $(OBJDIR)/bl32.elf $(OBJDIR)/bl32.bin
$(Q) cp -f $(OBJDIR)/libnsc$(LIBEXT) $(TOPDIR)/lib/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
MEMORY
{
/* FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x80000 */ /* 512k */
FLASH (rx) : ORIGIN = START_ADDRESS_BL32, LENGTH = 0x80000 /* 512k */
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x18000 /* 160k */
FLASH_NCS (rx) : ORIGIN = 0x0003F000, LENGTH = 0x00000400
}
Expand Down

0 comments on commit 7cfd8f5

Please sign in to comment.