Hot answers tagged

8

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 flash memory. The Optiboot wraps this in a function. A pointer to this function is put in a 'vector table' at the beginning of the bootloader. The first pointer ...


6

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 the code onto the board, that is upload via programmer. You could edit that and change some fuses yourself. But you could also probably just use MCUdude ...


6

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 flash_array[] = { 5, 6, 7, 8 }; void function_reading_ram(const uint8_t *array) { uint8_t secondElement = array[1]; // ... } void function_reading_flash(...


4

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 differ between flash/SRAM in a separate class (one per type). You get data hiding and possible separation of concerns for free. Instead of putting the array in ...


3

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 problem as you can choose the size for file system in the partition table and also you can upload the file (there is a plugin in the arduino IDE for this ...


3

I will expand on KIIV's comment here. This is a known issue to the people who wrote the Arduino framework. Essentially, the pointers to PROGMEM and RAM are both data pointers (think of a pointer like an array index, but for the entire RAM/Flash itself rather than one chunk of it that you manage) of the same size and type. They cannot be told apart since ...


2

The classic avr-gcc way is to have dedicated functions with different names e.g. void* memcpy(void* dest, const void* src, size_t n); // Only works if src is RAM vs. void* memcpy_P(void *dest, PGM_VOID_P src, size_t n); // Only works if src is PROGMEM BTW: That's mentioned in a comment to the question already by @Delta_G. More about the example memcpy_P ...


2

Things to check: Partition arrangement selected. You have to make sure to keep the same partition arrangement between uploads. Partition arrangement selected. You have to make sure that the partition arrangement you have chose supports OTA uploads. You have to reset the ESP8266 manually after your USB upload. You can only do an OTA update to a sketch that ...


2

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 only drawback is that the flash memory gets erased every time you upload a new (or new version of a) sketch. For my application that works but for other ...


2

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: +----+-+-------------+-------------+---------------------+ |BOOT|P|OTA Program 1|OTA Program 2| SPIFFS | +----+-+-------------+-------------+------...


2

For a flash chip, no it's not possible to erase a single byte. The closest you can do is to read an entire sector into memory, erase that sector, modify your in-memory copy, then write the sector back. You would be better using an SPI SRAM or PSRAM chip instead of a flash chip.


1

If you have a sketch which can write its updated version into EEPROM of ATmega328p and then boootload from the EEPROM, then you can use the flash for the same purpose. The ATmega328p has 32kB of flash and only 1kB EEPROM. For my ArduinoOTA library I developed a way to store the uploaded binary in upper half of the flash and then let the bootloader copy the ...


1

You are correct, MISO, MOSI and SCK are common to all the SPI devices. Be sure they are all set up for clock polarity etc. The CS\ line is the select line. If the device is not selected it does not matter what goes on with MISO, MOSI and SCK. There are chips such as the 74HC138 that will give you chip selects with just a few additional pins. 1 pin gives you ...


1

I'm not clear if this is the page address or the byte address from which I will start recording? That is the byte address. As the data sheet in section 8.5.13 says: If an entire 256 byte page is to be programmed, the last address byte (the 8 least significant address bits) should be set to 0. If the last address byte is not zero, and the number of clocks ...


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