Skip to content

GIGA:/Portenta H7 can not malloc(51200) current ArduinoCore-zephyr #272

@KurtE

Description

@KurtE

Describe the bug
Can not 51k of memory, currently my test programs for GIGA display are all bus faulting

Target board + cli verbose compilation output
Arduino GIGA with a GIGA display

Full verbose compilation output, ideally with arduino-cli invocation or from IDE 2.3.3+

Output of Serial Monitor

*** Booting Zephyr OS build v4.2.0-27-g09722075b043 ***
[00:00:04.497,000] <inf> usb_cdc_acm: Device suspended
[00:00:04.759,000] <inf> usb_cdc_acm: Device configured
Buffer: 0

Optional: attach the sketch

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial && millis() < 5000) {}
  pinMode(LED_BUILTIN, OUTPUT);

  void *buffer = malloc(51200);
  Serial.println((uint32_t )buffer, HEX);
  printk("Buffer: %p\n", buffer);
}

void loop() {
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  delay(500);
}

Additional context
In real sketch I was trying the malloc was part of:

  //Allocate memory to the framebuffer
  uint32_t sizeof_framebuffer = 2 * 160 * 160;
  void* ptrFB = malloc(sizeof_framebuffer);
  printk("\tptrFB: %p %u\n", ptrFB, sizeof_framebuffer);
  // Cast the void pointer to an int pointer to use it
  uint8_t* frameBuffer = static_cast<uint8_t*>(ptrFB);

  printk("Before setFrameDesc\n");
  display.setFrameDesc(160, 160, 160, sizeof_framebuffer);
  printk("After setFrameDesc\n");
  display.startFrameBuffering();
  printk("After startFrameBuffering\n");
  fillScreen(RGB565_DARKGREY);

Debug output from that sketch:

*** Booting Zephyr OS build v4.2.0-27-g09722075b043 ***
height: 480, width: 800, rotated: 1
setup called
[00:00:04.503,000] <inf> usb_cdc_acm: Device suspended
[00:00:04.766,000] <inf> usb_cdc_acm: Device configured
Display::begin(0) called
        1
        2
        3 1 0
        4
        5
- Capabilities:
  x_resolution = 480, y_resolution = 800
, supported_pixel_formats = 105
  current_pixel_format = 32, current_orientation = 0
After display.begin() 1
Before getrameBuffer
        FB: 0xc0000080
        ptrFB: 0 51200
Before setFrameDesc
After setFrameDesc
After startFrameBuffering
[00:00:04.879,000] <err> os: ***** BUS FAULT *****
[00:00:04.886,000] <err> os:   Precise data bus error
[00:00:04.894,000] <err> os:   BFAR Address: 0x10000
[00:00:04.902,000] <err> os: r0/a1:  0xc0000440  r1/a2:  0x00010000  r2/a3:  0x0001efbc
[00:00:04.905,000] <err> os: r3/a4:  0xc0000c61 r12/ip:  0x00000000 r14/lr:  0x0809c937
[00:00:04.916,000] <err> os:  xpsr:  0x81000000
[00:00:04.923,000] <err> os: s[ 0]:  0x00001000  s[ 1]:  0x2405bc90  s[ 2]:  0x00000000  s[ 3]:  0x2405bca8
[00:00:04.928,000] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x0804715f  s[ 6]:  0x2405bd04  s[ 7]:  0x00000000
[00:00:04.941,000] <err> os: s[ 8]:  0x2405bd04  s[ 9]:  0x2403058b  s[10]:  0x00001000  s[11]:  0x00000000
[00:00:04.946,000] <err> os: s[12]:  0x0000000c  s[13]:  0x0809219d  s[14]:  0x0000c800  s[15]:  0x00000004
[00:00:04.951,000] <err> os: fpscr:  0x24073348
[00:00:04.959,000] <err> os: Faulting instruction address (r15/pc): 0x080a7ae6
[00:00:04.969,000] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:04.971,000] <err> os: Current thread: 0x240060c8 (main)
[00:00:04.980,000] <err> os: Halting system
uart:~$ Timeout while waiting for high throughput clock

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions