Page 1 of 3
Bootloader upgrade (optiboot)
Posted: Mon Jun 13, 2011 9:34 pm
by rimai
Hello everyone,
I'd like to release the upgraded version of the Reef Angel Bootloader, which is a variant of the optiboot bootloader.
To upgrade your Reef Angel controller, you will need a in-system programmer.
More info on the in-system programmer and how to burn a new bootloader:
http://arduino.cc/en/Hacking/Bootloader ... Bootloader
The advantages of using the new bootloader:
- Original: 30720 available space
- Optiboot: 32256 available space
- Original: 57600 baud
- Optiboot: 115200 baud
- Immediate start of sketches
- Original: Unit resets and blinks 3 times and waits around 1 second to start sketches with both power on and upload code
- Optiboot: Unit resets and immediatelly starts sketches on power-on and only blinks and waits for upload code if it is manually reset or triggered by the COM port of your computer
- Watchdog timer functionality
- Original: enabling WDT would cause a continuous reset of the controller
- Optiboot: WDT check is built-in and you can use WDT timer to cause the controller to restart by itself in case of lock-ups
Before you burn the new bootloader, you will need to modify one file.
The file is called boards.txt and is located at C:\Program Files\Reef Angel Controller\hardware\arduino
Add the following to the top of the file:
Code: Select all
##############################################################
RA.name=Reef Angel Controller w/ optiboot
RA.upload.protocol=stk500
RA.upload.maximum_size=32256
RA.upload.speed=115200
RA.bootloader.low_fuses=0xff
RA.bootloader.high_fuses=0xde
RA.bootloader.extended_fuses=0x05
RA.bootloader.path=optiboot
RA.bootloader.file=optiboot_ReefAngel.hex
RA.bootloader.unlock_bits=0x3F
RA.bootloader.lock_bits=0x2F
RA.build.mcu=atmega328p
RA.build.f_cpu=16000000L
RA.build.core=arduino
How to burn the new bootloader:
- Download the attached file optiboot_ReefAngel.zip
- Extract the file to the folder C:\Program Files\Reef Angel Controller\hardware\arduino\bootloaders\optiboot
- Open Arduino IDE
- In the menu, navigate to Tools->Boards and select Reef Angel Controller w/ optiboot
- In the menu, navigate to Tools->Burn Bootloader and choose which ISP burner you have.
Note: The Reef Angel Installer can be reinstalled/updated and it will come with the bootloader file and the board.txt already modified.
Re: Bootloader upgrade (optiboot)
Posted: Tue Jun 14, 2011 8:11 am
by NanoTrevor
thanks for this roberto, how hard is it to get to the connector we need to connect to?
Re: Bootloader upgrade (optiboot)
Posted: Tue Jun 14, 2011 10:39 am
by binder
If we are unable to obtain this and handle this, is there an option for us to ship you our controller and have you upgrade / update it for us?
curt
Re: Bootloader upgrade (optiboot)
Posted: Tue Jun 14, 2011 12:33 pm
by rimai
NanoTrevor wrote:thanks for this roberto, how hard is it to get to the connector we need to connect to?
You can buy it at Digikey, Sparkfun or Adafruit:
http://parts.digikey.com/1/parts/408608 ... risp2.html
http://www.sparkfun.com/products/9825
http://www.adafruit.com/products/46
Or build a simple one yourself:
http://arduino.cc/en/Hacking/ParallelProgrammer
binder wrote:If we are unable to obtain this and handle this, is there an option for us to ship you our controller and have you upgrade / update it for us?
curt
Yes, just send me a PM if you would like to send me your head unit for bootloader upgrade.
Re: Bootloader upgrade (optiboot)
Posted: Sat Jun 18, 2011 1:53 pm
by binder
Have you had any problems with the new bootloader?
I can only communicate with my controller every second time. I try to connect the first time and it errors out. Then I try again and it connects. This is from a Windows XP machine.
I can also no longer communicate from linux. I get a programmer not responding error when communicating with the serial cable.
Just as a side note: the upload went fine with the bootloader.
Re: Bootloader upgrade (optiboot)
Posted: Sat Jun 18, 2011 2:39 pm
by rimai
I can't seem to be able to replicate the same problem on a Win7 x64.
Just as curiosity, which programmer did you use to burn the bootloader?
When avrdude starts the upload process, it resets the controller. Do you see the 3 flashes indicating it's been reset?
I just added the original bootloader to the 1st post if you want to go back.
I can try an XP machine on Monday.
Re: Bootloader upgrade (optiboot)
Posted: Sat Jun 18, 2011 3:13 pm
by binder
rimai wrote:I can't seem to be able to replicate the same problem on a Win7 x64.
Just as curiosity, which programmer did you use to burn the bootloader?
When avrdude starts the upload process, it resets the controller. Do you see the 3 flashes indicating it's been reset?
I just added the original bootloader to the 1st post if you want to go back.
I can try an XP machine on Monday.
I used the sparkfun programmer. It uses the usbtiny progamming. avrdude loads the bootloader just fine. after that, it can communicate but for me it was every 2nd time it would go through properly. i reverted back to the original bootloader that was already inside the bootloaders (I looked at the boards.txt file to see what the bootloader was). Reverting back lets me communicate again via linux and i haven't had problems yet.
I will say that I initially had to use avrdude from the command line to get it to work the first time. After that, arduino can upload the bootloader.
I'm going to try the new bootloader again later on tonight or this weekend.
curt
Re: Bootloader upgrade (optiboot)
Posted: Sat Jun 18, 2011 9:49 pm
by rimai
Ok, I was finally able to replicate the issue.
I'll investigate what it is.
It never happened yet for me when I try loading a code from RAGen, but if I load simple codes, it always does it.
Re: Bootloader upgrade (optiboot)
Posted: Sat Jun 18, 2011 10:42 pm
by binder
rimai wrote:Ok, I was finally able to replicate the issue.
I'll investigate what it is.
It never happened yet for me when I try loading a code from RAGen, but if I load simple codes, it always does it.
It happened to me on my SetInternalMemory and RAMenus PDE files. Just letting you know.
curt
Re: Bootloader upgrade (optiboot)
Posted: Sun Jun 19, 2011 8:43 pm
by rimai
I've uploaded optiboot_ReefAngel_v2.zip to 1st post.
Can you try that one, Curt?
I've changed some stuff, but I had to kind of disable the no-wait boot. So, you will get the 3 blinks no matter on power-on or reset.
Let me know if it works on Linux now.
Roberto.
Re: Bootloader upgrade (optiboot)
Posted: Sun Jun 26, 2011 5:40 pm
by chrome
Curt just wondering if you verified that this optiboot v2 fixed your problem with having to upload multiple times? I'm running the original v1 optiboot and am just starting to have that problem as well.
Re: Bootloader upgrade (optiboot)
Posted: Sun Jun 26, 2011 5:51 pm
by binder
I haven't tested the v2 fully yet. Preliminary tests did prove that Windows communications had improved but Linux was still a no go. I'm going to test again either tonight or tomorrow. I had some other stuff to code with the libraries first before I test again.
I will post my results.
curt
Re: Bootloader upgrade (optiboot)
Posted: Sun Jun 26, 2011 6:04 pm
by chrome
Sweet thanks.
Btw do you know if you have to enable the WDT functionality in your sketch or is it automatic?
Re: Bootloader upgrade (optiboot)
Posted: Sun Jun 26, 2011 6:20 pm
by binder
chrome wrote:
Btw do you know if you have to enable the WDT functionality in your sketch or is it automatic?
I think you have to add the functionality into your sketch but I'm not positive on this. Roberto will have to answer that question.
curt
Re: Bootloader upgrade (optiboot)
Posted: Sun Jun 26, 2011 6:26 pm
by rimai
It has to be added, but I'm waiting your tests with Linux before we go there.
There are advert effects on using WDT at the moment. It is rebooting the controller every time it enters into menu settings screen. The reason is that once the user enters the settings change screen, the main loop function is never executed and thus causing the WDT not to reset and it times out causing the controller to reboot itself.
Once we get the bootloader resolved, we can add wdt_reset() lines on the menu screens to prevent this from happening.
Re: Bootloader upgrade (optiboot)
Posted: Sun Jun 26, 2011 10:39 pm
by aranax
Just following thread as I am having the same issue (menu reset and having to connect more than once).
Jeremiah
Re: Bootloader upgrade (optiboot)
Posted: Mon Jun 27, 2011 12:11 pm
by binder
Just tested out optiplex V2 and it's the same. Here's what I noticed:
Once upgraded, I was able to upload my RAMenus sketch from Win XP using Arduino 0022. After that, I tried to communicate with my standard Linux install using the optiplex communication protocols:
Code: Select all
RA.name=Reef Angel Controller w/ optiboot
RA.upload.protocol=stk500
RA.upload.maximum_size=32256
RA.upload.speed=115200
RA.bootloader.low_fuses=0xff
RA.bootloader.high_fuses=0xde
RA.bootloader.extended_fuses=0x05
RA.bootloader.path=optiboot
RA.bootloader.file=optiboot_ReefAngel.hex
RA.bootloader.unlock_bits=0x3F
RA.bootloader.lock_bits=0x0F
RA.build.mcu=atmega328p
RA.build.f_cpu=16000000L
RA.build.core=arduino
That's the same on both WinXP and Linux.
I was unable to communicate with my controller. It attempts to communicate. It resets the board but it boots too fast for it to receive the commands. So when the computer is sending the commands, the controller is already running and ignoring the requests.
I then went back to WinXP and tried to upload more code. I sent the SetInternalMemory file over. That went through fine. I tried to reload the RAMenus file and haven't been able to. The computer tries to send the code, the controllers screen blacks out and the it attempts to receive the commands but it fails. Here's what the output is:
Code: Select all
avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
System wide configuration file is "C:\Program Files\Reef Angel Controller\hardware/tools/avr/etc/avrdude.conf"
Using Port : \\.\COM3
Using Programmer : stk500v1
Overriding Baud Rate : 115200
avrdude: ser_open(): setting dtr
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: Send: Q [51] [20]
avrdude: Recv:
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
avrdude done. Thank you.
The controller's screen stays black and I have to power cycle it to get it to run the setinternalmemory code again. I was able to get it to receive the setinternalmemory file again but that's it. I cannot upload my ramenus code at all now. I've tried reopening Arduino but that hasn't worked.
So, it looks like this version didn't help any either.
curt
Re: Bootloader upgrade (optiboot)
Posted: Mon Jun 27, 2011 12:15 pm
by chrome
Yep thats the same error I am currently getting with optiboot v1.. however its random and only happens at certain times. Sometimes it works after the 2nd or 3rd time I upload, sometimes on the first try... completely random.
Re: Bootloader upgrade (optiboot)
Posted: Tue Jun 28, 2011 2:41 pm
by rimai
One more time.
I uploaded v2.1 to original post.
Let me know if the problem still persists.
Re: Bootloader upgrade (optiboot)
Posted: Tue Jun 28, 2011 5:32 pm
by binder
rimai wrote:One more time.
I uploaded v2.1 to original post.
Let me know if the problem still persists.
I think we may be on to something here. I just uploaded the new bootloader to my controller using Win XP. I then plugged it into my Linux machine, then uploaded my SetInternalMemory. It worked like a charm. I was then able to upload my RAMenus file just fine. I've since uploaded it 3 times in a row without any problems. The upload does seem to be faster too. The red LED stays on during the upload (it's either solid or blinking too fast for it to flicker). The controller starts up with virtually no delay. It's almost like an "instant on" controller now. It really does seem faster at bootup than the original bootloader.
So far, I am impressed with the bootloader. I've got it running and will keep it running with my testing.
Good job!
curt
Re: Bootloader upgrade (optiboot)
Posted: Wed Jun 29, 2011 9:28 am
by rimai
Awesome.
Keep me updated.
I'm going to start getting the wdt function inside the libraries.
Re: Bootloader upgrade (optiboot)
Posted: Wed Jun 29, 2011 10:44 am
by binder
rimai wrote:Awesome.
Keep me updated.
I'm going to start getting the wdt function inside the libraries.
Will do. If there's some code you want me to test with the wdt function, just let me know.
How often does it need to be "touched"? 500ms, 1 second, 5 seconds?
curt
Re: Bootloader upgrade (optiboot)
Posted: Wed Jun 29, 2011 4:26 pm
by rimai
Re: Bootloader upgrade (optiboot)
Posted: Sun Jul 03, 2011 11:19 am
by rimai
Did you have any problems uploading sketches?
Try this:
Code: Select all
void setup()
{
pinMode(7,OUTPUT);
}
void loop()
{
digitalWrite(7,HIGH);
delay(500);
digitalWrite(7,LOW);
delay(500);
}
Can you still upload sketches fine after uploading the above code?
Re: Bootloader upgrade (optiboot)
Posted: Sun Jul 03, 2011 5:51 pm
by binder
Have you tested the WIFI module after using the new optiboot bootloader?
I just plugged in my wifi module to my controller to test. I reconfigured my wifi module to be baudrate of 115200 (set u b 115200) then saved & rebooted. I plugged in my wifi module to the controller and rebooted. I tried to browse to the page but kept getting garbage being sent to me. I tried the root and wifi pages with just a bunch of garbage.
Any thoughts?
curt
Re: Bootloader upgrade (optiboot)
Posted: Sun Jul 03, 2011 6:38 pm
by chrome
I was having trouble with the wifi once I updated the bootloader as well.. it was a random issue. Everything is a random issue with the ReefAngel it seems... like my temp2 sensor either locking up or getting stuck on a certain temp.
I also got the "garbage" sent back (tera term also has garbage sent back to it), but figured this was normal, as I didnt play with the wifi much on the normal bootloader. I also couldn't get the IP stuff working so instead of the wifi looking for webbanner on reefangel.com, it would look to my local box. I had quite a few pm's with Roberto about it, but all his solutions didn't solve the issue. Did all the stuff Roberto recommended, and still wouldn't work. He eventually gave up PM'ing me on how to fix it.
The only thing I could get to work consistently was the /r99 command on port 2000... and honestly I hate this solution, because it makes it harder to forward ports and host some scripts on remote servers to parse the data.
The only reason I wanted the Reefangel in the first place was for the Wifi, but its total fail IMO. I'm pretty close to just tossing it all in the garbage and getting an apex
Re: Bootloader upgrade (optiboot)
Posted: Sun Jul 03, 2011 6:43 pm
by rimai
Hey Curt,
You need a beer to keep your brain going, man!!!
I think that question was asked without much thinking... lol
Line 381 from ReefAngel.cpp v.0.8.5.15
So, everything still runs at 57600.
You can change it if you want to, but it would cause a lot of confusion.
Only the bootloader runs at 115200, but that's just the upload speed and it's transparent to the user.
Re: Bootloader upgrade (optiboot)
Posted: Sun Jul 03, 2011 7:12 pm
by binder
rimai wrote:Hey Curt,
You need a beer to keep your brain going, man!!!
I think that question was asked without much thinking... lol
Line 381 from ReefAngel.cpp v.0.8.5.15
So, everything still runs at 57600.
You can change it if you want to, but it would cause a lot of confusion.
Only the bootloader runs at 115200, but that's just the upload speed and it's transparent to the user.
DOH! (in a Homer Simpson voice).
I'm not quite sure what all is going on with the new bootloader. I switched the wifi board back to 57600 and loaded the default bootloader and it works fine now for me. I'm gonna re-test the new bootloader again later but I had to get things working properly for something I'm testing.
curt
Re: Bootloader upgrade (optiboot)
Posted: Thu Jul 07, 2011 1:41 pm
by rygh
Just FYI for all:
I have successfully enabled the watchdog timer on my sketch.
Running windows, optiboot, no wifi.
Very easy. Enabled at setup, and I only needed two places to clear it. One in the main
loop in my sketch, and one in the GUI setup loop.
I set delay to 1 second. I don't really see any reason to go faster.
I did test it with a while(1), and it reset fine.
Re: Bootloader upgrade (optiboot)
Posted: Tue Jul 12, 2011 3:05 pm
by binder
rimai wrote:Did you have any problems uploading sketches?
Try this:
Code: Select all
void setup()
{
pinMode(7,OUTPUT);
}
void loop()
{
digitalWrite(7,HIGH);
delay(500);
digitalWrite(7,LOW);
delay(500);
}
Can you still upload sketches fine after uploading the above code?
Yeah, I can upload without any problems. I just loaded the v4 bootloader and haven't had any problems. I used windows to upload the bootloader and then switched over to linux. I ran the code, then uploaded my internal memory pde then the ramenus pde and reloaded it again. So far, so good.
Haven't messed around with the wdt stuff yet. I've been working on some other stuff instead.
curt