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?
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.
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?
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.
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
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?
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 .
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
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
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
Hi Mikko,
Hi Mikko,
Thank you for the speedy update. I will use the update and let you know further.
Thanks & Regards,
Omkar
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
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
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
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
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
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