Monthly Archives: February 2014

Creating a portable UECIDE bundle

Since the very beginnings of UECIDE there has been a little known feature that allows you to create your own portable bundle of UECIDE.  That is, your own copy of UECIDE that you can place on a USB memory stick, network drive, SD card – wherever you like – and wherever or however you access it you get all the same boards, cores, compilers, etc.

The most common platform for wanting to do this on is, of course, Windows, so we’ll detail doing it on that platform, but the principle is the same for all others.

Ok, so what do you need to get started with making your own portable bundle?  First, you need to download the latest version of UECIDE.  You need to ensure you get the “full” version, so it includes the Java Runtime Environment (JRE), and get it as a ZIP file, not an installer.

Step two is to just extract the ZIP as normal, (maybe onto your desktop?), and run UECIDE.  Once UECIDE is up and running, install your boards, compilers, cores, etc as per normal.  Make sure everything works.

Now comes the magic…

Close UECIDE – you won’t need it for a few moments.

All the things you have downloaded will have been placed into your own user’s “uecide” folder.  Assuming your username is “Bob”, (Hi, Bob…) that will be located in C:\Users\Bob\AppData\Roaming\uecide.  Open that location in an explorer window – you’ll see a preferences.txt file, and folders named “boards”, “cache”, “cores”, “compilers” and “plugins”.  You’re interested in, of course, the “boards”, “cache” and “cores” folders.

In a second window, open up the location you extracted your UECIDE ZIP file to.  One of the folders in there is called “hardware”.  Open that folder.  It should be completely empty.

Drag-and-drop the boards, cores and compilers folders out of your uecide folder and into the empty hardware folder.  It may take a moment or two to move all the files – compilers often have huge numbers of small files in them.

One that’s finished you are as good as done.  If you downloaded any plugins, such as the Grapher plugin, you will want to get those into the bundle too.  They go in a slightly different location.  Where you extracted the UECIDE ZIP, alongside the hardware folder you found earlier, there should be a “plugins” folder.  That should have some plugins (.jar files) in there already.  The plugins folder in your user’s uecide folder should also contain .jar files.  Just drag them from one to the other, as you did with the boards etc.

And that’s about it.

Fire up UECIDE again and make sure everything is still there and working right.  You can drag the whole extracted UECIDE zip folder onto wherever you want to keep it, and run it direct from there.  Try it out.  Plonk it onto a USB memory stick, plug it into your friend’s computer, and you should be able to run UECIDE direct from it, including all your boards and other downloads being there already.


Linking binary files

Have you ever had the need to add a binary file to your sketch?  You know, you are working on a project with a TFT screen, and you have a couple of nice icons you’d like to import into the sketch to then display them on the screen, or you’ve got some hardware attached for generating audio, and you’d like to embed a couple of small WAV files into your sketch.  It’s not the easiest thing to do, normally, is it?  It typically involves converting the binary file into source code, usually an array, and adding it into your sketch that way.  A bit clumsy really.

Well, with the release of the latest version of UECIDE (0.8.3b), there is a better way (compiler permitting):

You can now create a special folder inside your sketch called “objects”.  Any files placed in this folder will be gathered together at compile time, and converted (usually with objcopy) into object (.o) files.  These files are then linked with your sketch, and you get full access to the data in them.

No more messing with programs to convert the file into source code.

So how does it work?

Well, at this moment in time it’s only supported for PIC32 targets, but it will be rolled out to the other major compilers as soon as we are able, but the standard toolchain command “objcopy” has the ability to convert just about anything into an object file.  When it creates the object file it adds a couple of standard symbols into it as well, so you can access the data.  These symbols give you the start address of the data, the end address of the data, and the size of the data.  Each one is unique and is derived from the source file the object file is created from.

So let’s say you have a file “icon.565”, which is an icon file you have converted into 16-bit “565” format common to most TFT screens.  Placing that in the “objects” folder and compiling your sketch will create “icon.565.o” in the build folder, which is then linked to the sketch.  Now, unfortunately it’s not just a case of defining an “extern” to the symbols you want to use.  Instead you have to use a little tiny bit of assembly to reference the symbols.  Don’t worry, it’s pretty straight forward:

extern uint16_t icon[] asm(“_binary_objects_icon_565_start”);

You can then access the array “icon[]” and get at all your data.

The format of the symbols is: _binary_(munged filename)_start, _binary_(munged filename)_end and _binary_(munged filename)_size.  The munged filename is the path of the file you added, including the “objects” folder, with any slashes and dots replaced with underscores.  Thus, icon.565 becomes _binary_objects_icon_565_start etc.