Recent

Author Topic: How to build with MBF framework and STM32 [solved]  (Read 4887 times)

petex

  • Jr. Member
  • **
  • Posts: 69
How to build with MBF framework and STM32 [solved]
« on: January 15, 2021, 10:57:17 am »
hello,
I am experiencing frustration with getting the MBF framework to work with STM32. I see lots of units related to the STM32 so I am guessing it does work.

I have down loaded the package. From what I can see is that some (including cpuinfo.pas) of the existing units need to be patched with STM32 definitions before starting.

Why does this need to be done ? Is it not possible to have a clean build ?
Where are these units that need to be patched ?
Are they part of the compiler ?

I am guessing that some initial $DEFINES are required to define the particular controller, or maybe these are done behind the scenes by the compiler user options. (-CpARMV7M
-WpSTM32F103X8 )

Is there a WIKI to explain how to use this framework with STM32 controller types ? I didn't see any sample or test projects using STM32.
« Last Edit: January 25, 2021, 10:22:57 am by petex »

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: How to build with MBF framework and STM32
« Reply #1 on: January 15, 2021, 11:33:53 am »
I have down loaded the package. From what I can see is that some (including cpuinfo.pas) of the existing units need to be patched with STM32 definitions before starting.

Why does this need to be done ? Is it not possible to have a clean build ?
Where are these units that need to be patched ?
Are they part of the compiler ?

I am guessing that some initial $DEFINES are required to define the particular controller, or maybe these are done behind the scenes by the compiler user options. (-CpARMV7M
-WpSTM32F103X8 )
Michael or maybe Don is best suited to help you get going with MBF.

From quick inspection the patches add several STM controllers to the compiler.  Several files need to be updated for this to work.  If your particular controller is already supported by trunk you probably don't need the patches (I haven't studied them in detail).

I am guessing that some initial $DEFINES are required to define the particular controller, or maybe these are done behind the scenes by the compiler user options. (-CpARMV7M
-WpSTM32F103X8 )
The compiler generates defines for the CPU type (subarch) and controller automatically (if the controller is supported by the compiler obviously).

Have you tried compiling one of the examples without applying the patches?  If there isn't a project file for your particular controller, just open one of the existing ones and change the -Cp, -Wp and -d settings according to your desired controller.

Edit:
Apologies for the misinformation in the above sentence. It seems that MBF needs to provide controller specific settings which are provided in controller specific include files. Luckily Michael is now helping you!
« Last Edit: January 15, 2021, 04:03:23 pm by ccrause »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: How to build with MBF framework and STM32
« Reply #2 on: January 15, 2021, 12:39:20 pm »
Quote
Michael or maybe Don is best suited to help you get going with MBF.

Indeed. Michael will be best suited to help.

Please note.

Work is done to integrate FreeRTOS and FPC for ARM mCPU's. This looks very (VERY) promising. We are in the process of integrating our efforts and Michael will introduce the necessary changes into FPC trunk (if acceptable by the devs) shortly (I hope).

Stay tuned.

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #3 on: January 15, 2021, 01:02:32 pm »
The first error encountered is no definition for __CONTROLLERTYPE__

I assume this is substituted with "STM32f013" in order to pull in the specific STM32 modules.

I tried setting it specifically e.g.
{$DEFINE __CONTROLLERTYPE__ = STM32F103}
{$DEFINE __CONTROLLERTYPE__  STM32F103}
but that syntax doesn't work. I suppose the compiler sets this up like FPC_VERSION.

Must be missing something here ????

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #4 on: January 15, 2021, 01:14:16 pm »
Sorry for coming late to the party....

Too bad that you are experiencing troubles with mbf.

I have been mostly working on mbf-freertos in the last time as this is (for me personally) the way to go in the future.

I started using the git-wiki for fpc-freertos and based on your comment it looks like it makes sense to do the same thing for mbf.

Please let me go through mbf with bluepill in mind, I will provide a new version later today based on what i find, i already found one or two places that could be done better for that special chip.

Please also note that mbf for bluepill is curently only good for gpio, uart and spi, i2c does not work for stm32f1, but it is something that can be implemented, I just never needed it and it was never asked for.

Michael


MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #5 on: January 15, 2021, 01:23:25 pm »
@Petex:

Can I ask you that you download latest fpcupdeluxe and as a preparation use fpcupdeluxe to install a version of fpc stable and lazarus stable or trunk to C:\fpcupdeluxe or $HOME/fpcupdeluxe on linux/mac

Please use exactly those directory names, then you can use prebuild compiler binaries without the need to tweak paths (Which always makes things more complicated)

When all works in the end then you can use whatever fpc/lazarus you have on your computer, but for the first steps it makes life a lot easier and cost only a little disk space.

Please keep me posted on your progress....
« Last Edit: January 15, 2021, 01:25:23 pm by MiR »

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #6 on: January 15, 2021, 01:28:41 pm »
hello,
I set this up in c:\fpcupdeluxe about 3 days ago. I shall re-update it, but it should be pretty much up-to-date and ready to go.

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #7 on: January 15, 2021, 01:31:19 pm »
Great!

What is really important is that you do not try to install embedded support for arm from there and do not try to install mbf from within fpcupdeluxe. This will currently only install compilers for armv6m which will be of no use for you. Just select the fpc/lazarus versions and hit the button to build both, then you are all set.

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #8 on: January 15, 2021, 01:57:49 pm »
I started to fill the WiKi for mbf, please check if what I write maskes sense....

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #9 on: January 15, 2021, 09:40:29 pm »
Sorry that it took longer than expected, I had to first remove the Dust from my Windows computer to be able to build the dependencies needed.

I added a small Blinky example to the SamplesBoardSpecific directory so that you have a starting point to play arround.

I own a Bluepill board and have compiled the sample on my Mac, it runs fine for me.

Please have a look at the Wiki:

https://github.com/michael-ring/mbf/wiki

and check if the installation steps work for you.

Michael

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: How to build with MBF framework and STM32
« Reply #10 on: January 15, 2021, 11:17:18 pm »
Please have a look at the Wiki:

https://github.com/michael-ring/mbf/wiki

Why didn't you add this to the FPC + Lazarus Wiki?

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #11 on: January 15, 2021, 11:21:24 pm »
I can do that in a later step, the documentation may still be incorrect and misleading/wrong, when dust has setteled then I am happy to add the content to the Lazarus Wiki.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: How to build with MBF framework and STM32
« Reply #12 on: January 16, 2021, 12:50:20 am »
Great, thanks!

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #13 on: January 16, 2021, 12:53:10 pm »
hello,
i have finally got around to trying to build based on your WIKI instructions.

I installed a fresh copy of laz/fpc for windows to the folder "fpcupdeluxe-mbf".
There's a wee bit of confusion as you added the "-mbf" extension and some references were without.

I unzipped the two packages to fpc folder as per wiki.
I updated fpc.cfg.
I opened up the blue pill blinky project and compiled......
Still getting errors


Quote

Compile Project, OS: embedded, CPU: arm, Target: Blinky: Exit code 1, Errors: 1, Hints: 2
Hint: Start of reading config file C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\fpc.cfg
Hint: End of reading config file C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\fpc.cfg
Verbose: Free Pascal Compiler version 3.2.1 [2021/01/15] for arm
Verbose: Copyright (c) 1993-2020 by Florian Klaempfl and others
Verbose: Target OS: Embedded
Verbose: Compiling Blinky.lpr
Fatal: Can't find unit system used by Blinky
Verbose: Compilation aborted
Verbose: C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\ppcrossarm.exe returned an error exitcode


MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #14 on: January 16, 2021, 01:51:41 pm »
The error message means that system.ppu could not be found.

This can have two reasons:

an issue with extracting the zip file or a typo in fpc.cfg.

I have added those lines to the Wiki, please check, if this looks OK for you then please attach your fpc.cfg file located here:

C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\fpc.cfg

---snip

Take the Path C:\fpcupdeluxe-mbf\fpc\units\$fpctarget\$fpcsubarch\rtl

and replace $fpctarget with 'arm-embedded' and $fpcsubarch with 'armv7m'

which will give you:

C:\fpcupdeluxe-mbf\fpc\units\arm-embedded\armv7m\rtl

Check that this directory exists and that it contains system.ppu

Then change to the Directory

C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\

and check that the file arm-embedded-as.exe exists.

When all checks are done you should be ready to compile your first program.....

« Last Edit: January 16, 2021, 01:58:10 pm by MiR »

 

TinyPortal © 2005-2018