So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By ElQuestion
#88289 Hello together,

i am using an ESP8266 and want to calculate a Checksum or Hash over all available memory. I tried to solve this problem myself but didn't manage to do so. Therefor i hope i can get here some help or tips. In the following i try to describe what i tried so far.

First of all i tried to understand what memory is available using an ESP8266. When i get it right, there is a RAM and Flash memory available. The difference between them is, that the Flash memory is no volatile. So i tried to access and read the Flash memory and ended up with the following sketch:

Code: Select all#include <Arduino.h>
#include <EEPROM.h>

#define EEPROM_SIZE 512

void setup() {
  Serial.begin(9600);
  EEPROM.begin(EEPROM_SIZE);
}

int i = 0;

void loop() {
  Serial.print(i);
  Serial.print(": ");
  Serial.println(EEPROM.read(i),DEC);

  i++;
  if(i>511){i=0;}
}


The sketch is running on my ESP8266 and should loop over the complet Flash memory (?). But strangely it prints always 255 for each address. That suprises me, why the Flash memory should only consists of 1s. Therefor i think, there must be an mistake somewhere....


Second i tried to access and read the RAM but could not find a way to do so.

I hope i posted my question using the right topic and described my tries correctly.

I also hope i can get some help here, and thanks for everybody in advance for reading my question.
User avatar
By martinayotte
#88319
ElQuestion wrote:But strangely it prints always 255 for each address. That suprises me, why the Flash memory should only consists of 1s. Therefor i think, there must be an mistake somewhere....

Not strange at all :
if all bits from a byte are 1, this make 0b11111111 = 255.
User avatar
By schufti
#88320 with your sketch you only read the emulated EEPROM (located in flash).
If you used "erase flash: all flash contents" or a new module then the default is 0xFF==255.

do you really need to calculate the checksum? This is allready done when flashing and checked every tike the esp boots up.
User avatar
By ElQuestion
#88375
martinayotte wrote:
ElQuestion wrote:But strangely it prints always 255 for each address. That suprises me, why the Flash memory should only consists of 1s. Therefor i think, there must be an mistake somewhere....

Not strange at all :
if all bits from a byte are 1, this make 0b11111111 = 255.


Yes, but that means that the complete memory only consits of 1s. I would have thought that there should be more variation.