Skip to content

Commit

Permalink
Add EEPROM retain menu option
Browse files Browse the repository at this point in the history
Closes #139
  • Loading branch information
MCUdude committed Aug 30, 2020
1 parent 694e5e6 commit 58457b2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 18 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ If you're into "generic" AVR programming, I'm happy to tell you that all relevan
* [Supported clock frequencies](#supported-clock-frequencies)
* [Bootloader option](#bootloader-option)
* [BOD option](#bod-option)
* [EEPROM retain option](#eeprom-option)
* [Link time optimization / LTO](#link-time-optimization--lto)
* [Printf support](#printf-support)
* [Pin macros](#pin-macros)
Expand Down Expand Up @@ -96,6 +97,10 @@ Brown out detection, or BOD for short lets the microcontroller sense the input v
| Disabled | Disabled | Disabled | Disabled | Disabled |


## EEPROM option
If you want the EEPROM to be erased every time you burn the bootloader or upload using a programmer, you can turn off this option. You'll have to connect an ISP programmer and hit "Burn bootloader" to enable or disable EEPROM retain. Note that when uploading using a bootloader, the EEPROM will always be retained.


## Link time optimization / LTO
After Arduino IDE 1.6.11 where released, There have been support for link time optimization or LTO for short. The LTO optimizes the code at link time, making the code (often) significantly smaller without making it "slower". In Arduino IDE 1.6.11 and newer LTO is enabled by default. I've chosen to disable this by default to make sure the core keep its backwards compatibility. Enabling LTO in IDE 1.6.10 or older will return an error.
I encourage you to try the new LTO option and see how much smaller your code gets! Note that you don't need to hit "Burn Bootloader" in order to enable LTO. Simply enable it in the "Tools" menu, and your code is ready for compilation. If you want to read more about LTO and GCC flags in general, head over to the [GNU GCC website](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html)!
Expand All @@ -104,7 +109,7 @@ I encourage you to try the new LTO option and see how much smaller your code get
## Printf support
Unlike the official Arduino cores, MiniCore has printf support out of the box. If you're not familiar with printf you should probably [read this first](https://www.tutorialspoint.com/c_standard_library/c_function_printf.htm). It's added to the Print class and will work with all libraries that inherit Print. Printf is a standard C function that lets you format text much easier than using Arduino's built-in print and println. Note that this implementation of printf will NOT print floats or doubles. This is a limitation of the avr-libc printf implementation on AVR microcontrollers, and nothing I can easily fix.

If you're using a serial port, simply use `Serial.printf("Milliseconds since start: %ld\n", millis());`. Other libraries that inherit the Print class (and thus supports printf) are the LiquidCrystal LCD library and the U8G2 graphical LCD library.
If you're using a serial port, simply use `Serial.printf("Milliseconds since start: %ld\n", millis());`. You can also use the `F()` macro if you need to store the string in flash. Other libraries that inherit the Print class (and thus supports printf) are the LiquidCrystal LCD library and the U8G2 graphical LCD library.


## Pin macros
Expand Down
65 changes: 48 additions & 17 deletions avr/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# Menu options
menu.clock=Clock
menu.BOD=BOD
menu.eeprom=EEPROM
menu.LTO=Compiler LTO
menu.variant=Variant
menu.bootloader=Bootloader
Expand Down Expand Up @@ -59,23 +60,29 @@ menu.bootloader=Bootloader
328.menu.bootloader.uart0.upload.protocol=arduino
328.menu.bootloader.uart0.upload.port=UART0
328.menu.bootloader.uart0.build.export_merged_output=true
328.menu.bootloader.uart0.bootloader.high_fuses=0xd6
328.menu.bootloader.uart0.bootloader.high_fuses=0b1101{bootloader.eesave_bit}110
328.menu.bootloader.uart0.bootloader.file=optiboot_flash/bootloaders/{build.mcu}/{build.clock_speed}/optiboot_flash_{build.mcu}_{upload.port}_{upload.speed}_{build.clock_speed}_{build.bootloader_led}.hex

328.menu.bootloader.uart1=Yes (UART1 328PB only)
328.menu.bootloader.uart1.upload.maximum_size=32256
328.menu.bootloader.uart1.upload.protocol=arduino
328.menu.bootloader.uart1.upload.port=UART1
328.menu.bootloader.uart1.build.export_merged_output=true
328.menu.bootloader.uart1.bootloader.high_fuses=0xd6
328.menu.bootloader.uart1.bootloader.high_fuses=0b1101{bootloader.eesave_bit}110
328.menu.bootloader.uart1.bootloader.file=optiboot_flash/bootloaders/{build.mcu}/{build.clock_speed}/optiboot_flash_{build.mcu}_{upload.port}_{upload.speed}_{build.clock_speed}_{build.bootloader_led}.hex

328.menu.bootloader.no_bootloader=No bootloader
328.menu.bootloader.no_bootloader.upload.maximum_size=32768
328.menu.bootloader.no_bootloader.build.export_merged_output=false
328.menu.bootloader.no_bootloader.bootloader.high_fuses=0xd7
328.menu.bootloader.no_bootloader.bootloader.high_fuses=0b1101{bootloader.eesave_bit}111
328.menu.bootloader.no_bootloader.bootloader.file=empty/empty.hex

# EEPROM
328.menu.eeprom.keep=EEPROM retained
328.menu.eeprom.keep.bootloader.eesave_bit=0
328.menu.eeprom.erase=EEPROM not retained
328.menu.eeprom.erase.bootloader.eesave_bit=1

# Variants
328.menu.variant.modelP=328P / 328PA
328.menu.variant.modelP.bootloader.cksel_bits=0111
Expand Down Expand Up @@ -271,6 +278,12 @@ menu.bootloader=Bootloader
168.menu.bootloader.no_bootloader.bootloader.extended_fuses=0xfd
168.menu.bootloader.no_bootloader.bootloader.file=empty/empty.hex

# EEPROM
168.menu.eeprom.keep=EEPROM retained
168.menu.eeprom.keep.bootloader.eesave_bit=0
168.menu.eeprom.erase=EEPROM not retained
168.menu.eeprom.erase.bootloader.eesave_bit=1

# Variants
168.menu.variant.modelP=168P / 168PA
168.menu.variant.modelP.bootloader.cksel_bits=0111
Expand All @@ -289,13 +302,13 @@ menu.bootloader=Bootloader

# Brown out detection
168.menu.BOD.2v7=BOD 2.7V
168.menu.BOD.2v7.bootloader.high_fuses=0xd5
168.menu.BOD.2v7.bootloader.high_fuses=0b1101{bootloader.eesave_bit}101
168.menu.BOD.4v3=BOD 4.3V
168.menu.BOD.4v3.bootloader.high_fuses=0xd4
168.menu.BOD.4v3.bootloader.high_fuses=0b1101{bootloader.eesave_bit}100
168.menu.BOD.1v8=BOD 1.8V
168.menu.BOD.1v8.bootloader.high_fuses=0xd6
168.menu.BOD.1v8.bootloader.high_fuses=0b1101{bootloader.eesave_bit}110
168.menu.BOD.disabled=BOD disabled
168.menu.BOD.disabled.bootloader.high_fuses=0xd7
168.menu.BOD.disabled.bootloader.high_fuses=0b1101{bootloader.eesave_bit}111

# Compiler link time optimization
168.menu.LTO.Os=LTO Disabled
Expand Down Expand Up @@ -462,6 +475,12 @@ menu.bootloader=Bootloader
88.menu.bootloader.no_bootloader.bootloader.extended_fuses=0xfd
88.menu.bootloader.no_bootloader.bootloader.file=empty/empty.hex

# EEPROM
88.menu.eeprom.keep=EEPROM retained
88.menu.eeprom.keep.bootloader.eesave_bit=0
88.menu.eeprom.erase=EEPROM not retained
88.menu.eeprom.erase.bootloader.eesave_bit=1

# Variants
88.menu.variant.modelP=88P / 88PA
88.menu.variant.modelP.bootloader.cksel_bits=0111
Expand All @@ -480,13 +499,13 @@ menu.bootloader=Bootloader

# Brown out detection
88.menu.BOD.2v7=BOD 2.7V
88.menu.BOD.2v7.bootloader.high_fuses=0xd5
88.menu.BOD.2v7.bootloader.high_fuses=0b1101{bootloader.eesave_bit}101
88.menu.BOD.4v3=BOD 4.3V
88.menu.BOD.4v3.bootloader.high_fuses=0xd4
88.menu.BOD.4v3.bootloader.high_fuses=0b1101{bootloader.eesave_bit}100
88.menu.BOD.1v8=BOD 1.8V
88.menu.BOD.1v8.bootloader.high_fuses=0xd6
88.menu.BOD.1v8.bootloader.high_fuses=0b1101{bootloader.eesave_bit}110
88.menu.BOD.disabled=BOD Disabled
88.menu.BOD.disabled.bootloader.high_fuses=0xd7
88.menu.BOD.disabled.bootloader.high_fuses=0b1101{bootloader.eesave_bit}111

# Compiler link time optimization
88.menu.LTO.Os=LTO Disabled
Expand Down Expand Up @@ -647,6 +666,12 @@ menu.bootloader=Bootloader
48.menu.bootloader.no_bootloader.build.export_merged_output=false
48.menu.bootloader.no_bootloader.bootloader.file=empty/empty.hex

# EEPROM
48.menu.eeprom.keep=EEPROM retained
48.menu.eeprom.keep.bootloader.eesave_bit=0
48.menu.eeprom.erase=EEPROM not retained
48.menu.eeprom.erase.bootloader.eesave_bit=1

# Variants
48.menu.variant.modelP=48P / 48PA
48.menu.variant.modelP.bootloader.cksel_bits=0111
Expand All @@ -665,13 +690,13 @@ menu.bootloader=Bootloader

# Brown out detection
48.menu.BOD.2v7=BOD 2.7V
48.menu.BOD.2v7.bootloader.high_fuses=0xd5
48.menu.BOD.2v7.bootloader.high_fuses=0b1101{bootloader.eesave_bit}101
48.menu.BOD.4v3=BOD 4.3V
48.menu.BOD.4v3.bootloader.high_fuses=0xd4
48.menu.BOD.4v3.bootloader.high_fuses=0b1101{bootloader.eesave_bit}100
48.menu.BOD.1v8=BOD 1.8V
48.menu.BOD.1v8.bootloader.high_fuses=0xd6
48.menu.BOD.disabled=BOD disabled
48.menu.BOD.disabled.bootloader.high_fuses=0xd7
48.menu.BOD.1v8.bootloader.high_fuses=0b1101{bootloader.eesave_bit}110
48.menu.BOD.disabled=BOD Disabled
48.menu.BOD.disabled.bootloader.high_fuses=0b1101{bootloader.eesave_bit}111

# Compiler link time optimization
48.menu.LTO.Os=LTO disabled
Expand Down Expand Up @@ -802,7 +827,7 @@ menu.bootloader=Bootloader
8.bootloader.unlock_bits=0x3f
8.bootloader.lock_bits=0x0f
8.bootloader.low_fuses=0b{bootloader.bod_bits}{bootloader.sut_cksel_bits}
8.bootloader.high_fuses=0b110{bootloader.ckopt_bit}010{bootloader.bootrst_bit}
8.bootloader.high_fuses=0b110{bootloader.ckopt_bit}{bootloader.eesave_bit}10{bootloader.bootrst_bit}
8.build.core=MCUdude_corefiles
8.build.variant=standard
8.build.board=AVR_ATmega8
Expand All @@ -824,6 +849,12 @@ menu.bootloader=Bootloader
8.menu.bootloader.no_bootloader.bootloader.bootrst_bit=1
8.menu.bootloader.no_bootloader.bootloader.file=empty/empty.hex

# EEPROM
8.menu.eeprom.keep=EEPROM retained
8.menu.eeprom.keep.bootloader.eesave_bit=0
8.menu.eeprom.erase=EEPROM not retained
8.menu.eeprom.erase.bootloader.eesave_bit=1

# Brown out detection - This is the first part of the low fuse bit concatenation
8.menu.BOD.2v7=BOD 2.7V
8.menu.BOD.2v7.bootloader.bod_bits=10
Expand Down

0 comments on commit 58457b2

Please sign in to comment.