Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By ReinholdHiller
#17240 I simply want to acces the first byte of the code, but all I get is a reboot. I'm sure I made a stupid error, but I don't see it.

Code: Select allint fubar(void) {

  return random(100);


void setup() {
  delay(5000);
  Serial.begin(115200);
 
  byte i = 7;

  char *foo;
  Serial.print("sizeof(foo): "); 
  Serial.println(sizeof(foo));
 
  Serial.println("1111");
  foo=(char *)&i;
  Serial.print("Addr: "); 
  Serial.println((unsigned long )foo,HEX);
  Serial.print("Value: "); 
  Serial.println((byte)*foo);

  Serial.println("2222");
  foo=(char *)&fubar;
  Serial.print("Addr: "); 
  Serial.println((unsigned long )foo,HEX);
  Serial.print("Value: "); 
  Serial.println((byte)*foo);     // <-- reboots here
}

void loop() {
  delay(1000);
}
User avatar
By jcmvbkbc
#17241
ReinholdHiller wrote:I simply want to acces the first byte of the code, but all I get is a reboot.

You can only access IRAM with aligned 4-byte reads/writes, the core does not support bytewise access.
User avatar
By jcmvbkbc
#17244
ReinholdHiller wrote:So what to do? My pointer looks aligned to me...

2222
Addr: 40210834
Addr: 1000000001000010000100000110100
Value:

Read whole uint32_t words and extract bytes from them.