Skip to main content
Share Your Experience: Take the 2024 Developer Survey
8 votes
Accepted

Can I force a function to live in the boot sector without overwriting the bootloader?

The Optiboot version 8 has a do_spm function which can be called from application. The Optiboot repository contains an example for the use of this function. SPM is the AVR CPU instruction to write to ...
Juraj's user avatar
  • 18k
7 votes
Accepted

Executing machine code at runtime Uno

The microcontroller is executing one command at a time from..where? Flash memory directly. The AVR core can only execute instructions from Flash memory. It uses a two-bus system known as Harvard ...
Majenko's user avatar
  • 105k
7 votes
Accepted

EEPROM.get returns bad data

You are saving a String object in EEPROM, which is useless. A string object does not store the contents of your string. Instead, it just stores: the memory address where the actual contents (the ...
Edgar Bonet's user avatar
  • 43.3k
7 votes

How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?

I am afraid there is no good solution to this problem. One option I do like is to use the __flash qualifier instead of PROGMEM: const uint8_t ram_array[] = { 1, 2, 3, 4 }; __flash const uint8_t ...
Edgar Bonet's user avatar
  • 43.3k
6 votes
Accepted

Extend program space by getting rid of bootloader on NANO

It's enforcing this line from the arduino:avr boards.txt nano.menu.cpu.atmega328.upload.maximum_size=30720 To be clear, the board is assumed to have a bootloader, even if you're not using it to get ...
timemage's user avatar
  • 5,299
5 votes

What programming practices should be adopted while coding sketches for Arduino?

Paul covered the most important points. This answer is intended to be a complement to his. First, you should keep in mind the general rules, which are more important than the more specific ones. The ...
Edgar Bonet's user avatar
  • 43.3k
5 votes

Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?

Yes you can. This Arduino IDE add on lets you make calls to code store in the bootload of memory so you can make changes to the flash memory. https://majek.sh/en/writing-to-internal-flash-on-arduino/ ...
CrossRoads's user avatar
  • 2,415
5 votes
Accepted

Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?

The answer is "yes, you can use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage, very similar to an STM32 microcontroller." One of these days I'm going to write an Arduino ...
Gabriel Staples's user avatar
4 votes
Accepted

Set EEPROM from PC before program

The simplest way would be to have two sketches. One that will store all the strings into EEPROM. After that you can upload the second actual sketch that uses the values stored in EEPROM. You ...
Gerben's user avatar
  • 11.3k
4 votes
Accepted

Writing your own Arduino flashing tool

This application already exists. It's called AVRDUDE: http://www.nongnu.org/avrdude/ You can download it compiled for Windows at the link above. This is the very flashing tool that the Arduino IDE ...
per1234's user avatar
  • 4,178
4 votes

How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?

There is also an OO solution possible, using the strategy design pattern, but this comes with some (slight) memory and performance penalties. You need to use C++ for this. Put each array you want to ...
Michel Keijzers's user avatar
4 votes
Accepted

How do I get the size of my program at runtime?

Just to warn you, I minimally tested this, but it seems to work. In the Due's linker script there are these relevant lines, containing the named rom section. MEMORY { rom (rx) : ORIGIN = ...
timemage's user avatar
  • 5,299
4 votes

How .data + .text section can be = How much flash the final program will consume

Just to expand on what JRobert said, variables which are initialized, and other literals (eg. the word "foo" in your example) have to come from somewhere, and thus are stored in program (...
Nick Gammon's user avatar
  • 38.3k
3 votes

How to save a hex file into Arduino Flash to send it via Serial?

If I understand your question correctly, you need to integrate this data into a .ino script. Probably as a byte array. Then the script can read the array and Serial.write its content. You could ...
dda's user avatar
  • 1,588
3 votes

What programming practices should be adopted while coding sketches for Arduino?

Keep in mind that RAM is even less. 32KB is a fair lot of code, since C/C++ is highly efficient. "Don't save **** in RAM." If you need to load images into a display, save the images on an SD card. ...
aaa's user avatar
  • 2,695
3 votes

Set EEPROM from PC before program

I think here is a confusion about the three types of memory. EEPROM, FLASH and SRAM are completely separate. EEPROM is like your file storage. FLASH contains you program and static values. SRAM is the ...
Kwasmich's user avatar
  • 1,513
3 votes
Accepted

Flashing ESP8266 over WiFi whith samrtphone?

ESP8266 OTA can be performed through a web browser as detailed in the ESP8266 OTA information page. Since a smartphone has a web browser I can see no reason why you can't use that.
Majenko's user avatar
  • 105k
3 votes

Trying to flash ESP8266 with Arduino UNO

You do not need the level shifter. The input pins of the ESP8266 contain over-voltage (though not over-current) protection. All you need to do is limit the current that can flow through the over-...
Majenko's user avatar
  • 105k
3 votes
Accepted

Flashing an ATtiny85 with a NodeMCU?

It can be done. Your Digispark has SPI pins, which are ISP pins. For the esp8266 there is an ESP8266AVRISP library for OTA upload to AVR. You can use the example of the library. You must wire the SPI ...
Juraj's user avatar
  • 18k
3 votes
Accepted

AVR-GCC can't call function located on fixed address

I've tried this code with arduino and it worked (i taught, of course, i can't add the "-Wl,--section-start=.app_start=0xFA0" flag to the compilation process so the function not gonna be moved to other ...
Dankó Dávid's user avatar
3 votes

Can't flash ESP8266 anymore (NodeMCU)

The fix ended up being to use a 220ohm resistor between D3 and GND (It has been pointed out, though I haven't tested it, that just wiring D3 to ground on startup should have the same effect). Then ...
Tyler C's user avatar
  • 147
3 votes
Accepted

Reading contents of ESP8266 Flash from inside sketch

I think you're reading of flash is slightly wrong while ESP.flashRead takes a unit32_t pointer for output data, the read "count" argument is in bytes - looking at Updater.cpp code it does this ...
Jaromanda X's user avatar
3 votes

EEPROM.get returns bad data

Just to have the full working code, I ended up with this: #include <EEPROM.h> char serial_characters[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"}; // 7 chars for serial and one for string end '...
adrianTNT's user avatar
  • 252
3 votes
Accepted

ESP8266 OTA update with different flash size settings?

The basic problem is that when you upload over OTA you don't upload the partition structure. The ESP32's flash is split into a number of "partitions" or areas. It might look something like: ...
Majenko's user avatar
  • 105k
3 votes
Accepted

ESP32: best way to embed certificates

I don't know what you need that Preferences thing for, but I would use SPIFFS/FAT anyway. Simply store the certificate in a file in flash and read that file when you need it. The required space is no ...
Sim Son's user avatar
  • 1,869
3 votes

D1 mini esp8266 error: esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

I'm not sure if this will help EVERYONE, but I hope it at least helps someone. I had the same issue with several different boards (3 Nano's, 2 NodeMCU ESP8266's, and 1 Uno). I searched and searched ...
jsmwrench's user avatar
3 votes

Reading & writing a configuration file on an Adafruit Circuit Playground Express

The problem was using the Arduino SAMD board core instead of the Adafruit SAMD board core. The Adafruit SAMD board core is not visible unless you add: https://adafruit.github.io/arduino-board-index/...
user3308886's user avatar
3 votes
Accepted

Creating firmware redundancy on Arduino Nano

More powerful MCU with large flash memory have partitioning or flash memory banks where they can switch between different versions of the firmware. They have a register to set the start address so the ...
Juraj's user avatar
  • 18k
2 votes

How to read/write variables persistenly on Arduino Due (no EEPROM/shield)?

This library called DueFlashStorage was created by Sebnil and is in the Arduino Library Database Tool! It basically takes the EEPROM functionality and applies it to the Flash storage on the DUE. The ...
Jay Rosey's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible