Code Monkey home page Code Monkey logo

avr_boot's Introduction

avr_boot

SD card bootloader for atmega processors

As easy as it can get! I spent days with this. Hopefully you wont!

  • for any ATMega with 4096kb Bootloader
  • uses Petit FatFs R0.03 for FAT12, FAT16, FAT32
  • looks for FIRMWARE.BIN and flashes it nearly instantly
  • without any interference to your application
  • no CRC Check and no version bytes in EEPROM (see KISS)

Boards Manager installation

avr_boot is integrated in Arduino IDE version 1.6.4 or greater!!! See here for instructions.

Manual installation

This is with avr-gcc and avrdude under linux with an Atmega1284p and AVRISP mkII! Adaption to your case (WinAvr, another Atmega, another flash-tool) will not be complicated...

  • adapt Makefile
    • MCU_TARGET: Your atmegaXXX
    • BOOT_ADR: in bytes not words!
    • F_CPU: CPU Frequency (not critical. A higher value will work as well)
    • SD_CS_PORT: Data Register of the SD CS pin(see the datasheet for your microcontroller)
    • SD_CS_DDR: Data Direction Register of the SD CS pin
    • SD_CS_BIT: Bit of the SD CS pin
    • USE_LED: For debugging 0...deactivate or 1...active
    • USE_UART: For debugging 0...deactivate or divider (UBRR) for baudate see http://wormfood.net/avrbaudcalc.php
  • update spi_pins.h with the SPI pins of your microcontroller if not already defined
  • if using USE_LED adapt LED-pins in asmfunc.S
  • if you want to add FAT12 adapt pff/src/pffconfh.h (default ist FAT16 + FAT32)
  • if you want to support lower case filenames adapt pff/src/pffconfh.h (default is uppercase)
  • if you prefer another filename instead of FIRMWARE.BIN adapt main.c
  • make (you may need to do "sudo apt-get install avr-libc gcc-avr")
  • set fuses: avrdude -c avrispmkII -p m1284p -U hfuse:w:0xda:m
  • flash: avrdude -c avrispmkII -p m1284p -Uflash:w:./avr_boot.hex:i -Ulock:w:0x3F:m

Put your sketch on SD card

  • in Arduino IDE go to File > Preferences and check "Show verbose output during compiliation"
  • compile sketch and find the location of your /tmp/buildxxx/sketch.cpp.hex
  • make bin file: avr-objcopy -I ihex -O binary sketch.cpp.hex FIRMWARE.BIN
  • copy the file into the root of an SD (FAT16/FAT32)
  • put it into the SD slot of your ATmega
  • reset it
  • it might already have happend!

Bootloader sizes

Compiled under linux for atmega328p / atmega1284p

  • 3674 / 3724 bytes
  • 3984 / 4034 bytes debugging with USE_LED
  • 3992 / 4052 bytes debugging with USE_UART

Tested successfully on

  • ATmega168
  • ATmega328P
  • ATmega32u4
  • ATmega1284P
  • ATmega2560 (see issue #2)

Serial support - Help wanted

it should not be impossible to fit a normal serial bootloader (with automatic baudrate detection?) into the remaining bytes ... help is appreciated!

KISS

If you wish you can add CRC Check or versioning with EEPROM but I prefere to keep things simple. avr_boot will reflash your FIRMWARE.BIN as long as it is present. Is this a problem? No! It happens nearly instantly and only differing bytes are flashed really. You may consider putting your logic into your application and perform a CRC Check after the fact to inform the user and delete or rename FIRMWARE.BIN

Thanks to

Alternatives

... call me stupid, but I passed several days debugging those - without success ...

avr_boot's People

Contributors

per1234 avatar zevero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.