Issue in loading bss and data to memory

1

I have a very simple project compiled for cortex-A53 with arm-compiler-6 (armclang). This project contains a main.c, a scatter file and a startup.s. This is its scatter file:

LOAD 0x00000000
{
  ROM +0x0
  {
     startup.o(BOOT, +FIRST)
     * (+RO)
  }
  TEST_DATA 0x40000 EMPTY 0x1000
  {
  }
  RAM +0x0
  {
    * (+RW, +ZI)
  }

  ARM_LIB_STACKHEAP +0x0 EMPTY 0x00010000
  {}
}

This is the init code in startup.s in short:

start64:  
  // Which core am I
  // ----------------
  MRS      x0, MPIDR_EL1
  AND      x0, x0, #0xFF                     // Mask off to leave Aff0
  CBZ      x0, boot                          // If core 0, run the primary init code
sleep:
  WFI
  B        sleep
boot:
  // Disable trapping of CPTR_EL3 accesses or use of Adv.SIMD/FPU
  // -------------------------------------------------------------
  MOV      x0, #0                           // Clear all trap bits
  MSR      CPTR_EL3, x0


  // Install a vector table
  // -----------------------------
  .global  vectors
  LDR      x0, =vectors
  MSR      VBAR_EL3, x0


  // Configure SCR_EL3
  // ------------------
  MOV      w1, #0              // Initial value of register is unknown
  ORR      w1, w1, #(1 << 11)  // Set ST bit (Secure EL1 can access CNTPS_TVAL_EL1, CNTPS_CTL_EL1 & CNTPS_CVAL_EL1)
  ORR      w1, w1, #(1 << 10)  // Set RW bit (EL1 is AArch64, as this is the Secure world)
  ORR      w1, w1, #(1 << 3)   // Set EA bit (SError routed to EL3)
  ORR      w1, w1, #(1 << 2)   // Set FIQ bit (FIQs routed to EL3)
  ORR      w1, w1, #(1 << 1)   // Set IRQ bit (IRQs routed to EL3)
  MSR      SCR_EL3, x1

  ISB

  // Initialize stack pointer
  // ------------------------
  .global Image$$ARM_LIB_STACKHEAP$$ZI$$Limit
  LDR      x0, =Image$$ARM_LIB_STACKHEAP$$ZI$$Limit
  MOV      sp, x0

  // Branch to scatter loading and C library init code
  .global  __main
  B        __main

Unfortunately when the data and bss are placed in the RAM section, the project does not run at all. When I place them in the ROM section, the project runs properly but, of course, I can only read global variables but not modify their value. In general, I can both read and write from RAM during runtime. I suspect that some stage is missing in my init code. As I understand, __scatterload which is called by __main is responsible for initializing the ZI to zero. Thank you for your help.

assembly
linker-scripts
cortex-a
armclang
asked on Stack Overflow Nov 28, 2019 by Ofa

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0