OK, I just arrived at home, lets start. I will update this post based on my and your progress, so please recheck...
I also have the stm32l432 board, so let's use this one.
First step is to make the board work with GDB.
I will try to be as complete as possible in the explanations, so please forgive me if I repeat stuff you already did.
Download texane/stlink binary for Windows:
Man page on github:
https://github.com/texane/stlinkLink to the Downloads:
https://github.com/texane/stlink/releases/tag/1.3.0Now download a recent GDB if you do not alread have one:
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloadsFor building embedded code this version of the tools unfortunately does not work, you will need to download an older version on Windows:
https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_3-2016q1/gcc-arm-none-eabi-5_3-2016q1-20160330-win32.exe?revision=d07f533b-4a72-49ef-adbf-5302fb396073?product=GNU%20Arm%20Embedded%20Toolchain,32-bit,,Windows,5-2016-q1-updateDirect link:
https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_3-2016q1/gcc-arm-none-eabi-5_3-2016q1-20160330-win32.exe?revision=d07f533b-4a72-49ef-adbf-5302fb396073?product=GNU%20Arm%20Embedded%20Toolchain,32-bit,,Windows,5-2016-q1-updateNow install the toolchain, in the end you will see an opened cmd-window, keep that open, we will need it in a moment.
Unpack the contents of stlink-1.3.0-win64.zip and copy all the files from the bin directory to some place where you want to keep them. Only the binaries are needed, the rest does not matter.
Now connect the Board to your computer and start
st-util.exe
it will detect your board and display this message:
st-util.exe
st-util 1.3.0
2019-07-03T21:33:32 INFO C:\Users\Jerry\Desktop\stlink-master\src\common.c: Loading device parameters....
2019-07-03T21:33:32 INFO C:\Users\Jerry\Desktop\stlink-master\src\common.c: Device connected is: L43x device, id 0x10016435
2019-07-03T21:33:32 INFO C:\Users\Jerry\Desktop\stlink-master\src\common.c: SRAM size: 0xc000 bytes (48 KiB), Flash: 0x40000 bytes (256 KiB) in pages of 2048 bytes
2019-07-03T21:33:32 INFO C:\Users\Jerry\Desktop\stlink-master\src\gdbserver\gdb-server.c: Chip ID is 00000435, Core ID is 2ba01477.
2019-07-03T21:33:32 INFO C:\Users\Jerry\Desktop\stlink-master\src\gdbserver\gdb-server.c: Listening at *:4242...
Now activate the cmd window that was left open by the installation of the arm-tools
cd bin
and now start gdb:
arm-none-eabi-gdb.exe
GNU gdb (GNU Tools for Arm Embedded Processors 8-2018-q4-major) 8.2.50.20181213-git
Copyright (C) 2018 Free Software Foundation, Inc.
...
For help, type "help".
Type "apropos word" to search for commands related to "word".
in gdb enter:
target remote localhost:4242
You will now see communication between texane and gdb.
(gdb) target remote localhost:4242
Remote debugging using localhost:4242
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x08004420 in ?? ()
(gdb)
All good until here?
Lets continue.....
Next step is to blink something....
Download this file:
http://temp.michael-ring.org/Blinky.elfPut it in an easy to reach place (For me this is my Desktop) and then go back to gdb:
(gdb) file /Users/ring/Desktop/Blinky.elf
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /Users/ring/Desktop/Blinky.elf...
now we load the file to the controller:
(gdb) load
Loading section .text, size 0x193c lma 0x8000000
Loading section .data, size 0x105 lma 0x800193c
Start address 0x8000a38, load size 6721
Transfer rate: 16 KB/sec, 3360 bytes/write.
and now we start the program:
You should now see the LED blinking on your Board. Congratulations, you just ran your first Freepascal Application on the board!!!
Keep me posted if you also succeeded, meanwhile I will now recompile Lazarus with the patches from Martin.....
OK. Let's build lazarus with the latest tricks...
I have Lazarus installed in C:\azarus, the fpc came with this Lazarus, use your fpc from another path if you need....
First, let's download the trunk version of Lazarus,you need trunk to be able to upload your binary to your device from within Lazarus:
either do:
svn co
http://svn.freepascal.org/svn/lazarus/trunk lazarus-stm32
or download sources from here:
https://wiki.lazarus.freepascal.org/Lazarus_Snapshots_Downloadsunpack it in a convenient place (Desktop for me) and then change in the top-directory:
and do the build:
PATH=C:\Lazarus\fpc\3.0.4\bin\x86_64-win64
make
Lazarus working? Great!!!!
Let's build a fresh fpc with support for the stm32l432kc:
Download my patches for fpc here:
https://github.com/michael-ring/mbf/tree/master/PatchesDownload trunk of fpc here:
ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/source/fpc.zipin case you are unable to apply my patches you can download a snapshot from 04.07.2019 here:
http://temp.michael-ring.org/fpc-stm32.zipand unpack fpc in a convenient place, Desktop for me....
put the downloaded patch in Desktop. Then do:
cd <name of your fpc-directory-you-just-downloaded>
if you need to apply the patch for extended stm32 support run:
patch -p0 <..\fpc-trunk-stm32l4.patch
patching file compiler/arm/cpuinfo.pas
Hunk #1 succeeded at 334 (offset 15 lines).
Hunk #2 succeeded at 964 (offset 15 lines).
patching file compiler/systems/t_embed.pas
Hunk #1 succeeded at 471 (offset 7 lines).
patching file rtl/embedded/Makefile
Hunk #1 succeeded at 361 (offset -2 lines).
patching file rtl/embedded/Makefile.fpc
patching file rtl/embedded/arm/stm32l431xx.pp
patching file rtl/embedded/arm/stm32l432xx.pp
patching file rtl/embedded/arm/stm32l433xx.pp
patching file rtl/embedded/arm/stm32l442xx.pp
patching file rtl/embedded/arm/stm32l443xx.pp
patching file rtl/embedded/arm/stm32l451xx.pp
patching file rtl/embedded/arm/stm32l452xx.pp
patching file rtl/embedded/arm/stm32l462xx.pp
patching file rtl/embedded/arm/stm32l471xx.pp
patching file rtl/embedded/arm/stm32l475xx.pp
patching file rtl/embedded/arm/stm32l476xx.pp
patching file rtl/embedded/arm/stm32l485xx.pp
patching file rtl/embedded/arm/stm32l486xx.pp
patching file rtl/embedded/arm/stm32l496xx.pp
patching file rtl/embedded/arm/stm32l4a6xx.pp
patching file rtl/embedded/arm/stm32l4r5xx.pp
patching file rtl/embedded/arm/stm32l4r7xx.pp
patching file rtl/embedded/arm/stm32l4r9xx.pp
patching file rtl/embedded/arm/stm32l4s5xx.pp
patching file rtl/embedded/arm/stm32l4s7xx.pp
patching file rtl/embedded/arm/stm32l4s9xx.pp
all good?
For convenience we now go to the bin directory of the Arm Bintools ( C:\Program Files (x86)\GNU Tools ARM Embedded\5.3 2016q1\bin ) and copy the content of the bin directory to c:\pp\bin
Now only take the new arm-none-eabi-gdb.exe from the bin directory of the Arm Bintools ( C:\Program Files (x86)\GNU Tools ARM Embedded\8 2018-q4-major\bin ) and copy it to c:\pp\bin
create the directory if it does not exist.
now let's build the crosscompiler:
make clean buildbase installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7em BINUTILSPREFIX=C:\pp\bin\arm-none-eabi-
We are now VERY close.... (hopefully....)
Time to configure Lazarus:
For simplicity, go to the directory where you built the new lazarus and open a shell:
then add the path to the freshly build crosscompiler:
PATH=C:\Lazarus\fpc\3.0.4\bin\x86_64-win64;C:\pp\bin\x86_64-win64
and start lazarus:
startlazarus
this makes sure that lazarus finds the crosscompiler.
Now apply the config changes as displayed in the screenshots, please note that the 4th screenshot is in another posting because I can only upload 250k per post.
After doing this configuration I created this simple program:
program project1;
var
a,b: integer;
begin
a := 10;
b :=20;
end.
then I make sure that st-util.exe is running and I start debugging.....
Works like a charm! (At least most of the time, in the die-hard cases I use ozone.......
E.O.M.