Open source PBP bootloader


Closed Thread
Results 1 to 40 of 41

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Open source PBP bootloader

    Quote Originally Posted by mister_e View Post
    Hint: ASM ORG & PBP (see mostcompilers) are poor bedfellows when you don't know why and how they interract.
    Well I must admit not knowing. I know it makes no sense to use it in this way, I know PBP won't be paying attention to it, therefore probable conflicts will arrise.
    Plausible solution, compile without ORG, use the HEX to get the ASM code, then add some ORG & GOTO, recompile the asm and try to make it work
    This sounds like a quick fix not in line with the intention of this project.
    Still Plausible: Hack a .LIB and or .INC to use Labels in your Bootloader code instead of ORG.
    If we can have the hack as part of the "package" maybe. Right now it seems more then too much to ask folks to rem out config lines

    Lots of possibilities, my favourites being 100% pure ASM.
    we already have that. The purpose here is to try and make a PBP bootloader, for all to use and abuse.

    Thanks for pointing in the direction of the first of many (maybe) problems. I feel like I saw something in the PBP bible about defining code locations, but it is at work
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Open source PBP bootloader

    Well, there's an easy alternative. Compile your bootloader without ORG, see how much code space it needs. Once you know it, add an ORG at the END of your bootloader + Label. Your bootloader must jump to this Label when it exit.

    Code:
    'bootloader code here
    Goto GetOutOfHere
    
    @ ORG WhateverYouDecide 
    GetOutOfHere:
    Now when you want to use the bootloader, in your application code you need to use DEFINE RESET_ORG... and Period.

    Code:
    DEFINE RESET_ORG WhateverYouDecide
    ' and your application code goes there
    Now go figure how interrupt will work and how to integrate it, have fun!
    http://www.picbasic.co.uk/forum/show...1662#post31662

    Readme.txt:
    ORG Define

    It may sometimes be useful to move the start of the generated code to a
    location other than 0. This can be used to move the program code beyond
    a boot loader, for example. A Define has been added to the compiler to
    allow a different reset address to be specified for the 14-bit core PIC
    MCUs and the PIC18 parts.

    Define RESET_ORG 100h

    This Define moves the starting location of the program, the reset vector,
    to the specified address. The interrupt vector(s) follow at their usual
    offset, followed by the library and program code.

    For 14-bit core devices with more than 2K of code space, only interrupts
    in assembler may be used. On Interrupt will not work properly if the
    device has more than 2K of code space and RESET_ORG is not 0. For
    assembler interrupts in a device with more than 2K of code space and
    RESET_ORG something other than 0, the values of W, STATUS and PCLATH must
    be saved by whatever program now resides at the PIC MCU's fixed vector
    locations before the jump to the new vector location. In general, the
    save locations are named wsave, ssave and psave. The information on these
    save locations should be provided with the boot loader or whatever program
    requires the altered origination so that the register values may be restored
    at the end of interrupt processing.

    For 14-bit enhanced core devices with more than 2K of code space,
    On Interrupt may be used but the values of W, STATUS and PCLATH must not be
    changed to get to the interrupt vector as they will not be restored upon
    return from the interrupt. This usually means bra will be used to jump to
    the new interrupt vector location. Interrupts in assembler do not require
    any special treatment.

    Either 14-bit core PBP library must fit into the first 2K of code space.
    The PIC18 PBP library must fit into the first 32K of code space. It is best
    for RESET_ORG to start on an even 256 word boundary.
    Last edited by mister_e; - 7th March 2011 at 04:05. Reason: link
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default Re: Open source PBP bootloader

    Are you just converting the exsisting serial bootloader over to PBP? I had thought you were going to make a new bootloader from scratch in pure PBP.

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Open source PBP bootloader

    The goal is a new one using pure PBP. To get me started, I am attempting to convert the existing Microchip serial one, AN851. For me this does 2 things, it has shown me just how the guts of the BL work, and I thought by starting there, we are able to test the GUI with it.

    To that end, I do have a much better feel for how they work, at least this one. So we can make this work and build onto it, or start over with a completly new one. No matter to me
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Open source PBP bootloader

    If you want to get the code to compile, rem the first 2 @org's. change the last to to 800 and 808. These need to be changed anyway as I think they were not far enough in memory.

    I have been digesting what Steve has pointed to. My understanding is this: I need to let PBP take care of memory!! The first @ORG is un-needed as PBP will place the code at 00 anyway. So that just needs to be deleted. I think the for the interrupt redirect, we just need a
    Code:
     DEFINE INTHAND NewIntLocation
    then in our application code:

    Code:
    DEFINE RESET_ORG 800
       GOTO Start ' or whatever you favorite label is
    NewIntLocation:
       Do your Interrupt thing
    
    Start:
       Code till your hearts content, (or MEM is full)
    So if I am correct, the only thing left is context saving in the real interrupt vector before jumping.

    Now as for the rest of the code, I need some help here. I have a crazy mix of PBP commands and direct register addressing. I want to get rid of the direct addressing. This is really bad in the comm part. Do we want to use HSERIN/OUT or SERIN/OUT. I think using SER would be nicer in the aspect we can then use any pins to do this, and have control over true vs inverted signals. It will also be a trivial matter to use I2C instead of SER using the bit-bang approach.

    Let me just throw in my opinion here, speed is NOT the issue. This is a bootloader, It will not be used often once your app is done.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: Open source PBP bootloader

    I need to create bootloader for PIC18F that program flash from external I2C memory, eg 24lc512.
    I'll probably write bootloader in pbp and asm.

    If I understand correctly how bootloader works, there is 2 ways to implement bootloader.
    -One is to make bootloader that sits on beginning of flash, then on address 4 and 8, need to be GOTO to new int vector. That will add one more GOTO before executing int, PBP already add one. I don't like that GOTO's.
    -Other option is that first instruction in flash is GOTO Bootloader, and to put bootloader on end of flash. Then there is no need to remap interrupt. When bootloader finish job, then GOTO 1
    In main program only need to remap reset vector to 1.
    Am I understand how it works?

    For now I'll create LED blink program, that use bootloader with reset vector at 1.
    And then try to make bootloader that will program that hex to flash. For start hex will be in LOOKUP2, until I get flesh erase and write to work, then comunication...

    Probably I should start with analyzing syntax of hex file.

    Is there anyone interested and willing to help?

  7. #7
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: Open source PBP bootloader

    Edit timeout...
    Address for int are 8 and 24, and GOTO takes 2 program word so, reset org should be 4.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts