Crc32 Hash for Multicast Ethernet address resolution in MPC5748G

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Crc32 Hash for Multicast Ethernet address resolution in MPC5748G

跳至解决方案
2,629 次查看
farozeibnejava
Contributor III

How to calculate Crc32 Hash for Multicast Ethernet address resolution in ENET MPC5748G or similar MCUs? i tried many different website codes but could not get it working.

标签 (1)
标记 (2)
1 解答
2,137 次查看
martin_kovar
NXP Employee
NXP Employee

Hello Danish.

I am sorry for the long delay. I tried to find out some information regarding your question.

I spoke with my colleague, who is ENET MCAL developer and he applied me, that there is missing some information in MPC5748G reference manual and also in MCAL documentation regarding CRC algorithm.

The code used in MCAL is correct, but right now, I am not able to point you to any document which describes it. Requirement for documentation update was created, so I hope next release of MCP5748G reference manual will be correctly updated and this information regarding CRC will be added.

Regards,

Martin

在原帖中查看解决方案

9 回复数
2,137 次查看
farozeibnejava
Contributor III

Any reply please!!

0 项奖励
回复
2,138 次查看
martin_kovar
NXP Employee
NXP Employee

Hello Danish.

I am sorry for the long delay. I tried to find out some information regarding your question.

I spoke with my colleague, who is ENET MCAL developer and he applied me, that there is missing some information in MPC5748G reference manual and also in MCAL documentation regarding CRC algorithm.

The code used in MCAL is correct, but right now, I am not able to point you to any document which describes it. Requirement for documentation update was created, so I hope next release of MCP5748G reference manual will be correctly updated and this information regarding CRC will be added.

Regards,

Martin

2,136 次查看
farozeibnejava
Contributor III

Thanks for help Martin. much appreciated

0 项奖励
回复
2,137 次查看
martin_kovar
NXP Employee
NXP Employee

Hello Danish,

I am not sure if I understand your question correct. Are you looking for the following polynomial to compute the CRC32 hash?

pastedImage_1.png

Regards,

Martin

0 项奖励
回复
2,137 次查看
farozeibnejava
Contributor III

Hi Martin,

No. I already have the Polynomial and also the working C code from Freescale MCAL. What is need is a written description of how to calculate this Crc. i.e. Initial value, Input Reflection, Output reflection, Final Xor value. I don't find this information in MPC5748G Reference Manual in ENET Multicast address resolution chapter. Only Polynomial is defined there.

regards,

Danish

0 项奖励
回复
2,137 次查看
martin_kovar
NXP Employee
NXP Employee

Hello Danish,

please check this web page:

Catalogue of parametrised CRC algorithms 

Look at the CRC-32, which is used for Multicast address resolution in ENET module.

Hope it helps.

Regards,

Martin

0 项奖励
回复
2,137 次查看
farozeibnejava
Contributor III

Hi Martin,

it says, 

width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926 residue=0xdebb20e3 name="CRC-32"

Final xorout here is given as 0xffffffff, but Freescale MCAL uses xorout=0x00000000. And Freescale code actually works on MPC5748G hardware and final xorout=0xffffffff doesn't work. This is really confusing me since i'm unable to provide any traceability on this final xorout=0 value. if there were some deviations in ENET controller it should have been made clear in MCU reference manual.

regards,

Danish

0 项奖励
回复
2,137 次查看
martin_kovar
NXP Employee
NXP Employee

Hello Danish,

my colleague sent me some source code, which he uses for CRC32 calculation in Kinetis microcontrollers. Because ENET module is the same, you can use this code also for MPC5748G:

void ENET_AddMulticastGroup(ENET_Type *base, uint8_t *address)

{

    assert(address);

 

    uint32_t crc = 0xFFFFFFFFU;

    uint32_t count1 = 0;

    uint32_t count2 = 0;

 

    /* Calculates the CRC-32 polynomial on the multicast group address. */

    for (count1 = 0; count1 < ENET_FRAME_MACLEN; count1++)

    {

        uint8_t c = address[count1];

        for (count2 = 0; count2 < 0x08U; count2++)

        {

            if ((c ^ crc) & 1U)

            {

                crc >>= 1U;

                c >>= 1U;

                crc ^= 0xEDB88320U;

            }

            else

            {

                crc >>= 1U;

                c >>= 1U;

            }

        }

    }

 

    /* Enable a multicast group address. */

    if (!((crc >> 0x1FU) & 1U))

    {

        base->GALR |= 1U << ((crc >> 0x1AU) & 0x1FU);

    }

    else

    {

        base->GAUR |= 1U << ((crc >> 0x1AU) & 0x1FU);

    }

}

Regards,

Martin

0 项奖励
回复
2,137 次查看
farozeibnejava
Contributor III

Hi Martin,

As i mentioned previously, i have the running code without any issue. My problem is that I can't provide Traceability of this algorithm to any document. (which is requirement for Safety Team in our department). Can you provide any document from Freescale that may provide some insight. Or perhaps link to some online content.

You provided this link...

  • please check this web page:

      Catalogue of parametrised CRC algorithms 

It say final xor value is 0xFFFFFFFF but your friend's code doesn't use this final xor value. why is it so?

regards,

danish

0 项奖励
回复