Recent

Author Topic: Programming and debugging  (Read 43732 times)

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #120 on: September 02, 2019, 09:53:05 am »


Quote
I tried to add something like -dnucleof103 (or something similar - this is from my memory and I can not check for exact switch until I get home). That was the compile switch I saw in one MBF project for STM32F103. Unfortunatelly that switch was not supported in FPC 3.0.4.
I found it in MBF repo: https://github.com/michael-ring/mbf/blob/master/Samples/Blinky/Blinky-nucleof103rb.lpi

These were the switches from that project:
Quote
-XParm-none-eabi-
-Wpnucleof103rb
-dnucleof103rb
I think I tried to add to my project only f103 ones and failed, probably because FPC 3.0.4 didn't recognize them.
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 #121 on: September 02, 2019, 10:24:45 am »
I will create a pre-configured zip file for you, this will be what in the future will be integrated in fpcupdeluxe.

I will see if I can finish this tonight..... 

It will then also include mbf framework and a blinky example for Bluepill.

Michael

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #122 on: September 02, 2019, 12:02:04 pm »
I will create a pre-configured zip file for you, this will be what in the future will be integrated in fpcupdeluxe.
Thanks a lot for the effort!

I will see if I can finish this tonight.....
Take your time. I am not in a hurry.
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 #123 on: September 02, 2019, 06:29:24 pm »
can you please post your commandline/Settings in Lazarus?
Code: Pascal  [Select][+][-]
  1. C:\PRG\Lazarus\stm32\fpc\bin\i386-win32\fpc.exe
  2. -Tembedded
  3. -Parm
  4. -CpARMV7M
  5. -MObjFPC
  6. -Scghi
  7. -Os1
  8. -gw2
  9. -Xg
  10. -l
  11. -vewnhibq
  12. -Filib\arm-embedded
  13. -Fu.
  14. -FUlib\arm-embedded
  15. -FE.
  16. -oproject1
While looking at this I have realized that unlike yours, my Project / Compiler Options / Custom options is empty. So I added -XParm-none-eabi- and -dnucleof103rb (-Wpnucleof103rb was not accepted) but it didn't change anything. I have attached my project.

please check that you st-link is latest firmware and also that your flash is not write / read protected.
Screenshot attached.
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 #124 on: September 02, 2019, 07:09:01 pm »
... So I added -XParm-none-eabi- and -dnucleof103rb (-Wpnucleof103rb was not accepted) but it didn't change anything. I have attached my project.

There is no nucleof103 variant defined in the compiler.  I'm not familiar with the arm range, but try -WpSTM32F103X8, see https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/arm/cpuinfo.pas?view=markup#l781

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #125 on: September 02, 2019, 07:16:19 pm »
arm Support in 3.0.x releases is quite old, with only few supported chips. The party is going on in trunk 8-)

The BluePill may be supported but honestly, I have not started a 3.0.x arm crosscompiler for years....


avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #126 on: September 03, 2019, 12:05:20 am »
There is no nucleof103 variant defined in the compiler.  I'm not familiar with the arm range, but try -WpSTM32F103X8, see https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/arm/cpuinfo.pas?view=markup#l781
Thanks. That unit was very informative. This is the error after -WpSTM32F103X8 switch was added: "Fatal: Can't find unit STM32F10X_MD used by project1". I guess my next stop will be trunk.

arm Support in 3.0.x releases is quite old, with only few supported chips. The party is going on in trunk 8-)
I will join the party. Hopefully there will be fireworks.  8)
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 #127 on: September 03, 2019, 10:11:22 am »
Quick update:
Scripted Building of the toolchain took a little longer than I expected, I have now all needed components built for Mac and Windows, hope that the final steps will not take that long. 

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: Programming and debugging
« Reply #128 on: September 03, 2019, 10:38:47 am »
I have not started a 3.0.x arm crosscompiler for years....
Then you should refrain from any comments.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

ccrause

  • Hero Member
  • *****
  • Posts: 1093
Re: Programming and debugging
« Reply #129 on: September 03, 2019, 12:26:16 pm »
I have not started a 3.0.x arm crosscompiler for years....
Then you should refrain from any comments.
Michael has contributed many arm controller units over the years.  He probably doesn't work all that much on stable branches.

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Programming and debugging
« Reply #130 on: September 03, 2019, 09:25:33 pm »
Here's the first version:

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

Please download, then create a new x86_64 instance of Lazarus with fpcupdeluxe (this will make debugging a lot easier, let's start simple!!!)

Please refer to the screenshot for reference...

After this unpack the zip-File into the root of your new instance.

For full integration you now need to patch the fpc.cfg file located in fpc/bin/x86_64-win64/

There is one change needed:

First find this:
Code: Pascal  [Select][+][-]
  1. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget
  2. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget/*
  3. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget/rtl

and replace it with this:

Code: Pascal  [Select][+][-]
  1. #ifdef embedded
  2. # Extended searchpath for units and other system dependent things on Embedded Targets
  3. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget/$fpcsubarch
  4. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget/$fpcsubarch/*
  5. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget/$fpcsubarch/rtl
  6. #else
  7. # searchpath for units and other system dependent things
  8. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget
  9. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget/*
  10. -FuC:\fpcupdeluxe-embedded\fpc/units/$fpctarget/rtl
  11. #endif
  12.  
  13. # binutils prefix for embedded compiling
  14. #IFDEF embedded
  15.   -XP$FPCTARGET-
  16. #ENDIF

Now configure the debugger according to the screenshot.

If you want a quick result for your bluepill download a mbf snapshot here:

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

and load the Blinky sample in mbf/SamplesBoardSpecific/Blinky-Bluepill

I am still experiencing issues with debugging on Windows, I have never used the cheap stlink clones on windows, so some more work is needed.

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

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #131 on: September 04, 2019, 12:25:11 am »
Thanks. I had issues with trunk. I will try again tomorrow.
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 #132 on: September 04, 2019, 09:16:57 am »
I guess I think it is time to say that I hate chinese clone boards  >:D

I could fix my debugging issues (for now only on my MAC)...

Reason is that there is a compatibility issue with the chinese clone stm32f103 chips and Texane(st-util) and official ST-Link.

I have used latest trunk version of st-util and this version fails flashing more than one Page (1024 bytes).

Fortunately I had an older version of st-util on my mac, this version works fine and with some tweaking of the Debugger configuration in Lazarus I was able to load/debug my code on STLink Clone and Bluepill.

I am now checking if I can do the same fix for Windows......

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Programming and debugging
« Reply #133 on: September 05, 2019, 02:07:26 am »
I followed the instructions with 2 exceptions. 1st is that I start my GDB server on port 2345, and 2nd is that I incidentally installed into other dir, so I had to adjust fpc.cfg accordingly:
Code: Pascal  [Select][+][-]
  1. #ifdef embedded
  2. # Extended searchpath for units and other system dependent things on Embedded Targets
  3. -FuC:\PRG\Lazarus\stm32x64\fpc/units/$fpctarget/$fpcsubarch
  4. -FuC:\PRG\Lazarus\stm32x64\fpc/units/$fpctarget/$fpcsubarch/*
  5. -FuC:\PRG\Lazarus\stm32x64\fpc/units/$fpctarget/$fpcsubarch/rtl
  6. #else
  7. # searchpath for units and other system dependent things
  8. -FuC:\PRG\Lazarus\stm32x64\fpc/units/$fpctarget
  9. -FuC:\PRG\Lazarus\stm32x64\fpc/units/$fpctarget/*
  10. -FuC:\PRG\Lazarus\stm32x64\fpc/units/$fpctarget/rtl
  11. #endif

I have then unpacked zip file to overwrite existing files, set IDE debugger settings as per screenshot, set project debugger backend to this new debugger settings, start debug server which is waiting on port 2345, put break point into my previous simplest example (your blupill sample project link is not working), and run it. I still get the same error.  %)

If you think I should use 5432 port and use your exact dir then please say so and I will. I have also unplugged and reset my blue pill many times, and immediately after IDE debug error started STM32 CubeProgrammer to check if I can connect, and I can. I can also debug from PlatformIO, as in screenshot.

I am still experiencing issues with debugging on Windows, I have never used the cheap stlink clones on windows, so some more work is needed.
I am really sorry for the trouble. If you think that it could help I might try to burn Black Magic Probe firmware into my ST-Link v2 clone.

After reading your comments I suspect there is something not good between STM32Cube debug server and my ST-Link. I can debug with Platformio IDE and Mikroelektronika Pascal IDE, but with STM32Cube it seams like I am able to program but not debug. Screenshot attached. That may be the problem. It is late now so I will continue testing tomorrow.
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 #134 on: September 05, 2019, 08:08:42 am »
Please download:

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

and extract it.

then start st-util.exe, this will start the texane stlink gdbserver.

For me it works fine with my bluepill clone. Download and Debugging OK. You will need to configure Port 4242 for debugging, see Screenshot.

Please remember that your example will not work unless you set proper Custom Options.

I my example I use:
-Cparmv7m
-WpBluePill
-dBluePill

Here's the correct Download link for the mbf snapshot:

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






 

TinyPortal © 2005-2018