cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE Execute command before debug

LSpad.1
Associate III

Hi,

i would like to execute command after i click the debug icon, but before the debug starts.

In particular:

  • I have an app with a bootloader. The bootloader check the CRC of the firmware before start it.
  • Right now i generate, thanks to post build operation, a binary file with header, firmware and footer, a complete binary.
  • I have disable the Download in the Debug configuration, so the debugger does not flash the firmware.
  • I need a point where place the command for flashing the complete firmware with the header and the footer. This point should be before the debug session start, and after i click the debug icon.

Do you think it is possible? How can i do that?

Thank you in advance

3 REPLIES 3
Ivaylo Ilchev
Associate III

Instead of post/pre build commands use CDT files makefile.init, makefile.defs and makefile.targets. For CRC you may add target to /makefile.targets (file must be created!):

CRC_Tool := 'C:\Tools\crc.exe'
 
crc: all
	-@echo 'Calculating CRC'
	$(CRC_Tool) $(wildcard *.bin)

Press Shift-F9, add target crc, execute crc

To debug application, you don't need a bootloader, CubeIDE will start application from ld flash address, but you have to add code to move the stack as first lines to main:

#define FLASH_START 0x800....
....
int main()
{
  /* USER CODE BEGIN 1 */
  __disable_irq();
  SCB->VTOR = FLASH_START | VECT_TAB_OFFSET;
  __DSB();
  __enable_irq();
  ...

LSpad.1
Associate III

Hi, thanks for the answer.

It is not clear how i can create a CRC based on the binary file before i create that binary file. Are you sure is it possible with CDT files?

Regarding the debug: it is clear that if i launch debug from the IDE the debug and the application work. But if i reboot the board, the bootloader does not recognize the CRC of the application, and it won't start anymore.

Ivaylo Ilchev
Associate III

crc: all

command(s)

This means:

  • build "all" target first if something changed
  • Run crc command(s)