This is tiny (0.5KB) bootloader for AVR Atmega8 microcontroller. For Atmega88/168/328 support, check bootloader included in my other project: lcd88 (but without encryption).
Protocol supported by bootloader: XMODEM
It also support (optional) simple encrypted binaries.
Encryption is based on xor, swap bits and changing bytes order in packet. There are 2 coefficients used for 'encryption':
- starting point within packet (variable 'poczatek')
- offset for next byte in packet (variable 'mieszacz' - must be a prime number less than 128)
You could add seed for xor if you wish :-)
Simple FreePascal converter from ihex to binary, and encrypter also is attached.
It supports only uploading flash image starting from 0 address. Programming eeprom, fuses etc. is NOT supported.
Use AVRA to compile.
Before compiling adjust some defines:
- ZEGAR - set to your clock frequency in Hz
- If you need image decryption, uncomment '.define use_crypt' and adjust 'mieszacz' and 'poczatek' variables.
- UART_RATE - set to other speed if 9600 is not what you like
Compile simply by 'avra bootloader.asm'
Use your favorite burner. Avrdude works fine.
Fuses and lock bits:
Required:
- BOOTRST=0
- BOOTSZ1=1
- BOOTSZ0=0
Recommended:
- BLB12=0
- BLB11=0
Boot process:
- Set serial to 9600, 8 bits, parity none, 1 stop bit
- Print greeting over serial
- Wait max 2 seconds for 'B' (capital 'b')
- If received char is other than 'B' -> boot
- If timeout exceeded -> boot
- Print second part od greeting
- Wait max 2 seconds for 'P' (capital 'p')
- If received char is other than 'P' -> boot
- If timeout exceeded -> boot
- Switch to xmodem communication and wait for binary data
So, simply speaking you need:
- Connect to Atmega via serial and run some terminal application (for example Minicom)
- After boot you should get some prompt
- Hit 'B' and then 'P'
- Use some application to transfer code (for example lsz if you have binary image)
- After programming reset controller ot hit enter in console
XEBOOTloader was written by Marek Wodzinski (me) in 2007 based on Atmel Atmega8 datasheet, with small modification in 2011, and finally released to public in 2014.
Public repository: https://github.com/majekw/xeboot
My blog post about Xeboot: http://majek.mamy.to/xeboot/
This bootloader is licensed unded GPL v3 license.
Commercial use: you could use it to upload your own proprietary software to chip as long as you treat this bootloader as separate software.
In short:
- you put/deliver 2 pieces of software (XEBOOT + your software) = OK
- you put one software into chip (treating XEBOOT as part of your software) = BAD
Values of encrypting variables you could keep secret.