SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32

assembly interrupt is ineffective; Default_Handler acts instead

I have encountered a problem and I don’t know how to continue so I’m looking for help.

I have created a project in sw4stm32.
Using board Nucleo-L053r8
Using sw4stm32 in Debian10. amd64.

In this project I so far used a single C file (klavirko.c)
At some point I decided that I’m not happy with the timing performance of my interrupt function.
So far using one interrupt (IM6_DAC_IRQHandler)
So I decided to rewrite this interrupt function in assembly.

I have already programmed in assembly (not very much) but not on ARM.
(I have on msp430 and ATmega) but ready to learn the ARM M0 assembly.

I commented out my interrupt function in the C file.
I added a new file (klavirko_asm.s) to the project.
In this file I so far made only a simple function which immediately returns:

.global TIM6_DAC_IRQHandler
.section .text.TIM6_DAC_IRQHandler,"ax",%progbits
.type TIM6_DAC_IRQHandler, %function
pop {pc}

I just wanted to know that it works, and when confirmed, start writing the actual code.
But it doesn’t work.
The microcontroller never enters my new interrupt function (it did enter my C function, when it still existed)
Instead it enters the Default_Handler in file startup_stm32l053xx.s:

.section .text.Default_Handler,"ax",%progbits
b Infinite_Loop

My problem now is that I do not know how to make my interrupt function visible.
I don’t even know on which level I’m missing something?
something missing in my assembly file?
something missing is the project configuration?
something else?

I am aware that startup_stm32l053xx.s defines a weak replacement mechanism which makes the Default_Handler happen.
But it is supposed to stop being effective if I define a function with the correct name which I just did.
Also I’m sure than my file klavirko_asm.s is not omitted during compilation because if I write some nonsense there, the compilation fails.

I tried to look through the internet for written answers but this was not successful and now I feel like I understand less than before.

I don’t know how to continue so I will appreciate any help.
Thank you in advance.


The problem is probably that the linker eliminates your code, thinking it’s not used; try suppressing the weak definition for TIM6_DAC_IRQHandler in startup_stm32l053xx.s to see if it solves the problem.

Bernard (Ac6)

Hello and thank you for the reply.
My problem is solved.

I read your response.
So it must be a linker thing, apparently.
Like, the linker does only see this weak definition in startup_stm32l053xx.s:
.weak TIM6_DAC_IRQHandler
.thumb_set TIM6_DAC_IRQHandler,Default_Handler
But does not see my definition in klavirko_asm.s.

Your suggestion was to remove the weak definition.
But I thought that this can not be the solution.
This way the weak definition will no longer be seen,
but my intended definition will most likely not “appear” because of it.
and this should result in a failure to assemble because it would be putting an unknown symbol into the interrupt vector.

So I focused on the topic of why would it not be seen.
I thought,
In klavirko_asm.s I tell that this is a global symbol,
.global TIM6_DAC_IRQHandler
but maybe in startup_stm32l053xx.s, where the interrupt vector is defined this information is not known.
I thought that I should add there the information that there is this global symbol elsewhere.
But before I could try it, I have done somehing else which turned out to be the solution.

I added these statements (copied from startup_stm32l053xx.s) so that the assembler would be at the same correct state when reaching my statements:
.syntax unified
.cpu cortex-m0plus
.fpu softvfp
(also added size information while doing it.)
So my file klavirko_asm.s now looks like this:

.syntax unified
.cpu cortex-m0plus
.fpu softvfp

.global TIM6_DAC_IRQHandler
.section .text.TIM6_DAC_IRQHandler,"ax",%progbits
.type TIM6_DAC_IRQHandler, %function
bx lr

.size TIM6_DAC_IRQHandler, .-TIM6_DAC_IRQHandler

Now everything works.
The processor corrwectly enters and leaves the interrupt now.
Now I can focus on the actual work to write the interrupt function.