const char array in code space on 32bit processor, e.g. ESP8266

Hi

I need to put a large bitmap into code space on a ESP8266 Arduino (Wemos D1 mini).

static const unsigned char BitmapExample1[] =
{
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
// and many more

PROGMEM has no effect for ESP8266.

The compiler certainly has a means for this, but I don't know how yet.

This may have been answered many times, but there are so many PROGMEM related posts that I did not find the answer.

Jean-Marc

on ARM, "const" is usually sufficient to cause data to be put in FLASH instead of in RAM.

(Hmm. Look like not the ESP8266, though. I did find this http://marrin.org/2017/01/16/putting-data-in-esp8266-flash-memory/ using "esp8266 flash data" as search string.

http://esp8266.github.io/Arduino/versions/2.0.0/doc/filesystem.html

My question seems not so trivial as I thought.

@westfw

Thank you for the link; it explains why the compiler for ESP8266 avoids to try to solve this.

@groundFungus

Thank you for the link.
I do not want to put the bitmap in a file system, it should be part of a code example.

My display is 640x384; so for drawBitmap() test, the bitmap example needs be shortened for ESP8266.

Jean-Marc

Now I am completely confused, finally.

No RAM is taken with this code:

  const uint8_t* ptr = BitmapExample1;
  const uint16_t sz = sizeof(BitmapExample1);
  //display.drawBitmap(BitmapExample1, sizeof(BitmapExample1));
  //display.drawBitmap(ptr, sz);
Sketch uses 238205 bytes (22%) of program storage space. Maximum is 1044464 bytes.
Global variables use 63036 bytes (76%) of dynamic memory, leaving 18884 bytes for local variables. Maximum is 81920 bytes.
Low memory available, stability problems may occur.

But RAM is taken with this code:

  const uint8_t* ptr = BitmapExample1;
  const uint16_t sz = sizeof(BitmapExample1);
  //display.drawBitmap(BitmapExample1, sizeof(BitmapExample1));
  display.drawBitmap(ptr, sz);
Sketch uses 253197 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 78012 bytes (95%) of dynamic memory, leaving 3908 bytes for local variables. Maximum is 81920 bytes.
Low memory available, stability problems may occur.

What happens here, how does the compiler know?

The method to be called is

    void drawBitmap(const uint8_t *bitmap, const uint16_t size);

Jean-Marc