Menu

New possibilities for PIC Bootloader

Dan
2013-07-25
2013-08-02
  • Dan

    Dan - 2013-07-25

    Dear Edorul. and All.

    Because you are taking over the thought of Claudiu Chiculita, that the hard-to-use(constraint) exist as the bootloader of the PIC Tiny AVR / PIC Bootloader +.

    Rewriting of code enforcement 0x0000_0x0002, the following constraint is enforced by force copy of the first four words of the source code.

    1.With or without using interrupts, it is necessary to write the code jumps to the user program in the four words in the first source code.

    2.I can not describe the relative jump instruction system in four words during the initial source code.

    MOVWF PCL,F
    ADDWF PCL,F
    BRA
    BRW

    CALLW is allowed exception.

    MOVLW 0xXX
    MOVLP 0xYY
    CALLW
    JMP 0xZZZZ

    3.CALL or GOTO to 0x0000 from the user program.
    4.CALL or GOTO to 0x0001 from the user program.
    5.CALL or GOTO to 0x0002 from the user program.

    Is shown in the attached Image2.jpg,
    but you have mounted the flash beyond the reach of GOTO instruction Enhanced mid-range PIC is almost.

    And it supports BRA instructions that do not reach the effect on the PCLATH if Enhanced mid-range PIC.

    So if you can jump to the boot loader in one word BRA instruction as AVR, instruction substitution requires only one word in many PIC.
    (876/877/886/887/87/88/873/883/874/884/721 exceptions)

    I do not can check the work I do not have the PIC corresponding to
    Image2.jpg,
    It can be solved by PIC many constraints above 1,2,4,5 this way will hopefully if.

    Constraints_3 exist any AVR, but if you use the bootloader support,
    because it does not jump to 0x0000 in reset, constraints_3 also eliminates.

    Best regards,
    Dan

     

    Last edit: Dan 2013-07-25
  • Dan

    Dan - 2013-07-25

    Dear Edorul. and All.
    (Continuation)

    1).Enhanced mid-range PIC(Program mem>2kW)

    Change one word of 0x0000 forced rewriting.

    0000:BRA IntrareBootloader (The jump in the direction of negative)

    Case1
    First word the beginning of the source code BRA or GOTO

    org first_address
    0000:GOTO $XXXX (Converted to GOTO in the case of BRA)

    Case2
    Other than those above(Include the CALL)

    org first_address
    0000:Copy of 0x0000
    0001:GOTO $0001

    2).Program mem<4kW

    Change one word of 0x0000 forced rewriting.

    0000:GOTO IntrareBootloader (The jump in the positive direction)

    Case1
    First word the beginning of the source code GOTO

    org first_address
    0000:GOTO $XXXX (Copy of 0x0000)

    Case2
    Other than those above(Include the CALL)

    org first_address
    0000:Copy of 0x0000
    0001:GOTO $0001

    3).PIC16F876/877/886/887/87/88/873/883/874/884/721

    Changed to a 2-word 0x0001 and 0x0000 forced rewriting.

    0000:COMF PCLAT,F
    0001:GOTO IntrareBootloader
    or
    0000:DECF PCLAT,F
    0001:GOTO IntrareBootloader

    Case1
    Any first two words of the source code does not contain GOTO, CALL,
    "MOVWF PCLAT,F", "ADDWF PCLAT,F" .

    org first_address
    0000:CLRF PCLATH
    0001:Copy of 0x0000
    0002:Copy of 0x0001
    0003:GOTO $0002

    However, the following syntax is impossible.

    MOVLW 0xXX
    MOVWF PCLATH
    GOTO $XXXX

    Case2
    First word of the source code GOTO

    org first_address
    0000:CLRF PCLATH
    0001:GOTO $XXXX (Copy of 0x0000)

    Case3
    Second word of the source code GOTO

    org first_address
    0000:CLRF PCLATH
    0001:Copy of 0x0000
    0002:GOTO $XXXX (Copy of 0x0001)

    However, the following syntax is impossible.
    BSF PCLATH,X
    GOTO $XXXX

    Case4
    First word of the source code CALL

    org first_address
    0000:CLRF PCLATH
    0001:CALL $XXXX (Copy of 0x0000)
    0002:CLRF PCLATH
    0003:GOTO $0002

    (However, PCLATH is unchanged at $ XXXX subroutine)

    Case5
    Second word of the source code CALL

    org first_address
    0000:CLRF PCLATH
    0001:Copy of 0x0000
    0002:CALL $XXXX (Copy of 0x0001)
    0003:GOTO $0002

    (However, PCLATH is unchanged at $ XXXX subroutine)

    Case6
    CALL+GOTO

    org first_address
    0000:CLRF PCLATH
    0001:CALL $XXXX (Copy of 0x0000)
    0002:CLRF PCLATH
    0003:GOTO $YYYY (Copy of 0x0001)

    Case7
    CALL+CALL

    org first_address
    0000:CLRF PCLATH
    0001:CALL $XXXX (Copy of 0x0000)
    0002:CALL $YYYY (Copy of 0x0001)
    0003:GOTO $0002

    (However, PCLATH is unchanged at $ XXXX subroutine)

    Case8
    MOVLW+"MOVWF PCLAT,F"
    MOVLW+"ADDWF PCLAT,F"

    org first_address
    0000:CLRF PCLATH
    0001:GOTO $ZZZZ ($ZZZZ is obtained by calculation)

    Best regards,
    Dan

     

    Last edit: Dan 2013-07-25
  • edorul

    edorul - 2013-07-25

    Hello Dan!

    I'm sorry but I don't understand what will be the benefits of this method?
    Will it still be compatible with every compilers (Microchip XC8, CCS C Compiler, Great Cow Basic, etc...) without having to modify the code specialy for TinyBootlader?

    Best regards,
    Edorul

     
  • Dan

    Dan - 2013-07-25

    Dear Edorul.

    Thank you very much for reply.

    My suggestion this time is to increase the degree of freedom of the source code that you create.

    Of Claudiu Chiculita basic idea (of PIC16F part) is PIC16F876/877/886/887/87/88/873/883/874/884I feel that's what it was made to be well. Basis.

    Of Claudiu Chiculita basic idea (of PIC16F part) was a reasonable way only in the PIC of the times there is no relative jump instruction.

    I think that the setting itself PCLAT is unnecessary and often in PIC low amount of memory on the other hand.

    Can CALL instruction and GOTO instruction to access the entire area in the PIC(Program mem of <4kW), setting PCLAT is required "MOVLW PCL, F" "ADDLW PCL, F" and only when using.

    BRA instruction and BRW instruction is implemented in Enhanced mid-range PIC more recent,
    It can be programmed (without considering the setting of PCLATH) do not use "MOVLW PCL, F" "ADDLW PCL, F" and the.

    Compatibility issues

    Like when you add the AVR, are you with the problem is the process of four-word boot loader and leading size of the forced rewriting area.

    There is no need to change the firmware of the PIC ever created.

    It is not just a change in the table of PIC16F "User Software" listed in http://www.etc.ugal.ro/cchiculita/software/tinybldusage.htm

    Best regards,
    Dan

     

    Last edit: Dan 2013-07-25
  • edorul

    edorul - 2013-07-26

    Hello Dan!

    I still don't understand the benefits of theses changes, but it seems usefull for you ^_^ So, if it's still compatible with old firmwares and with applications made with different compilers without having to modify the code specialy for TinyBootlader, then you can modify TinyBootloader the way you want!

    Attached to this post the latest version.

    Best regards,
    Edorul

     
  • Dan

    Dan - 2013-07-26

    Dear Edorul.

    Thank you very much Do Ri to hear the views of the stage in the investigation.

    I will look the source program.
    Thank you very much.

    It's just a simple example.

    0000:CLRF PCLATH
    0001:GOTO 0x400

    The above will work correctly on any PIC16F.

    However, on the assumption that PCLATH is cleared by initial,

    0000:MOVLW YY
    0001:GOTO 0x400

    When you write with,

    It operates in the PIC16F1823, but it is a program that does not work in PIC16F1827.

    Even in the case of programming that does not use the interrupt,

    0000:MOVLW XX
    0001:MOVWF YY
    0002:MOVLW AA
    0003:MOVWF BB
    0004:CALL DDDD

    Ease of use adds to descriptions such as can be.

    From the post, and then, re-examination,

    By Replace the first word and the 2nd word in the 16F of all,

    COMF PCLAT,F
    GOTO IntrareBootloader

    1)0000 If the GOTO or BRA
    2)0001 If the GOTO or BRA
    3)For 0000:MOVLW + 0001:ADDWF(MOVWF) PCL,F or 0000:MOVLW + 0001:BRW
    4)Other (contains CALL,CALLW)

    We believe that it can be simplified to

    Thank you very much.

    I will post firmware of MEGA48 (operation confirmed) and MEGA88 (operation confirmed) in the near future.

    Best regards,
    Dan

     
  • Dan

    Dan - 2013-07-27

    Dear Edorul.

    Sorry, I will suspend this discussion.

    I can now feel comfortable that I have made in the firmware clear the PCLAT while I advance the discussion and may be reasonable.

    This point seems to have been considered even Claudiu Chiculita, there is a description of the following notinybld16F88.asm in tinybld198.

    way_to_exit ;exit in all other cases; must be BANK0/1
    BANK0_ ; changed MOJ (RCSTA in bank 0, not bank 1)
    bcf RCSTA,SPEN ; desactivate UART
    clrf PCLATH ; added for missing pagesel in most programs
    ; when the destination of the first goto is in the same page

    I'm thinking better to modify the firmware is good, but your opinion How is?

    To apply is chip shown above Image2.jpg

    Best regards,
    Dan

     

    Last edit: Dan 2013-07-27
  • edorul

    edorul - 2013-07-27

    Hello Dan!

    You will think I'm very stupid as I still don't understand everything (^_^;)
    In fact, the last time I've programmed a PIC in assembly, it was in 1998... so I can't see all the subtilities of your examples.

    Anyway (as I already told you) if this could be usefull for you and that it won't "destroy" present fonctionnalities of TinyBootloader, you can modify everything you want: I trust you.

    Best regards,
    Edorul

     
  • Dan

    Dan - 2013-07-27

    Dear Edorul.

    Thank you very much for the warm words.

    It's clear the PCLAT at the exit of the bootloader it was impossible in the PIC other than the extended mid-range PIC.

    I attach the new firmware of the extended mid-range PIC.

    It has been tested by using the PIC16F1827.

    I normally does not require that a clear PCLAT in the first four words in the extended mid-range PIC.

    Best regards,
    Dan

     
  • Dan

    Dan - 2013-07-28

    Dear Edorul.

    I have tested the end of the ATMEGA88 and ATMEGA48.

    Bootloader, but I worked flawlessly,

    I encountered a bug EEPROM (the EEP file) is not writable by the ATMEGA48.
    HOST to be down.

    This symptom occurs only with ATMEGA48.

    Sample program of ATMEGA48,

    EEP file is identical erase_EEPROM_demo and EEPROM_dump_demo, source code, but is almost together,

    For some reason, It can not write the EEPROM when load the erase_EEPROM_demo.hex.

    I attach the log.

    Take a look here as well, but will report again if I see something.

    Best regards,
    Dan

     
  • edorul

    edorul - 2013-07-28

    Hello Dan!

    Thank for the many modified PIC16 firmwares!

    For the ATmega48 EEPROM problem, I think I've found where it does come from.
    The line:

    :03010000517283B6
    

    tell 0x51 must be put at address 0x100, 0x72 at 0x101, 0x83 at 0x102
    but 0x100 = 256 and ATmega48 EEPROM size is only 256, so the data values are put outside the "picEEPROM" array variable.

    Best regards,
    Edorul

     
  • Dan

    Dan - 2013-07-28

    Dear Edorul.

    Reviews of bugs ATMEGA48 program was my mistake.

    There is no bug in the host program.

    I'm sorry.

    (Since it was set EEPROM data to a location beyond the capacity.)

    Best regards,
    Dan

     
  • Dan

    Dan - 2013-07-29

    Dear Edorul.

    I'd like a modification of the host program.(shown in //@1)

    reason:
    Mistake the value of zl register is the first instruction of the source to change the zl register.

    Then How can this partial,
    Do you be correctly detection of the Error code "N" in the format?

                if (((returnedValue >= 0x30) && (returnedValue <= 0x39)) // 0 to 9
                    || ((returnedValue >= 0x41) && (returnedValue <= 0x5A))) // A to Z
    

    Best regards,
    Dan

     
  • edorul

    edorul - 2013-07-29

    Hello Dan!

    You're right, the correct code is:

    // CRC OK code is the device Family (or 'K' for old firmwares). 'N' is for CRC error
    if (((returnedValue >= 0x30) && (returnedValue <= 0x39)) // 0 to 9
        || ((returnedValue >= 0x41) && (returnedValue <= 0x5A) && (returnedValue != 0x4E))) // A to Z (except 'N' as it can't be a Family, it's only for CRC error)
    

    Thanks for the bug report :-)

    best regards,
    Edorul

     
  • Dan

    Dan - 2013-07-30

    Dear Edorul.

    I re-update the firmware of the extended mid-range pic.

    Sorry to trouble you, but please give me an update.

    I apologize for the inconvenience, thank you.

    I'm sure in PIC16f1827 PIC16F1507 and the working.

    Best regards,
    Dan

     
  • edorul

    edorul - 2013-07-30

    Hello Dan!

    Thanks for the firmwares and the good news about the PIC16F1827 and PIC16F1507 :-)

    Can you explain "please give me an update". Do you want I put TinyBootloader v0.8.0 online? Or I send it to you? Or do you want something else?

    Best regards,
    Edorul

     
  • Dan

    Dan - 2013-07-30

    Dear Edorul.

    I have been incorporated in the new firmware is my opinion.

    http://www3.hp-ez.com/hp/bequest333/page47
    http://www3.hp-ez.com/hp/bequest333/page48

    It is Japanese, but said the idea to this page.

    While we examined the same for pic18 current,
    It does not ask you to update at this time.

    Please, please release the v0.8.0.

    Best regards,
    Dan

     
  • edorul

    edorul - 2013-07-30

    Konbanwa!

    I've took a glance at your web pages and I liked your explications and schematics about how AVR and PIC bootloaders are working. I need to do the same for the TinyBootloader+ documentation, I think I'll copy your work ^_^

    There is no problem, today or tomorrow I'll release the v0.8.0.

    Best regards,
    Edorul

     
  • Carlo DrSurfer

    Carlo DrSurfer - 2013-08-02

    Hello Edorul, I just jumped in, good work!

    I'm currently working on PICs (18F4620 in this moment) and found your work.

    Thanks to your modified firmware, I finally have obtained a custom bootloader for my RS485 based board: it's strictly related to my hardware, so I think it is not interesting for anyone else.

    I've noticed several misspelled words here and there and I think that is totally a waste of time fixing them on my own copy. If you want some help on this side... I'm available. Let me know, eventually on private (my email is on my sourceforge profile page).

    Best regards
    Carlo

     
  • edorul

    edorul - 2013-08-02

    Hello Carlo!

    Thanks a lot for your post and it's with pleasure that I accept your proposal :-)
    How do you want to proceed? Do you want to fix the actual "docs/web site" and when I'll make some modifications I'll send them to you before puting them online?

    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.