Can I copy application and configuration from a Arduino

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

Hello

I am a new to the forum and first time user of both Arduino and Atmel devices. I have done lots with the small PICs in the past so not completely new too embedded world

I need some general help with using the AVR Studio 7 and Arduino. So the story is that I need some RS232 to SD card data loggers. I bought a few of these from sparkfun and very good they are. But they are expensive and I’m a cheap skate and I need 20 of them and cost stacks up.

So I bought some openlogs from China as £2 is better than £15. Anyway they didn’t work and I figured out they have no software installed. I have never used Arduino before downloaded Arduino software and followed online advice to install the OpenLog sketch. Well that didn’t work either as the Arduino IDE wouldn’t talk to the AVR microcontroller. So after more reading I figured out I need a boot loader.

First thing I found is the SPI programming header is covered in solder mask and the pads are bloody tiny. Scraped off the solder mask and soldered in some jumper cables.

Next problem is I didn’t have a programmer so I bought the shareware avrIsp II. Following an online tutorial I installed AVR studio 7 and got the OPtiboot HEX file from the Arduino directory on my computer. I found I could read and write to the Arduino and download load optiboot hex but still could not get it to talk to the Arduino IDE - no flashing blue light on the OpenLog.

I then found out that the boot loader could be down loaded from the Arduino IDE. Unfortunately this didn’t work because there’s a conflict between the AVRIsp driver installed with AVR Studio and the Arduino IDE. Apparently a known problem- well it wasn’t known by me LOL.

I found I could download the boot loader using my bus pirate via the Arduino IDE. I get a little blue light flashing on my open log about every half second, I assume that’s a good sign. I can now connect using the Arduino serial cable and download sketches. So I must be on the home run.

So here my questions

I assume when I downloaded the bootloader using the bus pirate and the Arduino IDE it must have correctly set all the memory configuration OSC settings and fuse bits and lock bits etc?

Given that I was unable to do this using AVR studio originaly can I use AVR studio now to read back all the successful configuration and make a note of the configuration settings. I have tried this but I’m not convinced the read function in AVR Studio is actually reading the configuration correctly, I think it’s just showing what I setup originally and not what’s on the working mega chip now.

I uploaded the memory using the AVR Studio 7 from the working Mega 328P and compared this to the OPtiboot hex file I extracted from the Arduino directory and they are totally different. So my question is when you down load the boot loader using the Arduino IDE which boot loader does it actually install. Is it the OPtiboot or Something else.

Finally this has been a total pain in the arse apart prom paying £15 for a genuine OpenLog from sparkfun is there a easier way of downloading the open log sketch. Can I just get a combined hex file that has the OpenLog and bootloader compiled as a single hex file I can install using the AVR Studio.

Finally I have a bit of experience using PIC microcontrollers but never used Atmel or Arduino so I’m a bit confused etc.

I can provide more information if required.

Many thanks https

://youtu.be/40rtp0qQo-I

https://youtu.be/7BVsCzf3Gyw

https://www.sparkfun.com/products/13712

https://github.com/sparkfun/OpenLog

This topic has a solution.
Last Edited: Mon. Dec 11, 2017 - 07:09 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AllTheGearNoIdea wrote:

...I figured out they have no software installed.

 

Are you sure?

 

The Chinese ones I've just looked at on eBay all say...

 

"The latest version of the firmware (included with this board)..." and "...Preprogrammed ATmega328 and bootloader."

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Thanks for the reply

The ones I had said the same. When I probe them out the box they won’t talk to the Arduino IDE and when I scope the crystal pins the clocks not running. So I think they have no software installed. However I could be wrong. If you could give my some pointer I could do a read from AVR Studio if i know what I should be looking for. Obviously lots of people selling these in China the four I bought do nothing.

Perhaps I should simplify my long winded question. Can I use AVR Studio 7 to read everything including configuration from a known working logger and then use this to program my other applicationless devices.

Regards Chris

Last Edited: Sat. Dec 9, 2017 - 10:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

AllTheGearNoIdea wrote:
I figured out they have no software installed.

How? Did you read out the flash and get "junk" (only 0xFFs or 0x00, 0x01, 0x02...) back? How do you know the lock bits are not set?

 

AllTheGearNoIdea wrote:
when I scope the crystal pins the clocks not running. So I think they have no software installed.

The clock running or not is not dependent on firmware being installed.

 

Power up an AVR direct from the factory and it will have a running clock.

 

Fuse bits matter though. Example: If fuses have been set to use an external crystal but there actually isn't one then there will be no valid clock and the AVR will not be running.

 

OTOH, if there atually is a crystal but the fuses have not been set to so that it is used then it won't oscillate.

 

AllTheGearNoIdea wrote:
I assume when I downloaded the bootloader using the bus pirate and the Arduino IDE it must have correctly set all the memory configuration OSC settings and fuse bits and lock bits etc?

Second time I say this in 12 hours: Assumption is the mother or much evil.

 

AllTheGearNoIdea wrote:
I have tried this but I’m not convinced the read function in AVR Studio is actually reading the configuration correctly, I think it’s just showing what I setup originally and not what’s on the working mega chip now.

Unlikely, at the least. If Atmel Studio reports a successful configuration then it read out what the fuse bits are. Unless the lock bits are set..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

I will double check the clock I have some of the other boards that I have not yet programmed so I can check this. However I think it’s unlikely I am wrong here. When I say the clocks not running I mean the external crystal oscillator was not running. I assume if these are anything like the PIC chip it Mega could have been running from the an internal oscillator clock source.

 

I just want to know if I read from the device does this read everything including the configuration. Regarding the lock bits I don’t really understand W hat these are are they the Atmel equipment of code protection used on PICs

 

No I did not try reading the software originally I just found the Arduino IDE would not connect and it did not function as it was designed to operate and the external oscillator was not running. Which would be pointless given it’s got a crystal installed. So I assumed it’s not programmed. It walks and quacks like a duck.   I think it did have some stuff in the memory not all FFs. But a may be confusing the order i did things here.

 

By junk I mean when I install the boot loader using the Bus pirate and Arduino IDE . If I then read the memory back using the AVR studio the hex file looks total different than the OPtiboot bootloader I tried to install using AVR studio. Hence my question is which boot loader version is installed by the Arduino IDE etc.

 

So when i load the Boot loader using the bus pirate and ardiuno IDE I get proof of life as the blue LED flashes on teh open log. When I program the optiboot boot loader using AVE studio I get bugger all.

 

Perhaps another way of look at this is what setting regarding config fuses bits correct version of boot loader do i need. If knowbody can answer this question then my next question is can i upload these from a working device.

 

Regards Chris

 

 

Thanks for the replies regards Chris

Thanks

Last Edited: Sat. Dec 9, 2017 - 04:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AllTheGearNoIdea wrote:
Regarding the lock bits I don’t really understand W hat these are

Then it's time to read up on them in the ATmega328 data sheet.

 

They are essentially configuration bits that protect the AVR from further programming and/or readout.

 

AllTheGearNoIdea wrote:
f I then read the memory back using the AVR studio the hex file looks total different

That could very well be an idiosyncrasy of the hex file format. There is not one distinct representation of a specific flash memory content. So the hex file used for programming flash and the hex file from a subsequent readout might well differ "in text" but match when it comes to the flash contents they describe. Yes, they can differ substantially. This is the nature of hex files.

 

AllTheGearNoIdea wrote:
I just want to know if I read from the device does this read everything including the configuration.

Ahh.., there's that "I just want to know" as if there is a clear Yes or No answer. But there isn't. It depends:

 

  • If you use the Device Programming dialogue in Atmel Studio, and if you there select to read out the fuses it will read out the fuses. Still with the earlier caveat that if the lock bits are set to protect readout then you will probably get garbage back.
  • If you use the dialogue to read out the lock bits the same applies. You'll get their state, if they are not set to block readout.
  • If you use the dialogue to read out the flash contents you will get a .hex file with the flash contents encoded in that format. Again, if the lock bits are set to prevent readout you will get a file of garbage.

 

No, there will be no message telling you that the device is locked for readout. You'll just get garbage.

 

Tell us, the firmware you're trying to read out - is it protected by copyright?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Is this your thread at EEVblog : https://www.eevblog.com/forum/mi... ?

 

Always tell if you have cross-posted to another site. Not doing so might lead to bad karma here.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

What you call the configuration are the fuses, and they are not part of the same memory space as the flash. You need to read them separately. Same for the EEPROM, it's in a different memory space.

 

The Arduino IDE, while talking through the serial interface, needs an Arduino bootloader to be installed, or it will not be able to communicate. Different bootloaders can have different sizes and entry points, so they require different fuse settings.

 

Could you tell us the size of each of the bootloaders you tried, and also the setting of the high fuse (hfuse)?

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

Yes I did cross post to the EEVBlog forum and then posted here as I found this forum later and thought it more appropriate. I’m really not sure why it would be a cause of offence bad Kama ?

 

I had not thought of the different memory format arranging the hex files differently.  I think the file lengths were also radically different.

Yes your quite right I should read the data sheet. However, I was hoping to avoid going to far down the rabbit hole and was looking for a quick answer.  I’m not a school boy asking to do his homework, I’m just looking for some help and a short cut as I have helped people out in the past regardless of the motivation. I just want to programmer a few data logger and move on.   

 

Regarding the boot loader perhaps I’m not explain correctly.  I know that the ATmega328 needs a boot loader before it can serial interface to the Arduino and I want to know what the correct fuse setting are for ATmega328. I am trying to load the Optiboot boot loader.  It was my understanding reading the from git hub that the Openlog uses the Optiboot loader.   I had assumed that this would be common knowledge within an Arduino forum what Optiboot is and what it does.  The optiboot.hex file can be copied from the Arduino directory from a computer that has the Arduino IDE installed on it.

 

I have found that I can program the boot loader using the Arduino IDE  using the bus pirate.  So that really solves my problem. I don’t need to use the AVR Studio but I would like to try and get it to working if I can.  Especially as I now have a AVRispII to use.

So I’m trying to install the Optiboot loader on ATmega328. If I’m using the wrong boot loader perhaps you could advise if there is a better alternative to use with ATmega328. 

 

I dont think the lock bit would have been set as everything is open source.  Would the lock bits need to be set to make the bootloader or application code function.

 

Im away from the workshop for the next few days.  When I’m back in the workshop I will try and connect to one of the other blank units but I’m getting to the point where it’s probably just easier to pay sparkfun the £15.00 for programmed units. 

 

 It’s not really the software issue it’s also the boards from china have the SPI connections brought out by very small via’s that are covered in solder mask, perhaps again backings up my idea that these have been delivered without firmware.   I don’t really fancy the idea of spending half a day under the microscope trying to solder jumper wires on the other units

 

From what you have said this obviously isn’t particularly straightforward process and required a deeper level of knowledge that I’m prepared to commit my time to learning.  

 

Many Thanks for the help and replies. Best regards

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

I buy lots of Chinese stuff also, you have to accept that sometimes you get lemons. Could you post the link for the ones you bought, so that we can avoid them in the future?

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

AllTheGearNoIdea wrote:
Yes I did cross post to the EEVBlog forum and then posted here as I found this forum later and thought it more appropriate. I’m really not sure why it would be a cause of offence bad Kama ?

It's not the cross posting per se, it's not telling/informing bout it. The root cause for cross-posts being bad is that separate people potentially will spend time at both ends giving the same answers - in effect that wastes the time of one of them.

 

A simple "I also have this thread XXX running a OTHER_SITE" is the remedy.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

AllTheGearNoIdea wrote:
I assume if these are anything like the PIC chip it Mega could have been running from the an internal oscillator clock source.

 

That is a really bad assumption! If you configure an AVR for an external crystal, and there is no crystal connected, you end up with NO CLOCK! That has tripped up so many  AVR users. Well, actually, what HAS tripped up the most folks is to configure for an "External Oscillator" when, in fact, you have an "External Crystal" (nb: all crystal are external). 

 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Dec 9, 2017 - 09:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
It's not the cross posting per se

There are people who believe that cross-posting is inherently evil.

 

But I'm with Johan: So long as you make clear that you've done it, and provide links, that's fine.

 

You also need to make the effort to keep all your threads updated:

 

  • when further information comes to light, be sure to share it on all forums;
  • if the problem is solved, be sure to notify all forums;
  • etc.

 

 

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

awneil wrote:

JohanEkdahl wrote:
It's not the cross posting per se

There are people who believe that cross-posting is inherently evil.

 

But I'm with Johan: So long as you make clear that you've done it, and provide links, that's fine.

 

You also need to make the effort to keep all your threads updated:

 

  • when further information comes to light, be sure to share it on all forums;
  • if the problem is solved, be sure to notify all forums;
  • etc.

 

 


awneil wrote:

JohanEkdahl wrote:
It's not the cross posting per se

There are people who believe that cross-posting is inherently evil.

 

But I'm with Johan: So long as you make clear that you've done it, and provide links, that's fine.

 

You also need to make the effort to keep all your threads updated:

 

  • when further information comes to light, be sure to share it on all forums;
  • if the problem is solved, be sure to notify all forums;
  • etc.

 

 

ok thanks

Regards Chris

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

El Tangas wrote:

I buy lots of Chinese stuff also, you have to accept that sometimes you get lemons. Could you post the link for the ones you bought, so that we can avoid them in the future?

https://www.ebay.co.uk/itm/272722398494

Ok thanks this is a link to the eBay seller

Regards Chris

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

Thats NOT an Arduino unit, it's an Arduino compatible Datalogger!

 

Did you download the code and viewer from the Github link the ad links to?

 

YOu have probably wiped out the fuse settings in those boards and for certain the application and bootloader.

 

Since you have Studio and an ISP programmer, I suggest you program the fuses for the UNO first.  THEN program the Optiboot bootloader that is located in your Arduino directory  THEN load up teh application from the Github

 

JIm

 

 

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

Jim I did not wipe anthying out. I established that the boards did not function before ever connecting the programmer I have several working examples for comparison. Given I have these working now we can close the thread.

Thanks for everyone’s input and help

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AllTheGearNoIdea wrote:

...I have these working now we can close the thread.

 

What was the problem? Always good to know in case anyone else with the same problem finds this thread with a web search.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Hello Bob

The solution is not to bother loading the bootloader using AS7 and use the Arduino IDE instead. Well maybe this is not a solution but it saves all the trouble of trying to set the fuses and lock bits. I was hoping that I could just read the fuses back using AS7 but I haven’t got any further doing this and don’t want to invest any further time as at the end of the day I was simply trying to program my OpenLog devices.

Thanks for the replies regards Chris

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

To read fuse settings in AS7 you simply go into the programming screen, click on Fuse Settings, and click READ.

Thanks for getting back to us.

Cheers
Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

AllTheGearNoIdea wrote:
 I have these working now we can close the thread.

You do that by marking the solution: http://www.avrfreaks.net/comment...