ER9X and FrSky using Mac OS X (full article)

[For more up to date information since the writing of this article, please see the gruvin9x project at Google Code.]

So I’ve joined the craze. I now have a Eurgle/FlySky/Imax/Turnigy 9X “cheapo Chinese” RC transmitter, which has been (massively) upgraded with ER9X firmware (based on the great foundational work of TH9X) and added to that an awesomely  reliable yet very well priced Free-Sky ACCST (FHSS) 2.4GHz radio module — WITH TELEMETRY.

This post was intended to be my own online notes of the firmware compile/installation procedures etc for Mac OS X. But I’ve fleshed it out some, so hopefully others will find it useful too.

There’s a TONNE of other discussion on this topic at the RC Groups official ER9X thread if you care to wade through it. Oh and the very first post there has a bunch of useful links. Well worth a look.

Programming Set-Up

SparkFun Pocket AVR Programmer

Hardware

For the physical programming / re-flashing of the ATmega64A micro-controller in the ’9X, I chose the SparkFun (USB) Pocket Programmer. It works really well and is not at all expensive. (SparkFun have a some really cool stuff by the way. Stop by for a while and check them out!)

AVRDUDECrossPack - OS X AVR Development SuiteSoftware

I prefer to do stuff on my Mac. Fortunately, so do many people who work with Atmel AVR chips. There’s a nice packaged installer named CrossPack that has everything you need for cross-compiling C/C++ AVR code on your Mac, using GCC. CrossPack also comes bundled with AVRDUDE, which is used to operate the programmer hardware — the SparkFun Pocket Programmer in my case.

Ready-to-Run Firmware

There are pre-compiled hex file versions of ER9X available on the project site that you can just upload immediately using AVRDUDE. Download the latest version here (Right-click/Save Target As may be needed on that link.)

Flashing Read-to-Run Firmware

You can now burn your er9x.hex file using AVRDUDE  like this …

avrdude -c usbtiny -p atmega64 -B 1 -U flash:w:er9x.hex

AVRDUDE will should find the USB port the programmer is connected to. If not, try unplugging the programmer and plugging it back in. (You need to do this at least once after installing CrossPack. No reboots are required. This is NOT Windows! :-P )

That will erase your chip, write in the new firmware and then read back the code to verify it all went OK.

Oh by the way; leave the tiny little switch on the programmer PCB set to “Power Target”. That will power up the 9X in a fashion it isn’t used to —switches disconnected and what not. The stock ‘V2′ firmware will run and start sounding alert beeps. But just ignore it. The new firmware will soon put paid to that! :-P

Compiling Your Own Code

I intend extending and modifying my version of ER9X, so I checked out the source code using SVN (Subversion) and instructed on the ER9X Project page. From a shell prompt …

~$ svn checkout http://er9x.googlecode.com/svn/trunk/ er9x

That creates a folder named ‘er9x’, within which you’ll find all the project documentation (not much) and the all-important ‘src’ directory, where the actual project code resides and gets built.

To build the code ready for programming (having first installed CrossPack of course), change to the ‘src’ directory (cd src) and continue with the instructions on the ER9X Project page as follows …

To make the standard version type: make
To make the JETI DUPLEX enabled version type: make EXT=JETI
[Gruvin] To make the FRSKY enabled version type: make EXT=FRSKY

NOTE: The FRSKY version will kill your Throttle-Hold and Aileron-Dual-Rate switches unless you’ve rewired them appropriately inside the box, which is actually a bit tricky. So you best start with the standard build first and worry about all that later.

Assuming that works the way it did first time for me, you’ll now have an ‘er9x.hex’ file ready for programming into your radio.

Once your radio is wired and ready for flashing (see below!), here is the command to send up the firmware. You can do it manually via AVRDUDE as above, or take advantage of the provided ‘make’ directives. Again, from the ER9X Project page …

make wflash AVRDUDE_PROGRAMMER=usbtiny

NOTE: ‘usbtiny’ it the correct programmer tag for the SparkFun Pocket Programmer. If you edit the ‘Makefile’ file and change the default programmer to ‘usbtiny’, you can then just type ‘make wflash’ on its own from that point on.

Backing up the EEPROM — which holds all your model programming! By default, each time you program a new version of the firmware, the entire ATmega64 gets wiped — including any model programming data you may have slaved over! Here’s how you take a backup of the EEPROM before re-flashing each time …

make reeprom AVRDUDE_PROGRAMMER=usbtiny TARGET=backupeeprom

You can leave out the grey text if you’ve edited your Makefile to use ‘usbtiny’ by default. (The default target is er9x.bin I believe.)

If you don’t have the full source package, you can read the EEPROM data manually using AVRDUDE as follows …

avrdude -c usbtiny -p atmega64 -B 1 -U eeprom:r:backupeeprom:r

(You need the :r on the end to create non-existent files for some reason.)

In either case, your EEPROM data, (containing all your model programming data) will be stored in a file name ‘backupeeprom’. You can of course use any filename you like.

If you want to take a peek inside that binary EEPROM data file, try something like 0xED from http://www.suavetech.com/0xed/0xed.html.

CODE SIZE: The complete ER9X compiled code base as at revision 262 appears to be less than 48KBytes — including the 8K splash screen graphic. The ATmega64 has 64KBytes of FLASH program memory and 4KBytes of static RAM. If I’m reading the data properly, only about 400 bytes of the RAM is currently in use. (Seems low though?) In any case, things are looking good for adding lots of extra functionality.

Getting Wired

OK. So the above is a basic summary of how to compile the ER9X firmware from C++ source and get it installed in your radio. But there’s something missing — the wiring for actually programming to the ATmega64A chip inside the radio! (This part is mandatory too as it happens — go figure! :P )

Luckily, the manufactures have included nice big (3mm or so) solder pads for this purpose.

IMPORTANT: The picture below shows a typical ‘V2′ transmitter, as has been shipping for a few months as at time of this writing. The V1 unit  had an error on the PCB where the ‘SCK’ programming pad (wire 7 below) connected one pin too far left on the ATmega64 chip. So watch out for that! If you have a V1 unit, you can still get things going. But you’re going to have to be more careful to get a wire soldered to the right place. (Notes about this also in the linked ‘online version’ instructions below.)

There is a PDF file guide for this included with the ER9X source code, which we ‘checked out’ above. Here’s a link to the online version. However, that guide assumes use of a ‘special’ colour-coded cable that you probably don’t have. You can still figure it out by cross referencing various things, but …

When I ordered my SparkFun Pocket Programmer, I had them add a spare programming cable. I cut the two ‘remote’ connectors off of that and used it to wire up my radio. Long story short — here’s a photo of my installation, using a stock SparkFun cable …


Click image for full size.
Yellow digits show wire numbers, starting from the red one.

You should hot-glue the ribbon cable to the PCB so that the wires and delicate PCB pads won’t get broken when the cable gets tugged.

NOTE: The two hot-glued little resistors and fine wires to the left are the re-wiring necessary to free up the ATmega64A serial comms port, which is otherwise connected to the Throttle-Hold and Aileron-DR switches. The switches get moved to two other spare ports.) This mod is only necessary if you intend using the EXT=JETI or EXT=FRSKY compiler tags when building the source. The code will then automatically re-assign the THH and AIL switches appropriately. See here for more details.

What to Expect

After programming, you can expect to feel a little bit anxious! Do not fret. The feeling is completely normal. :-D

Put the rear cover back on the transmitter and REMEMBER to reconnect the cable connector! The first time I flicked the power switch after programming I got absolutely nothing. Not even a beep or a flicker. “Uhoh!” … then I realised the thing wouldn’t go so well without the power being connected!

During boot-up, the ER9X firmware checks a few things. You’ll get one or more “alerts” on screen, like “Throttle not set idle” and a message about there being no alarms — meaning the beeper is turned off, as it is by default. Also, all switches have to be in the “off” state — that is, all front switches ‘up’ and top switches ‘back’. Oh and don’t worry — all these power-up warnings can be disabled through settings in the ER9X menus if you don’t want them.

Once you clear those messages away (by pressing [EXIT] for each or whatever), you should see the (also optional) ER9X splash/title screen. From there, it just gets better and better.

The first thing you’ll want to do is set the ‘mode’ to ‘Mode 1′, for your throttle on the right, right? — since no one in their right mind would ever use Mode 2 now, would they? :P OK, maybe some. Mode 2 is the default in any case. Can’t figure that one out personally. Oh well.

The menu you want is accessed by holding down the [LEFT] button. But now it’s time to dig into the operating instructions. You WILL need to read them for actual model programming, believe me. Once you get your head around how it works, you’ll wonder how you ever got on with the over-simplified, bare bones menus of other RC units.

Where was I again? Oh! The manual! Right. There’s a link hiding near the top the ER9X Project website of course. But here’s another for convenience — ER9X Users Manual

Battery Upgrade

OK. For one thing, flying an expensive model air plane with eight dry-cells in a flimsy holder isn’t really my cup of tea, as they say. So something had to be done there. Now, since most every 2.4GHz transmitter module (including the stock unit and my Fr-Sky telemetry upgrade) only requires about 6V for full operation (and essentially wastes the additional voltage into heating a regulator IC), I went ahead and followed the advice of Bruce Simpson over at RCModelReviews.com for a CHEAP and nifty battery upgrade. See his article A DIY $8 Lithium Transmitter Battery for details on installing a low cost, high capacity, safe and highly reliable Li-Ion pack for your 9X. Yay \o/

Trustfire 2400mAh Li-Ion power pack for Turnigy 9X

You do not need to futz with the 8.2KOhm resistor as advised for the stock Turnigy 9X radio low-bat alarm after upgrading your firmware to ER9X. One of the cool things about ER9X is that you get to set your own low-battery voltage warning level (and calibration) right from the user menu. So you can use whatever battery pack you choose in the range of about 7 to 12V. (I don’t recommend running anything more than 12.8 volts (8 x new AA alkalines) and I maintain that 7.4V Li-Ion (or Li-Po) is by far the best way to go.)

Bringing the Cable Out

Finally, I used a dremel tool to cut a rectangular hole in the upper right (as viewed fro the rear) of the battery compartment. This is to allow the programming cable to exit the radio without having to take it apart each time I change the firmware. (If you look carefully at the image above, you’ll see the green circuit board showing through the hole.)  Others have installed funky sockets in the case — but I didn’t much see the point of going to that hassle, since my custom battery pack allows the extra room to just do it this way.

    • Irwan
    • January 30th, 2011

    I too, have joined the craze about 9x even though I own furans t-8th and jr8103xp with frisky diy.
    The 9x will be getting a trait module and er9x firmware. It’s nice to have radio that’s cheap enough to be abused, but powerfull enough for most flying.
    This one will be kept in my car along with 450 clone, now My chances to fly are also higher now.
    For the bat mod, its har to get li-ion around here, unless I crack open disposed laptop battery, or cell phone battery. But envelop will be easier to get and last as long :)

      • Admin
      • January 30th, 2011

      The Li-Ion battery mod includes the supplier — http://www.dealextreme.com. About US$8, including delivery to just about anywhere. We’re using the “protected” TrustFire brand cells, at a stated 2400mAh. They seem fine. (The “protection” is real. It’s a little round circuit board appended to the end of each cell to protect from over/under charge.)

    • mike
    • November 15th, 2011

    Anyone had this happen??? I’m using the smartieparts board, with these commands, and throwing an error….

    usr$ avrdude -c usbasp -p atmega64 -B 1 -U flash:w:er9x.hex

    avrdude: error: programm enable: target doesn’t answer. 1
    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.01s

    avrdude: Device signature = 0×000000
    avrdude: Yikes! Invalid device signature.
    Double check connections and try again, or use -F to override
    this check.

    avrdude done. Thank you.

      • Admin
      • November 15th, 2011

      Yes. I’ve seen that. We ultimately deemed the smatrtieparts board to be faulty and are having it replaced. The replacement has not yet arrived however, so it is not yet known for certain. [The replacement smartieparts pogo board subsequently arrived and worked perfectly.] Another programmer — an AVR ISP MkII, temporarily hard wired to the same board — proved to work without issue. It’s still all rather strange.

      Out of interest, what version of AVRDUDE do you actually have and is it running on Windows, Linux or Mac? (In our case, the same fault occurred both on the Mac and under Windows 7. But I’d be curious to know, regardless.)

      By the way, the -B 1 in the command line to AVRDUDE is telling the programmer to go as fast as it can (basically). You might try having it go slower — say, -B 10 — and see if that helps. If using eePe, you can add -B 10 as an addition option in the configuration screen It will override the default (usually.)

      Another feature of the fault we experienced was particularly odd. Specifically, the smartieparts board would still happily program the EEPROM, just not Flash. It will be very interesting to see if the replacement does in fact work any better and therefore, whether or not there isn’t some other contributing factor.

      Another possibility is that your ATmega has got itself, ‘fuse bricked’. If that is the case, then it likely isn’t running the firmware code at all any more (it won’t boot up). If that’s the case, it’s a whole other story. There is an article or two about dealing with a fuse-bricked rig on the gruvin9x and er9x project sites (in doc folders) — probably the th9x site also. (I think it’s a PDF file named something like ‘Fuse Brick.pdf’.)

      You might also like to take this discussion up at Google Groups gruvin9x-discuss mailing list. There’s only a dozen or so members at last check, but someone might be able to help. You can also try the much more busy RCGroups.com ER9X threads, though I warn you there is a lot of traffic there so you better be able to read fast. :-P

    • William
    • February 2nd, 2012

    Hi Gruvin
    I have seen your name every where they mention the er9x. glad to see you have written something specific to what I am interested in doing. Using my Mac, my er9x FW and my flysky th9x.

    Unfortunately I am not a that great working inside of terminal and quite frankly it scares me. So I did manage to re-flash my th9x on a pc using the smartie board programming chip and get the EL backlight installed all in one fell swoop. And so far I am loving the better firmware.

    But I want to be able to install and run eepe on my mac and create files with various models and configurations on my Mac. So for someone who does not need to flash the firmware anymore and just want to plug in the TX and swap in and out eepe files what steps should I take? Hope you can help. Thanks

      • Admin
      • February 2nd, 2012

      Hi William

      I wasn’t aware I was quite that popular. Scary. :p

      Firstly, working at the Terminal in Unix system, logged in as a standard user is pretty darn safe. Unlike Windows (of old) you don’t have access to delete anything but your own personal files. Hmmm. Wait a minute – that’s the most important stuff! OK. Forget I said that. :p

      There are three things you need to get eePe (or companion9x, which I prefer at the moment) working on the Mac.

      1. eePe itself — the Mac OS X version.
      2. The Qt4 Library for Mac. (This isn’t usually included with OS X compiled versions of eePe or companion9x, as far as I know.)
      3. AVRDUDE for Max OS X.

      eePe for Mac OS X … I’m not sure there is a readily available Mac OS X version of eePe project site’s Downloads area or not. But I do know that eePe can be compiled for the Mac and runs well. (I’ve done it.) So there must be a readily downloadable version, somewhere. Last I checked, the same was also true of companion9x.

      The Qt4 Library is used by both eePe and companion9x. You can get that from http://qt.nokia.com/. Whilst it’s theoretically possible to include just the necessary parts of Qt4 inside an eePe or c’9x application bundle (so you don’t have to install the full Qt4 library yourself) I’m not aware of anyone who has actually made it work. Personally. I prefer to have Qt4 installed on it’s own anyway. This keeps the individual application download size way smaller and helps ensure you’re running the latest version of Qt.

      AVRDUDE for Mac … this can be downloaded as source and compiled, then installed. But I’m betting you don’t want to go there. Installing the CrossPack suite that I spoke of in the above article is therefore likely the easiest way to get it done. You’ll end up with everything you need to compile source code in the process, but that shouldn’t matter much.

      Once all that is installed, eePe should run fine and allow you to up/download EEPROM model data to/from your radio, just as you would on Windows — only nicer. :-D

  1. July 18th, 2011