Bootloader for 9X (M128) - Works

Cant get your radio to work? General Hardware issues?
Post Reply
MGeo
Posts: 21
Joined: Fri Feb 03, 2012 4:43 pm
Country: -

Bootloader for 9X (M128) - Works

Post by MGeo »

Hi,

I've learned much from this forum so thought I would post a working mod on my 9X in case it helps others. I like the bootloader feature on my Taranis, and want something similar for my 9X. I also wanted to use already existing connectors if possible, AVRDUDE/eePe compatible. Maybe this already exists but I missed it? So...

I have a Turnigy 9X with the following mods:
- M128 processor mod
- Telemetry pin relocate mod on 9X main board
- FrSky DJT module with RX-TX brought out to Pin 2-5 respectively
- MAX3232 based level converter between M128 RX-TX pins and module connector pin 2-5
- LCD Backlight and backlight PWM transistor drive mod (not needed for the purposes of this post).

I started with a fairly well documented AVR109 compatible M128 bootloader avrprog_boot from http://siwawi.bauing.uni-kl.de/avr_proj ... rprog_boot. This bootloader has a few start-up options including one that goes to bootload if you pull a defined pin during power-up. I changed this to use the 9X "DOWN" button pin. So to enter bootload you hold DOWN while you power up. It runs at 38400 bps so you have to set the right AVRDUDE flag in your command options ('-b'), and of course specify the correct COM port ('-P') that matches your serial adapter (or hardware serial port if you and your computer are old enough:). You also need to tell AVRDUDE you are using and AVR109 based programmer ('-c').

With this option it exits to the main program after programming complete. I got this working with AVRDUDE but found it would not work with eePe, which uses multiple AVRDUDE entries to save EEPROM and then burn. So I mod'ed the bootloader to stay in bootload continuous. When done you exit by powering down and then power back up for normal run. You have to load the bootloader first via ISP programming but after that you can just use the bootloader.

So now I program by pulling the DJT module out, and use an FTDI programmer connected to RX, TX, GND pins of the module connector without cracking the case open. I have to use FTI's FT_PROG utility to invert the TX/RX pins to make it compatible with my MAX3232 converter inputs. I've also done this wireless Bluetooth using an HC-06 adapter to prove to myself it works. For that I had to use another converter (ugh!) to invert but it works fine.

The pic shows my FTDI connector plugged into the module TX-RX lines. I'm powering the TX off the FTDI with the case still open for test (connected to my ISP Power and Ground connector pins. But I've also tested it using battery power and module TX-RX-GND connection only.

If interested, to use you would use ISP to set your M128 fuses using the txt file settings I attached below. Then program flash with the main.hex file attached. With the right hardware modes you are done. In eePe, make sure you set the -P COM port, -c AVR109 programmer, and -b 38400 flags in 'Options'. And off you go. I've included the source main.c if you are interested what the changes look like to the bootloader code.

Hope this helps someone.

Thanks,
George
Attachments
IMG_0268.JPG
main.hex
(3.25 KiB) Downloaded 367 times
main.c
(14.61 KiB) Downloaded 344 times
ATMega128_Fuses.txt
(288 Bytes) Downloaded 339 times
Last edited by MGeo on Fri Mar 13, 2015 10:38 am, edited 2 times in total.

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Bootloader for 9X (M128) - Works

Post by jhsa »

Later versions of Er9x for m128 already have a bootloader. To enter bootloader mode just start the radio with both horizontal trims pressed inwards.

I use a FTDI connected directly to the main programmer MISO, MOSI and GND lines.. no need to invert the FTDI. This is already TTL level. On the back of the radio is RS232 level as far as I know. No need to remove the RF module.

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Bootloader for 9X (M128) - Works

Post by MikeB »

erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
MGeo
Posts: 21
Joined: Fri Feb 03, 2012 4:43 pm
Country: -

Re: Bootloader for 9X (M128) - Works

Post by MGeo »

Oops :oops: , sorry about that. I did look at that thread (too) quickly and decided it was about the MegaSound board.

Oh well, I learned a bit about bootloaders and AVRDUDE in the process.

Best Regards,
George
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Bootloader for 9X (M128) - Works

Post by MikeB »

I have the bootloader running on the M64 as well, but the FrSky version is so nearly full I've chosen not to include it.

I've used the "Optiboot" code that I first used on the Megasound board. When I get a chance I shall try to get it on to the '2561 as well.

Rather than start in the bootloader, I've chosen to still start in the main application, but if I find both trim switches active I jump to the bootloader code.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

Post Reply

Return to “Hardware”