Author Topic: STM32 vectors in assembly, how to generate with lsb set! FIXED TY :)  (Read 1661 times)

0 Members and 1 Guest are viewing this topic.

Offline fourtytwo42Topic starter

  • Super Contributor
  • ***
  • Posts: 1183
  • Country: gb
  • Interested in all things green/ECO NOT political
Hi I am using an STM32F3xxxxx (Cortex M3) in assembler! Just wrote my first interrupt code and got "hard fault". Traced this to me being extremely naughty and loading the interrupt vector as usual with the ISR address BUT ARM objects if this is EVEN (something to do with thumb) apparently all ISR's must start on an odd address to avoid this. I have searched high and low and have found no way of ensuring this alignment. Does anybody know the appropriate incantations to be included in order to solve this problem ?
« Last Edit: May 04, 2018, 07:50:34 pm by fourtytwo42 »
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: STM32 vectors in assembly, how to generate with lsb set!
« Reply #1 on: May 04, 2018, 06:36:09 pm »
As long as you assemble your code as Thumb (-mthumb for gas), the toolchain should handle this automatically.

Offline fourtytwo42Topic starter

  • Super Contributor
  • ***
  • Posts: 1183
  • Country: gb
  • Interested in all things green/ECO NOT political
Re: STM32 vectors in assembly, how to generate with lsb set!
« Reply #2 on: May 04, 2018, 06:44:31 pm »
Thank you for your reply :) There are only two modules, one containing the vector table and the other the isr, both have these lines at the beginning
@ compiler switches
  .syntax unified
  .cpu cortex-m4
  .thumb

I am not sure whats in the makefile where gcc is called up, I will go check it :)
Couldnt find it BUT the log shows gcc being called with -mthumb. I am worried this is being overriden in the linker with all the ALIGN=4 stuff ?

I am using openstm32
« Last Edit: May 04, 2018, 07:22:18 pm by fourtytwo42 »
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: STM32 vectors in assembly, how to generate with lsb set!
« Reply #3 on: May 04, 2018, 07:11:47 pm »
Seems you need to explicitly mark symbols as functions using either the .thumb_func or .type symname, %function directives.
 
The following users thanked this post: fourtytwo42

Offline fourtytwo42Topic starter

  • Super Contributor
  • ***
  • Posts: 1183
  • Country: gb
  • Interested in all things green/ECO NOT political
Re: STM32 vectors in assembly, how to generate with lsb set!
« Reply #4 on: May 04, 2018, 07:15:36 pm »
Ahh like "   .type   Reset_Handler, %function"
Thank you so much for shining a light on it :)
I am still wading my way through the morass........

Perfect :) Just been in Linux to test, has to be immediatly before label not just anywhere it seems as in

   .type   tim16_int, %function
tim16_int:
« Last Edit: May 04, 2018, 07:40:14 pm by fourtytwo42 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf