Recent

Author Topic: compiling with offset entry point [SOLVED]  (Read 1471 times)

diego bertotti

  • Full Member
  • ***
  • Posts: 101
compiling with offset entry point [SOLVED]
« on: April 08, 2020, 01:45:40 pm »
hi

i'm trying to use hid usb bootloader, outside arduino ide, and i can flash using usb bootloader.

my code work fine when i upload it using stlink swd, but don't work when i flash it using hid usb bootloader. I guess this is because bootloader use the first space of flash memory ($080000000) and my code is automatically displaced to $08000800 (2 kB bootloader used space) by the flasher program (hid-flash.exe).

then this is why i need compile to displaced entry point.

somebody knows how i can do that?

thank you

diego
« Last Edit: April 10, 2020, 12:59:15 am by diego bertotti »

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: compiling with offset entry point
« Reply #1 on: April 08, 2020, 03:21:46 pm »
You can try passing -Ttext=0x08000800 (or what ever your desired location is) to the linker.  This can be done via the compiler by using the -k option:
Code: [Select]
fpc -k-Ttext=0x08000800 ...Or if you are working in Lazarus it can be set under Project Options | Compiler Options | Compilation and Linking in the bottom right: Pass options to linker...

Alternatively compile and generate linker script by passing -sh to the compiler, then edit the linker script accordingly and manually execute the ppas script to link the final executable.

diego bertotti

  • Full Member
  • ***
  • Posts: 101
Re: compiling with offset entry point
« Reply #2 on: April 08, 2020, 04:01:52 pm »
ok, thank you for the info.

i'll try later

diego bertotti

  • Full Member
  • ***
  • Posts: 101
Re: compiling with offset entry point
« Reply #3 on: April 09, 2020, 12:49:01 am »
ok, tested and works!!!!

go to tools-> configure external tools-> add

title: usb hid bootloader (moved entry point + $800)

program filename:C:\Users\user\AppData\Local\Arduino15\packages\stm32duino\tools\win\hid-flash.exe

parameters: $ProjPath()$NameOnly($ProjFile()).bin com1

check "scan output for fpc messages"

and in project->project options->compiling and linking->

check the "pass option to linker -k delimiter is space"

add this text: "-Ttext=0x08000800"

now, set jumper boot1 to 1 in the bluepill board. connect to computer using usb cable and you can flash it. after that, unplug the usb cable, set boot1 jumper to 0.

thats all

caution! bootloader set microcontroller hardware to do the job. this settings are not undoed and can affect your program behavior. verify it

 

TinyPortal © 2005-2018