News:

;) This forum is the property of Proton software developers

Main Menu

Help with bootloader only working up to 0x7fff

Started by PicNoob, Jan 02, 2025, 01:44 AM

Previous topic - Next topic

PicNoob

Happy new year!

I'm sure I'm missing something obvious here but I've been staring at this code for awhile now and don't see the issue. It works great up to 128 blocks, but doesn't write over that. At first I thought the issue was with the compiler on the 18F26K80 when the program got over 0x7fff, but after hours of debugging finally did a manual chip read and noticed blocks after 0x7fff missing.


Quote'--------------------------------------------------------------------------------------------------------------------------------------------------------
FLASH_WRITE:

    'Start at data address 0x800
        TBLPTRU = 0     'xx000000
        TBLPTRH = 8     '00000010
        TBLPTRL = 0     '00000000
                       
    Repeat
         
         'Transmit direction to start a block of 64
            HRSOut 70
           
           
        'Load data from USART to buffer
            Timer0 = 0 
            T0IF = 0
                                       
            For index = 0 To 63
                While serial_in_count = serial_in_count2 And T0IF = 0 : Wend 'wait for next data byte or timeout         

                If T0IF = 1 Then 'Error: transmission unexpectedly terminated
                    Return
                Else
                    buffer[index] = serial_in[serial_in_count2]
                    Inc serial_in_count2
                    If serial_in_count2 > 74 Then
                        serial_in_count2 = 0
                    EndIf
                    Timer0 = 0
                EndIf
            Next
 
                               
        'Start at ram address 32 (buffer address)
            @Lfsr 0,0x100   
       
          'Write a block of 64 bytes (8 blocks of 8 bytes)
            @tblrd *-
            For index = 0 To 7
                For index2 = 0 To 7
                  TABLAT = POSTINC0
                    @tblwt +*         
                Next
                EECON1 = %10000100
              EECON2 = 0x55
              EECON2 = 0xAA
                EECON1.1 = 1
            Next
            @tblrd *+
                                                     
   
    Until TBLPTRH = 255 'end of code space
       
    'Disable self-modifying ability before leaving
    EECON1.2 = 0
                     
Return

PicNoob

Ugh embarrassed to say I found the cause and it turns out the boot loader code above is perfectly fine. Issue came down to an int16 instead of int32 assignment in my interface for loading firmware.

I'll leave the post up for posterity if anyone needs help with good boot loader code for an 18F series. :)

Frizie

I myself use the Tiny Multi Bootloader+ (TBL+) for 18F45K22 PICs with complete satisfaction  :D
Ohm sweet Ohm | www.picbasic.nl

Craig

#3
Frizie Did you download that from sourceforge?
What I saw which I found rather interesting is that Evan Venn seems to be involved with the Tiny Multi bootloader project.
It looks very promising with many new devices supported!

Frizie

#4
I had Evan Venn set up a Tiny Multi Bootloader+ (= TBL+) to my specifications for the 18F45K22.
TBL+ is a very small bootloader (less than 100 words) that works 100%  :D

I placed the TBL+ editor as a plugin in the Positron Editor.
After compiling, pressing the TBL+ plugin at the top of the Positron Editor is enough to shoot the .HEX of the Positron PIC Basic program with the bootloader into the PIC (so without using a PIC programmer).

You only need a PIC programmer once (to first program the bootloader in the PIC), after that the PIC can always be programmed without a programmer  ;D

More info on Evans site:
https://pickitplus.co.uk/Typesetter/index.php/TinyBootLoader%2B-BootLoader
Ohm sweet Ohm | www.picbasic.nl

PicNoob

#5
Quote from: Frizie on Jan 03, 2025, 09:29 AMI myself use the Tiny Multi Bootloader+ (TBL+) for 18F45K22 PICs with complete satisfaction  :D

I must run lots of I/O while in the bootloader so custom was the only way to go. But I'm also taking up around 1400 bytes on my latest version. 200 bytes sounds really small!