Recent

Author Topic: Programming and debugging  (Read 43736 times)

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #135 on: September 05, 2019, 08:22:02 am »
then start st-util.exe, this will start the texane stlink gdbserver.
Thank you so much. I will try all of this when I get home.  ::)

-WpBluePill
-dBluePill
This is new to me. Probably one of the reasons trunk is needed.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #136 on: September 05, 2019, 08:33:05 am »
I implemented

bluepill, blackpill and maplemini (afaik the mother of all pills) two days ago, so no surprise you never saw them before .....

Beeing able to use those shortcuts requires two things, a ppcrossarm from trunk and a patch file provided by me that adds tons of embedded controllers to fpc. Hopefully soon fpcupdeluxe will make the whole process more accessible and less error prone.

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #137 on: September 05, 2019, 03:13:28 pm »
I implemented bluepill, blackpill and maplemini (afaik the mother of all pills) two days ago, so no surprise you never saw them before .....
Amazing  8)

Beeing able to use those shortcuts requires two things, a ppcrossarm from trunk and a patch file provided by me that adds tons of embedded controllers to fpc.
Since I now have trunk fpc and trunk laz from yesterday, do I need that patch? If I do then is it the patch already mentioned somewhere in this thread?

Hopefully soon fpcupdeluxe will make the whole process more accessible and less error prone.
I do hope so.

Btw, I just saw that PlatformIO also uses Texane ST-Util GDB server, so I might also try to locate it and try to use it from Lazarus:
https://docs.platformio.org/en/latest/plus/debug-tools/custom.html#st-util-and-st-link

I didn't check yet what is used by Mikroelektronika Pascal IDE as programming and debugging work there too.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #138 on: September 05, 2019, 03:47:39 pm »
As Bluepill + friends are only aliases I had to write nine lines of code, so perhaps not that amazing at all.....

The important part for you is that you installed my zip file that contains a freshly built crosscompiler with my patches included.
This is only temporary, when Alfred starts the real integration you will get this crosscompiler built based on current trunk by fpcupdeluxe.

What we are doing here is preparation steps for a smooth integration in fpcupdeluxe.
'
Good to know that platformio is also using texane, if my build does for some reason not work for you then there's the fallback to the binary provided by platformio.
« Last Edit: September 06, 2019, 08:46:39 am by MiR »

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #139 on: September 06, 2019, 01:12:33 am »
Tried to apply your patches with command line and Tortoise, but failed miserably. Then copied your fpc source directory over mine, but fpcupdeluxe failed to rebuild fpc after that.

It's getting late. I will try tomorrow manual compilation.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #140 on: September 06, 2019, 08:25:18 am »
Hmmm... your last post confuses me a little, seems I have mislead you in some way.

There is currently no need for you anymore to apply patches to be able to start embedded development.

The steps to success are:

Download

http://temp.michael-ring.org/embedded-deluxe-win10-x86_64.zip

Create a fresh x86_64 instance of Lazarus+FPC with fpcupdeluxe, check that it starts fine.

After this unpack the zip-File you just downloaded into the root of your new instance. The directory structure in the zip file is the same as in your fpcupdeluxe instance, after unpacking you should be able to see:

ppcrossarm.exe

in the

fpc\bin\x86_64-win64 

directory.

Now extend the fpc.cfg file located in fpc\bin\x86_64-win64 as described on the previous Page of this thread.

Download the new binaries for the gdbserver:

http://temp.michael-ring.org/stlink-1.5.1-win10-x86_64.zip

put them somewhere and start the gdbserver by starting st_util.exe

Configure the gdbserver settings in Lazarus with port 4242 (See Screenshot on previous Page)

For the very first verification that all is well download my mbf-Snapshot

http://temp.michael-ring.org/mbf-snapshot.zip

and extract it to some place .

Then load the Blinky Project in

mbf\SamplesBoardSpecific\Blinky-Bluepill in your Lazarus Instance, ignore the eror message about system not found...

This small example compiles and runs well on the BluePill, so it is a good starting point to verify your installation.

Compile it, Hit Run and single step through the code.


« Last Edit: September 06, 2019, 08:32:32 am by MiR »

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #141 on: September 06, 2019, 10:14:40 am »
Hmmm... your last post confuses me a little
After following your previous instructions and trying to compile project1 I had some issues. I do not remember if error was the same or some unit was reported missing, but after that I tried mbf blue pill example and that definitely reported some missing stm32f103*.pas unit. That was the reason why I tried to apply your patches. When that didn't work I tried to replace my whole fpcsrc dir with your archive, but then fpcupdeluxe failed in rebuilding. It was late and I was tired so I left manual compilation for next day.

When I get home I will try to literally follow your latest instruction and report back. I will do it with fresh fpc trunk and laz trunk from an archive I made 2 days ago with fpcupdeluxe.

Thank you for your patience, time, and all effort and support you have shown. I really appreciate it.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #142 on: September 06, 2019, 11:47:31 pm »
The steps to success are:

Download

http://temp.michael-ring.org/embedded-deluxe-win10-x86_64.zip

Create a fresh x86_64 instance of Lazarus+FPC with fpcupdeluxe, check that it starts fine.

After this unpack the zip-File you just downloaded into the root of your new instance. The directory structure in the zip file is the same as in your fpcupdeluxe instance, after unpacking you should be able to see:

ppcrossarm.exe

in the

fpc\bin\x86_64-win64 

directory.
Checked.

Now extend the fpc.cfg file located in fpc\bin\x86_64-win64 as described on the previous Page of this thread.
Checked and attached fpc.cfg for verification.

Download the new binaries for the gdbserver:

http://temp.michael-ring.org/stlink-1.5.1-win10-x86_64.zip

put them somewhere and start the gdbserver by starting st_util.exe
Checked

Configure the gdbserver settings in Lazarus with port 4242 (See Screenshot on previous Page)
Checked and screenshot attached.

For the very first verification that all is well download my mbf-Snapshot

http://temp.michael-ring.org/mbf-snapshot.zip

and extract it to some place .

Then load the Blinky Project in

mbf\SamplesBoardSpecific\Blinky-Bluepill in your Lazarus Instance, ignore the eror message about system not found...

This small example compiles and runs well on the BluePill, so it is a good starting point to verify your installation.

Compile it, Hit Run and single step through the code.
Checked.

Running was not possible because of compilation error:
Quote
Project checks, Hints: 1
Note: passing compiler option -Cp twice with different values
Compile Project, OS: embedded, CPU: arm, Target: Blinky: Exit code 1, Errors: 1
Fatal: Can't find unit STM32F103XB used by Blinky

Warning seams to be irrelevant since it looks like -Cp has twice the same parameter but with different capitalization:
Quote
C:\PRG\Lazarus\stm32x64\fpc\bin\x86_64-win64\fpc.exe
-Tembedded
-Parm
-CpARMV7M
-MObjFPC
-Scgi
-O1
-gw2
-l
-vewnhibq
-Fi..\..\Source
-Filib\arm-embedded
-Fu..\..\Source
-Fu.
-FUlib\arm-embedded
-FE.
-oBlinky
-Cparmv7m
-WpBluePill
-dBluePill

I can find compiled unit here:
Quote
c:\PRG\Lazarus\stm32x64\fpc\units\arm-embedded\armv7m\rtl\stm32f103xb.o
c:\PRG\Lazarus\stm32x64\fpc\units\arm-embedded\armv7m\rtl\stm32f103xb.ppu

but there is no source for it. Now I come to the point when I need patches, but as previously explained I was not able to apply them. If you want I can try again and report back detailed steps I took.

EDIT: I forgot to say that compilation error shows with and without setting project debugger backend to ST-Link v2 gdb server.
« Last Edit: September 07, 2019, 12:04:36 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

ccrause

  • Hero Member
  • *****
  • Posts: 1093
Re: Programming and debugging
« Reply #143 on: September 07, 2019, 08:42:52 am »
Quote
C:\PRG\Lazarus\stm32x64\fpc\bin\x86_64-win64\fpc.exe
-Tembedded
-Parm
-CpARMV7M
-MObjFPC
-Scgi
-O1
-gw2
-l
-vewnhibq
-Fi..\..\Source
-Filib\arm-embedded
-Fu..\..\Source
-Fu.
-FUlib\arm-embedded
-FE.
-oBlinky
-Cparmv7m
-WpBluePill
-dBluePill

I can find compiled unit here:
Quote
c:\PRG\Lazarus\stm32x64\fpc\units\arm-embedded\armv7m\rtl\stm32f103xb.o
c:\PRG\Lazarus\stm32x64\fpc\units\arm-embedded\armv7m\rtl\stm32f103xb.ppu

There is no option that points FPC to the custom config file. In Lazarus, go to Project Options - Compiler Options - Config and Target then uncheck "Use standard compiler config file" and check "Use additional compiler config file" and specify the path to the customized fpc.cfg.

If this still doesn't work then select "Show everything (-va)" under the verbosity setting.  This should then show the detail of where FPC reads information and configuration.  For more information you can also select "Show used files" and for even more information "Show tried files".  Studying this should then reveal where the problem lies.

Edit - I noticed in an earlier post that the fpc.cfg file is supposed to be in the compiler folder, so my first suggestion above should not be required, unless the compiler detects another config file higher up in its search order.  Anyway -va should display the location of the config file actually used by the compiler.
« Last Edit: September 07, 2019, 09:45:05 am by ccrause »

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #144 on: September 07, 2019, 09:59:25 am »
Thank you Christo, you are 100% right.

As Windows is not my primary platform all my installations were done by fpcupdeluxe and it does not place a common fpc.cfg in a place outside of it's own installation directory.

I compiled my program with -va option and told messages window not to filter any message and saw the following search order for fpc.cfg:

Code: Pascal  [Select][+][-]
  1. Debug: [0.016] Configfile search: fpc.cfg
  2. Debug: [0.016] Configfile search: C:\Users\ring\fpc.cfg
  3. Debug: [0.016] Configfile search: C:\ProgramData\fpc.cfg
  4. Debug: [0.016] Configfile search: C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\fpc.cfg
  5. Verbose: Reading options from file C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\fpc.cfg
  6. Hint: Start of reading config file C:\fpcupdeluxe-embedded\fpc\bin\x86_64-win64\fpc.cfg
  7.  

Avra, when you run compile with -va param you will most likely have a hit for fpc.cfg in one of the other directories.

You may also remove the -cparmv7m parameter from the custom options, there has been a long standing issue that this parameter was not filled in the main configuration of lazarus but obviously this has been fixed in trunk

« Last Edit: September 07, 2019, 10:51:01 am by MiR »

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #145 on: September 07, 2019, 11:03:11 am »
There is no option that points FPC to the custom config file. In Lazarus, go to Project Options - Compiler Options - Config and Target then uncheck "Use standard compiler config file" and check "Use additional compiler config file" and specify the path to the customized fpc.cfg.
I do not have custom config file. As you can see in attached screenshot from directory file search, The only fpc.cfg file is the one I have in "c:\PRG\Lazarus\stm32x64\fpc\bin\x86_64-win64\fpc.cfg" and that is the one fpcupdeluxe made and I modified according to instructions.

If this still doesn't work then select "Show everything (-va)" under the verbosity setting.  This should then show the detail of where FPC reads information and configuration.  For more information you can also select "Show used files" and for even more information "Show tried files".  Studying this should then reveal where the problem lies.
Now I have added -va to project compiler options and just in case also set "Show everything" in Project options Verbosity form. This time with Project Options / Show Options I also show absolute instead of relative paths to let it be more clear. Screenshots attached.

It doesn't matter if I Compile, Build, or Clean up and Build, error about missing unit STM32F103XB is the same. This time I do show all messages instead of just shown in IDE message window. You can find them in attached zip archive.

Avra, when you run compile with -va param you will most likely have a hit for fpc.cfg in one of the other directories.

Sorry, that is not the case. Here is relevant part of full message output shown in attached zip archive:
Code: Pascal  [Select][+][-]
  1. [0.004] Configfile search: fpc.cfg
  2. [0.004] Configfile search: C:\Users\avra\fpc.cfg
  3. [0.004] Configfile search: C:\ProgramData\fpc.cfg
  4. [0.004] Configfile search: C:\PRG\Lazarus\stm32x64\fpc\bin\x86_64-win64\fpc.cfg
  5. [0.004] (11026) Reading options from file C:\PRG\Lazarus\stm32x64\fpc\bin\x86_64-win64\fpc.cfg
  6. [0.004] Hint: (11030) Start of reading config file C:\PRG\Lazarus\stm32x64\fpc\bin\x86_64-win64\fpc.cfg

That is the fpc.cfg I changed according to instructions and attached previously.

UPDATE: I could not upload Verbosity.png because of forum limitations. Basically it shows that I have checked all verbosity options of the project.
« Last Edit: September 07, 2019, 11:12:53 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #146 on: September 07, 2019, 12:18:26 pm »
I checked your fpc.cfg and saw some lines at the end that show me that you tried to build the Embedded Target of fpcupdeluxe.

Please do not do this, this stuff is something quite incomplete that only allows you to build code for Cortex-M0 Chips.
There was also another minor problem in your fpc.cfg, but this should not have hurt anything.

Please do as I advised, completely delete your stm32x64 directory, then build lazarus+fpc trunk, do not build anything else. Re-Follow the steps needed for complete installation, do not edit the fpc.cfg.

Then take the fpc.cfg file attached here, it works for your installation directory, I followed my own steps, used your installation directory and successfully built the mbf project.

If after cleanup/rebuild and using my fpc.cfg it still does not work for you then please send me the complete buildlog vith -va option enabled, I can then compare with the installation I did on my computer.

« Last Edit: September 07, 2019, 12:30:24 pm by MiR »

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #147 on: September 07, 2019, 12:44:55 pm »
Looking in your last debug log I see what are most likely the consequences of building embedded target:

[0.559] (SYSTEM)   (10002) PPU Name: C:\PRG\Lazarus\stm32x64\fpc\units\arm-embedded\rtl\system.ppu

Lazarus finds a wrong system.ppu (this one is most likely from the 'embedded' target, when you look in my zip file you will see that in this place there is no system.ppu

One more issue:

the arm-embedded/armv7m/rtl directory was never searched by the compiler, this is the directory where the units actually are. Hopefully this problem is sorted out when you use my fpc.cfg

julkas

  • Guest
Re: Programming and debugging
« Reply #148 on: September 07, 2019, 12:49:44 pm »
I implemented

bluepill, blackpill and maplemini (afaik the mother of all pills) two days ago, so no surprise you never saw them before .....

Beeing able to use those shortcuts requires two things, a ppcrossarm from trunk and a patch file provided by me that adds tons of embedded controllers to fpc. Hopefully soon fpcupdeluxe will make the whole process more accessible and less error prone.
Can you share (Mini HOW-TO, Patches, Examples, Scripts, ...) on github?

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #149 on: September 07, 2019, 01:24:20 pm »
Most of the stuff is already available on github, check

https://github.com/michael-ring/mbf/tree/master/Patches

but I found out that for people the learning curve for embedded is a little too steep as you have to compile trunk and apply several patches for all the supported platforms, unfortunately not that much works out of the box, especially when it comes to debugging.

That's why I am now trying to put all the stuff inside of fpcupdeluxe. If you want to follow that work then have a look at my cloned version of fpcupdeluxe https://github.com/michael-ring/fpcupdeluxe , I have not yet pushed my changes but as soon that I am confident that my changes also work for other people I will push and then create a pull request for fpcupdeluxe and will also upgrade the patches on mbf.


« Last Edit: September 07, 2019, 01:29:26 pm by MiR »

 

TinyPortal © 2005-2018