When you buy a BLHeli_S ESCs, the factory has pre-programmed those with the BLHeli_S firmware for you. This firmware comes in two parts, the BLHeli_S bootloader and the main firmware. The bootloader is the code that allows you to upload the latest BLHeli_S firmware using the blheli suite or -configurator.
When you build your own ESC using you will have to do this initial firmware upload on your own. There are (at least) two ways to do it:
- EFM8 ISP: Use a commercial or diy arduino based efm8 programmer and upload the firmware through the ISP pins of the controller. You will have to connect to GND, C2CK, and C2D. There are tons of tutorials how to prepare such an arduino isp adapter and how to program and use it within the blheli suite.
- EFM8 serial bootloader: The empty, unprogrammed EFM8 processors come preloaded with a custom silabs bootloader. This one uses a different protocol and a different pin than the blheli toolchain uses for further upgrades but can be used for easy and convenient first time flashing.
In this tutorial I am going to explain how to do the initial flashing using the second way of using the internal factory bootloader. The nice thing is that you do not need any fancy ISP programmer and you do not need to prepare an arduino.
Building the programmer
You probably have all the tools you will need at your home. Just grab any usb to serial converter with 3.3V I/O levels from your scrap bin. I used one of those cp2102 based boards. Now grab some fixing pins out of your wifes sewing box. If you plan to flash several of those boards it helps to enhance the fixing pins with those pogo pins as I did. For one or two-time use the normal fixing pins will do fine. Have a look at the following pictures on how to wire up the cable:
I recently wrote a short tutorial on how to use the efm8load.py script I wrote. Just download/clone the efm8load repository and in case the efm8load.py script complains, install any missing python packages. Now it is time to grab the BLHeli_S firmware. My tinyPEPPER ESC will need the following hex file depending on which CPU you soldered to the board:
EFM8BB10 CPU: O_L_5_xxxx.HEX
EFM8BB21 CPU: O_H_5_xxxx.HEX
You can find the latest hex files on the blheli_s repository. In this tutorial we are going to use version 16.6. You can download this specific hex file by clicking on the link above. Make sure to flash the right one for your CPU.
With everything ready connect the usb to serial converter power supply lines (GND and 3.3V) to the power pads of the tinyPEPPER esc. You can temporarily solder them to the PCB as I did. Now comes the tricky part: You will have to connect the RX and TX lines from the usb to serial converter to the pins of the efm8. The current revision v0.3 has pads for both, the older revisions only had the RC_IN pad (connect this to usb2serial TX) and the other pin had to be contacted directly at the IC package:
Don’t worry if you slip and short circuit this pin to the ones next to it. Nothing bad will happen, in the worst case the upload will not even start.
With the needle probes in place it is now time to fire up the efm8load.py script. I am using the EFM8BB10 CPU, so make sure to flash O_L_5…HEX. You will either need a second person or do some sleep tricks as I did:
user@machine :~/src/efm8load> sleep 10 && ./efm8load.py -w O_L_5_REV16_6.HEX
This way the machine sleeps for 10 seconds before executing the upload. So after pressing enter you will have ten seconds to position the needle probes. You might have to increase this on your first tries, after you flashed some more boards you get faster with that 😉
If all goes well you will see some lines of debug info running through your terminal:
######################################## # efm8load.py - (c) 2016 fishpepper.de # ######################################## > opening port '/dev/ttyUSB0' (115200 baud) > uploading file 'O_L_5_REV16_6.HEX' > checking for device > success, detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20) > detected EFM8BB1 cpu (variant EFM8BB10F8G_QFN20, flash_size=8192, pagesize=512) > will erase page 0 (0x0000-0x01FF) ..snip.. > writing segment 0x0000-0x0005 > delaying write of flash = 0x02 to the end > write at 0x0001 ( 5): 0x19 0xfd 0x02 0x00 0xb3 > verifying segment... OK ..snip.. > write at 0x1D80 (118): 0x85 0xb1 0xdb 0xc3 ... 0xe8 0xb1 0x06 0x01 > verifying segment... OK > will now write flash = 0x02 > write at 0x0000 ( 1): 0x02 > verifying segment 0x0000-0x0005... OK ..snip.. > verifying segment 0x1A40-0x1A6F... OK
The important parts are the verifying segment lines. All should end with “OK”. If the programming does not start at all and the script complains about no device found or bad reply detected just try it again, you might have had the needles positioned in the wrong way.
Flash a second time?
If something goes wrong during this initial flashing progress you will not get a connection to the silabs bootloader again. The efm8 factory bootloader does autostart only on empty, unprogrammed devices — but don’t worry, there is a trick!
You can re-enable the bootloader startup by pulling the C2D pad low during cpu startup. Just remove the power, grab some wire and solder it to the C2D pad and ground. You can leave this connected until your flashing succeeded.
Did it work?
Most probably yes 😉 But let’s have a look. Hook up the ESC to any flight controller you have on your desk. Connect the power input to 3.3-4.2V (not more!), GND and the four RC_IN pads to the fc output. Now fire up the blheli configurator app and click connect and read setup. All four ESCs should appear now.
Let’s play some tones
Only proceed to this step if all four ESCs appeared on the configurator screen. Click disconnect and remove the power to the ESC. Now solder any small motor you have at your hand to one of the ESCs. You can use anything from 1103 to 1806 sized motors, just make sure not to mount any props and that the bell can freely spin. If your motor is small enough you can power it from the 3.3V output of the usb to serial converter. I did this in the past with the 1103 motors, however this is not good practice and out of spec of the voltage regulator. You might fry it, so better use a real power supply 😉
Now be quiet and apply the power. If your board is working you will hear the famous beep noise — if something went horribly wrong you will not hear the melody and take a smell of the magic blue smoke 🙁
If there was no smoke and some melodic beeps you can now try to run the motor. Fire up the betaflight configurator and switch to the motor tab. Enable the output and gently move the slider higher. The motor should start spinning smoothly. Do not make big changes, your power supply will be able to absorb big induction spikes from the regenerative breaking phase… If the motor does only stutter and you hear some beeps you most likely connected it wrong. Make sure that you connected all three phases to a single ESC. On revisions 0.1 and 0.2 the phase tabs of one esc were split to top and bottom layer! On the never revisions this is not the case, connecting it the wrong way got much harder on those…
Congratulations, you just finished probably your very first ESC on your own!
Is there any way to flash the EFM8BB1/2 from windows? Do you know any commandline tool for uploading the *.HEX?
I have soldered one PEPPER ESC, but cannot figure how to flash it…
You could try my efm8load.py. This might need some tweaking in the python code to open the serial port under windows.
Can the tinyPEPPER be safely configured using BLHeliSuite via 1-wire on ESC input using a 5V arduino Nano when it’s connected to 1S battery?
You should use a 3.3V arduino or make sure that the voltage on the I/O does not exceed 4V.
If you are advantageous could add something like a 220-330 Ohm resistor in series with the data cable and try it anyway. I would assume that it would work fine as I had some efm8 running on 5V accidentally for a while. But no guarantee for that 😉
The easiest part is to use a flight controller in passthrough mode. You could also use an old one that you do not fly anymore. I have one old spracing F3 for those purposes 🙂
Hmm… resistor seems to be a safe bet, but the datasheet says “All pins 5 V tolerant under bias” whatever “under bias” means… I agree a (spare) FC would be better, but I just recently found interrest in this hobby and am trying to repurpose a toy drone with brushless motors using this esc.
Hi fish ! great work, i really love your designs i just wish some of these bastards like banggood would mention you as the creator but anyways, i bought one of the star 4 esc’s from them and when i flashed it with the blheli configurator it just fails all the time i can’t even change the motor direction, when i hit write setup it just goes right back to default would you happen to know why?
Did they work before you tried to flash it? Maybe you flashed the wrong hex?
Well normally i flash every esc before i use it to the latest firmware but i used the google chrome blheli config app, the esc works but the throttle ranges are all messed up, i got another from amazon and in the process of flashing i started to see magic smoke out of nowhere lol and i used a 1s battery
Sorry to hear that 🙁 Did you try dshot as well?
quick question, to test the ESC it’s mandatory to use a FC with Betafligth?¿ or can i use a arduino to test it?
thanks in advace for your answer
An Arduino or a Servotester (e.g. this one) should do 🙂
Cool! Thanks for putting this together!
Do you think an FTDI programmer would work for this purpose? Just have to make sure the 3.3v vs 5v jumper is set to 3.3 and otherwise connect ground and the RX/TX pins on the presoldered pins, right?
This is the device i’m talking about:
Only other items I can find around are an STM8/32 ST-LINK programmer, and a USBASP programmer for ATMEGAs.
Yes a FTDI adapter will work just fine , i have flashed mine with it and all went just fine 🙂
yes this will work. ftdi adapters are the best ones you can buy 😉
Whew 🙂 thanks!