SD card datas : region 'hub' overflowed

alex93alex93 Posts: 11
edited 2017-08-03 - 17:36:54 in Robotics
Hi all,

First of all , sorry for my bad english.

I am actually working with an activitybot and i would like to save some datas ( distance reached by each wheel for example) on the onboard SD card.
However , i got an error during compilation :

/Applications/ cmm/move_forward2.elf section `.bss' will not fit in region `hub'
/Applications/ region `hub' overflowed by 1820 bytes
collect2: ld returned 1 exit status
Done. Build Failed!

Your program is too big for the memory model selected in the project.

I don't really understand why , here is the program :
#include "simpletools.h"
#include "abdrive.h"
#include "ping.h"                             
#include "stdbool.h"  

int distLeft[4],distRight[4];
int DO = 22, CLK = 23, DI = 24, CS = 25; 

int a=0;

int main()                    
 sd_mount(DO, CLK, DI, CS);
  FILE* fp = fopen("test.txt", "w");
  drive_getTicks(&distLeft[0], &distRight[0]);
  print("distLeft[0] = %d, distRight[0] = %d\n", distLeft[0], distRight[0]);  // START
    [indent]if (ping_cm(8) >= 30)
      drive_goto(48, 50);
      drive_goto(0, 0); 
    }                       [/indent]
  drive_getTicks(&distLeft[1], &distRight[1]);
  print("distLeft[1] = %d, distRight[1] = %d\n", distLeft[1], distRight[1]); // Distance traveled
  fprintf(fp,"Left wheel: %d and Right wheel: %d",distLeft[1],distRight[1]);
  fclose(fp);                                                                 // Close the file
  char s[50];                                                                // Buffer for characters
  fp = fopen("test.txt", "r");                                               // Reopen file for reading
  fread(s, 1, 50, fp);                                                      // Read 15 characters
  fclose(fp);                                                               // Close the file

  print("Datas are: ");                                                      // Display heading
  print("%s", s);                                                           // Display characters
Could you help me ? , thanks in advance !


  • When I build your file I get a program size of 32,540 bytes. So it would just fit in hub RAM, but there's not much space for the stack or heap. The function fprintf() pulls in a lot of code from the libraries. Try including the attached file into your project. It contains a simple printf and fprintf that only understands the %s, %d and %x formats. I get a program size of 28,936 when I build using printf.c.
Sign In or Register to comment.