Menu

PIC18F26K22 and MPLABX

technoo
2013-07-03
2013-07-23
  • technoo

    technoo - 2013-07-03

    Hi,

    I am currently trying to get the tinyPicBootloader to work with PIC18F26K22, however, it only seems to work when I compile the HEX file with MPLAB 8 IDE (C18 compiler). When using MPLABX IDE (XC8 compiler), it seems the HEX file is in a different format, tinyPicBootloader is then throwing an error :

    "
    Error: hex file too large, writing bootloader firmware!!!
    Error: problem in writing PIC memory!!!
    Close COM9 serial port
    "

    Is there anything I should try in order to have a correct HEX file generated from MPLAB X IDE ?

    • I have been able to correctly use the tinyPicBootloader for PIC16F1508 and MLABX IDE without a problem, maybe the fact that PIC18F26K22 has eeprom is causing problem ? -

    Thanks a lot for your help,
    Mat

     
  • edorul

    edorul - 2013-07-03

    Hello Mat,

    Is it possible the "hex" file is effectively too big? May be you have some code optimizations activated in C18 compiler and not in XC8?

    In order to try to understand the problem(s) can you give me:
    - the "hex" file generated by C18
    - the "hex" file generated by XC8
    - the "ID code" your firmware use (if you don't know how to find this code, you can display it by this way: in "debug" tab check "show PIC answer during Check PIC" and then click on [Check PIC] or [Write Flash]).

    Best regards,
    Edorul

     
  • edorul

    edorul - 2013-07-06

    Hello Mat,

    have you succeeded to make your application for PIC18F26K22, compiled with XC8, working with "tiny Bootloader+" ?

    Best regards,
    Edorul

     
  • technoo

    technoo - 2013-07-12

    Hi edorul,

    Sorry for late response, was pretty busy lately.

    Here are the two HEX files :
    (The one on mplabX)

    :1000000056EF00F0FF00FF00FACF03F0FBCF04F043
    :10001000E9CF05F0EACF06F0E1CF07F0E2CF08F034
    :10002000D9CF09F0DACF0AF0F3CF0BF0F4CF0CF010
    :10003000F6CF0DF0F7CF0EF0F8CF0FF0F5CF10F0B0
    :100040009EAA01D001D015D09E9A8AAC01D002D0D0
    :10005000010E01D0000E026E023A024602468A509C
    :100060000218BF0B02188A6EAECF01F0C8EC00F088
    :1000700000D010C0F5FF0FC0F8FF0EC0F7FF0DC095
    :10008000F6FF0CC0F4FF0BC0F3FF0AC0DAFF09C093
    :10009000D9FF08C0E2FF07C0E1FF06C0EAFF05C0C4
    :1000A000E9FF04C0FBFF03C0FAFF1100C0EF00F03E
    :1000B00094EC00F0D0EC00F0B0EC00F0000E136E09
    :1000C000000E126E8A8E8A9C00D01228D8B4132893
    :1000D000D8A401D001D022D08AAE01D002D0010E26
    :1000E00001D0000E116E113211328A5011187F0B9F
    :1000F00011188A6E8AAC01D002D0010E01D0000E18
    :10010000116E113A114611468A501118BF0B111881
    :100110008A6E000E136E000E126E00D0124A132A61
    :10012000D4D7D3D756EF00F09B8E9B809B829B84C5
    :100130009B969B989B9A9B8C010E926E000E936EE1
    :10014000980E946EF19E010E0F010F01386F000E94
    :100150000F010F01396F000E0F010F013A6F1200EE
    :10016000330EAF6EAC94B896AC98AC8AAB88AB8EBD
    :10017000AC8AAB88AB8E9E989D989D8A9E9A120001
    :10018000186A176A166A156A146A000158EF00F0B7
    :1001900000D0ACA201D001D0FCD701C0ADFF12004D
    :1001A000F2946298F296F290F28CF28E1200FF00B6
    :020000040020DA
    :08000000FFFFFFFFFFFFFFFF00
    :020000040030CA
    :0E000000FF251F3FFFBF85FF0FC00FE00F4021
    :00000001FF

    (the one on mplab8)
    :020000040000FA
    :06000000F3EF00F0120016
    :020006000000F8
    :08000800670EAF6EAC94B896D0
    :10001000AC98AC8AAB88AB8E9E989D989D8A9E9A30
    :1000200012009B8EC00E9B1407099B6E9B8C010EC9
    :10003000926E936A980E946EF19E0F01010E386FC6
    :10004000396B3A6B1200D9CFE6FFE1CFD9FFACA2F2
    :10005000FED7FE0EDB50AD6EE552E7CFD9FF1200A2
    :10006000D9CFE6FFE1CFD9FFE652DF6AFE0EDB50C3
    :10007000DF5C03E20000DF2AF9D7E552E552E7CF63
    :10008000D9FF1200D9CFE6FFE1CFD9FFE652DF6AF0
    :10009000140EDF5C06E2640EE66EE2DFE552DF2A54
    :1000A000F7D7E552E552E7CFD9FF1200D9CFE6FFE7
    :1000B000E1CFD9FFE652DF6ADF50026E036AD890C3
    :1000C000035004E6C80E025C000E035803E2DADFB8
    :1000D000DF2AF2D7E552E552E7CFD9FF1200F294BA
    :1000E0006298F296F290F28CF28E12009ADFF7DFAD
    :1000F0008BDF8A8E8A9C020EE66EA5DFE552450EE6
    :10010000E66EA1DFE5524C0EE66E9DDFE5524C0E29
    :10011000E66E99DFE5524F0EE66E95DFE552C6DFDB
    :080120008A7E8A7CFCD71200E4
    :08012800060EF66E000EF76EE4
    :10013000000EF86E0F010900F550056F0900F5502B
    :10014000066F03E1056701D03DD00900F550006F4F
    :100150000900F550016F0900F550026F0900090010
    :10016000F550E96E0900F550EA6E09000900090032
    :10017000F550036F0900F550046F09000900F6CF30
    :1001800007FFF7CF08FFF8CF09FF00CFF6FF01CF39
    :10019000F7FF02CFF8FF0F01035302E1045307E01A
    :1001A0000900F550EE6E0307F8E20407F9D707CF10
    :1001B000F6FF08CFF7FF09CFF8FF0F010507000E84
    :0601C000065BBFD7120030
    :0A01C600380EF36E00EE00F00F0E8D
    :1001D00001D81200EA6002D0EE6AFCD7F350E96061
    :0601E0001200EE6AFCD7DC
    :0A01E6001EEE00F02EEE00F0F86AA5
    :1001F000019C94EC00F002EC01F076EC00F0FBD7EF
    :020200001200EA
    :020202004800B2
    :020204001200E6
    :00000001FF

    If I get rid of those 4 lines at the end of the MPLABX hex file, it seems that the tinybootloader will work ok...however I am not sure of what I am deleting... :
    :020000040020DA
    :08000000FFFFFFFFFFFFFFFF00
    :020000040030CA
    :0E000000FF251F3FFFBF85FF0FC00FE00F4021

    ID code I use is 0x66. (I also tried with an ID without eeprom as I thought this might have caused issue but this did not work either)

    As for optimization I don't think there is a difference in my setting between C18 and XC8. And the code is very small as well so I think the size is not a real issue, more like something to do with massive address at the end of the HEX file.

    (sorry for post formatting, I am not sure how to make that look more "neat")

    Thanks again for your help,
    Mat

     
  • edorul

    edorul - 2013-07-13

    Hello Mat,

    With your problem I've learnt that they are "User ID" bytes in PIC18 devices, for the user to store data, such as code version numbers, etc... Thanks ;-)

    I've modified "Tiny Bootloader+", now if there are "User ID" bytes in hex file they will be discarded (not written) instead of displaying "Error: hex file too large, writing bootloader firmware!!!".
    I've attached to this post the new version. Can you test it and tell me if everything is fine?

    Can you tell me which bootloader firmware you've modified to make it work with your PIC18F26K22?

    best regards,
    Edorul

     

    Last edit: edorul 2013-07-13
  • technoo

    technoo - 2013-07-22

    Hi, I haven't changed anything within the bootloader firmware, I am using "TinyB18F18F2420-4420" project. (I have only modified what's necesseray to make it work with 18F26K22)

    We are however infront of a problem, the bootloader seems to work fine until the last block where it tries to copy some data onto 0xFF00 address.

    Here is the log of tinyBootPicLoader (I went back to a project with MPLAB8 as I think it might be a different issue which is preventing us from actually testing the PIC18F26K22 under MPLABX) :

    "
    Open COM9 serial port
    Check Device...
    Device answer: 0x66 0x4B
    first byte OK, now check ID-code...
    idCode = $66
    family = C
    description = 18F w/64KB flash & 1024B EEPROM
    flash mem = 65536 bytes
    EEPROM mem = 1024 bytes
    Bootloader size = 200 bytes
    Transfert block size = 64 bytes
    Found: 18F w/64KB flash & 1024B EEPROM
    Warning: Config bytes found, just writing data
    minMemPos=00000000, maxMemPos=0000FF40, blockSize=64
    first 4 words at address 0xFF38:
    0xEFEA
    0xF000
    0x0012
    0x0000
    Transfering file...
    write mem pos: 0x00000000(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x00, TBLPTRL=0x00, block=64
    A0 EF 7F F0 12 00 00 00 33 0E AF 6E AC 94 B8 96 AC 98 AC 8A AB 88 AB 8E 9E 98 9D 98 9D 8A 9E 9A 12 00 9B 8E C0 0E 9B 14 07 09 9B 6E 9B 8C 01 0E 92 6E 93 6A 98 0E 94 6E F1 9E 0F 01 01 0E 38 6F
    CRC OK (0x13)
    write mem pos: 0x00000040(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x00, TBLPTRL=0x40, block=64
    39 6B 3A 6B 12 00 D9 CF E6 FF E1 CF D9 FF AC A2 FE D7 FE 0E DB 50 AD 6E E5 52 E7 CF D9 FF 12 00 D9 CF E6 FF E1 CF D9 FF E6 52 DF 6A FE 0E DB 50 DF 5C 03 E2 00 00 DF 2A F9 D7 E5 52 E5 52 E7 CF
    CRC OK (0xDA)
    write mem pos: 0x00000080(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x00, TBLPTRL=0x80, block=64
    D9 FF 12 00 D9 CF E6 FF E1 CF D9 FF E6 52 DF 6A 14 0E DF 5C 06 E2 64 0E E6 6E E2 DF E5 52 DF 2A F7 D7 E5 52 E5 52 E7 CF D9 FF 12 00 D9 CF E6 FF E1 CF D9 FF E6 52 DF 6A DF 50 02 6E 03 6A D8 90
    CRC OK (0xCE)
    write mem pos: 0x000000C0(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x00, TBLPTRL=0xC0, block=64
    03 50 04 E6 C8 0E 02 5C 00 0E 03 58 03 E2 DA DF DF 2A F2 D7 E5 52 E5 52 E7 CF D9 FF 12 00 F2 94 62 98 F2 96 F2 90 F2 8C F2 8E 12 00 9A DF 8C DF 8A 8E 8A 9C DB DF DA DF D9 DF D8 DF D7 DF D6 DF
    CRC OK (0x9F)
    write mem pos: 0x00000100(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x01, TBLPTRL=0x00, block=64
    52 0E AE 5C 03 E0 72 0E AE 5C 01 E1 FF 00 8A 7E 8A 7C F0 D7 12 00 06 0E F6 6E 00 0E F7 6E 00 0E F8 6E 0F 01 09 00 F5 50 05 6F 09 00 F5 50 06 6F 03 E1 05 67 01 D0 3D D0 09 00 F5 50 00 6F 09 00
    CRC OK (0x38)
    write mem pos: 0x00000140(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x01, TBLPTRL=0x40, block=64
    F5 50 01 6F 09 00 F5 50 02 6F 09 00 09 00 F5 50 E9 6E 09 00 F5 50 EA 6E 09 00 09 00 09 00 F5 50 03 6F 09 00 F5 50 04 6F 09 00 09 00 F6 CF 07 FF F7 CF 08 FF F8 CF 09 FF 00 CF F6 FF 01 CF F7 FF
    CRC OK (0x21)
    write mem pos: 0x00000180(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x01, TBLPTRL=0x80, block=64
    02 CF F8 FF 0F 01 03 53 02 E1 04 53 07 E0 09 00 F5 50 EE 6E 03 07 F8 E2 04 07 F9 D7 07 CF F6 FF 08 CF F7 FF 09 CF F8 FF 0F 01 05 07 00 0E 06 5B BF D7 12 00 38 0E F3 6E 00 EE 00 F0 0F 0E 01 D8
    CRC OK (0x72)
    write mem pos: 0x000001C0(byte)
    send: TBLPTRU=0x00, TBLPTRH=0x01, TBLPTRL=0xC0, block=64
    12 00 EA 60 02 D0 EE 6A FC D7 F3 50 E9 60 12 00 EE 6A FC D7 1E EE 00 F0 2E EE 00 F0 F8 6A 01 9C 8B EC 00 F0 F8 EC 00 F0 76 EC 00 F0 FB D7 12 00 12 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    CRC OK (0x61)
    write mem pos: 0x0000FF00(byte)
    send: TBLPTRU=0x00, TBLPTRH=0xFF, TBLPTRL=0x00, block=64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF EA EF 00 F0 12 00 00 00
    no answer
    Error: problem in writing flash memory!!!
    Close COM9 serial port
    "

    HEX FILE :
    "
    :020000040000FA
    :06000000FEEF00F012000B
    :020006000000F8
    :08000800670EAF6EAC94B896D0
    :10001000AC98AC8AAB88AB8E9E989D989D8A9E9A30
    :1000200012009B8EC00E9B1407099B6E9B8C010EC9
    :10003000926E936A980E946EF19E0F01010E386FC6
    :10004000396B3A6B1200D9CFE6FFE1CFD9FFACA2F2
    :10005000FED7FE0EDB50AD6EE552E7CFD9FF1200A2
    :10006000D9CFE6FFE1CFD9FFE652DF6AFE0EDB50C3
    :10007000DF5C03E20000DF2AF9D7E552E552E7CF63
    :10008000D9FF1200D9CFE6FFE1CFD9FFE652DF6AF0
    :10009000140EDF5C06E2640EE66EE2DFE552DF2A54
    :1000A000F7D7E552E552E7CFD9FF1200D9CFE6FFE7
    :1000B000E1CFD9FFE652DF6ADF50026E036AD890C3
    :1000C000035004E6C80E025C000E035803E2DADFB8
    :1000D000DF2AF2D7E552E552E7CFD9FF1200F294BA
    :1000E0006298F296F290F28CF28E1200D9CFE6FF6F
    :1000F000E1CFD9FF020EE126DE6ADD6A92DFEFDF93
    :1001000083DF8A8E8A9CDECF02F0DDCF03F0FF0E04
    :10011000025CFF0E035804E38A7E8A7CDE6ADD6A95
    :10012000DF2A010E01E3DB2AEED7020EE15C02E2D8
    :0E013000E16AE552E16EE552E7CFD9FF120019
    :02013E00060EAB
    :10014000F66E000EF76E000EF86E0F010900F55006
    :10015000056F0900F550066F03E1056701D03DD03A
    :100160000900F550006F0900F550016F0900F550C6
    :10017000026F09000900F550E96E0900F550EA6EBA
    :10018000090009000900F550036F0900F550046FDC
    :1001900009000900F6CF07FFF7CF08FFF8CF09FFE6
    :1001A00000CFF6FF01CFF7FF02CFF8FF0F01035397
    :1001B00002E1045307E00900F550EE6E0307F8E290
    :1001C0000407F9D707CFF6FF08CFF7FF09CFF8FFED
    :0C01D0000F010507000E065BBFD71200F0
    :0401DC00380EF36E78
    :1001E00000EE00F00F0E01D81200EA6002D0EE6AB5
    :0C01F000FCD7F350E9601200EE6AFCD767
    :0401FC001EEE00F003
    :100200002EEE00F0F86A019C9FEC00F00CEC01F07F
    :0802100076EC00F0FBD71200B0
    :020218001200D2
    :00000001FF
    "

    Thanks again for your precious help,
    Best,
    Mat

     
  • edorul

    edorul - 2013-07-23

    Hello Mat!

    Thanks for this detailled post (but it seems that the HEX file is not exactly the one of the log of TinyBootloader+).

    I've tried with the Virtual Device but it's OK. So it seems that the problem doesn't come from the PC side.

    When you've modified the "TinyB18F18F2420-4420" firmware, have you changed "#define max_flash 0x4000" to "#define max_flash 0x10000"?
    After the "no answer. Error: problem in writing flash memory!!!" message, is the bootloader still working?
    For the moment, I have no other question that could help :-(

    Best regards,
    Edorul

     
  • technoo

    technoo - 2013-07-23

    Please forget my last message, we have found the issue as we were messing with the actual code of the bootloader. Everything is back up and running and works correctly with Pic18F26K22, let me know if you need any information.

    Thanks,
    Mat

     
  • technoo

    technoo - 2013-07-23

    Just saw your message, yes the problem was that we had change :

    #define first_address max_flash-200     ;100 words
    

    to

    #define first_address max_flash-400     ;100 words
    

    in order to have some debug info. We forgot about putting it back to 200...silly.

    Thanks for your great work,
    Mat

     
  • edorul

    edorul - 2013-07-23

    Thanks for the feedback!
    Îm happy to hear that it's working fine.

    Now, I hope it will work with XC8 and MPLABX.

    Best regards,
    Edorul

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.