CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CDC bootloader 18F67j50 [Solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

CDC bootloader 18F67j50 [Solved]
PostPosted: Thu Jul 11, 2019 8:24 pm     Reply with quote

Hi! im using the example cdc bootloader from CCS. Compiler version 5.046.

The bootloader works fine, the firmware that i need to load over usb works fine with no bootloader too.

The thing is, that when i include the usb_bootloader.h on the code, compile it and then load it using the bootloader, the code does not work properly...

The board has a 128x64 lcd, and with the code loaded using the bootloader, the words and drawings have some errors... and some functions doesnt work...

I will read the hex file using pickit to see if there any error on the loaded hex...

Any hint?

(SORRY FOR MY INGLISH).
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Thu Jul 11, 2019 10:45 pm     Reply with quote

Ok, here's an update... the hex files downloaded from the pic using pickit seems ok...

But, in the loaded code, if I comment the interrupts, the code runs fine... could be an error on the ORG statements used on the usb bootloader? I didn't change them.

Code:

#define LOADER_START       (0)
#define LOADER_SIZE        (0x2000)

#if defined(__USB_87J50__)
 #define APPLICATION_END    (getenv("PROGRAM_MEMORY")-9) //configuration bits
#elif defined(__PCD__)
 #define APPLICATION_END    (getenv("PROGRAM_MEMORY")-2)
#else
 #define APPLICATION_END    (getenv("PROGRAM_MEMORY")-1)
#endif

#if defined(__PCM__)
   #define LOADER_END      (LOADER_SIZE+0x40-1)
#elif defined(__PCH__)
   #define FLASH_SIZE getenv("FLASH_ERASE_SIZE")
   #if (((LOADER_SIZE) % FLASH_SIZE) == 0 )       //IF LOADER_SIZE is even flash boundary
      #define LOADER_END   (LOADER_SIZE-1)
   #else                                  //ELSE, goto next even boundary
      #define LOADER_END   (((LOADER_SIZE)+FLASH_SIZE-((LOADER_SIZE)%FLASH_SIZE))-1)
   #endif
#elif defined(__PCD__)
   #define FLASH_SIZE getenv("FLASH_ERASE_SIZE")/2
   #if (((LOADER_START+LOADER_SIZE) % FLASH_SIZE) == 0)
      #define LOADER_END (LOADER_START+LOADER_SIZE-1)
   #else
      #define LOADER_END (LOADER_START+(LOADER_SIZE+FLASH_SIZE-((LOADER_SIZE)%FLASH_SIZE))-1)
   #endif
#else
 #error PCM, PCH, and PCD only supported
#endif

#define APPLICATION_START  (LOADER_END+1)

#if defined(__PCH__)
 #define APPLICATION_ISR (APPLICATION_START+8)
#elif defined(__PCM__)
 #define APPLICATION_ISR (APPLICATION_START+4)
#elif defined(__PCD__)
 #define APPLICATION_ISR (APPLICATION_START+4)
#endif

//// --- end configuration --- ////////////////////////////////////////////

#ifdef _bootloader
 // bootloader won't use interrupts, instead it will poll USB IF
 #define USB_ISR_POLLING
 
 /*
  Provide an empty application, so if you load this .HEX file into the pic
  without an application this will prevent the pic from executing unknown code.
 */
 #org APPLICATION_START,APPLICATION_START+0xF
 void BlankApplication(void)
 {
   while(TRUE);
 }

 //we need to prevent the loader from using application space
 #if (APPLICATION_END > 0x10000)
   #org APPLICATION_START+0x10, 0xFFFF {}
   #if (APPLICATION_END > 0x20000)
      #org 0x10000, 0x1FFFF {}
      #org 0x20000, APPLICATION_END {}
   #else
      #org 0x10000, APPLICATION_END {}
   #endif
 #else
   #org APPLICATION_START+0x10, APPLICATION_END {}
 #endif

   #define USB_STRINGS_OVERWRITTEN
   char USB_STRING_DESC_OFFSET[]={0,4,12};
   
   #define USB_CONFIG_PID  0x000c

   // Here is where the "CCS" Manufacturer string and "SERIAL DEMO" are stored.
   // Strings are saved as unicode.
   // These strings are mostly only displayed during the add hardware wizard.
   // Once the operating system drivers have been installed it will usually display
   // the name from the drivers .INF.
   char const USB_STRING_DESC[]={
      //string 0
            4, //length of string index
            0x03, //USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
            0x09,0x04,   //Microsoft Defined for US-English
      //string 1  - manufacturer
            8, //length of string index
            0x03, //USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
            'C',0,
            'C',0,
            'S',0,
      //string 2 - product
            38, //length of string index
            0x03, //USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
            'C',0,
            'C',0,
            'S',0,
            ' ',0,
            'C',0,
            'D',0,
            'C',0,
            ' ',0,
            'B',0,
            'o',0,
            'o',0,
            't',0,
            'l',0,
            'o',0,
            'a',0,
            'd',0,
            'e',0,
            'r',0
   };
#endif   //_bootloader

#ifndef _bootloader
 //in the application, this moves the reset and isr vector out of the bootload
 //space.  it then reserves the loader space from being used by the application.
 #build(reset=APPLICATION_START, interrupt=APPLICATION_ISR)
 
 #org 0, LOADER_END {}

#endif
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Sat Jul 13, 2019 6:56 pm     Reply with quote

Hi! I really can't make it work. Is there an error for the interrupt vector positioning on the ccs example?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 13, 2019 7:22 pm     Reply with quote

Look at the code at the end of the Ex_usb_bootloader.c file.
In vs. 5.085, it looks like this at the end:
Code:

#if defined(__PCD__)
#int_default
#else
#int_global
#endif
void isr(void)
{
   jump_to_isr(APPLICATION_ISR);
}

If your version only has #int_default, then it's a CCS source code bug.
That bug has been fixed, as of vs. 5.066, with the code shown above
which now uses #int_global for PCM and PCH.
Since you are using vs. 5.046 it might have the bug in it.
See Ttelmah's post near the end of this 3-page thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=55739&start=30
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Sun Jul 14, 2019 7:21 am     Reply with quote

yes!!! it works now! thanks a lot PCM programmer
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group