Recent

Author Topic: Cross compile to arm CPU (STM32L1) embedded  (Read 263 times)

Ahi

  • New Member
  • *
  • Posts: 10
Cross compile to arm CPU (STM32L1) embedded
« on: July 09, 2020, 12:33:02 pm »
Does FPC support compiling to arm CPU (STM32L1) ; embedded (meaning run on bare hardware, NO operating system) ?

More info about CPU:

https://www.st.com/en/microcontrollers-microprocessors/stm32l1-series.html

I have seen references to "Android - arm" and "Linux -arm" but what about compiling to bare hardware without operating system ?

PascalDragon

  • Hero Member
  • *****
  • Posts: 1956
  • Compiler Developer
Re: Cross compile to arm CPU (STM32L1) embedded
« Reply #1 on: July 09, 2020, 01:32:55 pm »
For compiling for a CPU without any OS FPC has the target embedded, though it's not supported for all CPUs. However for ARM it's definitely supported (you can see the supported controllers here). However the STM32L1 is not part of them (the STM32L4 however is supported through patches by Michael Ring in his Microcontroller Board Framework).

You can either ask him if he can provide the necessary controller unit for the STM32L1 or you can try to generate one yourself. Look at the patches to see what needs to be added.

Ahi

  • New Member
  • *
  • Posts: 10
Re: Cross compile to arm CPU (STM32L1) embedded
« Reply #2 on: July 12, 2020, 11:09:10 pm »
I investigated this a little, since I am new to ARM microcontrollers.

The 32L100CDISCOVERY kit offers the following features:
STM32L100RCT6 microcontroller
MCU 32-bit ARM Cortex M3 RISC 256KB Flash 2.5V/3.3V 64-Pin LQFP Tray

That MCU is Cortex M3.

a quote from this page:
https://en.wikipedia.org/wiki/ARM_Cortex-M

"Conceptually the Cortex-M4 is a Cortex-M3 plus DSP instructions, and optional floating-point unit (FPU).
A core with an FPU is known as Cortex-M4F."

That makes me think, that to support the STM32L1 MCU,

in the best case FPC ARM embedded should have command line switches to optionally turn off:

1) generating of instructions that use the FPU
2) generating of instructions that do DSP

example: --no-fpu --no-dsp

And if not, I'd hope that I could (in the source of FPC-ARM):
{$UNDEF DSP}
{$UNDEF FPU}

since the text on the linked wikipedia page claims that the Cortex-M4 MCU (which the STM32L4 is) is nothing more than Cortex-M3 with added features: DSP (and optionally, also FPU).

So, the main issue is to either find suitable command line switches, or if not available, then hopefully just using a conditional directive to disable generating DSP and FPU instructions.

An additional issue is the constant definitions for any integrated peripherals.

I have previous experience about Atmel AVR 8-bit MCUs.
For them, a definition file for  integrated peripherals is available.
But how to find a similar file for the STM32L100RCT6 microcontroller ?

Do I need to install some C/C++ IDE for ARM development and the definition file (probably a .h file if it is meant to be used with C/C++ languages) should install as part of such IDE; if so, which IDE would be a good choice (hopefully including the necessary program to transfer the ARM executable to my development board that is equipped with the "Embedded ST-LINK/V2 debugger/programmer" (interface ?)

For Atmel AVR I just used avrdude to transfer the AVR executable from PC to a board with Atmel AVR MCU.

Does a similar separate tool exist for the ARM board with Embedded ST-LINK/V2 debugger/programmer as well ?

PascalDragon

  • Hero Member
  • *****
  • Posts: 1956
  • Compiler Developer
Re: Cross compile to arm CPU (STM32L1) embedded
« Reply #3 on: July 13, 2020, 10:43:28 am »
That makes me think, that to support the STM32L1 MCU,

in the best case FPC ARM embedded should have command line switches to optionally turn off:

1) generating of instructions that use the FPU
2) generating of instructions that do DSP

For FPC that is done by selecting the correct CPU (-CpXXX) and FPU (-CfXXX) types. For ARM Cortex M3 it would be CPU type ARMV7M and FPU type SOFT. As you can see here that can also be preconfigured for each controller type.

 

TinyPortal © 2005-2018