Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Hard Fault In Image Transfer

Hard fault in Image Transfer

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By iomkar , 28 May, 2020
Forums
General discussion

Hello Mikko,
I am trying to achieve image transfer object in STM32 controller environment. However I am getting hardware hardfault and microcontroller is getting stuck. When I tried to debug, I noticed that hardfault occurs at following code -

item = (gxImageActivateInfo*)gxmalloc(sizeof(gxImageActivateInfo));
arr_push(&target->imageActivateInfo, item);
#endif //DLMS_IGNORE_MALLOC
item->size = var_toInteger(size);
item->identification.size = 0;
if ((ret = cosem_getOctectString2(imageIdentifier->byteArr, item.identification.data,
sizeof(item.identification.data), (uint16_t*)&item.identification.size)) != 0)
{
return ret;
}
Here, I observed that though structure variable item has been allocated memory, it's member item.identification.data which is pointer to the data type unsigned char has not been allocated memory, which gives random memory address to item.identification.data pointer and hardfault is occurring at memset inside cosem_getOctectString2 function.
How to overcome this issue?

Regards,
Omkar

Profile picture for user Kurumi

Kurumi

6 years ago

Hi Omkar,

Hi Omkar,

I'm sorry, I need some more info. Are you implementing meter or client?
Is DLMS_IGNORE_MALLOC defined?

BR,

Mikko

iomkar

6 years ago

Hii Mikko,

Hii Mikko,
Apologies for inadequate information. I am implementing meter and DLMS_IGNORE_MALLOC is commented i.e. I am using malloc. Please let me know if more information is required.

Regards,
Omkar

Profile picture for user Kurumi

Kurumi

6 years ago

Hi Omkar,

Hi Omkar,

You are right. We have broken this. I made an issue from this.
https://www.gurux.fi/node/15917

We are testing this and release a new version today.

BR,
Mikko

iomkar

6 years ago

Hi Mikko,

Hi Mikko,
Thank you for the speedy update. I will use the update and let you know further.

Thanks & Regards,
Omkar

iomkar

6 years ago

Hi Mikko,

Hi Mikko,
While the update worked, I am now getting hardfault at following code in invoke image transfer function -
if (item->size % target->imageBlockSize != 0)
{
++cnt;
}
#ifndef GX_DLMS_MICROCONTROLLER
target->imageTransferredBlocksStatus.position = 0;
#endif //GX_DLMS_MICROCONTROLLER
target->imageTransferredBlocksStatus.size = 0;
ba_capacity(&target->imageTransferredBlocksStatus, (uint16_t)cnt);
for (pos = 0; pos != cnt; ++pos)
{
ba_set(&target->imageTransferredBlocksStatus, 0);
}
Here when in debug watch,in ba_set function, when &target->imageTransferredBlockStatus is passed, it's member data which is pointer to datatype unsigned char is pointing to memory address 0. which might be causing hardfault during value set.
How to resolve this issue?

Thanks & Regards,
Omkar

Profile picture for user Kurumi

Kurumi

6 years ago

Hi Omkar,

Hi Omkar,

This was a little hard to solve, but I believe that I have an answer to this, and the reason is clear.
You don't have enough memory available and ba_capacity can't allocate memory.

This is now fixed. Get the latest version.

BR,

Mikko

iomkar

6 years ago

Hello Mikko,

Hello Mikko,
You were right. Heap size was less for allocating memory. So, when I increase the heap size for STM32, image block transfer is working fine

Thanks & Regards,
Omkar

Profile picture for user Kurumi

Kurumi

6 years ago

Hi Omkar,

Hi Omkar,

This is good to serialize to flash and read it from there. It'll decrease the need for heap.

BR,
Mikko

ziml

5 years 9 months ago

Hi Omkar,

Hi Omkar,

I am trying to do the same thing for STM32. Did you manage to implement the image transfer?
Did you start with the GuruxDLMSServerExample or with the zephyr example for Nordic?
I'm trying to implement the imagetransfer for the Nordic/Zephyr example but I am not able to update the image, although the ImageTransfer Object is shown in the GuruxDirector. Any chance you can help me with that?

Cheers,
ziml

iomkar

5 years 9 months ago

Hii Ziml,

Hii Ziml,
I started with the GuruxDLMSServerExample and it worked successfully on increasing heap size as mentioned in above comment. I am not aware of zephyr example for Nordic, which you are trying to achieve .

Thanks ,
Omkar

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin