Menu

dsPIC30 Bootloader

Dan
2014-06-14
2018-05-26
1 2 > >> (Page 1 of 2)
  • Dan

    Dan - 2014-06-14

    Hi,All

    I was successful in writing flash of dsPIC30.

    I verified the Config and EEPROM current.

    Contributions Once I have completed.

    I think to become a template for 24/24H/dsPIC33.

     

    Last edit: Dan 2014-06-14
  • Dan

    Dan - 2014-06-16

    Hi,All

    dsPIC30 corresponding version was completed.

    I attach the host program.

    and ds30F3012's firmware.

    and ds33FJ128GP202's firmware.

    (If you create the firmware, also corresponds to the writing of the PIC24.)

    My Change: //$nn

    Details of the changes described in the ReadMe.txt

     

    Last edit: Dan 2014-06-18
  • Dan

    Dan - 2014-06-18

    Hi,All

    I was able to operate also confirmed PIC24HJ12GP202.

    Corresponding to the D type is almost complete.

     
  • Dan

    Dan - 2014-06-18

    Hi,All

    Distinction of the E-type and D-type.

    Relationship with the E-type and D-type is similar to the relationship of PIC18J and PIC18.

    "Frash Config Words" does not exist in the D-type.

    [Device corresponding to the D-type]
    dsPIC30F
    PIC24F
    PIC24FV
    PIC24HJ
    PIC24E(Partial)
    dsPIC33F(Partial)
    dsPIC33E(Partial)

    [Device corresponding to the E-type]
    PIC24FJ
    PIC24E(Partial)
    dsPIC33F(Partial)
    dsPIC33E(Partial)

     

    Last edit: Dan 2014-06-18
  • Dan

    Dan - 2014-06-21

    Hi,All

    Modified the host program, I also support E-Type.

    I attach the firmware and modified version host program.

    The host program the previous presentation, reset by the RTS was disabled.
    (Reset by the DTR is enabled.)
    ------------->
    I was back to the original specification in a modified version of this.

    Source Changes:
    //$nn ---> //$#nn

     
  • Dan

    Dan - 2014-06-23

    Hi,All

    Because I can cope with PIC device of all the Tiny AVR/PIC Bootloader+,
    for data transfer format, I will summarize here.

    Action command does not exist in Tiny AVR/PIC Bootloader+.
    Rather than a command from the host side, perform firmware is necessary to erase flash memory.

    1.The type of data transfer

    There are three data to be transferred from Tiny AVR/PIC Bootloader+ host.

    ①Flash Data
    ②EEPROM Data
    ③Config Data (24-bit PIC and PIC18F)

    Represents the character of one byte [] below.

    2.Data format of 14-bit PIC (PIC10F/12F/16F), "B"-Family

    ①Flash transfer format:
    [AddressH][AddressL][2*N][DataL(1)][DataH(1)]....[DataL(N)][DataH(N)][SUM]

    [AddressH] Start address of the flash page to override the data. (upper)
    [AddressL] Start address of the flash page to override the data. (lower)
    [2*N] Number of transfers of data as described in piccode.ini. (byte notation)
    [DataL/H(n)] Rewrite data (2*N)bytes.
    [SUM] Checksum.

    ②EEPROM transfer format:
    [EEAddressH][EEAddressL][2][EEData][0][SUM]

    [EEAddressH] Address of the EEPROM to override the data | 0x40 (upper)
    [EEAddressL] Address of the EEPROM to override the data. (lower) EEAddressH:EEAddressL >= 0x4000
    [2] Number of data transfers. (Always 2)
    [EEData] EEPROM 8-bit data to be rewritten.
    [0] Always 0.
    [SUM] Checksum.

     
  • Dan

    Dan - 2014-06-23

    3.Data format of 16-bit PIC (PIC18F), "C"-Family

    ①Flash transfer format:
    [AddressU][AddressH][AddressL][2*N][DataL(1)][DataH(1)]....[DataL(N)][DataH(N)][SUM]

    [AddressU] Start address of the flash page to override the data. (upper)
    [AddressH] Start address of the flash page to override the data. (middle)
    [AddressL] Start address of the flash page to override the data. (lower)
    [2*N] Number of transfers of data as described in piccode.ini. (byte notation)
    [DataL/H(n)] Rewrite data (2*N)bytes.
    [SUM] Checksum.

    ②EEPROM transfer format:
    [EEAddressU][EEAddressH][EEAddressL][1][EEData][SUM]

    [EEAddressU] Address of the EEPROM to override the data | 0x40. (upper)
    [EEAddressH] Address of the EEPROM to override the data. (middle)
    [EEAddressL] Address of the EEPROM to override the data. (lower)
    EEAddressU:EEAddressH:EEAddressL >= 0x400000
    [1] Number of data transfers. (Always 1)
    [EEData] EEPROM 8-bit data to be rewritten.
    [SUM] Checksum.

    ③Config transfer format:
    [CFGAddressU][CFGAddressH][CFGAddressL][14][CFGDataL(1)][CFGDataH(1)].....[CFGDataL(7)][CFGDataH(7)][SUM]

    [CFGAddressU] Start address of the Config data to overwrite the data | 0x80. (upper)
    [CFGAddressH] Start address of the Config data to overwrite the data. (middle)
    [CFGAddressL] Start address of the Config data to overwrite the data. (lower)
    CFGAddressU:CFGAddressH:CFGAddressL >= 0x800000
    [14] Number of data transfers. (Always 14)
    [CFGData(n)] Rewrite data (2*7)bytes.
    [SUM] Checksum.

    4.Data format of 16-bit PIC (PIC18F-J), "J"-Family

    ①Flash transfer format:
    [AddressU][AddressH][AddressL][2*N][DataL(1)][DataH(1)]....[DataL(N)][DataH(N)][SUM]

    [AddressU] Start address of the flash page to override the data. (upper)
    [AddressH] Start address of the flash page to override the data. (middle)
    [AddressL] Start address of the flash page to override the data. (lower)
    [2*N] Number of transfers of data as described in piccode.ini. (byte notation)
    [DataL/H(n)] Rewrite data (2*N)bytes.
    [SUM] Checksum.

    ②Config transfer format:
    [CFGAddressU][CFGAddressH][CFGAddressL][8][CFGDataL(1)][CFGDataH(1)].....[CFGDataL(4)][CFGDataH(4)][SUM]

    [CFGAddressU] Start address of the Config data to overwrite the data | 0x80. (upper)
    [CFGAddressH] Start address of the Config data to overwrite the data. (middle)
    [CFGAddressL] Start address of the Config data to overwrite the data. (lower)
    CFGAddressU:CFGAddressH:CFGAddressL >= 0x800000
    [8] Number of data transfers. (Always 8)
    [CFGData(n)] Rewrite data (2*4)bytes.
    [SUM] Checksum.

     
  • Dan

    Dan - 2014-06-23

    5.Data format of 24-bit PIC, "D"-Family

    ①Flash transfer format:
    [AddressL][AddressH][AddressU][3*N][DataL(1)][DataH(1)][DataU(1)]....[DataL(N)][DataH(N)][DataU(N)][SUM]

    [AddressL] Start address of the flash page to override the data. (lower)
    [AddressH] Start address of the flash page to override the data. (middle)
    [AddressU] Start address of the flash page to override the data. (upper)
    [3*N] Number of transfers of data as described in piccode.ini. (byte notation)
    [DataL/H/U(n)] Rewrite data (3*N)bytes.
    [SUM] Checksum.

    ②EEPROM transfer format:
    [EEAddressL][EEAddressH][EEAddressU][2][EEDataL][EEDataH][SUM]

    [EEAddressL] Address of the EEPROM to override the data (lower).
    [EEAddressH] Address of the EEPROM to override the data (middle).
    [EEAddressU] Address of the EEPROM to override the data (upper).
    [2] Number of data transfers. (Always 2)
    [EEDataL/H] EEPROM 16-bit data to be rewritten.
    [SUM] Checksum.

    ③Config transfer format:
    [CFGAddressL][CFGAddressH][CFGAddressU][18][CFGDataL(1)][CFGDataH(1)].....[CFGDataL(9)][CFGDataH(9)][SUM]

    [CFGAddressL] Start address of the Config data to overwrite the data. (lower)
    [CFGAddressH] Start address of the Config data to overwrite the data. (middle)
    [CFGAddressU] Start address of the Config data to overwrite the data. (upper)
    [18] Number of data transfers. (Always 18)
    [CFGDataL/H(n)] Rewrite data (2*9)bytes.
    [SUM] Checksum.

    6.Data format of 24-bit PIC, "E"-Family

    ①Flash transfer format:
    [AddressL][AddressH][AddressU][3*N][DataL(1)][DataH(1)][DataU(1)]....[DataL(N)][DataH(N)][DataU(N)][SUM]

    [AddressL] Start address of the flash page to override the data. (lower)
    [AddressH] Start address of the flash page to override the data. (middle)
    [AddressU] Start address of the flash page to override the data. (upper)
    [3*N] Number of transfers of data as described in piccode.ini. (byte notation)
    [DataL/H/U(n)] Rewrite data (3*N)bytes.
    [SUM] Checksum.

    ②Config transfer format:
    [CFGAddressL][CFGAddressH][CFGAddressU][30][CFGDataL(1)][CFGDataH(1)][CFGDataU(1)].....[CFGDataL(10)][CFGDataH(10)][CFGDataU(10)][SUM]

    [CFGAddressL] Start address of the Config data to overwrite the data. (lower)
    [CFGAddressH] Start address of the Config data to overwrite the data. (middle)
    [CFGAddressU] Start address of the Config data to overwrite the data. (upper)
    [30] Number of data transfers. (Always 30)
    [CFGDataL/H/U(n)] Rewrite data (3*10)bytes.
    [SUM] Checksum.

     

    Last edit: Dan 2014-06-24
  • edorul

    edorul - 2014-07-02

    Hello Dan!

    Thanks a lot for the new "D" and "E" families support in TinyBootloader+, the new firmwares and all the updates you made! You're great!!! I hope we'll meet one day :-)

    So, by now I'm gathering everything from your posts and I'll post a v0.9.0 with all your addons.

    Best regards,
    Edorul

     
  • Steven Nelson

    Steven Nelson - 2016-10-03

    I downloaded the code looking for the (partial) support of the dsPIC33E chips, and under the Type D folder, there are no files! Did these get dropped somewhere?
    I've been trying to modify MicroChip's dsPIC33E bootloaders, but have had little success--was hoping that Tiny Multi Bootloader+ might be the answer...

     
  • Dan

    Dan - 2016-10-04

    Hi,Nelson
    Please look for the following fofolders.

    Tiny_Avr-Pic_Bootloader+ (v0.9.0)
    Tiny Multi Bootloader+ (v0.10.0)

    Best regards,
    Dan

     
  • Ayinde Olayiwola

    Hi Dan, i have been trying for months on increasing the TinyBootloader size from 100words to about 200words for PIC18, what do i need to change in the code and PC Software?

     
    • Anobium

      Anobium - 2018-05-24

      Why? Same question.

       
  • Dan

    Dan - 2018-05-24

    Hi,

    1. Firmware size can not be freely selected.
      If the erase/write unit is 16 words
      84, 100, 116, 132 ...
      If the erase/write unit is 32 words
      100, 132, 164, ....
      If the erase/write unit is 64 words
      132, 196, .........

    Please make it to be N x U + 4 for erase/write unit U. (N = 1, 2, 3, ....)

    2.Change piccodes.ini
    Even if the corresponding device already exists, assign another number.
    The following is an example of PIC10F322

    ; PIC10 family
    ; example: PIC10F322 Flash: 512 words = 200h; 200h*2 = 400h
    ;-----------
    $11, B, 10F 322 (100W), $400, $000, default, 32,
    $12, B, 10F 322 (84W), $400, $000, 168, 32,

     
  • Ayinde Olayiwola

    Thank you Dan, That information was very helpful, so i can adjust the firmware size from the piccodes.ini only or do i need to change any other thing in the PC software?

    i really appreciate your reply.

     
  • Ayinde Olayiwola

    Hello Dan, please write an example for PIC16F877 to be firmware size to about 132 words

    ; PIC16 family
    ; example: PIC16F877 Flash: 8192 words = 2000h; 2000h*2 = 4000h
    ;-----------
    $31, B, 16F 876/877/876A/877A, $4000, $100, default, default,

     
  • Dan

    Dan - 2018-05-25

    exsample
    $40, B, 16F 876/877/876A/877A, $4000, $100, 264, default,

    $00 < NUMBER =< $FF

     

    Last edit: Dan 2018-05-25
  • Ayinde Olayiwola

    Hello Dan, Thank You for your replies, but when i inserted the example you gave to me and try to write into the MCU, i still get this error messages "Error: hex file too large, writing bootloader firmware!!!
    * Error: problem in writing MCU memory!!!"

     
  • Dan

    Dan - 2018-05-25

    Hi

    Error: hex file too large, writing bootloader firmware!!!
    * Error: problem in writing MCU memory!!!"

    Is the upper limit of HEX file 0x1F7B or less?

    Does this work?

    $40, B, 16F 886/887/876A/877A/876/877(132w), $4000, $100, 264, 32,

    ext clock 8MHz
    19200 bpr

     

    Last edit: Dan 2018-05-25
  • Ayinde Olayiwola

    Thank you Dan, i will check and give reply soon.

     
  • Ayinde Olayiwola

    I still get the same error messages, i found out that your code is still running on 20MHz even when the xtal is 8MHz

    xtal EQU 8000000 ; you may also want to change: _HS_OSC _XT_OSC
    baud EQU 19200 ; standard TinyBld baud rates: 115200 or 19200

    Receive:
    movlw xtal/2000000+2 ;for 20MHz => 11 => 1second
    movwf cnt1

     
  • Ayinde Olayiwola

    I imported my code to PIC18F452
    Here is the Hex File

    :020000040000FA
    :04000000AAEF3FF034
    :047F4C000000000031
    :107F500000000000240EAC6E0A0EAF6E900EAB6EE9
    :107F600041D8C1084EE1410EAD6E4B0EAD6E006AB8
    :107F700039D8F86E076E36D8F76E34D8F66EA96E1B
    :107F800031D8016E012A00EE09F0F56E2BD8EC6EA7
    :107F900001A0A86E012EF9D7006619D007AC03D056
    :107FA000040E18D812D0940E15D80A00080E056ECB
    :107FB00000EE0AF0080E066EEE50F56E0F00062E6B
    :107FC000FBD7840E07D8052EF5D7A694CED74E0E34
    :107FD000AD6ECDD7A66E550EA76EAA0EA76EA68261
    :107FE000000012000B0E026E036A046A9EAA03D000
    :107FF000AE5000261200042EF9D7032EF6D7022E1B
    :06800000F3D7AB9EA3D7ED
    :020000040030CA
    :04000000FFFAFEFE07
    :02000600FBFFFE
    :00000001FF
    
     
  • Ayinde Olayiwola

    my ASM code

        radix DEC
        LIST P=18F452
        ; change these lines accordingly to your application    
    #include "p18f452.inc"
    IdTypePIC = 0x41            ; must exists in "piccodes.ini"
    #define max_flash 0x8000    ; in BYTES!!! (= 'max flash memory' from "piccodes.ini")
    xtal EQU 20000000       ; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
    baud EQU 115200         ; standard TinyBld baud rates: 115200 or 19200
        ; The above 5 lines can be changed and buid a bootloader for the desired frequency (and PIC type)
    
        ;********************************************************************
        ;   Tiny Bootloader     18F series      Size=100words
        ;   claudiu.chiculita@ugal.ro
        ;   http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm
        ; 
        ; modified by Edorul:
        ; EEPROM write is only compatible with "Tiny PIC Bootloader+"
        ; http://sourceforge.net/projects/tinypicbootload/
        ;********************************************************************
    
        #include "spbrgselect.inc"  ; RoundResult and baud_rate
    
            #define first_address max_flash-180     ;100 words changed from 200
    
            __CONFIG    _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
            __CONFIG    _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_ON_2L
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
            __CONFIG    _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    
    ;----------------------------- PROGRAM ---------------------------------
        cblock 0
        crc
        i
        cnt1
        cnt2
        cnt3
        counter_hi
        counter_lo
        flag
        endc
        cblock 10
        buffer:64
        dummy4crc
        endc
    
    SendL macro car
        movlw car
        movwf TXREG
        endm
    
    ;0000000000000000000000000 RESET 00000000000000000000000000
    
            ORG     0x0000
            GOTO    IntrareBootloader
    
    ;view with TabSize=4
    ;&&&&&&&&&&&&&&&&&&&&&&&   START     &&&&&&&&&&&&&&&&&&&&&&
    ;----------------------  Bootloader  ----------------------
    ;PC_flash:      C1h             U       H       L       x  ...  <64 bytes>   ...  crc   
    ;PC_eeprom:     C1h             40h   EEADRH  EEADR     1       EEDATA  crc                 
    ;PC_cfg         C1h         U OR 80h    H       L       1       byte    crc
    ;PIC_response:     type `K`
    
        ORG first_address                       ;space to deposit first 4 instr. of user prog.
        nop
        nop
        nop
        nop
        org first_address+8
    
    IntrareBootloader
                                ;init serial port
        movlw b'00100100'
        movwf TXSTA
        movlw spbrg_value
        movwf SPBRG
        movlw b'10010000'
        movwf RCSTA
                                ;wait for computer
        rcall Receive           
        sublw 0xC1                      ;Expect C1h
        bnz way_to_exit  
        SendL IdTypePIC                         ;send PIC type
    MainLoop
        SendL 'K'               ; "-Everything OK, ready and waiting."
    mainl
        clrf crc
        rcall Receive           ;Upper
        movwf TBLPTRU
            movwf flag          ;(for EEPROM and CFG cases)
        rcall Receive           ;Hi
        movwf TBLPTRH
        rcall Receive           ;Lo
        movwf TBLPTRL
            movwf EEADR         ;(for EEPROM case)
    
        rcall Receive           ;count
        movwf i
        incf i
        lfsr FSR0, (buffer-1)
    rcvoct                      ;read 64+1 bytes
            movwf TABLAT        ;prepare for cfg; => store byte before crc
        rcall Receive
        movwf PREINC0
        btfss i,0       ;don't know for the moment but in case of EEPROM data presence...
            movwf EEDATA        ;...then store the data byte (and not the CRC!)
        decfsz i
        bra rcvoct
    
        tstfsz crc              ;check crc
        bra ziieroare
            btfss flag,6        ;is EEPROM data?
            bra noeeprom
            movlw b'00000100'   ;Setup eeprom
            rcall Write
            bra waitwre
    noeeprom
    ;----no CFG write in "Tiny PIC Bootloader+"
    ;       btfss flag,7        ;is CFG data?
    ;       bra noconfig
    ;       tblwt*              ;write TABLAT(byte before crc) to TBLPTR***
    ;       movlw b'11000100'   ;Setup cfg
    ;       rcall Write
    ;       bra waitwre
    ;noconfig
    ;----
                                ;write
    eraseloop
        movlw   b'10010100'     ; Setup erase
        rcall Write
        TBLRD*-                 ; point to adr-1
    
    writebigloop    
        movlw 8                 ; 8groups
        movwf counter_hi
        lfsr FSR0,buffer
    writesloop
        movlw 8                 ; 8bytes = 4instr
        movwf counter_lo
    writebyte
        movf POSTINC0,w         ; put 1 byte
        movwf TABLAT
        tblwt+*
        decfsz counter_lo
        bra writebyte
    
        movlw   b'10000100'     ; Setup writes
        rcall Write
        decfsz counter_hi
        bra writesloop
    waitwre 
        ;btfsc EECON1,WR        ;for eeprom writes (wait to finish write)
        ;bra waitwre            ;no need: round trip time with PC bigger than 4ms
    
        bcf EECON1,WREN         ;disable writes
        bra MainLoop
    
    ziieroare                   ;CRC failed
        SendL 'N'
        bra mainl
    
    ;******** procedures ******************
    
    Write
        movwf EECON1
        movlw 0x55
        movwf EECON2
        movlw 0xAA
        movwf EECON2
        bsf EECON1,WR           ;WRITE
        nop
        ;nop
        return
    
    Receive
        movlw xtal/2000000+1    ; for 20MHz => 11 => 1second delay
        movwf cnt1
    rpt2                        
        clrf cnt2
    rpt3
        clrf cnt3
    rptc
            btfss PIR1,RCIF         ;test RX
            bra notrcv
            movf RCREG,w            ;return read data in W
            addwf crc,f             ;compute crc
            return
    notrcv
        decfsz cnt3
        bra rptc
        decfsz cnt2
        bra rpt3
        decfsz cnt1
        bra rpt2
        ;timeout:
    way_to_exit
        bcf RCSTA,  SPEN            ; deactivate UART
        bra first_address
    ;*************************************************************
    ; After reset
    ; Do not expect the memory to be zero,
    ; Do not expect registers to be initialised like in catalog.
    
                END
    
     
  • Dan

    Dan - 2018-05-25

    Is your target 16F, 18F?

    Code made with 18f can not flow to 16F.

     
  • Ayinde Olayiwola

    I already changed the code back on 16F but its still conplaining about the same error,

    Initially the PC Software couldn't detect the MCU, then i detected this in the code

    MainLoop:
    movlw 'B'

    but now it was able to detect the MCU when i changed it back to
    

    MainLoop:
    movlw 'K'

    the problem is that it still conplain of memory even when 
      `#define first_address max_flash-132 ; 132 word in size`
    

    i really appreciate your replies

     
1 2 > >> (Page 1 of 2)

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.