Forum > Other OS

Tutorial: Developing STM32F1 Programs with FPC/Lazarus/STLINK in Linux(Detailed)

(1/1)

gasensor:
1. Install the binutils of C
sudo apt-get install binutils-arm-none-eabi

2. connection to prevent the Pascal compiler from finding the path
sudo ln -s /usr/bin/arm-none-eabi-as /usr/bin/arm-embedded-as
sudo ln -s /usr/bin/arm-none-eabi-ld /usr/bin/arm-embedded-ld
sudo ln -s /usr/bin/arm-none-eabi-objcopy /usr/bin/arm-embedded-objcopy

3. Compile Pascal
Download and go to the FPC source code directory
make all CPU_TARGET=arm OS_TARGET=embedded SUBARCH=armv7m -j$(nproc) PREFIX=/usr NOGDB=1

4. Install Pascal
sudo make crossinstall OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7m PREFIX=/usr NOGDB=1

5. Establish a connection
sudo ln -s /usr/lib/fpc/3.2.2/ppcrossarm /usr/bin/ppcrossarm

6. Testing, for STM32F1
fpc -Parm -Tembedded -Wpstm32f103xb -Cparmv7m  ./test.pas -vut

7. Where Lazarus needs to be set up:
"Project"->“Project Options”->"Custom Options"
"Custom Option" add line : "-WpSTM32F103XB"

"Project"->“Project Options”->"Compiler Options"
“Config and Target”:Target OS choose Embedded,CPU choose ARM,Target Processor choose ARMV7M(F4 choose ARMV7EM)
“Compilation and Linking”:Optimization Level Choose 0 or 1
“Debugging”:Uncheck “Generate info for the debugger”, If you do not need the online debugging function , Uncheck “Run users the debugger”  and FINISH.

If you need the online debugging function, check “Run users the debugger”. Proceed to the next step

8. Install gdb, stlink-gui
sudo apt-get install gdb gdb-multiarch stlink-gui

9. Tips for resolving GDB missing Python components
sudo rm -rf /usr/share/gdb/python
sudo apt update
sudo apt install gdb

10. Lazarus Options:
"Tools"->"Options"->"Debugger"
"Debugger backend": click"Add", "Debugger Type and Path"choose"GNU remote debugger(gdbserver)".
command type"gdb-multiarch"
“Debugger_Remote_Port”change to “4242”
"Debugger_target_Mode"choose“dtTargetExtendedRemote”
then click OK

11. Run GDB SERVER:
Connect stlink
st-util -m

12. Compile and debug

There may be imperfections, welcome to point out. Let's improve together.

Navigation

[0] Message Index

Go to full version