MAC address for KW40/41Z

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MAC address for KW40/41Z

Jump to solution
5,646 Views
sensenthuran
Contributor IV


Hi,

How we can write and read MAC address for KW40/41 MCUs. If we need to use the blhost, please let me know, how to use that.. (Read Once Command, Program Once Command ).

Thanks

1 Solution
4,062 Views
santiago_lopez
NXP Employee
NXP Employee

The way you program different MAC addresses in production is by using a programmer with serialization capabilities (i.e. P&E Cyclone Max). In our stack, the MAC Address is stored in a global variable under the name gBDAddress_c. First you need to open the .map file that is generated in you code, look for this variable and get where it is located in flash.

pastedImage_0.png

Once you have the variable address, you can now use the same binary to program all the MCUs and use the serialization tool to overwrite only the memory location that contains the MAC address. Instructions for doing this will depend on the flashing tool you will use in production. Attached you will find some instructions on how to do it using the Cyclone Max.

Hope it helps.

Best Regards

View solution in original post

15 Replies
4,062 Views
sensenthuran
Contributor IV

Thanks for all the clarifications. For completeness, if you could provide us the instruction for writing to that specific address using "blhost" or any other tool, it would be useful.

0 Kudos
Reply
4,062 Views
jasonchiang
NXP Employee
NXP Employee

Attached is the blhost read/write commands specical address.

4,062 Views
santiago_lopez
NXP Employee
NXP Employee

Hi Chiang,

Thanks a lot for this information, it is really useful.

Hi sensenthuran

Kinetis bootloader hasn?t been ported to be used with the connectivity software. Connectivity software uses a custom linker file that is not compatible with Kinetis bootloader and hence it is not included in the connectivity software stack. The only way to change the MAC address right now is trought the manufacturing tools with serialization capabilities available in the market.

Best Regards

0 Kudos
Reply
4,062 Views
santiago_lopez
NXP Employee
NXP Employee

Unfortunately Kinetis Bootloader is not supported by KW40/41 so BLHOST cannot be used with these MCUs.

Saludos

0 Kudos
Reply
4,062 Views
sensenthuran
Contributor IV

KW41 has kinetis bootloader:

# ./blhost -p /dev/ttyMSM1 -- get-property 1

Ping responded in 1 attempt(s)

Inject command 'get-property'

Response status = 0 (0x0) Success.

Response word 1 = 1258422272 (0x4b020000)

Current Version = K2.0.0

0 Kudos
Reply
4,062 Views
santiago_lopez
NXP Employee
NXP Employee

Hi sensenthuran

How are you connecting with the KW41 (USB port J6 in FRDM, UART Pins PTC7 and PTC7)? Also, are you flashing any example firmware from the Connectivity Software Package?

Saludos

0 Kudos
Reply
4,062 Views
sensenthuran
Contributor IV

NXP_Kinetis_Bootloader_2_0_0 supports blhost for KW41. It should be in early access program. Connected through UART.

0 Kudos
Reply
4,062 Views
johnny_pe
Contributor III

Hi sensenthuran!

Many production programmers for Kinetis have serialization capability to program MAC addresses. P&E Micro has the Cyclone Max,  Cyclone Universal, and Cyclone Universal FX. In addition to the serialization tool that was mentioned by the other poster, we also have tools that allow you to program it through a DLL or scriptable application.

Please visit us at our website if you have any questions.

Regards,
Johnny

P&E Microcomputer Systems, Inc.

0 Kudos
Reply
4,062 Views
leochao
Contributor II

Hi @Jose Santiago Lopez Ramirez

I found the memory location of variable "gBDAddress_c" is different in each App.

For example, that is the point what I found as below.

In heart_rate_sensor_BM.map:

gBDAddress_c            0x000225e8

In hci_app_BM.map:

gBDAddress_c            0x00014094

NXP_community_MAC_address.jpg

Does it mean that we need to overwrite the memory location again after we update another Apps on our unit?

For example, if we have heart_rate_sensor_app on KW41Z first then we program different MAC addresses on each unit.

After that we update hci_app on it, do we need to program MAC address again?

Is there any way to write MAC address into KW41Z that it may not be affected by different Apps?

Thanks

4,062 Views
antonioconcio
NXP Employee
NXP Employee

Hi Leo,

For KDS and more generally for GCC please refer to the below post:

https://mcuoneclipse.com/2012/11/01/defining-variables-at-absolute-addresses-with-gcc/

Cheers,

Antonio

4,062 Views
santiago_lopez
NXP Employee
NXP Employee

Hi Leo,

You are right, the memory location of the MAC address holding arraywill change with every application or even in the same application if the application code changes. To overcome this you need to make sure that this variable will have always the same location in memory. This has a different procedure depending on the IDE you are using. In IAR for example, adding a pragma before the variable in question does the trick.

#pragma location=address

char variable[size];

Saludos

Santiago López

4,062 Views
sensenthuran
Contributor IV

Thanks a lot @Jose Santiago Lopez Ramirez for the quick reply with detailed answer. Appreciate your help.

0 Kudos
Reply
4,063 Views
santiago_lopez
NXP Employee
NXP Employee

The way you program different MAC addresses in production is by using a programmer with serialization capabilities (i.e. P&E Cyclone Max). In our stack, the MAC Address is stored in a global variable under the name gBDAddress_c. First you need to open the .map file that is generated in you code, look for this variable and get where it is located in flash.

pastedImage_0.png

Once you have the variable address, you can now use the same binary to program all the MCUs and use the serialization tool to overwrite only the memory location that contains the MAC address. Instructions for doing this will depend on the flashing tool you will use in production. Attached you will find some instructions on how to do it using the Cyclone Max.

Hope it helps.

Best Regards

4,062 Views
sensenthuran
Contributor IV

Thanks @Jose Santiago Lopez Ramirez for your detail answer.  How we can program different MAC address for different KW40/41. Do we need to compile every time or can we load the same binary and use any utilities/tools to write different MAC address in the factory?

4,062 Views
santiago_lopez
NXP Employee
NXP Employee

Hi sensenthuran,

On the BLE Host Stack, the device MAC addresses are defined at compile time. For each device, the MAC address can be modified in the app_preinclude.h file.

pastedImage_0.png

If you want to read a MAC address from the BLE Client you must call the function Gap_ReadPublicDeviceAddress (in our demos it is called in the function BleApp_Config in app.c). After this, the gPublicAddressRead_c event will occur every time a new MAC address is discovered. You must obtain these MAC addresses in the BleApp_GenericCallback (in app.c) by reading the pGenericEvent pointer as shown in the image below.

pastedImage_1.png

Every time a new MAC address is found nearby, this callback function will be called.

Let me know if this is what you are looking for.

Best Regards