0
\$\begingroup\$

I have an ARM-M0+ (SAMD21G18).

I have a project that has a bootloader and another with application.

When I try to go to debugging I suspect the following:

  • the ROM is erased
  • application flashed only
  • the program goes to fault mode.

I guess this is because of VTOR thing and SP in address 0x00000.

I've searched the internet, and people suggest to use application alone... but then how?

Is there another way to prevent debugger from erasing bootloader area?

enter image description here

enter image description here

enter image description here

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

I'm aware I'm extremely late to the party here, but having just been through the same - this may help somebody.

In Studio, go to the application project's Properties -> Tool -> Programming Settings, change from Erase entire chip to Skip programming.

Now, flash your bootloader and application manually through the Device Programming interface (Ctrl+Shift+P) or atprogram, or whatever other means you're using, then simply start a debug session as normal. However, at this point you will not be able to debug the bootloader, only the application. To debug both in a single session, read on below.

Note, it's worth combining both the bootloader and application hex files into one single file, using srec-cat as an automated post-build action in Studio.

In the application project Properties, go to Build Events and add the following in the Post-build event command line.

srec-cat <path_to_bootloader_outputs>\boot.hex -Intel <path_to_application_outputs>\app.hex -Intel -o <path_to_new_combined_image>\combined_image_name.hex -Intel

To be able to debug both the bootloader and application now in a single debug session, navigate to the application Properties -> Advanced -> Additional modules, and add the .elf file for the bootloader, ensuring you tick Only debug symbols (no writing), whilst doing so.

If you now program the combined hex file containing both the bootloader and application, then start a debug session with Skip programming enabled, you will be able to symbolically debug both the bootloader and application, as if they were one.

\$\endgroup\$
1
\$\begingroup\$

There are two ways to fix this:

  1. Tell the programmer to erase sectors instead of the full chip.
  2. Try and link the binary of the bootloader in your debug image. This way when the programmer loads the image, the bootloader is included.
\$\endgroup\$
4
  • \$\begingroup\$ in both cases i dont know how to do it. the project (linker settings / script) is pre configured by atmel allready i dont know how to do it.. and i couldnt find programmer erase settings \$\endgroup\$ Commented May 22, 2019 at 12:16
  • \$\begingroup\$ @Hasanalattar Perhaps the user manual of the atmel toolchain can help you with this. I can't help you with Atmel studio. \$\endgroup\$
    – Jeroen3
    Commented May 22, 2019 at 13:56
  • 1
    \$\begingroup\$ This might be a good time to export your project from Atmel studio and start controlling the build yourself, potentially in a way compatible with the rest of your organization's software practices. \$\endgroup\$ Commented May 22, 2019 at 15:49
  • \$\begingroup\$ " the project (linker settings / script) is pre configured by atmel" Its possible to use a custom linker script in atmel studio. I have done it before, but its been a while. You have to add a path to the custom script in your project settings. \$\endgroup\$
    – user4574
    Commented Mar 4, 2023 at 1:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.