Fuses settings and use of FLASH memory

I read about the fuse settings, and managed to install a newer Bootloader on my ATmega328P (an Arduino Nano). This saved up 1K of program memory, so, after changing some settings inside the boards.txt file to be: "nano.menu.cpu.atmega328.upload.maximum_size=32256" (line 145) and the fuse "nano.menu.cpu.atmega328.bootloader.high_fuses=0xDE" (line 150). It works fine. From what I understood, the setting of this fuse tells the compiler how much program memory is available on the board, counting that there's some space dedicated to the Bootloader.
Now, as I don't need a Bootloader anymore, I could overwrite it using an UNO as a programmer through SPI and I would be done. I calculated (please correct me if I'm wrong) that the line 145 should look like this, without the Bootloader taking its space: "nano.menu.cpu.atmega328.upload.maximum_size=32768", but I really don't know how I should change the fuse settings in order to use the full capacity of the program memory, as I couldn't find any information online (even whether it is possible or not).
Any kind of help is widely appreciated =D
Also, sorry for not being very good with english. I'm still learning, it's not my native lenguage.

Since you already know how to change the bootloader, the easiest thing to do is use MCUdude's MiniCore which allows you to select "No bootloader" under the IDE's Tools menu.

There was no need to modify the boards.txt file when changing the bootloader on the Nano, just burn the bootloader with the IDE set for UNO and from then on select UNO as the board type when compiling.

Modifying boards.txt has the disadvantage that an update to the boards package will overwrite all your changes.

Thanks for answering!
I've installed it, and tried it. Juts to be sure, Ioverwritten the original 'boards.txt' over the modified one. At first I was able to upload with no problems, but the Nano started not to boot after a bit. Avrdude started telling me that the programmer (Arduino UNO as ISP) is not responding, and now he spits out the error in the screen shot below (both uploading with the board set to 'Arduino AVR boards > Arduino Nano' and with 'MiniCore > ATmega328'). I checked the wiring several times, as I've read online. I also tried burning the bootloader again, and it won't work.
Maybe there's something wrong with the settings shown in the screenshot. My programmer is an original Arduino UNO, and the target is an Arduino Nano clone board.
Thanks in advance :smiley:

EDIT: So, I've tried burning the bootloader again onto the Nano board, just to see if I could upload a sketch through USB. At first it told me that the programmer is not responding, then that it was not able to open the COM port too (as you can see in the screenshot below). I really don't know what to do at this point...

Do you have any external components connected to the nano? What were you doing when the nano stopped booting?

Do you have the capacitor connected between reset and ground on the UNO you are using for the Arduino as ISP? Although it seems odd that it would have worked in the past if that were the problem.

How are you connecting the UNO to the Nano? If you are using jumper wires, verify that one of those has not gone bad - the wire can break at the connector while the outer insulation is still holding things together.

No, I don't have anything connected to the Nano when uploading. I don't remmeber exactly what I was doing neither or in hardware in software (as pretty much nothing has changed since the setup that worked) when the Nano stopped working, I just rember, right after installation of MiniCore, enabling Compiler LTO (I needed some optimization, otherwise the sketch would be too big) and setting the bootloader option to 'No bootloader'. That's when things started working, from then nothing was changed, and Nano started not to boot after the first sketch upload (even the first upload wasn't working perfectly, but it booted and ran quite well).
No, I don't have a capacitor between RESET and GND. From what I'vre read, a 10uF electrolytic capacitor should be put there. The strange thing is that I've already burnt the Bootloader two times successfully onto the Nano, the first right after the purchase (as it was a clone and it had the old bootloader), so I assume SPI worked fine even without it.
I'm connecting the two board with jumper wires, yes, and I just checked all of them: none is missing connection.
I've also done a loopback test on the Nano (connected directly through USB), and it doesn't seem to work. Maybe because there's not a bootloader on it, but I doubt this is the cause. I did the same test on the UNO, and it worked.
Thanks again for answering, I really appreciate your help :slight_smile:

A little update: I managed to burn the bootloader again onto the Nano, I just had missed a step during the settings setup. This gave me back some hope: the SPI still works. I then uploaded a sketch of the project I'm working on (using the Nano board type selected, not MicroCore) and it worked!
I then tried uploading it with MicroCore, and while the data on the chip was written and verified by avrdude, the screen I got hooked won't show anything, and the sound doesn't work either: I assume it doesn't boot. I tried doing the same with the blink sketch, and it worked (with and without the bootloader!)r. I'll write the current settings for my Nano: Board:"ATmega328" ; Clock:"External 16MHz" ; BOD:"BOD 2.7V" ; EEPROM:"EEPROM retained" ; Compiler LTO:"LTO enabled" ; Variant:"328P / 328PA" ; Bootloader:"No Bootloader" ; Port:"COM5 (Arduino UNO).
Maybe it's a matter of space tho. The blink sketch is really small compared to my project, which hold almost all the flash available, without the bootloader. The screen uses SDL and SCA pins (A4 and A5 on the Nano), also the Nano has A6 and A7 pins, which the UNO doesn't have, from what I can see. Maybe it's a compatibility problem: as both the board have the onboard LED it the blink sketch works, but maybe when I'm referring to the additional pins (A6 and A7) of the Nano something goes wrong when compiling. I really don't know...

Note that A6 and A7 are only usable as analog inputs, they will not work for digital input/output.

Yup I know that! I use them to read two potentiometers' outputs.
Do you have any idea about what I should do or test to see why some sketches work and some don't, without the bootloader? I would try to just remove parts one by one from the project and see when it starts working. But maybe you've got better advice ;D

Thanks a ton for answering, you're helping a lot a pretty much dumb student

Does the same code work when there is a bootloader installed, then stop working without the bootloader? Without actually seeing the code it can be very difficult to guess at what the problem might be, there are some things that are done differently with a bootloader installed, such as checking to see the cause of a processor reset.

I've done more testing.
When i get over 32256 bytes with the program, it won't work. The space between 32256 and the maximum 32768 is the space needed by the bootloader. The compiler is telling me that the maximum program size is 32768, without the bootloader, but if I use the memory over the 32256 bytes, the Arduino won't work. I'm really unsure about why this happens, but my only theory is that the bootloader is still included (even if the option "no bootloader" is set) as long as there's enough space for it to be included, and when there's not enought space anymore it actually won't include it and the Arduino will (strangely) stop working. I couldn't find any info about it online.
Currently program size is 32336 bytes (98% of the available 32768 bytes), and it does upload and verify.
If you have a clue about what could be the problem, or you just have some knowledge to share, I will be really happy to read everything! Thanks once again for the help :slight_smile:

Did you do the Tools > Burn Bootloader process with "no bootloader" selected? That is necessary to set the fuses correctly, even though no bootloader is being put onto the atmega328.

In reference to one of your earlier posts, it is necessary to set LTO enable with MiniCore, for some reason it defaults to disabled - LTO is enabled by default in the Arduino core.

1 Like

I didn't burn it! Can't believe how dumb I am...
It now seems to work with no problems at all, thank you so much!