Skip to content

Cleaned up a few warnings and fixed strict-aliasing #1352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -1637,24 +1637,48 @@ public void setCompilingProgress(int percent) {

protected void size(String buildPath, String suggestedClassName)
throws RunnerException {
long size = 0;
String maxsizeString = Base.getBoardPreferences().get("upload.maximum_size");
if (maxsizeString == null) return;
long maxsize = Integer.parseInt(maxsizeString);
long textSize = 0;
long dataSize = 0;
String maxTextSizeString = Base.getBoardPreferences().get("upload.maximum_size");
String maxDataSizeString = Base.getBoardPreferences().get("upload.maximum_data_size");
if (maxTextSizeString == null) return;
long maxTextSize = Integer.parseInt(maxTextSizeString);
long maxDataSize = -1;
if(maxDataSizeString != null)
maxDataSize = Integer.parseInt(maxDataSizeString);
Sizer sizer = new Sizer(buildPath, suggestedClassName);
try {
size = sizer.computeSize();
long[] sizes = sizer.computeSize();
textSize = sizes[0];
dataSize = sizes[1];
System.out.println(
I18n.format(
_("Binary sketch size: {0} bytes (of a {1} byte maximum)"),
size, maxsize
textSize, maxTextSize
)
);
if(maxDataSize > 0) {
System.out.println(
I18n.format(
_("Memory usage: {0} bytes (of a {1} byte maximum)"),
dataSize, maxDataSize
)
);
} else {
System.out.println(
I18n.format(
_("Memory usage: {0} bytes"),
dataSize
)
);
}
} catch (RunnerException e) {
System.err.println(I18n.format(_("Couldn't determine program size: {0}"), e.getMessage()));
}

if (size > maxsize)
/* At least 10% of RAM should be reserved for stack/heap usage */
if (textSize > maxTextSize ||
(maxDataSize > 0 && dataSize > maxDataSize*9/10))
throw new RunnerException(
_("Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it."));
}
Expand Down
44 changes: 33 additions & 11 deletions app/src/processing/app/debug/Sizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,32 @@
public class Sizer implements MessageConsumer {
private String buildPath, sketchName;
private String firstLine;
private long size;
private long textSize;
private long dataSize;
private long eepromSize;
private RunnerException exception;

public Sizer(String buildPath, String sketchName) {
this.buildPath = buildPath;
this.sketchName = sketchName;
}

public long computeSize() throws RunnerException {
public long[] computeSize() throws RunnerException {
String avrBasePath = Base.getAvrBasePath();
String commandSize[] = new String[] {
avrBasePath + "avr-size",
"-A",
" "
};

commandSize[1] = buildPath + File.separator + sketchName + ".hex";
commandSize[2] = buildPath + File.separator + sketchName + ".elf";

int r = 0;
try {
exception = null;
size = -1;
textSize = -1;
dataSize = -1;
eepromSize = -1;
firstLine = null;
Process process = Runtime.getRuntime().exec(commandSize);
MessageSiphon in = new MessageSiphon(process.getInputStream(), this);
Expand All @@ -80,10 +85,10 @@ public long computeSize() throws RunnerException {
if (exception != null)
throw exception;

if (size == -1)
if (textSize == -1)
throw new RunnerException(firstLine);

return size;
return new long[] { textSize, dataSize, eepromSize };
}

public void message(String s) {
Expand All @@ -92,15 +97,32 @@ public void message(String s) {
else {
StringTokenizer st = new StringTokenizer(s, " ");
try {
st.nextToken();
st.nextToken();
st.nextToken();
size = (new Integer(st.nextToken().trim())).longValue();
String section = st.nextToken();
if(!section.startsWith("."))
return;
long bytes = (new Integer(st.nextToken().trim())).longValue();
//long addr = (new Integer(st.nextToken().trim())).longValue();
//System.out.println("Section: " + section + " with " + bytes + " bytes at address " + addr);
if(section.equals(".text") || section.equals(".data") || section.equals(".bootloader")) {
if(textSize < 0)
textSize = 0;
textSize += bytes;
}
if(section.equals(".data") || section.equals(".bss") || section.equals(".noinit")) {
if(dataSize < 0)
dataSize = 0;
dataSize += bytes;
}
if(section.equals(".eeprom")) {
if(eepromSize < 0)
eepromSize = 0;
eepromSize += bytes;
}
} catch (NoSuchElementException e) {
exception = new RunnerException(e.toString());
} catch (NumberFormatException e) {
exception = new RunnerException(e.toString());
}
}
}
}
}
18 changes: 18 additions & 0 deletions hardware/arduino/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.maximum_data_size=2048
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
Expand All @@ -24,6 +25,7 @@ atmega328.name=Arduino Duemilanove w/ ATmega328

atmega328.upload.protocol=arduino
atmega328.upload.maximum_size=30720
atmega328.upload.maximum_data_size=2048
atmega328.upload.speed=57600

atmega328.bootloader.low_fuses=0xFF
Expand All @@ -45,6 +47,7 @@ diecimila.name=Arduino Diecimila or Duemilanove w/ ATmega168

diecimila.upload.protocol=arduino
diecimila.upload.maximum_size=14336
diecimila.upload.maximum_data_size=1024
diecimila.upload.speed=19200

diecimila.bootloader.low_fuses=0xff
Expand All @@ -66,6 +69,7 @@ nano328.name=Arduino Nano w/ ATmega328

nano328.upload.protocol=arduino
nano328.upload.maximum_size=30720
nano328.upload.maximum_data_size=2048
nano328.upload.speed=57600

nano328.bootloader.low_fuses=0xFF
Expand All @@ -87,6 +91,7 @@ nano.name=Arduino Nano w/ ATmega168

nano.upload.protocol=arduino
nano.upload.maximum_size=14336
nano.upload.maximum_data_size=1024
nano.upload.speed=19200

nano.bootloader.low_fuses=0xff
Expand Down Expand Up @@ -213,6 +218,7 @@ mini328.name=Arduino Mini w/ ATmega328

mini328.upload.protocol=arduino
mini328.upload.maximum_size=28672
mini328.upload.maximum_data_size=2048
mini328.upload.speed=115200

mini328.bootloader.low_fuses=0xff
Expand All @@ -234,6 +240,7 @@ mini.name=Arduino Mini w/ ATmega168

mini.upload.protocol=arduino
mini.upload.maximum_size=14336
mini.upload.maximum_data_size=1024
mini.upload.speed=19200

mini.bootloader.low_fuses=0xff
Expand All @@ -255,6 +262,7 @@ ethernet.name=Arduino Ethernet

ethernet.upload.protocol=arduino
ethernet.upload.maximum_size=32256
ethernet.upload.maximum_data_size=2048
ethernet.upload.speed=115200

ethernet.bootloader.low_fuses=0xff
Expand All @@ -276,6 +284,7 @@ fio.name=Arduino Fio

fio.upload.protocol=arduino
fio.upload.maximum_size=30720
fio.upload.maximum_data_size=2048
fio.upload.speed=57600

fio.bootloader.low_fuses=0xFF
Expand All @@ -297,6 +306,7 @@ bt328.name=Arduino BT w/ ATmega328

bt328.upload.protocol=arduino
bt328.upload.maximum_size=28672
bt328.upload.maximum_data_size=2048
bt328.upload.speed=19200
bt328.upload.disable_flushing=true

Expand All @@ -319,6 +329,7 @@ bt.name=Arduino BT w/ ATmega168

bt.upload.protocol=arduino
bt.upload.maximum_size=14336
bt.upload.maximum_data_size=1024
bt.upload.speed=19200
bt.upload.disable_flushing=true

Expand Down Expand Up @@ -362,6 +373,7 @@ lilypad328.name=LilyPad Arduino w/ ATmega328

lilypad328.upload.protocol=arduino
lilypad328.upload.maximum_size=30720
lilypad328.upload.maximum_data_size=2048
lilypad328.upload.speed=57600

lilypad328.bootloader.low_fuses=0xFF
Expand All @@ -383,6 +395,7 @@ lilypad.name=LilyPad Arduino w/ ATmega168

lilypad.upload.protocol=arduino
lilypad.upload.maximum_size=14336
lilypad.upload.maximum_data_size=1024
lilypad.upload.speed=19200

lilypad.bootloader.low_fuses=0xe2
Expand All @@ -404,6 +417,7 @@ pro5v328.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328

pro5v328.upload.protocol=arduino
pro5v328.upload.maximum_size=30720
pro5v328.upload.maximum_data_size=2048
pro5v328.upload.speed=57600

pro5v328.bootloader.low_fuses=0xFF
Expand All @@ -425,6 +439,7 @@ pro5v.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168

pro5v.upload.protocol=arduino
pro5v.upload.maximum_size=14336
pro5v.upload.maximum_data_size=1024
pro5v.upload.speed=19200

pro5v.bootloader.low_fuses=0xff
Expand All @@ -446,6 +461,7 @@ pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

pro328.upload.protocol=arduino
pro328.upload.maximum_size=30720
pro328.upload.maximum_data_size=2048
pro328.upload.speed=57600

pro328.bootloader.low_fuses=0xFF
Expand All @@ -467,6 +483,7 @@ pro.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168

pro.upload.protocol=arduino
pro.upload.maximum_size=14336
pro.upload.maximum_data_size=1024
pro.upload.speed=19200

pro.bootloader.low_fuses=0xc6
Expand All @@ -488,6 +505,7 @@ atmega168.name=Arduino NG or older w/ ATmega168

atmega168.upload.protocol=arduino
atmega168.upload.maximum_size=14336
atmega168.upload.maximum_data_size=1024
atmega168.upload.speed=19200

atmega168.bootloader.low_fuses=0xff
Expand Down
Loading