Please recommend bootloader (and debugger)?

Go To Last Post
28 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am well into my first Arduino project, and have only just discovered this site.  I wish I found it earlier!  I have been using the Arduino software for development, and am now seeing there are other options.  And although new to Arduino, I am an experienced software developer, and have had a hard time debugging with Serial.print - and am now seeing there are other options for that too! 

 

So my project is based on the Pro Mini.  I have it connected to a BLE Bluetooth modem for communication with an iPhone.  I will have the need to upgrade the firmware from the iPhone, so will need to do my own bootloader (if there is code for that already, please let me know!)

 

Can anyone recommend what I should use for both uploading bootloaders, as well as debugging?  I've come across AVR Dragon.  Should I get that?  Anything better?  I am willing to spend some $$ if that will give me a better tool.

 

Sorry if this is a FAQ.  I've done some googling on this and didn't see the answers I'm seeking.

 

Thanks!

 

- Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel ICE is more modern and has effectively replaced Dragon now. Like Dragon there is a $50 version.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, thanks!  So it can be used to load a bootloader onto a Pro Mini?  And for debugging - will it let me set breakpoints, inspect variables, step through C++ source code?  How about simulating inputs and interrupts?  (I don't know if there is an emulator that does do that, but it would be nice!)  Or is there such a thing as a software emulator that effectively lets you do the same thing?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To get debugging, You'll need "Atmel Studio"

It does include a simulator, and there's an add-on specifically for Arduino.

Actually getting on-board debugging  with an Arduino Pro Mini will require that you make some minor HW modifications to the arduino (disable the "auto-reset" function.)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks.  I was just reading about Atmel ICE when you posted.  I'm seeing a lot of people confused about how to hook it up, and whether or not it will work with their particular CPUs.  I'll still get it if it's useful, but a software simulator sounds better.  So do you recommend the simulator in Atmel Studio over an ICE?  And if I go that route, what would you recommend I use for uploading bootloaders?  Newbie questions, I know!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

whether or not it will work with their particular CPUs. 

AFAIK, the Atmel ICE works with ALL Atmel CPUs.  It's the first Atmel debugger/programmer that does both ARM and AVR chips.

 

Atmel Studio is free, so there's no reason not to get it.  The Atmel ICE can be used to upload bootloaders (and for general purpose chip programming, whether or not you use it for debugging.)

 

In my experience, simulation is OK for debugging core code and algorithms, but gets messy as you start to need to simulate interaction with peripherals and external devices.  Setting up the simulated peripherals can be a complex as the program itself, or building real hardware, and you're never quite sure whether bugs are in you code, or in the way you've set up the simulator.  I'd much rather have a real on-chip debugger and real hardware.  (things are better if someone else has set up common peripherals for you, of course.)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OMG!!!!  I just installed Atmel Studio.  As I'm sure you know, it is basically a wrapper on top of Microsoft's Visual Studio.  I had no idea!  You don't know how happy this makes me.  I worked full time for over 10 years developing C++ applications on MS Visual Studio, so am very comfortable with it.  Coming from the Arduino IDE feels like I've been living among people that will only communicate in sign language, and coming to realize that they can speak English after all.  Or something like that ... you get the idea.

 

I will happily use Atmel Studio for now.  Arduino IDE: good bye and good riddance!  Maybe in the future I'll buy an ICE like Atmel ICE.  In the meantime, I could use a suggestion about how to burn a bootloader to a pro mini.  Or can I do that with an FTDI module and Atmel Studio...?

 

And maybe I should start another thread, but I'm having an issue with porting my code to Atmel Studio.

I ported my code over to Atmel Studio following instructions here: http://www.engblaze.com/tutorial-using-atmel-studio-6-with-arduino-projects/

 

Everything seems right, but in SoftwareSerial.cpp, the line:

 

#include <Arduino.h>

 

is giving an error "No such file or directory".

 

I did specify the include path for it in my compiler settings: "C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino". 

 

Arduino.h is in that folder.  Any ideas?

Last Edited: Thu. Mar 12, 2015 - 04:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Better yet is Visual Studio 2013 community + the Visual Micro plugin - BOTH are free.

There's a software-only debugger option for Visual Micro that's free to evaluate inexpensive if  you like it. It's not as fancy as a JTAG or SWD debugger but good enough for lots of cases.

 

http://www.visualmicro.com/

 

Amazing that MS opened Visual Studio 2013 Community at $0.00.

 

 

SoftwareSerial is a PITA. Can you use a  UART?

Last Edited: Thu. Mar 12, 2015 - 05:04 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Really?  Ok, I'll check it out.  What's the difference between that and Atmel Studio?  Or is that described somewhere?

 

Regarding SoftwareSerial - I know.  I'm using it for now, but am planning on trying to move everything to the mega serial lines.  For serial communication, I need to talk to my BLE modem, have a debugging monitor, and upload sketches (I guess I don't need to call executables that any more).  I think I can eventually get that all done by sharing Rx/Tx, but I'm not there yet - hence SoftwareSerial.

 

In any case, this isn't a SoftwareSerial issue I'm having.  It's some kind of strange issue with include paths on this IDE.  It should work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel Studio 6.2 (AS 6.2) uses Visual Studio 2010 and has no software-debugger other than the rarely used simulator. And support is from Atmel.

There's a Visual Micro plugin for AS 6.2.

This is fine.

 

But I prefer to use Visual Studio 2013 Community + Visual Micro since it's not Atmel-centric. And a newer version of VS.

 

Sorry - I know nada re software serial.

 

Last Edited: Thu. Mar 12, 2015 - 06:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dptdpt wrote:
For serial communication, I need to talk to my BLE modem, have a debugging monitor, ...
fyi, Adafruit's BLE board has SPI between the nRF8001 and AVR and a UART part in the iOS application.

dptdpt wrote:
... and upload sketches (I guess I don't need to call executables that any more).
Atmel Gallery has Atmel Serial Bootloader but :

  • mega328 is not implemented so would need a port to mega328.
  • the application stores the new application into external flash for the bootloader to burn.

Adafruit Industries

Introduction | Getting Started with the nRF8001 Bluefruit LE Breakout | Adafruit Learning System

Pinouts

https://learn.adafruit.com/getting-started-with-the-nrf8001-bluefruit-le-breakout?view=all#pinouts

Apple

Adafruit Bluefruit LE Connect on the App Store on iTunes

https://itunes.apple.com/us/app/adafruit-bluefruit-le-connect/id830125974

 Atmel Corporation

Atmel AVR2054 Serial and OTA Bootloader - Atmel Gallery

https://gallery.atmel.com/Products/Details/992efa59-3d2f-44b8-aa4d-ea7630026ed5

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the suggestion for the Adafruit board, but it's pricey compared to the BLE module I'm using ($20 vs $5). And as far as the Serial Bootloader, I'm hoping to not have to add external flash to my project. But maybe that will give me a start. I'll check it out.

Last Edited: Thu. Mar 12, 2015 - 06:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dptdpt wrote:

Thanks for the suggestion for the Adafruit board, but it's pricey compared to the BLE module I'm using ($20 vs $5). And as far as the Serial Bootloader, I'm hoping to not have to add external flash to my project. But maybe that will give me a start. I'll check it out.

 

Hi,

 

Do you have a link to your $5 BLE module?

 

Cheers,

 

Ross

 

Ross McKenzie, Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Better yet is Visual Studio 2013 community

Steve,

 

You keep mentioning that - does it REALLY integrate with Atmel's atbackend.exe so it can drive Atmel-ICE, JTAGICEmkII, JTAGICE3, Dragon and other programming/debugging tools from within the IDE?

 

Surely most of what sets AS6 apart from AS2010 is the work that has been done to integrate the Atmel debugger and simulator?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:

Do you have a link to your $5 BLE module?

 

 

Sure:

http://www.banggood.com/BLE-CC2541-Bluetooth-4_0-UART-Transceiver-Serial-Module-p-961876.html

Last Edited: Thu. Mar 12, 2015 - 11:01 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dptdpt wrote:

 

valusoft wrote:

Do you have a link to your $5 BLE module?

 

 

Sure:

http://www.banggood.com/BLE-CC2541-Bluetooth-4_0-UART-Transceiver-Serial-Module-p-961876.html

 

Thanks.

Ross McKenzie, Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Visual Micro's debugger on VS2013 CE has a subset of the function of Atmel's debuggers.

Visual Micro debugger :

  • via USB but further information at Visual Micro's web site states a wireless capability and, IIRC, Ethernet, UART, or Arduino Software Serial.
  • has a limited tracing capability.

Visual Micro - Arduino IDE fun for Visual Studio

Arduino IDE for Microsoft Visual Studio and Atmel Studio

http://www.visualmicro.com/page/Arduino-development-plugin-for-Visual-Studio.aspx

...

(about mid-page)

Visual Micro also includes an optional (not free) Arduino software debugger.

...

The usb debugger is a great assistance but does not have some features found in hardware debuggers. For example the Visual Micro debugger can only step between break points where as a hardware debugger can usually step each line of code. note: Changing break or trace point settings requires re-compile and upload to the Arduino

...

Visual Micro - Arduino IDE fun for Visual Studio

Visual Studio or Atmel Studio? - Arduino IDE for Visual Studio and Atmel Studio

http://www.visualmicro.com/page/User-Guide.aspx?doc=Getting-started-which-IDE.html

...

Advantages of Atmel Studio over Visual Studio

...

  • Atmel Studio has the simulator and various other tools.

...

Visual Micro - Arduino IDE fun for Visual Studio

How Tracepoints Influence Execution Speed of Your Sketch - Arduino IDE for Visual Studio and Atmel Studio

http://www.visualmicro.com/page/User-Guide.aspx?doc=Tracepoints-and-execution-speed.html

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dptdpt wrote:
... but it's pricey compared to the BLE module I'm using ($20 vs $5).
I "can't touch" that wink

The only counter I have are the Olimex nRF8001 modules at about 15USD retail IF the local or regional Olimex distributor has these in-stock; but, the Olimex modules are 3.3V instead of 5V capable.

The Future - hopefully BLEduino will have a sales channel.

The Present - if one doesn't want to wait Blend Micro may be a match.


www.olimex.com

https://www.olimex.com/Products/Duino/AVR/OLIMEXINO-NANO-BLE/

Bluetooth Low Energy module based on NRF8001 chipset for OLIMEXINO-NANO

www.olimex.com

https://www.olimex.com/Products/Modules/RF/MOD-nRF8001/

Bluetooth Low Energy module based on nRF8001 chipset

BLEduino: Bluetooth 4.0 Made Easy

http://bleduino.cc/

Arduino

Products

Arduino AtHeart

http://arduino.cc/en/ArduinoAtHeart/Products

(search for Bluetooth)

Edit : Blend Micro.

"Dare to be naïve." - Buckminster Fuller

Last Edited: Thu. Mar 12, 2015 - 08:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Reviving this thread...

 

So now I need to write my bootloader.  I've read up a bit on AVR bootloaders and have a basic understanding, but still have some studying to do. I am going to want to be able to upload firmware to a Pro Mini from an iPhone using Bluetooth (BLE).  The BLE modem connects to the AVR via the UART - Rx/Tx lines.  So I need a bootloader that can monitor these lines.  I suppose it would also be good if it remained compatible with avrdude.  My application firmware will also be using the BLE modem on the UART.

 

My vague plan for getting this to work is:

* When my main program gets a special message from the iPhone, indicating that it needs new firmware, it jumps into the bootloader.

* The bootloader takes over the Rx/Tx lines, and receives the new firmware.

* After updating the firmware, it jumps back into the main program.

 

Does this sound like a good plan?

 

If so, my questions are:

* Can you recommend bootloader source to use to get started?  Should I use the Atmel Serial Bootloader?

* How do I do the jumping back and forth between my application program and the bootloader? 

 

- Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When my main program gets a special message from the iPhone, indicating that it needs new firmware, it jumps into the bootloader.

Bad plan. Consider this scenario. The main program receives the message. It calls to the bootloader. It starts to receive the replacement code and program it into the AVR. Horror of horrors the power to the AVR dies part way through. Now you have an AVR that only has half (or less) of an app. It's quite possible that the stuff that does the receiving of the special message or the jumping to the bootloader has now gone. So now you have no way back into the bootloader to recover the situation! An app can be built to rely on parts of the bootloader and make use of those but a bootloader strategy cannot rely on any parts of the app being there because one day it might not be. For this reason a bootloader should be "self supporting". It should also be the case that the AVR BOOTRST fuse is enabled so that the thing that "runs first" at each an every power on is the bootloader. It will independently decide if there is new code to be gained (or just the absence of an app where there should be one may be trigger enough) and if it decides the AVr needs new code it gets on and has that conversation and gets it and programs it. All in the absence of relying on any app code. If it succeeds then the next time it starts it will determine there is no need to bootload so will just start the app code.

 

As for a "template". The Optiboot bootloader use for Arduino is probably a good place to start (simply because there's so much support availahble). It implements "AVR109" which is one of the protocols supported by avrdude. Your only complication is that it just talks "plain UART". So you will likely have to add some code to the start that not only initializes the UART but also "cranks up" the bluetooth interface to a point where it's willing to just echo AVR109 bytes from the "other side" to it. Then it can fall back to normal operation.

 

As for jumping. The app starts at 0x0000 so:

typedef void (*fptr_t)(void);

f_ptr_t reset;

int main(void) {
    reset = (ptr_t) 0x0000;
    reset();
}

that will "CALL 0". In fact you really want a "JMP 0" not a "CALL 0" but the fact that it's a CALL does not matter because one of the first things the code at 0x0000 is going to do is reset the stack pointer so any return address put on the stack will be "lost" anyway.

 

To get to the bootloader from the app the "safe" way is for the app to enable the watchdog timer then sit in a tight loop that does not contain WDR. After a few milliseconds the AVR will reset (very like power on in fact apart from the fact that WDRF in MCUSR is set) and because of BOOTRST it will start executing back at the start of the bootloader code. A side effect of a watchdog reset is that all the peripherals you may have programmed (ADC, timers, SPI, I2C, etc.) are set back to power on defaults so all are effectively "turned off" before entry back to the bootloader.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks clawson! There is nothing to do to initialize the BLE modem. So I thought I could just jmp to the bootloader address. If the watchdog timer technique is better, could you please elaborate on how that works? I don't know how to do what you're saying.
I will check out opiboot.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh then if the BLE just "looks" like the PC running avrdude as far as the AVR is concerned you can just pick up any ready-made, off-the-shelf bootloader and use that. Again Optiboot is probably the one to choose these days though "fboot" and "BLIPS" in the project section here are likely worth a look. The latter is AVR109 too so could be driven by avrdude while fboot has it's own protocol and hence its own fboot.exe for the PC end of things.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the advice.  I looked briefly at Optiboot.  It looks usable, although there are a ridiculous amount of conditional compilation directives and not the best commenting.  Nice clean code is always a good thing! 

 

Keep in mind that I'm on my own as far as writing the code for the other end of the connection.  I want to be compatible with something like avrdude and fboot that I can run directly from Atmel Studio when doing builds, but I also need to write the code for the iPhone to send build updates.  So is AVR109 documented somewhere, outside of looking at the code?

 

And based on what I am saying here, does that lead you to recommend anything in particular for a bootloader/protocol?

 

Thanks again!

 

- Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just found this unread thread on the 24th page of "Recent Discussions" (why on earth doesn't it group all the unread ones at the top of the list?!?)

 

AVR109 is, surprise, surprise, documented in Atmel Application Note AVR109. If you google it you will hit the PDF (and the accompanying .zip with code).

 

If you want a bootloader that can be "easily" driven from the PC side then perhaps look for one that does something like Xmodem/Ymodem file transfers (if you google "AVR xmodem bootloader" you will likely hit one or more). That way you would not need to write any "special" code o the sending end (iPhone or PC or whatever) as you could presumably just use an "off the shelf" terminal program if you can find one that includes Xmodem.

 

(Y and Z are better (though more complex!) versions of Xmodem in that they also transfer a file length - with Xmodem the perennial issue is "how do you know the byte transfer has finished?")

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks. And sorry to ask a googleable question. I thought I'd tried searching before asking, but I don't know why I wouldn't have come across that app note. I'll think about using xmodem. I guess I need to weigh the hassle factor of coding my own version of avrdude on the PC, vs coding it in objective c on IOS.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Rokie,

 

I'm also working on the similar things. Also wanted to upload code to Atmega328P over the bluetooth from my iPhone. I'm using Novacomm BLE module NVC_MDCS71 which is in transparent mode, itself handles all the connection establishment procedure(baudrate 19200). 

 

Can you tell me more about your project? at what stage you are right now? have you succeeded?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, I haven't gotten any further with the boot loader. Based on my research, it looks very doable, but I have been working on other things. I would be interested in collaborating with you on this though. If you are interested, can you PM me?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply!

 

Yes we can work in collaborative way.smiley I will post the further updates in this thread also to help other also.