Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code bloat?
07-01-2013, 08:05 PM,
#11
RE: Code bloat?
What is the current status of code size ?
Wiki pages seems to suggest that code size is smaller in Pinguino then Arduino . I'm confused , trying to compile simple blink diode example gives me 13% of space usage with Pinguino IDE .

"Another problem is the IDE, written in JAVA, it is based on C libraries and generates 4 kilobytes of code for an empty main loop. Pinguino is based on Python and SDCC. Before the compilation, a preprocessor translates specific instructions of the Arduino language to native C instructions. For example, digitalWrite(0,HIGH) is translated to PORTBbits.RBO = 1. Thus the execution speed is better.
"

Undecided
Reply
07-01-2013, 08:25 PM,
#12
RE: Code bloat?
As with almost every system there's a bunch of code that's generally included and then your own code. It's really only worth seeing how the code grows as you add more of your own code (when you care).

Maybe double up on the blink code and see the size change.

I'm not sure why it's even mentioned what the IDE is written in since it's not loaded on the target.

On many systems it's not code that's the scarce resource, it's RAM (or I/O pins).

John
Reply
08-01-2013, 12:17 PM,
#13
RE: Code bloat?
(07-01-2013, 08:25 PM)pingotg Wrote: As with almost every system there's a bunch of code that's generally included and then your own code. It's really only worth seeing how the code grows as you add more of your own code (when you care).

Maybe double up on the blink code and see the size change.

I'm not sure why it's even mentioned what the IDE is written in since it's not loaded on the target.

On many systems it's not code that's the scarce resource, it's RAM (or I/O pins).

John

Maybe you are right but when I compared tutorial on Arduino the code generated is around 1k while in Pinguino IDE it shown almost 3k for simple led blink code. That's simply not encouraging for newbie especially when documentation suggest quite opposite should happen.
Reply
08-01-2013, 02:55 PM, (This post was last modified: 08-01-2013, 02:56 PM by pingotg.)
#14
RE: Code bloat?
Try the kind of test I mentioned.

I'm using 32-bit chips which have so much flash that I'm unlikely to fill it and they're so cheap I can't see this as an issue, but if you're so worried then at least do some proper testing Smile

Just looking so crudely as you have is fairly pointless, sorry to say it.

John
Reply
28-05-2013, 08:32 PM,
#15
RE: Code bloat?
Hi, I've been working with Arduino and everything was nice until I had the need of getting more ATMega 328 microcontrollers. I live in Argentina and it's very difficult to get this IC's (or getting any sort of international shippings), so I saw on Pinguino the solution to my problems. I bought myself a Pickit 2, so I could burn the bootloader on a PIC 18F4550. I noticed the bootloader is way bigger than the one you get on Arduinos (Arduino bootloader weights around 2KB, while Pinguino's around 7KB). I like to work with 2x16 LCD Screens... And the only inclusion of the LCD library (just to use the lcd.begin statement) takes an 85% of the remaining 24KB!! The use of a couple of strings takes lots of space, not to mention floating point variables, which increase my program weight in 1% each one. I tried to modify the compiler's optimization flags, but I got no results... I've made a program on Arduino which has around 2000 lines, uses LCD, EEPROM, Speaker, and keyboard libraries... and it only uses 16KB from the total 30KB available. Invoking all these libraries together on Pinguino without writing a single line would cause the code not to fit on the flash...

Is there anything wrong with my Pinguino, did I do something wrong at the moment I burned the bootleader or is it that project is still too young and there are still many things to work on? It called my attention the fact that one of Pinguino's strong points is its way of optimizing code to reduce the size of it (claiming to do it better than Arduino), and to be honest I don't see many ones complaining about this, so I suspect this is not happening in general. Or is it?

Greetings from South America to everyone.
Reply
28-05-2013, 11:32 PM,
#16
RE: Code bloat?
In a 8-bit PIC (18F...), the code density of these PICs are worst that an equivalent AVR (Arduino), thanks to things like bank switching or using all time the W register for anything. Even written in assembly, a dumb KITT FX with leds, will be bigger in a PIC 18F that in an AVR.

Other thing, using the USB stack in a 18F eats a lot of RAM, and in case of a 18F2550/184550 have a block of RAM that ONLY can be used for USB stuff.

(28-05-2013, 08:32 PM)daniellibonati Wrote: Hi, I've been working with Arduino and everything was nice until I had the need of getting more ATMega 328 microcontrollers. I live in Argentina and it's very difficult to get this IC's (or getting any sort of international shippings), so I saw on Pinguino the solution to my problems. I bought myself a Pickit 2, so I could burn the bootloader on a PIC 18F4550. I noticed the bootloader is way bigger than the one you get on Arduinos (Arduino bootloader weights around 2KB, while Pinguino's around 7KB). I like to work with 2x16 LCD Screens... And the only inclusion of the LCD library (just to use the lcd.begin statement) takes an 85% of the remaining 24KB!! The use of a couple of strings takes lots of space, not to mention floating point variables, which increase my program weight in 1% each one. I tried to modify the compiler's optimization flags, but I got no results... I've made a program on Arduino which has around 2000 lines, uses LCD, EEPROM, Speaker, and keyboard libraries... and it only uses 16KB from the total 30KB available. Invoking all these libraries together on Pinguino without writing a single line would cause the code not to fit on the flash...

Is there anything wrong with my Pinguino, did I do something wrong at the moment I burned the bootleader or is it that project is still too young and there are still many things to work on? It called my attention the fact that one of Pinguino's strong points is its way of optimizing code to reduce the size of it (claiming to do it better than Arduino), and to be honest I don't see many ones complaining about this, so I suspect this is not happening in general. Or is it?

Greetings from South America to everyone.
I'm afraid that I have a blog : zardoz.es
Reply
29-05-2013, 09:33 AM, (This post was last modified: 29-05-2013, 10:25 AM by regis.)
#17
RE: Code bloat?
Quote:I noticed the bootloader is way bigger than the one you get on Arduinos (Arduino bootloader weights around 2KB, while Pinguino's around 7KB).
Pinguino has USB bootloader and the USB stack is far more complex than the serial one. However, the last version of the bootloader (4.x) is about 3K, please try it :

.hex   Bootloader_v4.9_18f4550_X20MHz.hex (Size: 7.84 KB / Downloads: 2)

On Pinguino 4550 + bootloader v4.x :
- empty sketch (setup+loop) is 280 bytes long.
- the code below is from 17202 bytes down to 10250 bytes long after a bit of optimization (x.4 rev. 848) :

Quote:void setup()
{
pinMode(USERLED, OUTPUT);
lcd.pins(0, 1, 2, 3, 4, 5, 0, 0, 0, 0); // RS, E, D4 ~ D8
lcd.begin(2, 0);
lcd.printf("hello, world!");
}

void loop()
{
toggle(USERLED);
delay(1000);
}
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
29-05-2013, 03:26 PM,
#18
RE: Code bloat?
It's common in C for printf to pull in lots of things. Anyone really worried about size can choose not to use printf, especially in a very size-conscious system.

I recall a similar discussion pre-web about C on a Z80, with the same sort of outcome. The embedded system concerned did not actually need printf but the coder hadn't thought about it.

John
Reply
29-05-2013, 03:52 PM,
#19
RE: Code bloat?
Oops, you make me think about another optimization (rev. 849) :
lcd.print("hello, world!"); -> code size: 3134 / 29695 bytes (10% used)
lcd.printf("hello, world!"); -> code size: 10234 / 29695 bytes (34% used)
If anyone has an Arduino board to compare ...


(29-05-2013, 03:26 PM)pingotg Wrote: It's common in C for printf to pull in lots of things. Anyone really worried about size can choose not to use printf, especially in a very size-conscious system.

I recall a similar discussion pre-web about C on a Z80, with the same sort of outcome. The embedded system concerned did not actually need printf but the coder hadn't thought about it.

John
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
29-05-2013, 06:12 PM, (This post was last modified: 29-05-2013, 06:16 PM by pingotg.)
#20
RE: Code bloat?
Cool!

@daniellibonati - you can get PIC bootloaders that are much smaller but all the ones I can recall use a UART. Clearly you could use one of those even with this project if you rewrote a few parts.

This page may help http://www.opensourcepic.org/bootloader.php

I'm using PIC32 so size isn't really a problem and I do like USB as the connection & power.

John
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)