• AVR Freaks

Hot!PIC32MZ - unable to boot into application

Author
tekworld
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2021/01/24 20:44:32
  • Location: 0
  • Status: offline
2021/01/25 18:00:31 (permalink)
0

PIC32MZ - unable to boot into application

I have a new custom board with PIC32MZ2048EFM.
 
Before jumping into any serious firmware development, I am trying to validate that the board is usable in general and I am able to run my code on it.
 
I am using MPLAB-X 5.45 with Harmony 3 framework, and a PICkit 3 adapter.
 
I wrote a simple application to blink an LED and I'm able to run it from MPLAB using "Debug main project" button - everything seems to work fine running this way.
I thought that I could just disconnect the PICkit adapter and my board would still operate standalone because the code is already in flash... but that doesn't work. The processor does not boot into my code at all. I also tried using "Program device for Production", and the programming part goes through successfully - but after disconnecting PICkit and rebooting the board, the processor again does not boot.
 
The CPU is configured to use an external 24MHz oscillator, which appears to work correctly (LED blinks at the proper rate when running on debugger).
 
Since I've never worked with PIC32 and MPLAB before, I am wondering if any special trick is required to make PIC32MZ boot up into user code outside of debugging environment? Attached is a snapshot of configuration bits.
 
This may or may not be software-related, because the board is brand-new. Unfortunately, this is the only PIC32 hardware I have at the moment.
 
Is there a reference "LED blinky" application for PIC32MZ and MPLAB that is proven to work and I can download, build, and run?
 
Any suggestions appreciated! Thank you!

Attached Image(s)

#1

12 Replies Related Threads

    boatbodger
    Super Member
    • Total Posts : 148
    • Reward points : 0
    • Joined: 2011/03/27 15:39:07
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/26 07:56:46 (permalink)
    4 (1)
    The implication is that you've used Harmony to create the project, so - if that is the case - the 'C' startup code should be linked in, and you should have a 'sane' linker script ensuring your code is 'landing' at a sensible place.
    If you use the icon with the downward-pointing green arrow 'Make and progam Device Main Project' it should continue to work after you have removed the debugger.
    I assume you have taken care of the state of the PIC's reset line when the debugger is unplugged - it needs to be pulled high with a resistor (sorry to ask the obvious...).
    Hope this helps.  My own initiation into the murky world of PIC32Z only started a year ago, so I feel for you ;)
     
     
    #2
    tekworld
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2021/01/24 20:44:32
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/26 19:59:22 (permalink)
    0
    boatbodger
    The implication is that you've used Harmony to create the project, so - if that is the case - the 'C' startup code should be linked in, and you should have a 'sane' linker script ensuring your code is 'landing' at a sensible place.
    If you use the icon with the downward-pointing green arrow 'Make and progam Device Main Project' it should continue to work after you have removed the debugger.
    I assume you have taken care of the state of the PIC's reset line when the debugger is unplugged - it needs to be pulled high with a resistor (sorry to ask the obvious...).
    Hope this helps.  My own initiation into the murky world of PIC32Z only started a year ago, so I feel for you ;)


    Thank you for your support!
    I don't see anything obviously wrong, and it's a very simple circuit. I tried pulling down PGC/PGD lines on my board - was thinking maybe they are floating, but that didn't help.
    I do have a pull-up resistor on MCLR (reset) line, but no capacitor to ground. The datasheet shows a capacitor "to prevent unintentional resets from brief glitches". I'll try that next...
    I guess eventually I'll find a combination that works :)
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 19146
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/27 00:34:14 (permalink)
    0
    Are you sure your Hardware is good?
    All Vcc and Grouds connected?
    Decoupling Caps?
    Good power Supply.
     
    #4
    cirilo.b
    Junior Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2020/09/08 18:40:42
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/27 00:50:06 (permalink)
    0
    Did you use the icon with the green arrow to program your code as boat-bodger suggested? If you only use the "run (debug) code" icon from MPLAB rather than the other program icon you will not have a usable program in flash when you disconnect the debugger.
    #5
    tekworld
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2021/01/24 20:44:32
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/27 05:55:38 (permalink)
    0
    NKurzman
    Are you sure your Hardware is good?
    All Vcc and Grouds connected?
    Decoupling Caps?
    Good power Supply.

    I am not sure about this board - this is new hardware.
    It does have decoupling capacitors per PIC32MZ datasheet, 10k pull-up on /MCLR with 0.1uF to ground. External 24MHz oscillator is stable.
     
    The power supply is switchmode, so some noise is present. I've been adding decoupling caps and playing around with grounding, but I don't see any effect of that whatsoever: with PICkit connected, it works 100% of the time (using "Debug main project" in MPLAB). When I use "Make and Program Main Project" button in MPLAB, it builds the project and loads it - I get this output:

    Device Erased...
    Programming...
    The following memory area(s) will be programmed:
    program memory: start address = 0x1d000000, end address = 0x1d003fff
    boot config memory
    configuration memory
    Programming/Verify complete

    ... but the code doesn't run.
    #6
    tekworld
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2021/01/24 20:44:32
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/27 06:01:30 (permalink)
    0
    cirilo.b
    Did you use the icon with the green arrow to program your code as boat-bodger suggested? If you only use the "run (debug) code" icon from MPLAB rather than the other program icon you will not have a usable program in flash when you disconnect the debugger.

    Yes, I use the "Make and Program Device Main Project" button.
    What I don't understand about MPLAB is how Debug and Production builds are different. Usually, with a microcontroller IDE, your program stays in flash no matter what - the JTAG can pause execution as needed via breakpoints. I want to be able to load and debug the same exact code as will go in Production.
    #7
    cirilo.b
    Junior Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2020/09/08 18:40:42
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/27 13:05:12 (permalink)
    0
    Check the project configuration and make sure that (a) the bootloader is not being excluded and (b) the programmer configuration is not instructing the programmer to avoid programming the bootloader region. From your description of the problem it is likely that you have no bootloader.
    post edited by cirilo.b - 2021/01/27 13:08:10
    #8
    tekworld
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2021/01/24 20:44:32
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/27 19:55:58 (permalink)
    0
    cirilo.b
    Check the project configuration and make sure that (a) the bootloader is not being excluded and (b) the programmer configuration is not instructing the programmer to avoid programming the bootloader region. From your description of the problem it is likely that you have no bootloader.

    Yes, from reading the datasheet something has to go in Boot Flash memory in order for this to work - but I didn't add any.
    Where can I add the bootloader in MPLAB? At this point all I need it to do is jump to my application.
    #9
    cirilo.b
    Junior Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2020/09/08 18:40:42
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/28 02:08:26 (permalink)
    0
    Unless you deliberately disabled the inclusion of crt0.s in the Properties dialogs or specified a custom linker script, then the bootloader is probably actually there and in the right place.
     
    The first thing I would try is to set the config for the Secondary Oscillator to disable that oscillator; in all the MZ family devices I've used, the SOSC is completely useless. I can't recall though if the problem with SOSC would cause the MCU to lock up.
     
    I don't see anything wrong with the sys clock setup, so if your clock is actually producing a clock signal within spec then that shouldn't be the problem.  If you do suspect a problem with the sysclk you can temporarily change the configuration to run off the internal fast RC and configure the PLL to produce ~100MHz just to see if it works then. (Fast RC is ~8MHz)
     
    I'm all out of ideas (it's easier to check everything with the board and code in front of you), but in a fit of desperation you can verify that the bootloader and application are where they belong - to do this you ensure that the Code Protect bit is not programmed, then program the device and read back the Boot and Program memory regions (I can't recall if the IDE has an option to save the data to a file). If you decode the HEX file you can verify that the data read matches up with what is expected.
     
    Well, maybe 1 more idea - how are you blinking the LED? If it's via an interrupt then possibly something else is misconfigured.  If you simply make your main app turn the LED on and leave it on, does the light come on?
    #10
    toms
    Senior Member
    • Total Posts : 131
    • Reward points : 0
    • Joined: 2006/03/07 18:06:24
    • Location: London, UK
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/28 04:34:41 (permalink)
    5 (1)
    tekworld
    What I don't understand about MPLAB is how Debug and Production builds are different. Usually, with a microcontroller IDE, your program stays in flash no matter what

    The code is there whether you program for debug or production. But the debug build includes a "debug executive" to enable interaction with the debug tool.
     
    I dont know the details for certain, but perhaps the debugger needs to instruct the debug executive to start running the code, so if you program a debug build and then remove the debugger, this can never happen.
     
    For production, simply create a production build and program that into your final boards and they will run just fine with or without the debugger attached. The code that executes the application itself is the same regardless of debug/production build, but the production build naturally leaves out the debug executive.
    #11
    tekworld
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2021/01/24 20:44:32
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/29 20:34:32 (permalink)
    0
    So after two weeks of trying to fix this problem (unsuccessfully), I created a brand-new project from scratch and now everything works fine.
     
    I checked - just to know what to look for next time - but I don't see any differences in any project options. I really don't have time right now to investigate any further, I have to move on with my project...
     
    I always had "Allow PICkit 3 to select memories" option checked, and "Boot flash" checkbox is checked (although it's greyed out).
     
    Thank you everyone for your suggestions!
    #12
    cirilo.b
    Junior Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2020/09/08 18:40:42
    • Location: 0
    • Status: offline
    Re: PIC32MZ - unable to boot into application 2021/01/30 14:40:08 (permalink)
    0
    The "Boot flash" checkbox shouldn't have been greyed out. Somehow the project must have been misconfigured so that the boot code is not included, but if that were the case I'm not sure why the "run+debug" worked unless MPLABX magically puts one in anyway when you debug.  I suspect the map file would hold the answers.
    #13
    Jump to:
    © 2021 APG vNext Commercial Version 4.5