Go Down

Topic: NEWER New Optiboot bootloader (Read 119115 times) previous topic - next topic

Curie

The minimal breadboard Duino article has chip ID and Nick's programming software that accepts many ID's.

Here's a page with what you may want directly:

http://www.gammon.com.au/bootloader





Hi,

I went through Nick Gammon's forum (http://www.gammon.com.au/forum/?id=11635) and am so happy to tell you that i could detect the ATmega328PB's signature correctly as well as could upload the bootloader onto the chip. Thank you for guiding me!

I think the issue was with the internal clock as somehow it couldn't detect the chip and i was stuck. On the forum, i found an alternative to it. Using the sketch Atmega_Board_Programmer, i got an alternative of getting a 8MHz clock signal on pin D9 of the programming board.
Now, i can move forward to programming my board :)



Curie

It is not in the data sheet. The most concrete information about shared use of SPI lines, that I can find, is here: http://ww1.microchip.com/downloads/en/appnotes/atmel-2521-avr-hardware-design-considerations_applicationnote_avr042.pdf , although this may not exactly cover your scenario.

However, there is a also lot of anecdotal evidence about the wisdom of keeping clear of the SPI lines when possible to minimise the risk of interference with attempts to program the device, for example: https://www.avrfreaks.net/forum/can-i-reuse-isp-pins-other-taskstarget-atmega164p?skey=reuse%20of%20spi%20lines

As a result of my own experience, I attempt to keep at least 1K away from the SPI lines where possible. I documented some of this here: https://forum.arduino.cc/index.php?topic=673817.0 (post#6 onwards)

Thank you for sharing the knowledge. I am sure it will help others as well.

Also, i finally could get the bootloader onto the chip!

henkees

Hi,

I am doing a thesis which include adding functionality to flash sketches over CAN (using a module). Optiboot should be kept as original as possible since the author of the thesis want to keep possibilities for the original sketch upload.

At the moment I'm trying to flash a sketch (example blink sketch but with external LED connected to pin 7) where the data bytes of the hexfile is put into an uint8 array and then written to flash. This is working as expected, I've compared the flash content using my flash method to uploading the sketch using Arduino IDE. The content of flash is exactly the same.

The problem is that the application never starts running. At power on, neither the built in LED or the LED connected to pin 7 flashes. If i but the reset button, the built in LED flashes constantly.

I suspect that my way of end the flash procedure and jump to application doesn't work. From my understanding, when the watchdog with time 1 second runs out, there should be a jump to 0x0000 since Optiboot only runs after a external reset. However, it seems like I get stuck in a bootloader loop.

Hardware: Arduino nano with ATmega328p, using version 8 of Optiboot.

Can anyone help me to understand what needs to be done to start the application after written a sketch to flash?

Attaching my function that writes to flash, which gets called just before the forever for-loop that reads UART.
Except that, no changes have been done to Optiboot.

Best regards,
Henrik


Coding Badly


Check your fuses.  Carefully check them again.


henkees

From my understanding the fuses doesn't affect execution from flash.
Are you referring to the lock bits?

How ever, lock bits are described in the datasheet to protect the memory from software updates, and my data get's stored in memory fine. It's after the flash the problem occurs. The execution of the loaded sketch doesn't start.

Best regards

6v6gt

There are also the HIGH fuse bits which determine boot sector size, start address and boot reset vector enabled status. The original Nano fuses settings are designed for a 2KB boot loader. Optiboot is 512B. However, the install bootloader option of the Arduino IDE, if you used that, normally ensures the correct fuse settings are made for the chosen bootloader (board type). Uno is usually a good choice of board type if you want to install Optiboot on a Nano.
Maybe this makes it clearer what the Fuse options are: https://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p

henkees

Since we are implementing CAN support in the bootloader we have extended the boot sector to 4096 bytes.
Highfuse are 0xD0 and I have changed the makefile's linker directives to: atmega328: LDSECTIONS  = -Wl,--section-start=.text=0x7000 -Wl,--section-start=.version=0x7ffe.

I have kept the functionality to upload sketches through UART in my version of Optiboot, and when I upload a sketch with Arduino IDE (using my version of Optiboot) the sketch runs fine. So the problem shouldn't be the placement of bootloader code or fuse for reset vector since a external programmer is needed for flashing bootloader?


westfw

#127
May 11, 2020, 08:55 pm Last Edit: May 11, 2020, 10:10 pm by Coding Badly
Did you see https://github.com/Optiboot/optiboot/issues/250 and https://github.com/Optiboot/optiboot/issues/247?
Basically, if you're going to try to reset your board via some mechanism other than hardware reset or poweron, you should reset both MCUSR and the watchdog at the beginning of your code.



GoForSmoke

Hi,

I went through Nick Gammon's forum (http://www.gammon.com.au/forum/?id=11635) and am so happy to tell you that i could detect the ATmega328PB's signature correctly as well as could upload the bootloader onto the chip. Thank you for guiding me!

I think the issue was with the internal clock as somehow it couldn't detect the chip and i was stuck. On the forum, i found an alternative to it. Using the sketch Atmega_Board_Programmer, i got an alternative of getting a 8MHz clock signal on pin D9 of the programming board.
Now, i can move forward to programming my board :)

Nick sez: "If you bought a "raw" chip direct from the manufacturer you should not have this problem, as the chips default to using an internal 8 MHz oscillator. But if you got your chip from a third party who already installed a bootloader, then the "fuse settings" may have been changed to expect the crystal."

Nick's Blog/Tutorial: Solving problems with uploading programs to your Arduino.
This gets into fuses, even covers using high-V programmers to unbrick AVRs.
http://www.gammon.com.au/forum/?id=11643

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Juraj

@henkees

  watchdogConfig(WATCHDOG_16MS); // for a reset of the MCU
  while (1); // to prevent return to application in the 15MS to reset
 

windoze_killa

#130
Oct 29, 2020, 04:15 am Last Edit: Oct 29, 2020, 04:16 am by windoze_killa
Hi All,

I am using an ATTiny3217 with a standard bootloader and everything is working fine. With this being the case would there be a reason to install the Optiboot bootloader? The only reason I installed a boot loader at all was to set the UPDI pin to GPIO as I NEEDED to use that pin for analog in.
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

CrossRoads

That's your call. Application specific, designer's choice.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

windoze_killa

Are you stalking me??

And thanks.
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

westfw

Quote
am using an ATTiny3217 with a standard bootloader
What do you think is the "standard" bootloader?  AFAIK, optiboot is the only tiny-1 series bootloader that's been implemented and works with Arduino.  (optiboot is what DrAzzy's "core" uses.)

windoze_killa

In the board manager you can select 3217 or 3217 (optiboot)
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

Go Up