AN #141 - M8 Bootloader


The Boot loader is only 128 words of code. It require one pin to tell when to boot. In this case PinC.1 is used. The amount of memory needed for loader is only 256 bytes . The Code for boot loader is modification of program written by David Moran - BootM8.Bas. I chose this code because of the small size and simplicity. In my edition of the loader boot process starts when PinC.1 is short to GND. Other wise processor starts the main code without any wait. The speed of sending data to CPU is setup for 19,200 bps what is optimum to use with internal 4 or 8 Mhz oscillator.

The fusebits need to be set for 128 bytes for the boot code, starting at $F80

Fusebits: Boot Application Bootloader End of Boot Reset
BOOTSZ1 BOOTSZ0 Size Flash Section Flash Section Application Address
1 1 128 $000 - $F7F $F80 - $FFF $F7F $F80


Standard Intel hex file can be sent: (spaces added for readability)
All record sizes must be even, AVR uses WORDs, not bytes

:Size Address Type Data Bytes Checksum
:10 00 00 00 26 C0 B3 C0 B3 C0 B3 C0 B3 C0 C5 C0 C5 C0 D0 C0 A4
:10 00 10 00 DB C0 E4 C0 ED C0 30 31 32 33 34 35 36 37 38 39 E7
-
-
:10 05 30 00 55 DF 08 95 57 E5 57 DF 52 E5 55 DF 54 E5 53 DF A2
:10 05 40 00 5C E2 51 DF 53 2F 52 95 49 DF 53 2F 47 DF 01 D0 33
:0B 05 50 00 08 95 5D E0 48 DF 5A E0 46 DF 08 95 A2 DC
:00 00 00 01 FF


Program for sending data to CPU is written in Visual Basic V6.0



ATm8Ld require to select com port . The message box will prompt you to set the port number on first run. If you want to change port any way change the number In text box , than hit CHANGE, Program will finish rewriting registry with new port number. After next start up program is ready to operate on the port. The Intel hex code of the program must be preloaded by using LOAD Program use widows file picker and full path will be remember in registry also The internal buffer will be fill with file . After next start up the same file will be used until you load other.





After Loading the file, set the switch in boot position. Power off ,and power on the board .Program will respond with Labels B ? instead of labels @ @



Now hit the SEND to send hex file to board.



Board will receive record by record hex code of micro program. Each record starts with labels B ? . I case of error the labels can change B ! for header mismatch and B C for bad check sum. Each record will be program into flash memory. The loader is only for flash code.



End Screen when whole program has been download to the board. The labels change again to @ @ and boot switch can be move for position RUN - PinC.1 open respect to GND . Board can be power down and power up. On power up downloaded program will start wit out any delay.

Download source code and files in an141.zip