Skip to content

Commit

Permalink
Merge pull request MarlinFirmware#1167 from thinkyhead/sd_freemem
Browse files Browse the repository at this point in the history
Use SdFatUtil::FreeRam() for freeMemory() if there
  • Loading branch information
boelle committed Dec 20, 2014
2 parents 889d7ba + 28c3ad2 commit 6062886
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,22 +402,27 @@ void serial_echopair_P(const char *s_P, double v)
void serial_echopair_P(const char *s_P, unsigned long v)
{ serialprintPGM(s_P); SERIAL_ECHO(v); }

extern "C"{
extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern void *__brkval;
#ifdef SDSUPPORT
#include "SdFatUtil.h"
int freeMemory() { return SdFatUtil::FreeRam(); }
#else
extern "C" {
extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern void *__brkval;

int freeMemory() {
int free_memory;
int freeMemory() {
int free_memory;

if((int)__brkval == 0)
free_memory = ((int)&free_memory) - ((int)&__bss_end);
else
free_memory = ((int)&free_memory) - ((int)__brkval);
if ((int)__brkval == 0)
free_memory = ((int)&free_memory) - ((int)&__bss_end);
else
free_memory = ((int)&free_memory) - ((int)__brkval);

return free_memory;
return free_memory;
}
}
}
#endif //!SDSUPPORT

//adds an command to the main command buffer
//thats really done in a non-safe way.
Expand Down

1 comment on commit 6062886

@gyz1990
Copy link

@gyz1990 gyz1990 commented on 6062886 Mar 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arduino:1.6.0 (Windows 7), :"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

SdFatUtil.cpp.o: In function SdFatUtil::FreeRam()': C:\Users\GsoftB\AppData\Local\Temp\build5743999789393343371.tmp/SdFatUtil.cpp:33: undefined reference toSdFatUtil::__brkval'
C:\Users\GsoftB\AppData\Local\Temp\build5743999789393343371.tmp/SdFatUtil.cpp:33: undefined reference to SdFatUtil::__brkval' C:\Users\GsoftB\AppData\Local\Temp\build5743999789393343371.tmp/SdFatUtil.cpp:36: undefined reference toSdFatUtil::__bss_end'
C:\Users\GsoftB\AppData\Local\Temp\build5743999789393343371.tmp/SdFatUtil.cpp:36: undefined reference to `SdFatUtil::__bss_end'
collect2: error: ld returned 1 exit status

Please sign in to comment.