Recent

Author Topic: stm32duino flash from lazarus  (Read 1689 times)

diego bertotti

  • New Member
  • *
  • Posts: 41
stm32duino flash from lazarus
« on: April 02, 2020, 10:35:48 pm »
first you must have stm32f1X installed on arduino ide and working.

path must be adapted to your computer!!!

tools->Configure external tools->ADD

title: Flash STM32F103C8 st-link swd

program file name: C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\stm32tools\2020.3.13\win\stlink\ST-LINK_CLI.exe

parameters:
-c SWD -P $ProjPath()$NameOnly($ProjFile()).bin 0x8000000 -Rst -Run -NoPrompt

Mathias

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #1 on: April 04, 2020, 03:52:01 pm »
Why don't you do it as described in this tutorial?
Then you can compile with F9 and upload directly.

Or does your variant have an advantage over the tutorial?

;)

https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_Entry_FPC_and_STM32/de

diego bertotti

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #2 on: April 08, 2020, 12:57:54 am »
Hi

Is just another way. i'm trying flashing in differents ways. this one using swd, but im trying hid_bootloader using usb, then we will have another chance.

Not always i want to flash memory after every change in code. ¿why? because i use a simulator software. Then i test it and after that, i will decide if i flash mem or still need changes in code.

I use simulide for avr microcontroller. A great project! check it!

thanks
« Last Edit: April 08, 2020, 01:51:19 pm by diego bertotti »

Mathias

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #3 on: April 09, 2020, 03:52:19 pm »
Quote
I use simulide for avr microcontroller. A great project! check it!

Do you have a link

avra

  • Hero Member
  • *****
  • Posts: 1910
    • Additional info
Re: stm32duino flash from lazarus
« Reply #4 on: April 09, 2020, 05:59:05 pm »
Quote
I use simulide for avr microcontroller. A great project! check it!

Do you have a link
https://simulide.blogspot.com/p/blog-page_4.html
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

diego bertotti

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #5 on: April 09, 2020, 08:40:45 pm »
this is it.

thanks avra!

im used with .hex code generated form lazarus and works. Still can't use debugger

try it. it have a few bug, but handy

Mathias

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #6 on: April 10, 2020, 05:23:01 pm »
I could do it with
Code: [Select]
apt-get install simavrto install.

But how do I start it?
Code: [Select]
$ simavr -m atmega328 Project1.binSomething starts in the console, but how does the GUI come about?

Do you have an example of an ATMega328p?8p?

diego bertotti

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #7 on: April 10, 2020, 08:39:15 pm »
I could do it with
Code: [Select]
apt-get install simavrto install.

But how do I start it?
Code: [Select]
$ simavr -m atmega328 Project1.binSomething starts in the console, but how does the GUI come about?

Do you have an example of an ATMega328p?8p?

https://www.patreon.com/file?h=35657927&i=5375144

compile blink example and load .hex file to a previously dragged arduino nano board from the bottom left repository (micro->avr->arduino) and press run at top (red button).

Code: Pascal  [Select][+][-]
  1. program blink;
  2. const
  3.   sl = 150000;  // Delay
  4.  
  5. procedure mysleep(t: int32);  // A simple delay
  6. var
  7.   i: Int32;
  8. begin
  9.   for i := 0 to t do
  10.     asm
  11.       nop
  12.     end;
  13. end;
  14.  
  15. begin
  16.   // Configure pin 5 Port b as output
  17.   DDRB := DDRB or (1 shl 5);
  18.  
  19.   repeat
  20.     // change LED
  21.     PORTB := PORTB or (1 shl 5);       // Pin 5 on (high)
  22.     mysleep(sl);                         // Delay
  23.  
  24.     // change LED
  25.     PORTB := PORTB and not (1 shl 5);       // Pin 5 off
  26.     mysleep(sl);                         // Delay
  27.   until 1 = 2;
  28. end.
  29. end.    
  30.  

and load blink.hex

you will see a blink led inside arduino board.

then you can draw an external board hardware like led buttons gates pot analog sources etc etc and simulate it
« Last Edit: April 10, 2020, 08:50:03 pm by diego bertotti »

diego bertotti

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #8 on: April 11, 2020, 02:18:51 pm »
Mathias, just take a look in the attachment.

An example of a real project working right now!

Mathias

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #9 on: April 11, 2020, 03:40:17 pm »
Code: [Select]
sudo apt-get install libqt5multimedia
sudo apt-get install libqt5multimedia5
sudo apt-get install libqt5xml5
sudo apt-get install libqt5script5
sudo apt-get install libqt5serialport5

I got it going after a couple of apt-get.
It is also unstable, there were memory access errors.
But the version is still beta.


diego bertotti

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #10 on: April 11, 2020, 04:10:46 pm »
this is it.

thanks avra!

im used with .hex code generated form lazarus and works. Still can't use debugger

try it. it have a few bug, but handy

i warn you, but is growing and getting better

diego bertotti

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #11 on: May 22, 2020, 01:39:31 pm »
hi

i found this.. great!

try it!

https://github.com/Turro75/stm32lazarustemplate

grazie mille valerio

Mathias

  • New Member
  • *
  • Posts: 41
Re: stm32duino flash from lazarus
« Reply #12 on: May 22, 2020, 01:59:21 pm »
Thanks for the link.
Has some interesting things with her.
What is still missing is a HW I²C.

What I am amazed at has the STM32 been supported by FPC for over 5 years?

PascalDragon

  • Hero Member
  • *****
  • Posts: 1742
  • Compiler Developer
Re: stm32duino flash from lazarus
« Reply #13 on: May 22, 2020, 02:57:34 pm »
What I am amazed at has the STM32 been supported by FPC for over 5 years?

Well, the arm-embedded target had been the first embedded target. And the first STM32 variant (stm32f103re) had been added on October 4th 2009. ;)

 

TinyPortal © 2005-2018