• AVR Freaks

18F14K50 diolan botloader port

Author
mad3d
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2010/11/28 14:35:29
  • Location: 0
  • Status: offline
2010/11/28 15:34:50 (permalink)
0

18F14K50 diolan botloader port

Hello,
 
I have been trying to port this bootloader (http://www.diolan.com/pic/bootloader.html) to a 18F14K50 pic, my board do uses 12mhz cristal and I have got others bootloaders working on it without problem ( just got .hex files on those ).
 
I have uploaded my modified diolan source to:
 
http://www.megaupload.com/?d=1NQZT9S8
 
Please, my friends, can you give it a look? I need help on this :(
I have been fighting with this last couple days and Im about to think its not posible, has anyone ported it to 18F2550 without using extended mode ?
Thanks in advance.
#1

6 Replies Related Threads

    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:18F14K50 diolan botloader port 2010/11/29 05:41:04 (permalink)
    0
    The original bootloader on the Diolan site is made on PIC18F4455.
    The USB engine itself is the same on all of PIC18F family. You don't need to touch to USB registers and its operations. But USB BDT (Buffer Descriptor Table) address and USB RAM address/size is unique to each device sub-family. You have to count in this difference on porting.

                  BDT     USB RAM
    PIC18F4455    400h    400h - 7FFh
    PIC18F14K50   200h    200h - 2FFh
    PIC18F2550    400h    400h - 4FFh


    First, build the original one on PIC18F4455
    And look in the map file. the map file gives you a good clues for porting.
    The original one maps USB_BDT at 400h, USB_HID at 500h

                  Section Info
    Section       Type    Address   Location Size(Bytes)
    ...
    USB_BDT      udata   0x000400       data   0x000090
    USB_HID      udata   0x000500       data   0x000080


    The details are given at the Sorted list on the map file
    You have to move (at least) these variables on usb.asm and boot.asm.

                       Symbols - Sorted by Address
              Name    Address   Location    Storage File
         ---------  ---------  ---------  --------- ---------
             ...
             ep0Bo   0x000400       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\usb.asm
             ep0Bi   0x000404       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\usb.asm
             ep1Bo   0x000408       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\usb.asm
             ep1Bi   0x00040c       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\usb.asm
          SetupPkt   0x000410       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\usb.asm
       CtrlTrfData   0x000450       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\usb.asm
    hid_report_out   0x000500       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\boot.asm
     hid_report_in   0x000540       data     extern C:\Working\testtest\bootloader-0.2.2\bootloader\fw\boot.asm


    For PIC18F14K50, the address is remapped as follows. (the size of SetupPkt is shrunk into 8 bytes)
    - ep0Bo          : 200h
    - ep0Bi          : 204h
    - ep1Bo          : 208h
    - ep1Bi          : 20Ch
    - SetupPkt       : 210h
    - CtrlTrfData    : 218h
    - hid_report_out : 258h
    - hid_report_in  : 298h


    On the source code,
    usb.asm

    ;-----------------------------------------------------------------------------
    ; USB Fixed Location Variables
    ; BDT
    USB_BDT        UDATA    0x200  ;;;; 0x400 <--------------- modified
        global    ep0Bo
        global    ep0Bi
        global    ep1Bo
        global    ep1Bi
        global    SetupPkt
        global    CtrlTrfData
    ep0Bo    res    4    ; Endpoint0 BD Out
    ep0Bi    res    4    ; Endpoint0 BD In
    ep1Bo    res    4    ; Endpoint1 BD Out
    ep1Bi    res    4    ; Endpoint1 BD In
    ; Buffers for SETUP and IN packets
    SetupPkt    res    8  ;;;; EP0_BUFF_SIZE    ; SETUP packet buffer <--------------- modified
    CtrlTrfData    res    EP0_BUFF_SIZE    ; IN packet buffer
    ...
    ...
    ...
    ;-----------------------------------------------------------------------------
    ; usb_sm_prepare_next_setup_trf
    ; DESCR : Prepare EP0 for next setup transfer
    ; INPUT : no
    ; OUTPUT: no
    ; Resources:
    ;    FSR2:    BDTs manipulation
    ;-----------------------------------------------------------------------------
        global    usb_sm_prepare_next_setup_trf
    usb_sm_prepare_next_setup_trf
        movlw    USB_SM_CTRL_WAIT_SETUP
        movwf    usb_sm_ctrl_state
        ; BDT configuration
        lfsr    FSR2, ep0Bo
        ; Buffer OUT configuration
        ; BDT CNT
        movlw    8    ;;; EP0_BUFF_SIZE       <--------------- modified
        movwf    PREINC2        ; BDT_CNT(ep0Bo)
        ; BDT ADDR
        movlw    LOW(SetupPkt)
        movwf    PREINC2        ; BDT_ADRL(ep0Bo)
        movlw    HIGH(SetupPkt)
        movwf    PREINC2        ; BDT_ADRH(ep0Bo)



    boot.asm

    ;--------------------------------------------------------------------------
    ; HID buffers
    USB_HID        UDATA    0x258    ;;; 0x500       <--------------- modified
        global    hid_report_out
        global    hid_report_in
    hid_report_out    res    HID_OUT_EP_SIZE    ; OUT packet buffet
    hid_report_in    res    HID_IN_EP_SIZE    ; IN packed buffer



    On the linker script, USB BDT and RAM is taken as the RAM bank at 0x200

    DATABANK   NAME=usb2       START=0x200          END=0x2FF       PROTECTED



    Other than USB, you may need to touch to configuration bits and stack location.

    Tsuneo
    #2
    mad3d
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2010/11/28 14:35:29
    • Location: 0
    • Status: offline
    Re:18F14K50 diolan botloader port 2010/11/30 08:09:02 (permalink)
    0
    Edit:
    Sorry I was not able to see your response my friend.
    Thank you very much!!!!
     
    Can you give me a hand on this stack location retouch?
     
    I will make some tests and let you know.
    Thanks again :)
    post edited by mad3d - 2010/11/30 08:25:41
    #3
    newfound
    Super Member
    • Total Posts : 1822
    • Reward points : 0
    • Joined: 2003/11/07 12:35:49
    • Status: offline
    Re:18F14K50 diolan botloader port 2011/01/19 09:43:45 (permalink)
    0
    chinzei

    The original bootloader on the Diolan site is made on PIC18F4455.
    The USB engine itself is the same on all of PIC18F family. You don't need to touch to USB registers and its operations. But USB BDT (Buffer Descriptor Table) address and USB RAM address/size is unique to each device sub-family. You have to count in this difference on porting.



    Actually yes you do have to change the code for the USB registers as some of these are NOT in the 18F14K50 ACCESS back as they are for the 18F4455.  Therefore you must ensure the BSR is pointing @ page 0xF00 and use the BANKED directive for affected registers.

    Compare the data sheets for USB registers NOT in the ACCESS bank on the 18F14K50. When you have corrected this and made the other changes Tsuneo pointed out then I would expect that you will have some joy.

    If you are still working on this let us know.

    EDIT:

    Affected registers are:

    UADDR
    UEIE
    UEIR
    UEP0-7
    UFRML /UFRMH (N/A)
    post edited by newfound - 2011/01/19 09:49:03
    #4
    daylosh
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2011/12/06 03:48:08
    • Location: 0
    • Status: offline
    Re:18F14K50 diolan botloader port 2011/12/06 04:00:44 (permalink)
    0
    Has anybody been able to get this port working? I'm fairly new to usb (i have a usb low pin count dev board) and i have played around with the microchip examples but i like the idea of the diolan bootloader. I shall implement what has been suggested above and work on it. If anyone has had any joy and wouldn't mind giving a guide it would be much appreciated. Day
    post edited by daylosh - 2011/12/06 04:01:54
    #5
    newfound
    Super Member
    • Total Posts : 1822
    • Reward points : 0
    • Joined: 2003/11/07 12:35:49
    • Status: offline
    Re:18F14K50 diolan botloader port 2011/12/06 09:53:13 (permalink)
    0
    I don't know of anyone doing a port but I cannot imagine that it would be difficult or take long to do.

    The info above looks pretty complete to me. Do the mods as outlined by Tsuneo and add the bank switching for the SPRs that I mentioned.

    You will need to alter the config word as it is not quite the same as for the 18F4455. Just copy what microchip have in the MAL but make sure that the XINST config option is enabled.
     
    #6
    newfound
    Super Member
    • Total Posts : 1822
    • Reward points : 0
    • Joined: 2003/11/07 12:35:49
    • Status: offline
    Re:18F14K50 diolan botloader port 2011/12/09 22:09:44 (permalink)
    0
    Stop press!

    The above only address the changes required to the USB portion. There are changes required for the bootloader proper as the write page size is smaller on the PIC18F14K50.  Copy this over the existing "write_code_loop" block in boot_asm.asm:


    #define BootWriteSizeMask 0x0f

    write_code_loop
            movff   POSTINC0, TABLAT
            tblwt+*                 ; *(++Holding_Register) = *data++
            movf    hold_r, W
            incf    hold_r          ; hold_r++
            andlw   BootWriteSizeMask
            xorlw   BootWriteSizeMask
            btfsc   STATUS,Z
           

            rcall   flash_write     ;     write_flash       Dump Holding Area to Flash
            decfsz  cntr
            bra     write_code_loop
           
            tstfsz  hold_r          ; if( hold_r != 0 )     Holding Area not dumped
            rcall   flash_write     ;       write_flash     Dump Holding Area to Flash
            return


    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5