-->
Page 1 of 3

Why can't I access code pointers?

PostPosted: Tue May 12, 2015 8:43 am
by ReinholdHiller
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);
}

Re: Why can't I access code pointers?

PostPosted: Tue May 12, 2015 8:53 am
by jcmvbkbc
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.

Re: Why can't I access code pointers?

PostPosted: Tue May 12, 2015 9:11 am
by ReinholdHiller
So what to do? My pointer looks aligned to me...

2222
Addr: 40210834
Addr: 1000000001000010000100000110100
Value:

Re: Why can't I access code pointers?

PostPosted: Tue May 12, 2015 9:18 am
by jcmvbkbc
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.