How much memory is lost to bootloader?

The USBDroid provides USB Host functionality for use as an Android peripheral as an Open Android Development Kit board. [Product page]
ninja2
Posts: 38
Joined: Sun Dec 25, 2011 3:25 am

How much memory is lost to bootloader?

Post by ninja2 » Fri Feb 10, 2012 11:57 am

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:

marks
Posts: 31
Joined: Wed Jan 04, 2012 8:13 pm

Re: How much memory is lost to bootloader?

Post by marks » Sat Feb 11, 2012 5:24 am

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.

ninja2
Posts: 38
Joined: Sun Dec 25, 2011 3:25 am

Re: How much memory is lost to bootloader?

Post by ninja2 » Sat Feb 11, 2012 10:51 am

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.)

marks
Posts: 31
Joined: Wed Jan 04, 2012 8:13 pm

Re: How much memory is lost to bootloader?

Post by marks » Sat Feb 11, 2012 10:23 pm

OK after a bit of testing:

28674 is fine
28676 and above fails on upload

Cheers,

Mark S.

ninja2
Posts: 38
Joined: Sun Dec 25, 2011 3:25 am

Re: How much memory is lost to bootloader?

Post by ninja2 » Sun Feb 12, 2012 12:01 am

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? :) )

marks
Posts: 31
Joined: Wed Jan 04, 2012 8:13 pm

Re: How much memory is lost to bootloader?

Post by marks » Mon Feb 13, 2012 8:51 pm

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.

ninja2
Posts: 38
Joined: Sun Dec 25, 2011 3:25 am

Re: How much memory is lost to bootloader?

Post by ninja2 » Mon Feb 13, 2012 9:02 pm

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

User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts: 297
Joined: Sat Oct 15, 2011 11:31 am

Re: How much memory is lost to bootloader?

Post by jonoxer » Tue Feb 14, 2012 12:11 pm

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

ninja2
Posts: 38
Joined: Sun Dec 25, 2011 3:25 am

Re: How much memory is lost to bootloader?

Post by ninja2 » Tue Feb 14, 2012 8:21 pm

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 ?

ninja2
Posts: 38
Joined: Sun Dec 25, 2011 3:25 am

Re: How much memory is lost to bootloader?

Post by ninja2 » Thu Feb 16, 2012 10:55 am

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 ...

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests