Go Down

Topic: New optiboot; beta testers welcome... (Read 117 times) previous topic - next topic

westfw

Quote
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():
Code: [Select]
  // 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.

Quote
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.

pito

Quote
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!

jmomjo


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:

Code: [Select]
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 :
Code: [Select]
#define UART_TX_BIT            7
#define UART_RX_BIT            6


2. Built it :
Code: [Select]
make atmega328 SOFT_UART=1 BAUD_RATE=19200

I use Arduino IDE 1.0.5 to flash Optiboot with USBtinyISP.
Content of boards.txt :
Code: [Select]
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.
Code: [Select]
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 :
Code: [Select]
...
Writing | #                                                  | 1% 0.08savrdude: Send: U [55] @ [40] . [00]   [20]
Writing | #                                                  | 2% 0.17savrdude: Send: U [55] . [80] . [00]   [20]
...

and stops very quickly :
Code: [Select]
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.

sirch

#333
Jul 18, 2013, 11:09 pm Last Edit: Jul 19, 2013, 08:29 am by sirch Reason: 1
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]

Mike T

instead of copying the "cores" directory, you can reference the original Arduino cores directory using the following line in boards.txt:
Code: [Select]
arduino_optiboot.build.core=arduino:arduino

"arduino_optiboot" has to be replaced by your own prefix

cabbagecreek

I want to be a betatester for a optiboot that works for the Arduino Mega 2560 and maybe solves my problem with wireless programming.

I got problems with wireless programming Arduino Mega 2560. It is working with Arduino UNO.

I was suggested to use Arduino IDE 1.0.5.
The Arduino IDE 1.0.5 did not change a thing..

I tried to add all loging that is availabe and created this loggs:

Programming with Arduino IDE 1.0.5 and the USB cable connected as COM71 and uploading Blink.ino:
Code: [Select]

Binary sketch size: 1 632 bytes (of a 258 048 byte maximum)
C:\Program Files (x86)\Arduino\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P\\.\COM71 -b115200 -D -Uflash:w:C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
        Copyright (c) 2007-2009 Joerg Wunsch

        System wide configuration file is "C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf"

        Using Port                    : \\.\COM71
        Using Programmer              : wiring
        Overriding Baud Rate          : 115200
avrdude: wiring_open(): releasing DTR/RTS
avrdude: wiring_open(): asserting DTR/RTS
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv: . [1b]
avrdude: Recv: . [01]
avrdude: Recv: . [00]
avrdude: Recv: . [0b]
avrdude: Recv: . [0e]
avrdude: Recv: . [01]
avrdude: Recv: . [00]
avrdude: Recv: . [08]
avrdude: Recv: A [41]
avrdude: Recv: V [56]
avrdude: Recv: R [52]
avrdude: Recv: I [49]
avrdude: Recv: S [53]
avrdude: Recv: P [50]
avrdude: Recv: _ [5f]
avrdude: Recv: 2 [32]
avrdude: Recv: t [74]
avrdude: stk500v2_getsync(): found AVRISP programmer
        AVR Part                      : ATMEGA2560
        Chip Erase delay              : 9000 us
        PAGEL                         : PD7
        BS2                           : PA0
        RESET disposition             : dedicated
        RETRY pulse                   : SCK
        serial program mode           : yes
        parallel program mode         : yes
        Timeout                       : 200
        StabDelay                     : 100
        CmdexeDelay                   : 25
        SyncLoops                     : 32
        ByteDelay                     : 0
        PollIndex                     : 3
        PollValue                     : 0x53
        Memory Detail                 :

                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
(some data deleted)

        Programmer Type : Wiring
        Description     : Wiring
        Programmer Model: AVRISP
avrdude: Send: . [1b] . [02] . [00] . [02] . [0e] . [03] . [90] . [86]
avrdude: Recv: . [1b]
avrdude: Recv: . [02]
(deleted alot ocf programmer data)
avrdude: Recv: . [0e]
avrdude: Recv: . [13]
avrdude: Recv: . [00]
avrdude: Recv: . [12]
### | 100% 0.26s

avrdude: 1632 bytes of flash written
avrdude: verifying flash memory against C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:
avrdude: load data flash data from input file C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:
avrdude: input file C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex contains 1632 bytes
avrdude: reading on-chip flash data:

Reading | avrdude: Send: . [1b] . [17] . [00] . [05] . [0e] . [06] . [80] . [00] . [00] . [00] . [81]
avrdude: Recv: . [1b]
avrdude: Recv: . [17]
avrdude: Recv: . [00]
(deleted olot of verifying data)
avrdude: Recv: . [ff]
avrdude: Recv: . [cf]
avrdude: Recv: . [0d]
avrdude: Recv: . [00]
avrdude: Recv: . [00]
avrdude: Recv: 3 [33]
### | 100% 0.19s

avrdude: verifying ...
avrdude: 1632 bytes of flash verified
avrdude: Send: . [1b] . [1f] . [00] . [03] . [0e] . [11] . [01] . [01] . [18]
avrdude: Recv: . [1b]
avrdude: Recv: . [1f]
avrdude: Recv: . [00]
avrdude: Recv: . [02]
avrdude: Recv: . [0e]
avrdude: Recv: . [11]
avrdude: Recv: . [00]
avrdude: Recv: . [19]

avrdude done.  Thank you.


Programming with Arduino IDE 1.0.5 and the SRF/XRF connected as COM70 and uploading Blink.ino:
Code: [Select]

Binary sketch size: 1 632 bytes (of a 258 048 byte maximum)
C:\Program Files (x86)\Arduino\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P\\.\COM70 -b115200 -D -Uflash:w:C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
        Copyright (c) 2007-2009 Joerg Wunsch

        System wide configuration file is "C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf"

        Using Port                    : \\.\COM70
        Using Programmer              : wiring
        Overriding Baud Rate          : 115200
avrdude: wiring_open(): releasing DTR/RTS
avrdude: wiring_open(): asserting DTR/RTS
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.


By looking at this the avrdude si sending 1b,01,00,01,0e,01,14 and waits for a
avrdude: Recv: . [1b]
avrdude: Recv: . [01]
avrdude: Recv: . [00]
avrdude: Recv: . [0b]
avrdude: Recv: . [0e]
avrdude: Recv: . [01]
avrdude: Recv: . [00]
...
If it dont receive this it tries again 5 times and report this message
Quote
avrdude: stk500v2_ReceiveMessage(): timeout


This errormessage can be found all over internet with the Arduoino Mega 2560.

This page is Arduino troubleshooting:
http://arduino.cc/en/Guide/Troubleshooting#toc1

On this page
Quote
The Arduino Uno and Mega 2560 use standard drivers (USB CDC) provided by the operating system to communicate with the ATmega8U2 on the board. Other Arduino boards use FTDI drivers to communicate with the FTDI chip on the board (or in the USB-serial convertor).


I have used the Arduino UNO and it is working but Not the Arduino Mega 2560!

The differance is that the Arduino UNO uses protocol Arduino (uno.upload.protocol=arduino in Board.txt)
while Arduino MEGA 2560 uses protocol wiring (mega2560.upload.protocol=wiring in Board.txt).

Another thing that ias different is that Arduino UNO uses a optiboot bootloader
(uno.bootloader.path=optiboot and uno.bootloader.file=optiboot_atmega328.hex in Board.txt)
while the Arduino MEGA 2560 uses stk500v2
(mega2560.bootloader.path=stk500v2 and mega2560.bootloader.file=stk500boot_v2_mega2560.hex in Board.txt)






westfw

Optiboot would need a significant re-write in order to work on the 2560, because the upload "protocol" that optiboot implements (stk500v1) only works for flash memory sizes less than 64k words (and the 2560 has 128k words.)

It would probably be easier to "fix" the stk500v2 bootloader.  It currently looks like it is not receiving ANYTHING on your wireless connection, which ought to be somewhat easy to figure out...

Unfortunately, I don't seem to have a lot of interest in "big" Arduinos.  My poor MEGA (1280 version) sits around neglected while I fiddle with 8k chips like the atmega8...

NicoHood

Sorry about referring here but you've probably the knowlegde to give me an assessment with this problem:
http://forum.arduino.cc/index.php?topic=126160.0

hiduino

#338
Aug 14, 2014, 02:32 am Last Edit: Aug 14, 2014, 02:34 am by hiduino Reason: 1
I have a need for my sketch to detect if the Arduino Uno R3 is being powered on vs reset.  The issue is that I have an audio DAC that is initialized from zero to 1/2 way audio level to avoid an audio "pop" sound on the output.  However, once it has been initialized and I do a soft reset it will cause the audio "pop" because of the initialization routine starting at zero level.

So I have been trying to use Optiboot-5.0 or Optiboot-6.0  for the reset flags passing to the main sketch.
Code: [Select]

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


I have in my main sketch the code to pass the flags.
Code: [Select]

uint8_t resetFlags __attribute__ ((section(".noinit")));
void resetFlagsInit(void) __attribute__ ((naked)) __attribute__ ((section (".init0")));
void resetFlagsInit(void)
{
 // save the reset flags passed from the bootloader
 __asm__ __volatile__ ("mov %0, r2\n" : "=r" (resetFlags) : );
}

void setup() {
 // Get reset flags
 resetFlagsInit();

 // ramp up to mid audio level to avoid pop, unless from reset.
 mcpDacInit();
 if (resetFlags & _BV(PORF)) {
   for(int i=0; i<=2048; i++) {
     mcpDacSend(i);
     delayMicroseconds(50);
   }
 }
}


The problem is it appears the "Adaboot no wait mod" is not working at all.  Each time I plug in the power from USB or the jack it still executes the bootloader (I see the LED start flashes).  So it appears the EXTRF (External Reset Flag) is always set along with the PORF (Power-on Reset Flag).  I am guessing this is due to how the hardware power-on reset circuit is done on the Arduino Uno R3.

@westfw have you verified that the "Adaboot no wait mod" actually still works?

I have modified the no-wait check to this instead and it appear to work correctly with my code now.
Code: [Select]

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



westfw

#339
Aug 14, 2014, 08:07 am Last Edit: Aug 14, 2014, 08:36 am by westfw Reason: 1
Quote
have you verified that the "Adaboot no wait mod" actually still works?

Hmm.  I works here on assorted atmega8, atmega168, and mega328p boards.  But not on my Uno SMD (r2)...
Your patch (actually, a variation of it) does seem to help...

( https://code.google.com/p/optiboot/issues/detail?id=111 )

oric_dan


Optiboot would need a significant re-write in order to work on the 2560, because the upload "protocol" that optiboot implements (stk500v1) only works for flash memory sizes less than 64k words (and the 2560 has 128k words.)

It would probably be easier to "fix" the stk500v2 bootloader.  It currently looks like it is not receiving ANYTHING on your wireless connection, which ought to be somewhat easy to figure out...

Unfortunately, I don't seem to have a lot of interest in "big" Arduinos.  My poor MEGA (1280 version) sits around neglected while I fiddle with 8k chips like the atmega8...
.
Does this mean that the maniacbug optiboot for the mega1284 will fail for programs > 64K?

Testato

maniacbug writed
Quote
Requirements
Works only on Arduino >= 1.0
Cannot be burned using USBtinyISP. That programmer cannot flash to chips with >64k flash size.

So I think that the maniacbug optiboot version is modified for sketch > 64K, but i do not looked inside code
- [Guida] IDE - http://goo.gl/ln6glr
- [Lib] ST7032i LCD I2C - http://goo.gl/GNojT6
- [Lib] PCF8574+HD44780 LCD I2C - http://goo.gl/r7CstH

westfw

Quote
Does this mean that the maniacbug optiboot for the mega1284 will fail for programs > 64K?

No, because it's a WORD count rather than a byte count.  The mega1284 (and the mega1280 as well) only have 64k words, so the optiboot loads (and works) fine using ArduinoISP.

oric_dan


westfw

I've checked in v6.1, incorporating this fix for the fast boot, and fixing OPTIBOOT_CUSTOMVER a bit.
Code: [Select]
  if (ch & (_BV(WDRF) | _BV(BORF) | _BV(PORF)))
      appStart(ch);


Go Up