Skip to content

Camera/Video on Portenta H7 mid carrier - DMA fails using shared memory #592

Description

@KurtE

This is semi related to #588

I'm using the Portenta H7 on the Portenta Mid Carrier. It fails to read in an image.
The Camera library code will start up normally, but will continuously time out to retrieve an image.

If you have the DEBUG stuff turned on in Zephyr DCMI, you will see it will continuously error on
the DMA transfers.

Additional context

Current work around, is to use normal memory for the buffer 0, such that the camera DMA code is
always transferring to normal memory.

Currently I have a hack in my copy of camera library that currently looks like:

bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byte_swap) {
...
	// Allocate video buffers.
	for (size_t i = 0; i < ARRAY_SIZE(this->vbuf); i++) {
		this->vbuf[i] = video_buffer_aligned_alloc(fmt.pitch * fmt.height,
												   CONFIG_VIDEO_BUFFER_POOL_ALIGN, K_NO_WAIT);
		if (this->vbuf[i] == NULL) {
			Serial.println("Failed to allocate video buffers number: " + String(i));
			return false;
		}
		//////////////////////////////////////////////////////////////////////////////////
		// Hackkkkkkkkkkk
		/////////////////////////////////////////////////////////////////////////////////
#ifdef ARDUINO_PORTENTA_H7_M7
		if (i == 0) {
			this->vbuf[i]->buffer = (uint8_t *)malloc(fmt.pitch * fmt.height);
		}
#endif

		this->vbuf[i]->type = VIDEO_BUF_TYPE_OUTPUT;
		ret = video_enqueue(this->vdev, this->vbuf[i]);
		if (ret != 0) {
			return false;
		}
		Serial.print("VBUF: ");
		Serial.print(i);
		Serial.print(" ");
		Serial.print((uint32_t)this->vbuf[i]);
		Serial.print(" ");
		Serial.println((uint32_t)this->vbuf[i]->buffer);
	}
...

I added the #ifdef code and printing out the buffers (which is not necessary)
Just wanted to verify where the buffers are:

call cam.begin
VBUF: 0 604044504 604190840
VBUF: 1 604044536 3222952128
VBUF: 2 604044568 3223105760
Camera started

With that was able to get images:

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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