Using the latest core

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
Post Reply
RedDogInCan
Posts: 7
Joined: Sat Nov 03, 2012 8:24 am

Using the latest core

Post by RedDogInCan » Sat Jan 26, 2013 1:22 pm

I came across this page whichs describes how to modify the boards.txt supplied with the Arduino IDE to use the latest core. This fixes the issue with the tone() function locking up the board.

I have tested it with the toneMelody example sketch in the 1.0.3 version of the IDE and everything seems OK.

sleat
Posts: 5
Joined: Thu Dec 20, 2012 7:49 am

Re: Using the latest core

Post by sleat » Mon Mar 04, 2013 11:17 pm

This looks really promising.

He gives this instruction:

"So in summary, simply updating the boards.txt file and using the standard core it all works as expected."

But, and forgive my ignorance here, I thought the system would "use the standard core" by default, if specified in boards.txt. How does one "use the standard core" or control what core is used at all other than from boards.txt.

I thought it was specifically stipulated in the core line of the boards.txt file.

Cheers,
Joe

RedDogInCan
Posts: 7
Joined: Sat Nov 03, 2012 8:24 am

Re: Using the latest core

Post by RedDogInCan » Thu Mar 07, 2013 2:34 pm

My understanding is that the Arduino IDE locates the core specified in the boards.txt relative to the location of the boards.txt file. The board profile supplied by Freetronics contains a subdirectory with a boards.txt and a core. As a result, the Arduino IDE will use the Freetronics supplied core instead of the core supplied with the IDE.

If you look at the boards.txt entry from both the Freetronics and the Github versions, you will see that they are essentially the same. The only difference is that the Github version is appended to the standard boards.txt whereas the Freetronics one lives in its own subdirectory.

I suspect Freetronics supplied their own core as Leonardo wasn't officially supported until 1.0.1 of the IDE. Later versions have included improved Leonardo support and so the Freetronics version is now out of date and not needed. The Getting Started Guide needs to be updated.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Using the latest core

Post by angusgr » Fri May 10, 2013 12:18 am

RedDogInCan is absolutely correct. The new Getting Started Guide now has a new board profile that will use the latest core on LeoStick V2.0 - tone() works, etc.

It is possible to update a V1.0 LeoStick to V2.0 to take advantage of this, too.

RedDogInCan
Posts: 7
Joined: Sat Nov 03, 2012 8:24 am

Re: Using the latest core

Post by RedDogInCan » Fri May 17, 2013 9:34 am

The Getting Started Guide still contains the warning about not using the tone function.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Using the latest core

Post by angusgr » Sat May 18, 2013 12:39 am

Good catch, thank you. Fixed.

RedDogInCan
Posts: 7
Joined: Sat Nov 03, 2012 8:24 am

Re: Using the latest core

Post by RedDogInCan » Mon May 20, 2013 11:57 am

Can you explain the difference between the Freetronics core and the official one supplied with the Arduino IDE?

The reason I ask is that I have a V1.0 Leostick and have been using the official core with no issues. This includes using the tone() function with no lock ups.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Using the latest core

Post by angusgr » Mon May 20, 2013 10:22 pm

RedDogInCan wrote:Can you explain the difference between the Freetronics core and the official one supplied with the Arduino IDE?

The reason I ask is that I have a V1.0 Leostick and have been using the official core with no issues. This includes using the tone() function with no lock ups.
Happy to! Sorry I didn't explain further with reference to the original post.

First, the easy one: As alluded to earlier in the thread, the V2.0 board profile uses the Leonardo core from whatever Arduino IDE is running. It's exactly the same as the Leonardo except it sets Freetronics USB IDs instead of Arduino ones. This is the same mechanism that AlchemyCS uses in the gist you posted originally. I suspect you already know all that, though.

The main difference in the V1.0 board profile and core ("Leonardo Beta" based) revolves around the bootloader interaction when the Arduino IDE wants to soft reset the board into the bootloader. V1.0 core enters the bootloader by literally issuing a "jump" instruction to the bootloader's address. As there's no actual reset no automatic resetting of registers or chip state happens, it only resets what the bootloader resets explicitly. For example the same USB enumeration is used, it does't bother to re-enumerate. The bootloader itself doesn't reset some registers properly. For instance, I've noticed with some PWM pins it's possible to reset and reprogram and still have the PWM active after reprogramming. The critical part though is that this bootloader does not (in my tests) play nice with the watchdog. I saw that issuing watchdog resets against a V1.0 bootloader caused it to go into a reset loop that required an actual power cycle to break.

This is the showstopper I found using the Leonardo/V2.0 core with V1.0 - the Leonardo core uses a watchdog reset to enter the bootloader, and this causes a reset loop.

FWIW I did also investigate writing a hybrid V1.0/V2.0 core that fixes the broken timer to allow tone(), adds the missing PWM channel, improves HID support and the Serial interface, etc. while also keeping the V1.0-compatible reset-to-bootloader method. I did some initial tests, but given the amount of extra testing to be sure such a hybrid is stable and usable across OSes (especially given the non-automatic resetting I mentioned), I chose to recommend people just update to the V2.0 bootloader instead.

I hope this explains things a bit. I'd be interested to know exactly how you're programming your LeoStick V1.0, what OS and Arduino IDE versions, and whether you have to manually reset or unplug/replug to program. It's entirely possible that when testing I missed something important.

Cheers,

Angus

Post Reply