Skip to content

Non Rtos build fails for ARM compiler #9523

Closed
@deepikabhavnani

Description

@deepikabhavnani

Description

Mbed OS example when built without rtos, fails in init for ARM compiler.
++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x51DB
Error Value: 0x12E6
For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF013D
-- MbedOS Error Info -
++ MbedOS Fault Handler ++

FaultType: HardFault

Context:
R0 : 000073EC
R1 : 00000000
R2 : 000083EC
R3 : 20000104
R4 : 000083EC
R5 : 000073EC
R6 : 000073FC
R7 : 200005DC
R8 : 00000000
R9 : 00000000
R10 : 000071AC
R11 : 000071AC
R12 : 00000000
SP : 2002FFD0
LR : 000012CF
PC : 000012E6
xPSR : 41000000
PSP : 00000000
MSP : 2002FF68
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000000
BFSR : 00000086
UFSR : 00000000
DFSR : 00000008
AFSR : 00000000
BFAR : 000073EC
Mode : Thread
Priv : Privileged
Stack: MSP

Crash location = __Heap_Initialize
Caller location = _init_alloc

Steps to compile non-rtos version for blinky:

  1. mbed import mbed-os-example-blinky
  2. Add .mbedignore with following data
    /test/
    mbed-os/rtos/*
    mbed-os/events/*
    mbed-os/features/*
    mbed-os/components/*
  3. Remove mbed_app.json - or set all configs as false.

Issue gets fixed with below change in linker file:

diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct
index 72a6efafe2..3a92ddf5b1 100644
--- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct
+++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_ARM_STD/MK64FN1M0xxx12.sct
@@ -131,6 +131,4 @@ LR_IROM1 m_interrupts_start m_text_start+m_text_size-m_interrupts_start {   ; lo
   }
   RW_IRAM1 ImageLimit(RW_m_data_2) { ; Heap region growing up
   }
-  ARM_LIB_STACK m_data_2_start+m_data_2_size EMPTY -Stack_Size { ; Stack region growing down
-  }
 }

Linker file was updated to have stack config option and later use it to have unified stack size across all targets.

Solution:

Correct the implementation of _mbed_user_setup_stackheap which assumes single stack and heap region of IARM1 is present in linker file.

extern "C" MBED_WEAK __value_in_regs struct __initial_stackheap _mbed_user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3)

We have alternate implementations for few targets, considering stack and heap as separate regions for Mbed 2 as well.

extern __value_in_regs struct __initial_stackheap _mbed_user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {

Impact:
#8039 - Affects K64F only and is part of 5.11 release
#9092 - All targets and is for 5,12

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions