2020/10/15 22:29:43
I'm currently trying to get a serial bootloader running for the PIC24FJ1024GA606. The bootloader is based on AN1157 and has been running without issues on the PIC24FJ128GA204 we use in other projects for years.
I have modified linker scripts for both the bootloader and the app part. They are based on working examples of the PIC24FJ128GA204 but with PIC24FJ1024GA606 linker scripts.

I can successfully flash a combined hex onto the MCU and it runs through the bootloader and jumps to the app. The app runs as it should as long as I don't use interrupts. As soon as an ISR is triggered I get a reset, it then runs through the bootloader again, jumps to the app and then again resets when the ISR is called.
Project details:
  • MCU runs in single partition mode
  • no AIVT, no boot segment active
  • App includes bootloader as loadable to create a combined hex
  • XC16 v1.50
  • MPLAB X v5.40
Some details for the bootloader part:
  • Bootloader starts at 0x100 (original origin of the unmodified linker script) and ends at 0x1800-1 (length 0x1700)
  • The app starts at 0x1800
  • IVT is modified to point to a location in a jump table in app code (interrupt vector method 2 in AN1157)
  • Compiler linker flag --no-ivt is set
Details for the app part:
  • App program starts at 0x1800 which is the start of the jump table for the remapped IVT
  • App itself starts at 0x1988 (just after table)
  • I have a method that populates the jump table with gotos to the ISR handles (as suggested in AN1157)
  • Compiler linker flag --no-ivt is set
I can't figure out why the MCU is reset when an ISR is called. The same principle for the linker scripts and IVT jump table is applied for the PIC24FJ128GA204 and there it works without issues.
I attached both linker scripts as well as the ISR handles file to this post. Any help is greatly appreciated.
2020/10/16 13:28:04
I have not looked at your code (no time), but the AN1157 BL does not need interrupt driven serial comm, in fact it should NOT use any interrupts at all. Then your application interrupts will be all vectors there are and no problems. I suspect you have used an interrupt in your BL code? If so, get rid of it.
Here is a link to a post I wrote back in 2014 with further links.
2020/10/17 06:14:22
The bootloader does not use interrupts, but I'll check just to make sure.
Maybe this title wasn't the best choice :-) (modified it ;-))
Thanks for the link. I think I've read most if not all of your posts in this forum up and down and tried a few of your methods and linker scripts. But couldn't get it to work. I've been scratching my head, because this method of bootloader and app works flawlessly on the PIC24FJ128GA204 we use. The bootloader code is pretty much the same, just modified to suit the other MCU (pin config, some defines, ...). For the app I created a new most basic project. Just 1 timer and a blinking LED. So, I can rule out any other issues.
I'm pretty convinced that the solution to make it work is quite banal. I'm just not seeing it.
2020/10/17 08:58:48
The bootloader code is pretty much the same, just modified to suit the other MCU (pin config, some defines, ...). For the app I created a new most basic project.

Maybe it is this:
On the PIC24 I was using it turns out that following reset the pin config is a one-time thing unless one configures it away in the control bits of the CPU so that you can define a pin more than once.
I had to do that in order to get my projects working because inside the boot loader it was set one way and then in the application I needed different pin configs.
But since it is 6 years back I don't remember exactly what the code to do that looked like...
2020/10/17 13:21:20
Yes, I read that in a few posts. If you're using MCC, then it's the last code line in the pin_manager.c module (I think) that locks the PPS.
I set the config to allow for multiple reconfigurations, so that this wouldn't become an issue. Also, the LED is already configures as such in the bootloader. The app config for that pin is the same.
2020/11/08 23:31:36
I put this issue aside for a while but want to pick it up again. Has anyone any ideas I could try or where I should take a look?
Anything is appreciated.
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account