Skip to content

Building failing in arm cortex-m0 #11167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ceolin opened this issue Nov 7, 2018 · 4 comments · Fixed by #11189
Closed

Building failing in arm cortex-m0 #11167

ceolin opened this issue Nov 7, 2018 · 4 comments · Fixed by #11189
Assignees
Labels
area: ARM ARM (32-bit) Architecture bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@ceolin
Copy link
Member

ceolin commented Nov 7, 2018

Building is failing when CONFIG_NO_OPTIMIZATIONS is enabled. This is the output for ./samples/hello_world/ with bbc-microbit as target.

Memory region         Used Size  Region Size  %age Used
           FLASH:      103636 B       256 KB     39.53%
            SRAM:        9240 B        16 KB     56.40%
        IDT_LIST:         120 B         2 KB      5.86zephyr/arch/arm/core/libarch__arm__core.a(isr_wrapper.S.obj): In function `_idle_state_cleared':
./zephyr/arch/arm/core/isr_wrapper.S:132:(.text._isr_wrapper+0x2c): relocation truncated to fit: R_ARM_THM_JUMP11 against symbol `_IntExit' defined in .text._HandlerModeExit section in zephyr/arch/arm/core/libarch__arm__core.a(exc_exit.S.obj)                                                                                                                             
collect2: error: ld returned 1 exit status
%
ninja: build stopped: subcommand failed.
@ceolin ceolin added bug The issue is a bug, or the PR is fixing a bug area: ARM ARM (32-bit) Architecture labels Nov 7, 2018
@SebastianBoe
Copy link
Collaborator

Reproduced.

diff --git a/samples/hello_world/CMakeLists.txt b/samples/hello_world/CMakeLists.txt
index 9c3c38b669..ad74422ed8 100644
--- a/samples/hello_world/CMakeLists.txt
+++ b/samples/hello_world/CMakeLists.txt
@@ -1,5 +1,7 @@
 cmake_minimum_required(VERSION 3.8.2)
 
+set(BOARD nrf51_pca10028)
+
 include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
 project(hello_world)
 
diff --git a/samples/hello_world/prj.conf b/samples/hello_world/prj.conf
index b2a4ba5910..8c8a1404c5 100644
--- a/samples/hello_world/prj.conf
+++ b/samples/hello_world/prj.conf
@@ -1 +1,2 @@
 # nothing here
+CONFIG_NO_OPTIMIZATIONS=y

@SebastianBoe
Copy link
Collaborator

SebastianBoe commented Nov 7, 2018

Fixed.

Not sure what kind of consequences this fix has though, it might be breaking things ...

diff --git a/arch/arm/core/isr_wrapper.S b/arch/arm/core/isr_wrapper.S
index 53c24645d7..d3c24d33f1 100644
--- a/arch/arm/core/isr_wrapper.S
+++ b/arch/arm/core/isr_wrapper.S
@@ -133,4 +133,4 @@ _idle_state_cleared:
 #endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
 
 	/* exception return is done in _IntExit() */
-	b _IntExit
+	bl _IntExit
diff --git a/samples/hello_world/CMakeLists.txt b/samples/hello_world/CMakeLists.txt

EDIT: This fix is no good.

@SebastianBoe
Copy link
Collaborator

The root cause and solution options are described in 1765276#diff-ef6459503728d8b77ea93b33e8de0117

Personally I think that porting to C is the best long-term solution. Not sure what to do short-term ...

SebastianBoe added a commit to SebastianBoe/zephyr that referenced this issue Nov 7, 2018
Put _isr_wrapper and _IntExit in the same file to ensure that they are
placed close together. When they are placed too far away from each
other the 'b' instruction in _isr_wrapper will not reach _IntExit on
Cortex-M0 platforms.

See zephyrproject-rtos#11167 for
details.

Signed-off-by: Sebastian Bøe <[email protected]>
@nashif nashif added the priority: medium Medium impact/importance bug label Nov 7, 2018
@ceolin
Copy link
Member Author

ceolin commented Nov 7, 2018

Fixed.

Not sure what kind of consequences this fix has though, it might be breaking things ...

diff --git a/arch/arm/core/isr_wrapper.S b/arch/arm/core/isr_wrapper.S
index 53c24645d7..d3c24d33f1 100644
--- a/arch/arm/core/isr_wrapper.S
+++ b/arch/arm/core/isr_wrapper.S
@@ -133,4 +133,4 @@ _idle_state_cleared:
 #endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
 
 	/* exception return is done in _IntExit() */
-	b _IntExit
+	bl _IntExit
diff --git a/samples/hello_world/CMakeLists.txt b/samples/hello_world/CMakeLists.txt

EDIT: This fix is no good.

Yeah, it override the link register, one change that works is save lr register into other register and restore it in _IntExit. But my re-organize these sections make more sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
3 participants