Recent

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

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #15 on: January 16, 2021, 02:42:44 pm »
hello,

in fpc.cfg, the paths involve the folder "units" which doesn't tie in to the location of system.ppu.
If i remove the /units, I get past the first hurdle.


-FuC:\fpcupdeluxe-mbf\fpc/units/$fpctarget/$fpcsubarch/rtl
-FuC:\fpcupdeluxe-mbf\fpc\arm-embedded\armv7m\rtl

It now cannot find arm-embedded-as.exe not found which is probably related error.

Another point is that when I copied the extra packages i was prompted to ovewrite fpc.cfg - I did not do this and notice the paths in your fpc.cfg do not have the -mbf extensions. It is confusing to the user here.


petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #16 on: January 16, 2021, 02:57:20 pm »
i can't find  "arm-embedded-as.exe" is this meant to be in the package d/l from git ?


It looks like there are assembler,linker etc  files with "none-eabi" if i substitute with "embedded" something happens
« Last Edit: January 16, 2021, 03:04:26 pm by petex »

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #17 on: January 16, 2021, 03:09:36 pm »
if i change the names of the exes substituing "none-eabi" with "embedded" i get this......


Quote
Compile Project, OS: embedded, CPU: arm, Target: Blinky: Success, Warnings: 1, Hints: 7
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
Verbose: Compiling C:\temp-svn\blue-pill\mbf-master\Source\MBF.STM32F1.SystemCore.pas
Verbose: Compiling C:\temp-svn\blue-pill\mbf-master\Source\MBF.BitHelpers.pas
Verbose: Assembling mbf.bithelpers
MBF.ARM.SystemCore.inc(110,30) Warning: Calling convention directive ignored: "OldFPCCall"
Verbose: Assembling mbf.stm32f1.systemcore
Verbose: Compiling C:\temp-svn\blue-pill\mbf-master\Source\MBF.STM32F1.GPIO.pas
MBF.STM32F1.GPIO.pas(513,8) Hint: Conversion between ordinals and pointers is not portable
MBF.STM32F1.GPIO.pas(514,5) Hint: Conversion between ordinals and pointers is not portable
MBF.STM32F1.GPIO.pas(515,5) Hint: Conversion between ordinals and pointers is not portable
MBF.STM32F1.GPIO.pas(516,5) Hint: Conversion between ordinals and pointers is not portable
MBF.STM32F1.GPIO.pas(517,23) Hint: Conversion between ordinals and pointers is not portable
Verbose: Assembling mbf.stm32f1.gpio
Verbose: Assembling blinky
Verbose: Linking C:\temp-svn\blue-pill\mbf-master\SamplesBoardSpecific\Blinky-Bluepill\Blinky
Debug: STM32F103XB
Verbose: 72375 lines compiled, 6.8 sec, 5764 bytes code, 537 bytes data
Verbose: 1 warning(s) issued
Verbose: 7 hint(s) issued



MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #18 on: January 16, 2021, 03:14:51 pm »
The errors before were 100% my fault, I did not doublecheck enough when I created the zip files.

I have now uploaded fixed versions of the zip files to my server, to fix your install please do the following:

create ftp\units directory

move arm-embedded directory in this directory

change the fpc.cfg file and change back to the proper directory name:

-FuC:\fpcupdeluxe-mbf\fpc\units\$fpctarget\$fpcsubarch\rtl

You can then either re-download and extract the binutils package or (if you have not already done) duplicate the arm-none-eabi- files and rename the second set to arm-embedded-

Sorry for that,

Michael

and congrats, you successsfully compiled the Blinky project in your last step....


Grmpf.. had to edit this post several times, pleasse re-read in case there are still issues...

« Last Edit: January 16, 2021, 03:19:50 pm by MiR »

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #19 on: January 16, 2021, 03:27:29 pm »
hello,

I shall follow your last instructions. Getting closer, thanks for that.

Quote
and congrats, you successsfully compiled the Blinky project in your last step....

Not so fast... The last (successful) build does not run on my setup. I have compared it to previous blinky project on Lazarus using the fpcupdeluxe embedded compiler which does run.

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #20 on: January 16, 2021, 03:44:33 pm »
I am just doing a clean install on windows to doublecheck my instructions....

Is there a bootloader installed on your Bluepill? I do not mean the ROM-Bootloader that you enable by pushing BOOT0 and NRST, that one if fine.....

By the way, do you own a debug probe? if yes, which one?

Michael

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #21 on: January 16, 2021, 04:16:12 pm »
FYI, just found out the hard way that it is necessary to install lazarus trunk when you want proper debugging, the last lazarus release lacks important changes that are needed for debugging.

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #22 on: January 16, 2021, 05:05:00 pm »
Following my own instructions, things look good, I can build and debug the Blinky example on my Windows computer and on my Mac without issue.

I will now create & verify examples for uart and spi, but will likely take until tomorrow.....

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #23 on: January 16, 2021, 05:20:35 pm »
hello

Quote

Is there a bootloader installed on your Bluepill? I do not mean the ROM-Bootloader that you enable by pushing BOOT0 and NRST, that one if fine.....

By the way, do you own a debug probe? if yes, which one?


I am a complete novice in using this Blue Pill card. I recently bought one to try out as it seemed so cheap and powerful. I am evaluating its capabilities and the development environments available at the moment. I really want to stick to Lazarus and not go back to C.

The program is loaded through the serial port (A9 and A10). I had a go at using the USB loader but there's a lot of faffing about to get that to work.


I don't own a probe for this. I've got a BDM probe for the centronics port somewhere, how likely is that going to work ?

Maybe you could upload your bin or hex file so I can try running it.

Quote
I will now create & verify examples for uart and spi, but will likely take until tomorrow.....

hey man, no rush you have been v. helpful so far. This is a long term project!!

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #24 on: January 16, 2021, 05:44:56 pm »
It is quite important to know how exactly you do the upload, it looks to me that you are using the UART via BOOT0 and RESET Button.

This then means that the uploaded program will run from flash start 0x08000000. For this start address my binary will work well.

When you have however some Arduino bootloader on the board (but I think you would not use Serial in that case) then the start address of the program must first be changed.

So which tool do you use for uploading your working example and which parameters do you use?

By the way, I found this quite good page:

https://www.electronicshub.org/how-to-upload-stm32f103c8t6-usb-bootloader/

which has a lot of different examples on how to upload for further reading...

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #25 on: January 16, 2021, 06:15:42 pm »
Yes i am using the boot0 and reset button method

I am using ST electronics loader - STMFlashLoader Demo.exe through a USB to TTL/CMOS Serial FTDI232 device at virtual port COM3.

I use all the defaults, start address 8000000, verify , jump to user program.

I will try your upload in due course, thanks.

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #26 on: January 16, 2021, 06:18:27 pm »
your Blinky image works OK on my setup.

There are considerable differences in file size.
« Last Edit: January 16, 2021, 06:27:20 pm by petex »

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #27 on: January 16, 2021, 07:13:35 pm »
Is you local git repo up to date with mbf? Also, any changes when you do a clean build (or simple delete the lib directory and rebuild)

Please also check that in your Blinky version the setting of the CPU speed is commented out, there is an issue in this routine...
« Last Edit: January 16, 2021, 07:15:47 pm by MiR »

MiR

  • Full Member
  • ***
  • Posts: 246
Re: How to build with MBF framework and STM32
« Reply #28 on: January 17, 2021, 11:55:20 am »
I have created bluepill samples for UART and SPI in the SamplesBoardSpecific directory, please pull the latest changes. The changeset is quite big because I saw that inlining of code does not work well in some cases for 3.2 and trunk compiler.

Michael

petex

  • Jr. Member
  • **
  • Posts: 69
Re: How to build with MBF framework and STM32
« Reply #29 on: January 17, 2021, 12:59:39 pm »
I have downloaded the three zip files from the WIKI.
I have copied evertything verbatim into the fpc folder.
Have rebuilt the blinky program with set cpu clock commented out.
Code: Pascal  [Select][+][-]
  1. {$INCLUDE MBF.Config.inc}
  2.  
  3. uses
  4.   MBF.__CONTROLLERTYPE__.SystemCore,
  5.   MBF.__CONTROLLERTYPE__.GPIO;
  6.  
  7. begin
  8.   SystemCore.Initialize;
  9. //  SystemCore.SetCPUFrequency(SystemCore.getMaxCPUFrequency);
  10.  
  11.   GPIO.Initialize;
  12.   GPIO.PinMode[TNativePin.PC13] := TPinMode.Output;
  13.  
  14.   repeat
  15.     GPIO.PinValue[TNativePin.PC13] := 1;
  16.     SystemCore.Delay(500);
  17.     GPIO.PinValue[TNativePin.PC13] := 0;
  18.     SystemCore.Delay(500);
  19.   until 1=0;
  20. end.    
  21.  

Successful build :-
Quote
Compile Project, OS: embedded, CPU: arm, Target: Blinky: Success, Warnings: 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
Verbose: Compiling C:\temp-svn\blue-pill\mbf-master\Source\MBF.STM32F1.SystemCore.pas
Verbose: Compiling C:\temp-svn\blue-pill\mbf-master\Source\MBF.BitHelpers.pas
Verbose: Assembling mbf.bithelpers
MBF.ARM.SystemCore.inc(110,30) Warning: Calling convention directive ignored: "OldFPCCall"
Verbose: Assembling mbf.stm32f1.systemcore
Verbose: Compiling C:\temp-svn\blue-pill\mbf-master\Source\MBF.STM32F1.GPIO.pas
Verbose: Assembling mbf.stm32f1.gpio
Verbose: Assembling blinky
Verbose: Linking C:\temp-svn\blue-pill\mbf-master\SamplesBoardSpecific\Blinky-Bluepill\Blinky
Debug: STM32F103XB
Verbose: 72377 lines compiled, 0.9 sec, 5772 bytes code, 537 bytes data
Verbose: 1 warning(s) issued
Verbose: 7 hint(s) issued


Downloaded the bin file and no success unfortunately.

here are the build files....


 

TinyPortal © 2005-2018