• AVR Freaks

"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working

Author
ernesto.arc
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2010/09/12 20:52:36
  • Location: 0
  • Status: offline
2010/09/24 14:20:21 (permalink)
0

"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working


Hello, 
Took several days trying to work with the bootloader for the PIC18F47J53 but I always get bad results .. Windows just says "Installation failed." Hardware is no problem because the example CDC_USB works well. 

I have installed: 
mcc18.exe v3.36 
MPLAB v8.50 
PICKIT3 
Microchip Solutions v2010-08-04 







I'm just programmed into the microcontroller project Device HID Bootloader Firmware for PIC18F47J53 Family Devices " 

And this does not work .. After you have programmed the microcontroller starts PICKIT3 and immediately displays the message:



To rule out hardware problem is, the other example program "CDC USB Device - Basic Demo." and this works well, which is why there must be something wrong with the example Bootloader.



This video shows the steps to follow to test the Bootloader for the PIC18F47J53. 

In the first part of the video program the USB-CDC example and show that it works well ... (The hardware is fine). Then program the Bootloader and this just does not work. 


http://www.youtube.com/watch?v=_IuEVn0Yy9k 



In my despair at having to run the bootloader, buy the PIC18F46J50, the soldiers on the same PCB which was the PIC18F47J53 and it set the Bootloader ... WORKED WELL ... So definitely not bad the hardware and firmware code who has problems. 

You know what part of the example code "HID Bootloader - Firmware for PIC18F47J53 Family Devices" in the "Microchip Solutions v2010-08-04" should be changed to work? 




#1

19 Replies Related Threads

    ernesto.arc
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2010/09/12 20:52:36
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2010/10/08 15:57:51 (permalink)
    0

    Still not working, someone please help me with this problem?.

    Examples of HID Mouse, it works fine, but the bootloader does not work.

    #2
    ernesto.arc
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2010/09/12 20:52:36
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/12 13:35:58 (permalink)
    0
    After several nights trying to solve the problem, I found the error in the project provided by Microchip (Bootloader for PIC18F47J53), the problem is in the address that points to EndPoint 0 ...

    The project was developed based on the Microchip Bootloader for PIC18F46J50 but RAM memory addresses are different and this was not changed. They should fix that detail if you want it to work.

    See you later!
    #3
    jrwhite
    Junior Member
    • Total Posts : 97
    • Reward points : 0
    • Joined: 2007/01/02 22:08:25
    • Location: Ontario Canada
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/14 16:26:45 (permalink)
    0
    Hi ernesto,

    Congratulations on your find.

    I'm about to port a project to the 47J53 that uses the HID bootloader.  Could you tell me where in the 47J53  bootloader project the EP0 addressing error is, and your correction?


    thanks,

    Jonathan


    #4
    sascha_focus
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2010/08/14 04:02:58
    • Location: Germany
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/15 11:59:00 (permalink)
    0
    Hello,

    can you tell me the changes?

    regards sascha
    #5
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/19 03:07:52 (permalink)
    0
    Finally, 18F47J53 PIM has come to me.
    As ernesto.arc said, the bootloader code has an error on the BDT location on this file.


    usbmmap.c

    /** U S B  F I X E D  L O C A T I O N  V A R I A B L E S *********************/
    //#pragma udata usbram4=0x400     //See Linker Script,usb4:0x400-0x4FF(256-byte)
    #pragma udata usbram4=0xD00     // <--------


    Tsuneo
    #6
    jrwhite
    Junior Member
    • Total Posts : 97
    • Reward points : 0
    • Joined: 2007/01/02 22:08:25
    • Location: Ontario Canada
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/19 09:26:34 (permalink)
    0
    Hi Tsuneo,

    Thank you very much.

    I was looking right at that line in usbmap.c.  What I couldn't figure out is that in the linker script for the 47J53, it doesn't mention USBRAM4, rather only has a reference to USB_VARS @ gpr10 (0xA00) .. and the 46J50 linker script @ gpr11 (0xB00 ).  Neither which matches gpr4.

    I tried searching for all references to ep0Bo, and I couldn't see where any caller was setting 0xD00 as the page.  I'm sure this is just my lack of knowledge about how the abbreviated USB bootloader stack works.  Also, I had thought that all RAM in the 46J50 / 47J53 was available to the SIE, so it wouldn't matter where you placed the BDT.

    Could you explain why and where the 0xD00 page reference comes from so I can understand the HID bootloader stack a bit better?

    Thanks so much,

    Jonathan


    #7
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/19 11:15:52 (permalink)
    0
    \You don't need to touch to the linker script at all.

    When address is assigned on "#pragma udata" declaration in C code, compiler generates a section of the name, starting at the specified address by itself. No section definition is required on a linker script.

    ex1.

    #pragma udata usbram4=0xD00       // start of section

    // Compiler generates usbram4 section starting at 0xD00
    // The variables declared here are mapped to usbram4 section.

    #pragma udata                     // end of section


    When #pragma udata declares just section name without address, the section should be mapped on a linker script.

    ex2.

    #pragma udata USB_VARS            // start of section

    // The variables are included in USB_VARS section.

    #pragma udata                     // end of section



    I tried searching for all references to ep0Bo, and I couldn't see where any caller was setting 0xD00 as the page.

    "#pragma udata" assigns the address

    Also, I had thought that all RAM in the 46J50 / 47J53 was available to the SIE, so it wouldn't matter where you placed the BDT.

    BDT locates on fixed address for PIC18F

    Tsuneo
    post edited by chinzei - 2010/10/19 11:28:24
    #8
    jrwhite
    Junior Member
    • Total Posts : 97
    • Reward points : 0
    • Joined: 2007/01/02 22:08:25
    • Location: Ontario Canada
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/19 17:35:30 (permalink)
    0
    Hi Tsuneo,

    Although new to C on PICs, I think I understand the #pragma / section linker directives as it seems to be pretty similar to assembly.  Thanks for the info though.  What I think tripped me up was the comment in usbmmap.c after the directive;
     
    #pragma udata usbram4=0x400     //See Linker Script,usb4:0x400-0x4FF(256-byte)
     
    This made me think that the BDT assignment was somehow related to the linker script, although, as you pointed out, I should have known this was an incorrect assumption based on it being an assignment.

    What I didn't realize is that the BDT address is specific for different parts, even though the SIE can access all RAM.  After re-reading the datasheets / usb sections, it's clearly specified that the BDT for the 46J50 must be at 0x400, and 0xD00 for the 47J53.

    I should have been more thorough in reading the datasheets instead of concentrating on the bootloader code.

    Thanks again for your help, and the help you've given to others,

    Jonathan

    post edited by jrwhite - 2010/10/19 20:41:21
    #9
    ernesto.arc
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2010/09/12 20:52:36
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/21 12:14:43 (permalink)
    0
    Hi everyone,
    If you want to understand the reason for the change to be done, should read the PIC18F47J53 datasheet on page 388 ... You see a table that says:

    FIGURE 23-5: EXAMPLE OF A BUFFER DESCRIPTOR

    You will find that BD0STAT = D00h.

    That is the error code that is the position BD0STAT ment for 46J50.

    see you later!
    #10
    Andy123
    Super Member
    • Total Posts : 567
    • Reward points : 0
    • Joined: 2005/04/25 14:20:54
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2010/10/22 05:20:46 (permalink)
    0
    Just want to confirm that D00 fix works for 18F27J53 as well
     
    for 27J53 there is another bug:
     
    in main.c line:     #if defined(__18F26J53)||defined(__18F26J53)|| \
             defined(__18F46J53)||defined(__18F47J53)

     
    should read:
        #if defined(__18F26J53)||defined(__18F27J53)|| \
            defined(__18F46J53)||defined(__18F47J53)
     
    post edited by Andy123 - 2010/10/22 06:27:18
    #11
    jfmateos
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2010/11/15 06:39:25
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> FIXED!!!!! 2011/01/30 11:53:39 (permalink)
    0
    Hi Andy.

    Could you tell me how did you compiled the bootloader for 18f27j53?

    I have selected PIC18F27J53 in Configure>Select device, but the make procces shows the following errors:


    Executing: "C:\MCC18\bin\mcc18.exe" -p=18F27J53 /i"C:\MCC18\h" "hid.c" -fo="hid.o"
    Executing: "C:\MCC18\bin\mcc18.exe" -p=18F27J53 /i"C:\MCC18\h" "main.c" -fo="main.o"
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:375:Error [1105] symbol 'LATE' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:375:Error [1101] lvalue required
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:375:Error [1105] symbol 'TRISE' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:375:Error [1101] lvalue required
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:449:Error [1105] symbol 'LATEbits' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:449:Error [1151] struct or union object designator expected
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:449:Error [1101] lvalue required
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:449:Error [1105] symbol 'LATEbits' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:449:Error [1151] struct or union object designator expected
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:449:Error [1101] lvalue required
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:454:Error [1105] symbol 'LATEbits' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:454:Error [1151] struct or union object designator expected
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:454:Error [1105] symbol 'LATEbits' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:454:Error [1151] struct or union object designator expected
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:454:Error [1101] lvalue required
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:455:Error [1105] symbol 'LATEbits' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:455:Error [1151] struct or union object designator expected
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:455:Error [1105] symbol 'LATEbits' has not been defined
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:455:Error [1151] struct or union object designator expected
    C:\Microchip Solutions v2010-10-19\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18F47J53 Family Devices\main.c:455:Error [1101] lvalue required


    #12
    pmgr
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2010/04/21 14:57:39
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/05 00:30:48 (permalink)
    0
    I have a problem getting this bootloader to work with the small code model (MCC18)

    Using the large code model, the bootloader shows up fine under Windows as HID USB device, no problems.

    Now when I change the code model to small, I get the yellow warning sign "USB device not recognized".

    The strange things is, that if I add the following line somewhere in my code:

    putrs2USART((const rom far char *)"TEST");

    the bootloader shows up correctly under Windows (same as compiling with large code model).

    Note that adding the line  

    putrs2USART((const rom char *)"TEST");

    without the far doesn't work.

    I know that all MCC18 libraries are compiled for the large code model. Could this be what is causing the problem? Do I need to recompile them for the small code model and if so, how do I do that exactly? Maybe the USB code uses some of the standard MCC libraries? Or maybe the standard libraries are already the problem:

    c018iz.o
    clib.lib
    p18f47j53.lib

    since they were compiled using the large code model?

    I have noticed the exact same thing with the CDC serial emulator so it seems to me that this is an issue either with the small code model or maybe something in the USB that is set to only work under large code model?

    Your input appreciated.

    Thanks, PmgR
    #13
    pmgr
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2010/04/21 14:57:39
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/06 12:42:54 (permalink)
    0
    Here is an update to this.

    I am using MCC18 using the small code model. I did not recompile the C18 libraries so the standard large code model libraries are being used.

    I have traced the problem down to the following:

    The USB stops working as soon as I add and call the following function from my code (address=0x10600 or anything else above 0xFFFF)

    unsigned char ReadProgMem(unsigned short long address)
    {
      return *((far rom unsigned char*)(address));
    //  return (unsigned char)0xFF;
    //  return *((rom unsigned char*)(address));
    }

    If I remove the "far" keyword (replacing the return line by any of the commented lines), the USB works fine, but then obviously the function doesn't return the correct program memory value as the address is beyond the 64kB border and needs the "far" keyword.

    Switching to the large code model also makes the problem go away, but due to other libraries which are compiled for the small code model, I need to stick with the small code model.

    The weird thing is that if I use a putrs2USART command anywhere in my code the problem disappears?? Not sure why that would matter at all.

    I need to know how I can fix this or how I can safely circumvent the problem so the function above will read the correct memory address while the USB remains functional. Maybe there is a bug in the HID USB code?

    Anyone any clues?
    #14
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/07 06:01:37 (permalink)
    0
    It is a TBLPTRU issue, if I am not wrong.
    In large model it is handled by compiler; otherwise it is not, so using/setting "far" pointer causes TBLPTRU (bits 16-23 of the Table pointer) to be set and never ever reset again - as the rest of your code expects.

    a
     TBLPTRU=0;

    after any of those access should work.

    GENOVA :D :D ! GODO
    #15
    pmgr
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2010/04/21 14:57:39
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/08 01:42:52 (permalink)
    0
    Dario, you are the man!

    Great, that seemed to work and reduced my bootloader by 300bytes!

    The question is now whether those "far" calls modify any other registers besides the TBLPTRU that needs to be saved/restored before and after the call.


    #16
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/08 03:12:38 (permalink)
    0
    Smile ok

    Hmmm, if I recall correctly, not...
    but you can look at disassembled code anyway.

    GENOVA :D :D ! GODO
    #17
    yonghui
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2009/11/24 21:01:16
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/11 23:57:18 (permalink)
    0
    Hi, 

    i am currently trying to use the HID bootloader for PIC18F47J53 and having problem with it, 
     the computer can detect the HID device. but the boot loader can't function properly. 
    it enters the bootloader mode when the button is press without a reset. Also, programming using the bootloader will cause the program does not run.  
    anyone having similar problem? how to solve for it? 
    The application start memory is incorrect?  0x1000

    im using Microchip Solutions v2010-08-04. 

    helps and explanations appreciated greatly. 

    thanks. 
    yonghui
    #18
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/12 00:40:53 (permalink)
    0

    im using Microchip Solutions v2010-08-04

    v2010-10-19 (the latest one) fixes above BDT location problems, at least.
    Try it, first.
    No one has concern of old version with obvious bugs.

    Tsuneo
    #19
    yonghui
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2009/11/24 21:01:16
    • Location: 0
    • Status: offline
    Re:"HID Bootloader - Firmware for PIC18F47J53 Family Devices"--->>> Not Working 2011/03/12 01:37:47 (permalink)
    0
    Hi Tsuneo, 

    thanks for the advice, i will try it. 
    im out of date. dont know there is a new version release. 


    regards, 
    yonghui
    #20
    Jump to:
    © 2019 APG vNext Commercial Version 4.5