• AVR Freaks

Hot!18F45K40 bootloader MCC MPLABX

Author
MartinNiggemann
New Member
  • Total Posts : 17
  • Reward points : 0
  • Joined: 2003/11/07 12:38:11
  • Status: offline
2020/02/18 07:45:54 (permalink)
0

18F45K40 bootloader MCC MPLABX

Hello,
I’m using a 18F45K40, MPLAB X (5.30), MCC Code Generator ( 3.95) and XC8 Compiler (2.10).
I have a bootloader project, generated with the bootloader module of MCC.
Bootloader is between 0x000 and 0x700, I have made necessary entries in the MCC.
The host program is between 0x000 and 0x1EED (stand alone)
I use UNIFIED BOOTLOADER Host Application 1.15.1, I also made the necessary entries (Bootloader Offeset 0x700 etc).
When I transfer the host program via the unified tool, the programm memory shows the following after the transfer:
Bootloader: 0x000 – 0x700
Hostprogramm: only from (0x701 – 0x1EED) from the standalone project  is transferred.
The part from the host program (0x000 – 0x700) is lost.
 
Can anyone help?
The host program is a assembler project, build in absolute code. Can this be the reason?

Best regards
Martin
#1

7 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3678
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: 18F45K40 bootloader MCC MPLABX 2020/02/18 08:23:45 (permalink)
    0
    MartinNiggemann
    The host program is a assembler project, build in absolute code. Can this be the reason?
    [/quoe]
     
    Might be. To check what exactly is reported to get lost, check the map file of your application!

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    mbrowning
    USNA79
    • Total Posts : 1746
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: online
    Re: 18F45K40 bootloader MCC MPLABX 2020/02/18 08:25:06 (permalink)
    0
    How are you expecting the bootloader and application to live in the same Flash space? Normally you would use the "codeoffset" linker option to move the application to above the bootloader, but I can't see how that works with absolute assembler. Since you are being the linker (using absolute assembly) you need to implement the codeoffset yourself in your assembly code.
     
    I think the bootloader should not be from 0-0x700, it should be from 0-0x6ff. Make the application reset org 0x700 and the interrupts at 0x708 and 0x718. Tell the bootloader the application is at 0x700 and it will include the appropriate GOTOs to jump to the new vectors.
     
    To test the application separately without the bootloader, implement GOTOs in assembly at 0, 8, 18 to jump to the new vectors.
    #3
    MartinNiggemann
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2003/11/07 12:38:11
    • Status: offline
    Re: 18F45K40 bootloader MCC MPLABX 2020/02/19 23:49:46 (permalink)
    0
    Hello, thanks for the answer,
    I have prepared the hostprogramm with the new vectors, now the bottloader puts the host prohgramm between 0x700 and 0x2000, perfect. I have checked this be reading out the programm meory.
    The bootloader is placed between 0-0x6ff, I have make the correct adress in the XC8 Compiler.
    But now, after the bootlaoder programms the flash and after the reset, the pc junps not to the new adress at 0x700, it jumps to 0x1E58 (always in the middle of teh host programm).
    The command "asm ("goto  "  str(NEW_RESET_VECTOR));" does not works corectly.
    Also asm ("goto 0x700") works not correctly;
    The new RESET vector adress is ignored.
     
    Can someone help?
     
    #4
    BMD
    Super Member
    • Total Posts : 445
    • Reward points : 0
    • Joined: 2003/12/02 21:42:52
    • Location: UK
    • Status: offline
    Re: 18F45K40 bootloader MCC MPLABX 2020/02/20 03:52:32 (permalink)
    0
    Hi,
     
    You should put a label at 0x700,
     
    Reset_Code  Code 0x700
    Reset_Vector:
     
    Then the goto should be
     
    goto  Reset_Vector

    Regards

    Brandon
    #5
    MartinNiggemann
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2003/11/07 12:38:11
    • Status: offline
    Re: 18F45K40 bootloader MCC MPLABX 2020/02/21 00:40:07 (permalink)
    0
    Oerfect, it works, thanks for the help.
    But I have still one little problem.
    I Use for verification the “CHECK_REST_VECTOR” from the bootloader MCC.
    After Programming the application to the host, the program stops.
     
    Here is the protocol from the unified host application:
     
    08:03:58.692 > Device: COM2 Bootloading started
    08:03:58.733 > Hex File (re)loaded...
    08:03:58.734 > (20) Sec Timeout Check per CMD
    08:03:58.734 > Reading Version ...
    08:03:58.734 > Failure Hint: Check Communication with Device
    08:03:58.815 > Bootloader Version Read Successful
    08:03:58.820 > Erasing Device ...
    08:03:58.821 > Failure Hint: Confirm Erase Range
    08:04:00.410 > Erase Successful
    08:04:00.411 > Programming Flash ...
    08:04:00.412 > Failure Hint: Confirm Hex Offset
    08:04:20.259 > Flashed Programmed
    08:04:20.260 > Retrieving Checksum ...
    08:04:20.260 > Failure Hint: Check Build Properties
    08:04:21.718 > Checksum Matched
    08:04:21.719 > Resetting Device
    08:04:41.774 > Device Failed to respond to command...
     
    After the RESET command, the application stops and nothing happens.
    The verification of the RESET fails.
    In the emulation, it stops at the RESET instruction.
    I have to start the program (run),…
    Without emulation, I have to make a power ON reset,…
    Why happens this? Why stops the program at the RESET?
    Why does the program not runs further on?
     
    Martin
    #6
    ssh19
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2019/12/21 09:15:33
    • Location: 0
    • Status: offline
    Re: 18F45K40 bootloader MCC MPLABX 2020/05/04 14:10:04 (permalink)
    0
    I had a similar issue until I check the source:

    bool Bootload_Required ()
    {
    // ******************************************************************
    //  Check an IO pin to force entry into bootloader
    // ******************************************************************
    #info  "You may need to additional delay here between enabling weak pullups and testing the pin."
        for (uint8_t i = 0; i != 0xFF; i++) NOP();
        if (IO_PIN_ENTRY_PORT_PIN == IO_PIN_ENTRY_RUN_BL)
        {
            return (true);
        }
    So, you need to make sure, that IO_PIN_ENTRY_PORT_PIN released(changed to IO_PIN_ENTRY_RUN_APP    1) before upload is complete. Othewise it will reboot back to bootloader, not to the application. 
    #7
    cTucker
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2014/04/14 13:51:49
    • Location: 0
    • Status: offline
    Re: 18F45K40 bootloader MCC MPLABX 2020/05/22 16:36:18 (permalink)
    0
    Hello Martin,
     
    This looks like the offset value is not being applied to the application (Hostprogramm).
    The Bootloader exist; and cannot (shouldn't) write over its own space; which for you is (0x000 – 0x700).
     
    Make sure to follow the instructions described fully in the User Guide. 
    https://www.microchip.com/promo/8-bit-bootloader
     
    Where the HostProgramm was build shouldn't matter if it is offset...so that would need to be applied to the project in whatever environment you are building it in. 
     
    If you ONLY have a raw hex file which is build with 0 as its origin point; there is going to be overlap between the Bootloader and the application. But if the produced Hex file conforms to Intel Hex format; and is shifted appropriately; it should not matter where it the file was build from. 
     
    I'm not sure the best resolution if you have a pre-build hex and no source.
    There might be an away to create a new project, use the hex as a loadable; and then apply an offset in the compiler linker settings. But I've never done something like that. 
     
    #8
    Jump to:
    © 2020 APG vNext Commercial Version 4.5