Need help uploading sketch to Leonardo/pro micro board without bootloader

Am trying to upload a sketch using my Arduino uno as a programmer to a pro micro/Leonardo (ATMEGA32U4 ) but I am getting this error:

recipe.preproc.macros pattern is missing

Error compiling for board Arduino Leonardo No Bootloader.

I followed this topic here (Remove Leonardo's bootloader - Microcontrollers - Arduino Forum) and edited my voards.txt file

Using this guide here(Installing an Arduino Bootloader - SparkFun Learn) to upload sketch to the Leonardo using my UNO.

Anyone able to help me ?

Thankyou.

There is a typo in Remove Leonardo's bootloader - #5 by Jiggy-Ninja - Microcontrollers - Arduino Forum

You need to change this line:

leonardoNB.build.core=arduono:arduino

to:

leonardoNB.build.core=arduino:arduino

I tried changing but I am getting a new error now ;/

In file included from sketch\heartgif.ino.cpp:1:0:

C:\Users\username\Documents\ArduinoData\packages\arduino\hardware\avr\1.8.1\cores\arduino/Arduino.h:257:10: fatal error: pins_arduino.h: No such file or directory

#include "pins_arduino.h"

^~~~~~~~~~~~~~~~

compilation terminated.

exit status 1
Error compiling for board Arduino Leonardo No Bootloader.

BTW My code works on the UNO, just not the Leonardo, its around 31KB

Please post the contents of your boards.txt file.

Please provide the path where the boards.txt file is located.

pert:
Please post the contents of your boards.txt file.

Please provide the path where the boards.txt file is located.

I deleted the one in C:\Users(username)\AppData\Local\Arduino15 as suggested in the other forum

My current one is: C:\Users\myusername\Documents\Arduino\hardware\attiny\avr

the boards.txt file just contains the text from the Forum I linked, I deleted everything except that. Did I do it wrong ?

I made a backup copy just incase, so do I add the Leonardo text from OP link into this ?

There are two different methods described in the forum post you are following:

@jsantosrico's method of modifying the existing boards.txt file.
@Jiggy-Ninja's method of creating a new custom boards.txt file.

The instructions about deleting C:\Users(username)\AppData\Local\Arduino15 are only needed for @jsantosrico's method.

kot0005:
My current one is: C:\Users\myusername\Documents\Arduino\hardware\attiny\avr

This indicates you're using @Jiggy-Ninja's method.

kot0005:
the boards.txt file just contains the text from the Forum I linked

Which text? @jsantosrico's or @Jiggy-Ninja's?

kot0005:
I deleted everything except that.

What do you mean by that?

What you're trying to do is fairly straightforward, and many people here on the forum can help you, but only if you provide enough information. I know for a fact that this will work fine, because I just tested it myself, following the exact instructions provided on that forum thread, with only the typo fix I mentioned earlier. So clearly you have not correctly followed the instructions. So all we need to do is to figure out where you went astray. The problem is that I can't see your computer so all I have to work with is the information you provide, and you're not providing enough information.

Hey am using jsantosrico's Text file ( I edited it with the correct line you gave me).

I just edited my .txt file, am not using Ninja's method.

OK, let's start over from scratch. There were some additional problems with those instructions that would have caused you new problems later, and I have now fixed those also:

Delete C:\Users\myusername\Documents\Arduino\hardware\attiny

Create a folder named C:\Users\myusername\Documents\Arduino\hardware\kot0005

Create a folder named C:\Users\myusername\Documents\Arduino\hardware\kot0005\avr

Create a file named C:\Users\myusername\Documents\Arduino\hardware\kot0005\avr\boards.txt

Open C:\Users\myusername\Documents\Arduino\hardware\kot0005\avr\boards.txt in a text editor.

Add the following to the file:

leonardoNB.name=Arduino Leonardo No Bootloader

leonardoNB.upload.tool=arduino:avrdude
leonardoNB.upload.maximum_size=32768
leonardoNB.upload.maximum_data_size=2560

leonardoNB.bootloader.tool=arduino:avrdude
leonardoNB.bootloader.low_fuses=0xFF
leonardoNB.bootloader.high_fuses=0xD7
leonardoNB.bootloader.extended_fuses=0xCB
leonardoNB.bootloader.unlock_bits=0x3F
leonardoNB.bootloader.lock_bits=0x3F
leonardoNB.bootloader.file=empty/empty.hex

leonardoNB.build.mcu=atmega32u4
leonardoNB.build.f_cpu=16000000L
leonardoNB.build.vid=0x2341
leonardoNB.build.pid=0x8036
leonardoNB.build.usb_product="Arduino leonardo"
leonardoNB.build.board=AVR_leonardo
leonardoNB.build.core=arduino:arduino
leonardoNB.build.variant=arduino:leonardo
leonardoNB.build.extra_flags={build.usb_flags}

Save the file.

Create a folder named C:\Users\myusername\Documents\Arduino\hardware\kot0005\avr\bootloaders\empty

Create a file named C:\Users\myusername\Documents\Arduino\hardware\kot0005\avr\bootloaders\empty\empty.hex

Open C:\Users\myusername\Documents\Arduino\hardware\kot0005\avr\bootloaders\empty\empty.hex in a text editor.

Add the following to the file:

:0200000002C03C
:00000001FF

Save the file.

Restart the Arduino IDE if it's running.

Connect your Uno to your Leonardo as shown in the Arduino as ISP tutorial

Connect the USB cable of your Uno to your computer.

Tools > Board > Arduino Uno

Tools > Port > select the port of your Uno

File > Examples > 11.ArduinoISP > ArduinoISP

Sketch > Upload

Wait for the upload to your Uno to finish. Your Uno is now an "Arduino as ISP" programmer.

(In the Arduino IDE) Tools > Board > Arduino Leonardo No Bootloader

Tools > Programmer > Arduino as ISP

Tools > Burn Bootloader

Wait for the burn bootloader process to finish successfully. You have now set the configuration fuses on the ATmega32U4 to not use the bootloader, so you can use the full 32 kB of flash memory on the microcontroller for your sketch.

Open the sketch you want to upload to the Leonardo.

Sketch > Upload Using Programmer
Because of the way I configured the boards.txt, you can actually just do a normal Upload if you prefer and it will have the same effect as Upload Using Programmer.

Here here are some images

My wiring to the Leonardo in in the last screenshot, pls let me know if you want more infos :slight_smile:

thanks heaps for helping me. Am sort of a noob, I just want my sketch in the Leonardo , I dont want to change it once its in there !

Go ahead and follow my instructions. It looks like you've been fiddling with every boards.txt you could find. You are going to end up with two different Tools > Board > Arduino Leonardo No Bootloader entries because of this. Make sure you select the one that is NOT directly under the "Arduino AVR Boards" section heading in the menu.

pert:
Tools > Board > Arduino Uno

Hey okay , I hit a roadblock here. I dont have Arduino uno in boards anymore ;/

Uploaded the screenshot at the bottom:

https://imgur.com/a/j0kT9KF

kot0005:
I deleted the one in C:\Users(username)\AppData\Local\Arduino15 as suggested in the other forum

What do you mean by this? Did you delete the entire C:\Users(username)\AppData\Local\Arduino15 folder? Or do you mean something else?

Just the Arduino15 folder haha, how do I get it back ? emptied recycle bin unfortunately;/

It's fine, you don't need it. I just needed to know which boards.txt you had modified. Since you deleted Arduino15, I know it's not that one.

Please uninstall and then reinstall the Arduino IDE. That will restore your Arduino AVR Boards installation and bring back the Arduino Uno board option.

pert:
Wait for the burn bootloader process to finish successfully. You have now set the configuration fuses on the ATmega32U4 to not use the bootloader, so you can use the full 32 kB of flash memory on the microcontroller for your sketch.

Open the sketch you want to upload to the Leonardo.

Sketch > Upload Using Programmer
Because of the way I configured the boards.txt, you can actually just do a normal Upload if you prefer and it will have the same effect as Upload Using Programmer.

Dont,

but new error: My sketch doesnt work when I connect my Leonardo to the USB, its a sketch for a SSD1306 .96 OLED Display,

Do I have to re do my libraries before uploading ?

Sketch uses 28128 bytes (87%) of program storage space. Maximum is 32256 bytes.
Global variables use 1457 bytes (71%) of dynamic memory, leaving 591 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch

I attached my sketch, OLED works when connected to Leonardo with bootloader btw

heartgif222.ino (89.7 KB)

Heyy Man, I wana say thnk you heaps for replying so fast lol !!

I tried uploading again and yess its working now

you are a Champ!!

You're welcome. I'm glad to hear it's working now. Enjoy!
Per