Posts

Showing posts with the label bootloaders

Customising Optiboot

Image
I wanted to setup programming my custom Atmega328p board over Bluetooth.  Some have used the connection pin to control the Reset pin of the AVR.  However I want to use Bluetooth constantly, and only trigger a reset upon receiving a specific string sequence.  This requires tweaking the bootloader, using Optiboot as a basis: (1) Change Baudrate to be mutually compatible with Bluebooth and AVR. (2) Set an EEPROM byte in the main application, which could be read (and written) in the Optiboot routine. Setting up Optiboot in the Atmel environment: - Setup a project as usual in Atmel Studio - Copy files over from github to the project folder: optiboot.c, pindefs.h, stk500.h and boot.h. EDIT: It seems there is an AtmelStudio folder already set up on github . Setting baud rate to be compatible with AVR and Bluetooth module: 57600 bps - Insert #define BAUD_RATE 57600 (as required) into optiboot.c . - Compile and link project with following settings: Compiler Mis...

Programming Atmega328p chip wirelessly with nRF24L01+ module - Part II

Image
Fitting nRF24L01+ code into a bootloader A brief follow up to an earlier  post .  I previously had a system working whereby I was able to program an Atmega328p chip, using a connected Arduino Nano, but crucially using an nRF24L01+ module rather than a wired UART/PC connection.  What I really wanted however was to remove the Arduino Nano, and to program the MCU chip 'directly' by use of a bootloader with nRF24L01+ code to replace with the usual UART functionality.  I thought initially that I wouldn't be able to cram the radio module code into a bootloader, but in fact it wasn't too difficult.  I used Optiboot as a starting point and implemented bi-directional radio control within the bootloader.  I think it ended up being less than 1024 words (2048 bytes). I'm not an expert here - but I had to modify the compiler and linker parameters to get things to work: Compiler flags: -g -Wall -Os -fno-split-wide-types -mrelax Linker flags: -Wl,-section-s...

Of Bootloaders and Nanos

Image
Restoring a Nano to a default Nano To use a Nano with default bootloader: Select "Arduino Nano" in the Arduino IDE and click "Burn Bootloader" under Tools (I'm using the USBtiny ISP). Alternatively use avrdude: Write ATmegaBOOT_168_atmega328.hex (found in Arduino/hardware/arduino/avr/bootloaders/atmega) with an ISP, i.e. avrdude -p m328p -c usbtiny -e -U flash:w:ATmegaBOOT_168_atmega328.hex Optiboot bootloader with a Nano To use the Optiboot which comes with the Arduino IDE (version 1.6.5) Add this to the boards.txt file in Arduino/hardware/arduino/avr ############################################################## atmega328o.name=[Optiboot] Arduino Duemilanove or Nano w/ ATmega328 atmega328o.upload.tool=avrdude atmega328o.upload.protocol=arduino atmega328o.upload.maximum_size=32256 atmega328o.upload.speed=115200 atmega328o.bootloader.tool=avrdude atmega328o.bootloader.low_fuses=0xff atmega328o.bootloader.high_fuses=0xde atmega328o...