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 support@ccsinfo.com

Urgent help needed with bootloader (Willing to pay anyone)

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



Joined: 20 Nov 2011
Posts: 7
Location: Doha/Qatar

View user's profile Send private message MSN Messenger

Urgent help needed with bootloader (Willing to pay anyone)
PostPosted: Sat Jan 11, 2014 5:29 am     Reply with quote

Greetings folks Very Happy
I've been working recently on a Bluetooth bootloader for a Dspic30F4013. The module used is an HC-05. I've manged to get it working and sending data visualized on putty/hyperterminal as a com port.
I get this error message whenever I compile my source code: "Out of ROM, a segment or program is too large funA"; funA which includes a read_ext_eeprom() function.
I did my research on the forum and I tried every single work around suggested by other members on different posts.
Here is what I tried:
1-Breaking down large functions into multiple smaller ones.
2- including the #separate directive
3- I tried to to replicate the read_ext_eeprom function with a similar one called rd_eeprom and then using the later to minimize the call to the bigger original one.
4- I tried removing all the auxiliary/unnecessary strings used for the bootloader interface like "Bootloader Version 1.0" and "Waiting for download......." and still running into the same issue.

Here is my main.c file

Code:

#include <main.h>


void application(void)
{
while(true)
   {
   printf("Hello World");
   //delay_ms(2000);
   }   
}


void main()
{
   
   setupBlueToothConnection();


   if(!input(PUSH_BUTTON))
   {
      printf("\r\nBootloader Version 1.0\r\n");
      // Let the user know it is ready to accept a download
      printf("\r\nWaiting for download...");
      // Load the program
      load_program();
   }

   application();

}



#int_default
void isr(void)
{
   jump_to_isr(LOADER_END+5);
}





The initialization data used to setup the bluetooth module is stored on an external I2C EEPROM, because it's large and would take most of the dspic memory.

And here is my main.h file:

Code:

#define DSPIC30F

#if defined DSPIC30F
   #include <30F4013.h>
   
   #fuses HS,NOWDT,NODEBUG,FRC, NOPUT, NOWRT, NOPROTECT
   #device PASS_STRINGS=IN_RAM
   //#include <string.h>
   #define XTAL_FREQUENCY 10M
   #use delay(clock=XTAL_FREQUENCY, crystal=10M)
   #use rs232(baud=9600, UART2)
   #define PUSH_BUTTON PIN_B12
#endif

#define EEPROM_SDA  PIN_F2
#define EEPROM_SCL  PIN_F3
#include <2408.c>



#define _bootloader

#include <pcd_bootloader.h>
#include <loader_pcd.c>
#org LOADER_END+1,LOADER_END+5



void funA()
 {
  for(int8 i = 0; i < 96; i++)   
    printf(read_ext_eeprom(i));
 }


void funB()
 {
  for(int8 i = 96; i < 110; i++)
    printf(read_ext_eeprom(i));
 }



void setupBlueToothConnection()
{
   

  funA();
  delay_ms(2000);
  funB();
  delay_ms(2000);
     
}


Here is my compiler version:

IDE 5.012
PCB 5.012
PCM 5.012
PCH 5.012
PCD 5.012


Pardon me if it's something obvious as I'm not a professional programmer/engineer.
I've spent a considerable amount of time trying to get this working.
Any help will be appreciated & many thanks in advance.


Last edited by msakms on Sat Jan 18, 2014 6:33 am; edited 2 times in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Sat Jan 11, 2014 6:17 am     Reply with quote

When doing any bootloader, you need to compile it first, with 'loader_end' set to a very large value.

Then look at the code, and see how big it is, and move loader_end down to the next page boundary above this.

The standard setting for loader_end, allows room for the standard bootloader. Anything larger, has to have this increased.

Best Wihse
msakms



Joined: 20 Nov 2011
Posts: 7
Location: Doha/Qatar

View user's profile Send private message MSN Messenger

PostPosted: Sat Jan 11, 2014 7:32 am     Reply with quote

Ttelmah wrote:
When doing any bootloader, you need to compile it first, with 'loader_end' set to a very large value.


This might sound stupid but please bear with me as I'm still new to the whole bootloader thing.
How can I determine this "very large value"? I have the datasheet memory map right infront of me Embarassed but I've no idea what should I do next although I've read the whole section about memory organization and I still don't know how to determine the page boundaries.

This sounds like a very simple issue & I'm on the verge of pulling out my hair Mr. Green

I added the following lines to hopefully spot any hints/patterns:
#warning Loader pages: LOADER_PAGES
#warning Loader end: LOADER_END
#warning Loader size: LOADER_SIZE
#warning Loader addr: LOADER_ADDR


And here's what i get:
#warning Loader pages: 19
#warning Loader end: ((19*(128/2))-1)
#warning Loader size: ((19*(128/2))-1)
#warning Loader addr: ((19*(128/2))-1) - ((19*(128/2))-1)


The error I get is this:

Out of ROM, A segment or the program is too large funA
Seg 004C0-004C4, 0006 left, need 00042

Edit:
I tried modifying #org LOADER_END+1, LOADER_END+5 by replacing the "+1" by subtracting larger values as a desperate measure and I always get "Out of ROM" error.
msakms



Joined: 20 Nov 2011
Posts: 7
Location: Doha/Qatar

View user's profile Send private message MSN Messenger

PostPosted: Sat Jan 18, 2014 6:36 am     Reply with quote

This took far so much time than it should be. I give up at this point, I have no problem to pay anyone to get this issue solved.
Kindly inform me ASAP if you're interested & thanks in advance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Mon Jan 20, 2014 1:49 am     Reply with quote

You must not change the +1, or +5, these are specific to the PIC hardware.

You just change 'LOADER_END'. Set if before loading bootloader.h, and the code will use this value. It must be one less than a page boundary, for the test, set it to perhaps triple or quadruple the default value. You are just making sure that it is a lot larger than your bootloader.

Then compile the bootloader, and look in the LST file for where the last instruction actually is. You then need to change the LOADER_END value to one less than the next page boundary above this instruction, and use this value in future.

The point is that the main code has to be above the bootloader, and 'where' this needs to be depends on the size of your bootloader. You have made the bootloader bigger, so you have to move the boundary.
msakms



Joined: 20 Nov 2011
Posts: 7
Location: Doha/Qatar

View user's profile Send private message MSN Messenger

PostPosted: Thu Jan 23, 2014 2:57 am     Reply with quote

Thank you so much. I appreciate your patience on this issue & have a wonderful day.
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