cancel
Showing results for 
Search instead for 
Did you mean: 

LibJPEG Hard Fault

Matt Barclay
Associate
Posted on September 18, 2017 at 21:27

I have a STM32F413CHU6 processor using FreeRTOS and LibJPEG as configured by STM32CubeMX.  LibJPEG is configured to use FreeRTOS memory allocation, and FreeRTOS heap is set at 150,000.

I'm trying to read JPEG data from memory.  My jpeg data are declared as:

const uint8_t mydata[]  = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, ... ... ... };

I set up the decode session like this:

struct jpeg_decompress_struct cinfo;

struct jpeg_error_mgr jerr;

uint8_t m_rowBuffer[2048];

JSAMPROW buffer[2] = {0};

uint32_t row_stride = 0;

buffer[0] = m_rowBuffer;

cinfo.err = jpeg_std_error(&jerr);

jpeg_create_decompress(&cinfo);

jpeg_mem_src(&cinfo, mydata, 4035);

jpeg_read_header(&cinfo, TRUE);

EDIT:  I solved a data corruption issue that was causing a crash in read_marker().  However, even with good JPEG data, it will wind up crashing into the Hard Fault Handler.

Not really sure where to go from here.  Has anyone had success with LibJPEG reading from memory on the STM32?

Thanks,

Matt

#jpeg
1 REPLY 1
AvaTar
Lead
Posted on September 20, 2017 at 07:43

I don't have experience with libJPEG on Cortex M devices, but I could imagine the lib functions pound heavily on the stack.

I would fill the stack space with a specific pattern, and check for it after a crash.

But if I remember correctly, FreeRTOS had some kind of stack check as well.