New optiboot; beta testers welcome...

You really don't need the flag. If everything is working correctly 0xFF will never be the tuned value (along with 0x00, 0x7F, and 0x80).

I wasn't sure what values OSCCAL could take, so I hedged my bets. The byte would have been wasted anyway as all opcodes are 2bytes long, so it does no harm being there and it acts as an extra measure of protection.

When reading Flash as data it is byte-wise. Check the LPM instruction for details.

Ahh, you were thinking about reading the flag to check it. I was thinking about the byte of program memory it takes to store. If necessary it can be removed later, but at the moment doing so will not reduce the overall size of the bootloader as it will take up an integer number of 64 byte pages. As it stands, the bootloader takes up exactly 9 pages. If at some point more space us needed, I will remove that check.

There is now a .zip file for Optiboot 5.0
There are no "important" changes for the core Arduino platforms in 5.0, but it does support the ATmega32, ATmega1284, and has a new makefile structure that should make it much easier to build custom version of optiboot from the source.
http://code.google.com/p/optiboot/downloads/detail?name=optiboot-v5.0.zip&can=2&q=

Excellent! Thank you!

@westfw:
Just a suggestion. You should update the rev. number into the comments of the optiboot.c file .
The last modify is still marked as " Mar 2013 - 4.6" :wink:

@westfw:
i tried to install optiboot5 on IDE 1.5.2 (windows) in the hardware directory, inside the sketch directory, like your installation guide, but do not work

the "hardware directory method" it is valid for 1.5.x branch of IDE ?

You should update the rev. number into the comments

oops!

make atmega328 AVR_FREQ=16000000 BAUD_RATE=1000000

BAUD RATE CHECK: Desired: 1000000, Real: 1000000, UBRRL = 1, Error=0.0%
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=16000000  -DBAUD_RATE=1000000 -DLED_START_FLASHES=3       -c -o optiboot.o optiboot.c
optiboot.c:277:2: error: #error Unachievable baud rate (too fast) BAUD_RATE
make: *** [optiboot.o] Error 1

Argh!

Why check for a UBRRn value below 3? The new baud rate check traps troublesome combinations very nicely...

make atmega328 AVR_FREQ=16000000 BAUD_RATE=900000

BAUD RATE CHECK: Desired: 900000, Real: 1000000, UBRRL = 1, Error=-11.1%
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=16000000 -DBAUD_RATE=900000
optiboot.c:252:2: error: #error BAUD_RATE error greater than -5%
make: *** [optiboot.o] Error 1

Testato:
@westfw:
i tried to install optiboot5 on IDE 1.5.2 (windows) in the hardware directory, inside the sketch directory, like your installation guide, but do not work
the "hardware directory method" it is valid for 1.5.x branch of IDE ?

Sorry for the bump, may you confirm that it is not compatible with IDE 1.5x ?

not compatible with IDE 1.5x

What do you mean by "doesn't work"? Doesn't compile? Boards.txt not imported to IDE? Something else?

The whole multi-platform stuff is still not finalized, so I've been delaying dealing with it. Actually, it's not working very well with the 1.0 stuff either, at least from a "build" perspective.

I've put up a 5.0a zip file download, due to problems people were having compiling 5.0 on some unix systems.
(I don't actually fix anything, but I now ignore errors in the "baudcheck" target, so that the build will proceed anyway.)

http://code.google.com/p/optiboot/downloads/detail?name=optiboot-v5.0a.zip

westfw:

not compatible with IDE 1.5x

What do you mean by "doesn't work"? Doesn't compile? Boards.txt not imported to IDE.

Board not appear under Ide 1.5

I am not a beta tester, but I have a simple question:
I want conditionally bypass the optiboot. At the start of the optiboot I do a check, and if negative I want to exit optiboot properly and I want enter the actual application. Could you advice me on the proper way, plz?
Thanks.

Another one:
I want add few hundreds bytes of code, placed before the actual optiboot show starts (no impact on the optiboot). The stuff compiles about 670bytes today, it will grow.
Q: provided my code works fine, is the only thing to consider the change of the fuses (to 512 words) and its starting address in boards.txt, or shall I be aware of something other as well?

I want conditionally bypass the optiboot. At the start of the optiboot I do a check, and if negative I want to exit optiboot properly and I want enter the actual application.

You should be able to add your check to the "no wait mod" section of main():

  // Adaboot no-wait mod
  ch = MCUSR;
  MCUSR = 0;
  if (!my_run_bootloader_check() || !(ch & _BV(EXTRF))) appStart(ch);

You should be careful that your check does not do much chip configuration beyond the reset state.

I want add few hundreds bytes of code, placed before the actual optiboot show starts (no impact on the optiboot). The stuff compiles about 670bytes today, it will grow.
Q: provided my code works fine, is the only thing to consider the change of the fuses (to 512 words) and its starting address in boards.txt, or shall I be aware of something other as well?

You'll also need to change the --section-start setting(s) in the optiboot Makefile, and the max sketch size in boards.txt If your code is 670 bytes, and optiboot is 500 bytes, then a 1k bootloader space won't be enough.

If your code is 670 bytes, and optiboot is 500 bytes, then a 1k bootloader space won't be enough.

It is 670 optiboot inclusive. Thanks!

NATO:
I need to get soft UART working with optiboot (to eventually re-assign TX and RX pins). For now, though, I'm using all default settings with the exception of this change to the make file:

atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DSOFT_UART'

The addition of the -DSOFT_UART should enable the soft UART, but after burning the bootloader, I can no longer upload sketches. When I compile without the soft uart option, the bootloader works fine. Also, it seems strange to me that the size of the two bootloaders differs by less than 10 bytes. I would think that the addition of the soft uart would increase the size of the bootloader significantly. Thanks.

@NATO or westfw

Have you finally got soft UART working ?

I need to re-assign hardware UART TX and RX pins on an atmega328p to read a very slow signal (1200 bauds).

With Optiboot 5.0a, I've :

  1. Changed pin_defs.h :
#define UART_TX_BIT            7
#define UART_RX_BIT            6
  1. Built it :
make atmega328 SOFT_UART=1 BAUD_RATE=19200

I use Arduino IDE 1.0.5 to flash Optiboot with USBtinyISP.
Content of boards.txt :

uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200

uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F

uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

I use avrdude version 5.11.1.

avrdude -C/home/jm/arduino-1.0.5/hardware/tools/avrdude.conf -v -v -v -v -F -b19200 -patmega328p -cstk500v1 -P/dev/ttyUSB0 -Uflash:w:sketch.cpp.hex:i

The flashing process starts :

...
Writing | #                                                  | 1% 0.08savrdude: Send: U [55] @ [40] . [00]   [20]
Writing | #                                                  | 2% 0.17savrdude: Send: U [55] . [80] . [00]   [20] 
...

and stops very quickly :

avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

I've also tried to use other baud rates (38400 and 57600) w/o success.

Thanks in advance for your help.

I have posted this in another thread but I thought I'd also post this here.

I have got he Optiboot boards to appear in the Arduino IDE.

What I did was create a Hardware folder in my sketches folder. Then added an optiboot folder which contains two folders bootloaders and cores and also boards.txt.
I then just copied everything into both bootloaders and cores - I guess these ought to be split out some how. I have NOT had chance to test this yet...

So I have

[ArduinoSketches]
|

  • optiboot
    |
  • /hardware
    |
  • boards.txt
    |
  • /cores
    | |
    | + [files]
    |
  • /bootloaders
    | |
    | + [files]
    |

[editied becaue I missed out the optiboot folder]