Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
bobgardner
PostPosted: Aug 20, 2007 - 09:36 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 17683
Location: Orlando Florida

I have 128 words free in my mega16 (256 bytes). Is there a bootloader that will fit? I know BLIPS and Megaload will fit in 256 words... Not matter what I try, I can't squeeze it down enough to have 256 words free....

_________________
Imagecraft compiler user


Last edited by bobgardner on Jan 28, 2011 - 06:00 PM; edited 1 time in total
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
theusch
PostPosted: Aug 20, 2007 - 09:44 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 22734
Location: Wisconsin USA

Where is HWMNBN when we need him?

If it weren't the tiniest bootloader, I'd suggest using proven routines common to the main code (U(S)ART driver routines come to mind) as bootloader-resident and share with the main code. But I suspect that with 128 words you'll need very tight crafting.

[There is always the Compiler Wars answer, but there are other threads for that. Wink ]

Lee
 
 View user's profile Send private message  
Reply with quote Back to top
CirMicro
PostPosted: Aug 20, 2007 - 09:58 PM
Posting Freak


Joined: Jun 04, 2007
Posts: 1075
Location: Cincinnati, Ohio - USA

Will you be using the UART? I have bootloader written in assembler that I believe would fit. I'll need to double check it though.
 
 View user's profile Send private message  
Reply with quote Back to top
John_A_Brown
PostPosted: Aug 21, 2007 - 09:35 AM
Raving lunatic


Joined: Sep 20, 2003
Posts: 3419
Location: Surrey, England

The first bootloader I "wrote" (actually I started from the Megaload program, stripped off the stuff I didn't need and re-wrote it in assembler) ran in 149 words, so I suspect it's possible to write one in 128 words. Mine didn't handle EEPROM, just Flash.
 
 View user's profile Send private message  
Reply with quote Back to top
CirMicro
PostPosted: Aug 21, 2007 - 01:07 PM
Posting Freak


Joined: Jun 04, 2007
Posts: 1075
Location: Cincinnati, Ohio - USA

The version I have that would fit is for a Tiny2313 which only handles Flash. Full functionality could fit if a custom protocol is used instead of AVR109 type.

I have one I started some time ago but never did get around to finishing it.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Aug 21, 2007 - 01:18 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 50115
Location: (using avr-gcc in) Finchingfield, Essex, England

Talking of protocols, what protocol do people implement to handle packet flow control (telling the PC to stop while a page is being erased/written)? Also what do you do about data validity (checksums/CRCs etc.)? Is the code, for example, trying to decode intel hex or is it packetised-binary at the stage it reaches the AVR?

I'm just wondering what would be optimal to keep the AVR hosted bit of the process as small as possible (but still workable!)

Cliff

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
H. Carl Ott
PostPosted: Aug 21, 2007 - 03:28 PM
Hangaround


Joined: Oct 03, 2001
Posts: 217
Location: NYC, USA

The xmodem bootloaders look pretty small.
could not find this here on freaks, but the web link looks okay.
http://www.ejberg.dk/temp/boot16.zip

Not sure who to credit though.


-carl
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
CirMicro
PostPosted: Aug 21, 2007 - 04:02 PM
Posting Freak


Joined: Jun 04, 2007
Posts: 1075
Location: Cincinnati, Ohio - USA

Quote:
The xmodem bootloaders look pretty small.


While being small it still looks to be about 350 bytes.


Quote:
Talking of protocols, what protocol do people implement to handle packet flow control (telling the PC to stop while a page is being erased/written)? Also what do you do about data validity (checksums/CRCs etc.)


As long as there is a way to read back the contents to be verified I don't really see any need for checksums or CRCs in most cases. I think it's been hard for many to let go of this concept since these days it has a much more limited use. It was originally used because it was more efficient to check individual packets of data so as to not need to retransmit all of the data if there only happened to be one bit of corrupted data and you are transmitting at a blazing 300 baud Smile

As far as waiting for a block to finish I would usually just wait for an acknowlegement from the AVR after each packet with a timeout on the PC side to avoid getting stuck in limbo should something go wrong.

The one protocol I had been working on basically puts all of the overhead on the PC side in order to keep things small on the Avr side. If I get time this week I'll try to finish things up and post them here.
 
 View user's profile Send private message  
Reply with quote Back to top
H. Carl Ott
PostPosted: Aug 21, 2007 - 04:21 PM
Hangaround


Joined: Oct 03, 2001
Posts: 217
Location: NYC, USA

Quote:

While being small it still looks to be about 350 bytes.


Dang,
I just looked at the the hex file and questimated it at about 275 bytes. But actually loading and compiling does it come out @ 175 words.
Too much to shave down to 128 words.

Well if you also have the option to write the host side software, you should be able to squeeze it in.

Sorry for the misfire,

-carl
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
theusch
PostPosted: Aug 21, 2007 - 04:28 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 22734
Location: Wisconsin USA

DigiKey:

Mega16: $6.45/qty. 1; $3.75/qty. 100
Mega324: $6.02/qty. 1; $3.98/qty. 100

Maybe if you were making 1M of the devices, you would save $230000. If you are making 10, then you lose $4.30. If you are making 100, then you save $23.00. Is your time worth it to squeeze into the Mega16?

Lee
 
 View user's profile Send private message  
Reply with quote Back to top
bobgardner
PostPosted: Aug 21, 2007 - 05:16 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 17683
Location: Orlando Florida

I've got 500 of em with a mega16. The bad thing is I need to remove 2 screws and remove the back plate to access the jtag, so I have a motivation to get some sort of serial loading working. See mcnallyelectronics.com for the front view.... back view has an 8 pin connector

_________________
Imagecraft compiler user
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Aug 21, 2007 - 05:32 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 50115
Location: (using avr-gcc in) Finchingfield, Essex, England

So do any of the "C vs Asm" veterans want to step up to the plate to see exactly how small a bootloader could be made? In C I think one will have to disable the auto-generation of vector tables and the preamble stuff to copy global inits and wipe non-init globals. But first a protocol for data transmission needs to be agreed. Anything non-standard is going to need a special PC app written while any of AVR109, Xmodem, IntelHex or whatever maybe has unnecessary protocol overhead "baggage" to contend with. Do you, for example, need EEPROM programming or is flash alone OK?

Cliff

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
KKP
PostPosted: Aug 21, 2007 - 05:47 PM
Resident


Joined: Jun 26, 2001
Posts: 825
Location: Silkeborg, Denmark

If it doesn't have to be AVRISP compatible, I'm pretty certain tinyloader 1.3 (tinyloader.kasperkp.dk/r13.zip) could be modified for M16 and still fit in 64 words.
Most of the intelligence of that loader is pushed onto the PC app in order to hit a 48 word target for Tiny13.
 
 View user's profile Send private message  
Reply with quote Back to top
AllN
PostPosted: Aug 21, 2007 - 06:13 PM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

clawson wrote:
So do any of the "C vs Asm" veterans want to step up to the plate to see exactly how small a bootloader could be made? In C I think one will have to disable the auto-generation of vector tables and the preamble stuff to copy global inits and wipe non-init globals. But first a protocol for data transmission needs to be agreed. ...?

Cliff
OH Yes, please do!!! Is the game on?
Great idea Cliff,
John

Edited:
John (js) Lennart and the rest of the 'secret order' you have just been challenged!!! Are you sissies or what?

_________________
Resistance is futile…… You will be compiled!


Last edited by AllN on Aug 21, 2007 - 06:17 PM; edited 2 times in total
 
 View user's profile Send private message  
Reply with quote Back to top
aweinstein
PostPosted: Aug 21, 2007 - 06:14 PM
Resident


Joined: Nov 30, 2001
Posts: 502
Location: Golden, CO (used to be Chile)

I have a bootloader that should fit in 256 bytes. It is heavily based in Design Note 32. It should work with avrprog. I also have a program written in Python to download the program to the AVR.

Let me know if you are interested.

_________________
Regards,
Alejandro.
http://www.ocam.cl
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
theusch
PostPosted: Aug 21, 2007 - 07:14 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 22734
Location: Wisconsin USA

Quote:

So do any of the "C vs Asm" veterans want to step up to the plate to see exactly how small a bootloader could be made?

<grin> As a matter of fact, I was looking at BLIPS and it has a few words of "slack" left in 256 words. I was going to do a quick C translation to see how it comes out. My compiler knows about "bootloader" apps, so some of the preamble, vector, etc. should be OK. A critical factor for pure C might be if it is critical to keep Z loaded and then do Z+ type of stuff. My compiler uses Z as its primary working register, and I'm guessing that I may end up with a lot of re-loading and thus blow it up a bit. My temptation would be to just implement for my desired target (Mega88) and only do page mode.

If I get the time to keep playing with it I'll post my results.

Actually the Tinyloader is so simple that the C version may not be much different--gotta look at it to see if there are any gotchas. Amazing work.

Lee
 
 View user's profile Send private message  
Reply with quote Back to top
AllN
PostPosted: Aug 21, 2007 - 07:27 PM
Posting Freak


Joined: Feb 14, 2007
Posts: 1858
Location: San Diego California

Well ˝ of the challenge as been accepted!!
(and the most beautiful cheerleader you ever saw sing.)
Yeah Lee he our MAN if he can’t do it NO ONE can!
Yeaaaaaaaaaaaaaaaaaaaah Lee!

What fun,
John

_________________
Resistance is futile…… You will be compiled!
 
 View user's profile Send private message  
Reply with quote Back to top
aweinstein
PostPosted: Aug 21, 2007 - 07:48 PM
Resident


Joined: Nov 30, 2001
Posts: 502
Location: Golden, CO (used to be Chile)

I left the bootloader and the PC application in http://www.ocam.cl/avrpybl .

I plan to release the bootloader in the future as open source. It needs some improvements yet, but it should work.

_________________
Regards,
Alejandro.
http://www.ocam.cl
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
KKP
PostPosted: Aug 21, 2007 - 08:26 PM
Resident


Joined: Jun 26, 2001
Posts: 825
Location: Silkeborg, Denmark

(looks around, spots a suitable M16 target)

If nothing unexpected arrives this weekend, for the fun of it, I'll look at an M16 version of Tinyloader;

Lee, I have a suspicion that the input to a C compiler that generates a tinyloader-like output is going to look like anything but C - for something like this there isn't what C is so often claimed to be by definition: A platform-independent, portable implementation. But, please prove me wrong, and I will provide support if you need a different PC side tool.

oh, and adding the whole thing into the peephole optimizer counts as cheating.

Kasper
 
 View user's profile Send private message  
Reply with quote Back to top
c_oflynn
PostPosted: Aug 21, 2007 - 08:39 PM
Raving lunatic


Joined: Mar 23, 2001
Posts: 2081
Location: Halifax, NS

Hello,

If you have a Dataflash on the application, you can have a simple bootloader that loads from the dataflash. Then the real bootloader is stored in the dataflash... you can really cram down the size then!

-Colin

_________________
VA3 YHZ - http://www.newae.com
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits