Page 1 of 1

How much memory is lost to bootloader?

Posted: Fri Feb 10, 2012 11:57 am
by ninja2
Background is this discussion I've been having over on Arduino forum, Programming section:
http://arduino.cc/forum/index.php/topic ... 7.html#new

1) does as a USBdroid have same bootloader as a genuine Uno?
2) how much flash memory is consumed by bootloader, etc
3) why does IDE report available bytes as 32,256 which just happens to be 32,768 - 512.
4) Is that 512 bytes for a small bootloader?
5) what's between about 28,600 and 32,256 in USBdroid flash memory space?
6) would USBdroid still work OK if I were to load optiboot V4.4 as discussed in the thread link above?

so many questions ! :shock:

Re: How much memory is lost to bootloader?

Posted: Sat Feb 11, 2012 5:24 am
by marks
Hi Ninja2,

I can run sketches which are larger than this quite happily. That said I couldn't initially when I didn't have all of my strings in progmem and lots of local function variables (I declare them globally now and re use them, storing anything I need later to the SD card). I wasted a lot of time working out what was going on and how to solve.

Sorry I have no idea about your other questions :(

Cheers,

Mark S.

Re: How much memory is lost to bootloader?

Posted: Sat Feb 11, 2012 10:51 am
by ninja2
Mark

Yes my story is similar. I've leant how to use PROGMEM to save SRAM overflows and now have lots of strings in flash/program memory, which swells my code size.

It would help to know exact size of your biggest running sketch, in bytes (when you compile ...)?

I get a message like "fail to upload" when I get over 28,600 bytes (approx.)

Re: How much memory is lost to bootloader?

Posted: Sat Feb 11, 2012 10:23 pm
by marks
OK after a bit of testing:

28674 is fine
28676 and above fails on upload

Cheers,

Mark S.

Re: How much memory is lost to bootloader?

Posted: Sun Feb 12, 2012 12:01 am
by ninja2
Excellent, thanks MarkS

I reckon that confirms the limit of available flash memory is about 4K less than it should / could be.

We really need help from Freetronics on this one (are you there Jon? :) )

Re: How much memory is lost to bootloader?

Posted: Mon Feb 13, 2012 8:51 pm
by marks
So Ninja,

Have you been "game" to try loading a new bootloader? Do you know if it's reversible if it doesn't work? Sorry for all of the questions but I'd like to add a few more features to the code I have running, but can't quite fit them in.

Cheers,

Mark S.

Re: How much memory is lost to bootloader?

Posted: Mon Feb 13, 2012 9:02 pm
by ninja2
Mark,
no not game yet. I'm hanging out for Freetronics to advise what they know about their bootloader first. We're in the same boat, I need that extra 4K for my remaining features! In fact I've had to comment a whole lot out for now to keep adding :x

I haven't loaded another bootloader before, although it shouldn't be too hard with all the guidance and advice on the forums. But questions is, what to revert to if it doesn't work!
cheers

Re: How much memory is lost to bootloader?

Posted: Tue Feb 14, 2012 12:11 pm
by jonoxer
The bootloader installed on the USBDroid is the Optiboot bootloader used on the Uno, but with our USB PID/VID. If you need to reflash it you can do it directly from the Arduino IDE: just use a compatible programmer such as an AVR ISP mk2 and select "Uno" as the board type. It'll work just fine, but report itself as an Uno instead of a Freetronics board. Functionally identical though.
--
Jon

Re: How much memory is lost to bootloader?

Posted: Tue Feb 14, 2012 8:21 pm
by ninja2
Jon

Thanks for that helpful info. As I understand optiboot v4.4 is just 512 bytes, which results in 32,768 - 512 = 32,256 bytes of useable flash memory.

32,256 bytes available memory is reported by the (1.0) IDE when I compile for the USBdroid, but we (myself and MarkS so far) are finding that available memory is only around 28,600 bytes. Can you offer any theory as to what's stealing ~ 4K of upper memory? And are you using optiboot 4.4 ?

Re: How much memory is lost to bootloader?

Posted: Thu Feb 16, 2012 10:55 am
by ninja2
OK with the help of some very knowledgeble people over on the arduino forum here: http://arduino.cc/forum/index.php/topic ... #msg692925 I can report .... my USBdroid is reporting the bootloader version as 3.3. Apparently this means it's highly likely to have the bug where 4K of upper memory becomes inaccessible.

Anyone can check there own bootloader version (it's explained by westfw over in that other forum thread. I think he's an Arduino guru, partly judging by how many posts show against his avatar but mostly by the quality of his advice)

So now I'm going to learn how to reprogram the bootloader ... that 4K progmem areas is gonna be all MINE :twisted:

if I succeed I'll report here, but don't hold your breath ...