Hope you can help me in bringing my Arduino setup into little "production".
I am using these small Beetle boards that are Arduino Leonardo based (ATmega32U4) and currently I have developed just a Arduino sketch that I upload directly over the board USB interface.
So I currently have not burned any fuses, any bootloader or any full bare metal software and I want evaluate my possibilitys for producing multiple write protected devices.
As far as I see the "normal" way would be to go bare metal and using an additional programming adapter. This device has to be connected with multiple pins on the current production board. Then I could burn a new bootloader or manipulate fuses (, I guess).
However for me the big disadvantage is that I have to connect (maybe solder) the device with the foreseen pins for every board. It would be much more comfortable if I could use the already established USB connection of the board itself.
So the question is:
Can I burn fuse bits from my Arduino embedded software itself? Let's say by building a serial command that enables or disables programming? I read from third party boodloaders that are made for OTA updates but maybe it is much simpler and I can somehow manipulate fuses from the application code.
Is it possible to burn fuses from the normal Arduino tooling and over the build in USB interface, without using an additional bare metal programming adapter?
If not, I guess I can programm one of my Leonardos to act as a programmer and then directly connect it with the production boards?
What I have is: Fuse calc Good video of burining a custom bootloader from IDE
I also have a USB to Serial adapter that I use for flashing Sonoff Wifi Power Plugs. It has connectors like GND, VCC (5V or 3.3V), RX, TX,DTR, CTS. Maybe I can use this device but I am not sure how to connect it to my production board? Maybe just connect 3.3V, GND and cross TX and RX? do I need to connect DTR and CTS?
Currently I have nothing Leonardo specific or my board specific.
Q1 and Q2
AFAIK, It isn't possible to change the fuse bit without an external programming tool.
This is the same whether it is a bootloader or a user application.
It is possible.
It is possible to use the serial adapter as an external programming tool, but the Arduino IDE doesn't support it, so you'll need to use another tool. EDIT: However, this is only when the serial adapter supports bit banging, such as FTDI.
Also, if there is no problem even if the writing is very very slow, any serial adapter with RTS and DTR probably can be used as a programming tool...
I found an old Arduino Uno R3 and loaded the sketch:
File -> Examples -> ArduinoISP -> ArduinoISP
Then I connected the Arduino Uno Programmer with my production board:
GND -> GND
5V -> 5V
10 (Reset) -> RES
11 (MOSI) -> MO
12 (MISO) -> MI
13 (SCK) -> SCK
Then I started AVRDUDESS 2.13 (avrdude 6.3).
Selected Programmer: Arduino
COM Port ...
Pressed MCU "Detect"
And the tool detected the ID 1E950F as a ATmega328P which seems to be wrong for my target board.
I am totally sure that I have only ATmega32U4 boards in use.
I tested the same with two other boards but the same result.
I tried to read the fuse bits and it returned always 0x00 for all.
Then I dumped the EEPROM and I am pretty sure that I know that most of the EEPROM memory should be cleared to 0x00. But the dumped file has random data...
Then I forced the avrdude with -F to treat the target as ATmega32U4. Same results.
Then I noticed that the Arduino Uno, that shall act as programming adapter, has a ATmega328P. So it seems that the tool tries to read from the programmer's controller instead of the real target.
And here I am currently stuck. I don't know why but the Arduino Uno seems to currently not act as a programmer. That's at least how it looks like for me.
I know your question is answered but in case you want to go for production, you need to make a programming jig with pogo pins that line up with the spi pins of your blank board. Google programming jigs. How do you think the beatle board got its bootloader flashed to it?
I think I finally will go with the Arduino Uno programming solution.
The FT232R was a promising solution but it seems to much pain to get rid of all the problems.
First, it seems that I would need to build the avrdude on my own to include licensed pthread libraries. These are used with the FTDI FT232R chip.
Second, it's not said that it will work afterwards since I read that there are problems with FTDI Sync bitbang and Win10 and I don't want to setup an old notebook for just this purpose.
Third, there are some badly rated youtube vids that are claiming to explain how to fix the FTDI drivers on a Win10 machine. No good sign in my opinion.
But I am fine and happy with the Arduino Uno solution I currently have. I build a pinhead adapter cable that fits exactly on my production boards without soldering. So I can program the devices before the production boards are placed into the housings.