This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF: Changing MAC address in the image file

Part Number: CC3220SF
Other Parts Discussed in Thread: UNIFLASH, CC3220R, CC3200, SYSCONFIG

Hello,

We want to change the MAC address of the CC3220SF during the production line.

1. I tried changing MAC address before compiling and wanted to see the offset of MAC address in the image, I see lots of changes in the image just by changing the MAC address. I am assuming the image is encrypted in some way. Is there any way to compile the image in an unencrypted manner, so that we can easily identify and change the MAC address?

2. From the other thread (https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/t/692337), I understand that MAC addresses can be changed by using sl_API or by using .bat scripts. Both of them are not effective for us.  We are thinking if we can use "Embedded Programming Schemes" from "Embedded Programming User Guide (SWPA230A)" and write MAC address to "RAW storage". Then read the RAW storage from the application and change MAC address using sl_API. This way is more convenient for our application to control the production environment. If this works, how to access the RAW storage from the application?

Thank you,

Kris.

  • Hi Kris,

    Way with modification of RAW data of image is not possible. Bootlaoder of CC3220 does not allow such kind of modification due to security reasons.

    I think best way for you is a create own image for each device using Uniflash CLI. This image you can use for Embedded Programming. Other good option is transport MAC address into device somehow (own serial or TCP/UDP protocol ) and use sl_ API to change it.

    Jan

  • Hi Jan,

    Thank you for the quick response on my second question.

    Could you also answer my first question, which is, is it possible to compile the image using an unencrypted manner? so that if I just change the MAC address and compile the image, I only see the MAC address different.

    Thank you,

    Kris.

  • Hi,

    No this is not possible. Also TI does not provide source code of image creator utility (uniflash_4.6.0\simplelink\imagecreator\bin\).

    Jan

  • Hi Kris,

    Jan is correct, there is no way to bypass the secure program and secure boot features on the CC32xxS or SF devices.

    The CC3220R is our non-secure device (network security only).

    Best regards,

    Sarah

  • Hi  and ,

    Thank you for the information, Recompiling the whole image or getting MAC from AP at production line is bit of a challenge for us now.

    I am thinking of a possibility and want to know if it can work.

    We are planning to program the firmware from the serial programmer.

    After the image is compiled and to be loaded in the serial flash using a SPI programmer. Can we append MAC address to the firmware file before writing to the serial flash and read that location of it from application after bootup?

    I will append some constant bytes (0xFFs or 0x00s) to make the location of MAC address fixed even when the size of the firmware changes.

    For example:

    If the firmware file is around 150KB can I append around 150KB of zeros and write the MAC address at 300KB, or even push it to the last segment of memory.

    While doing a wireless firmware upgrade, I am planning to read the MAC address before calling OTA firmware upgrade libraries and rewrite the MAC address before resetting the MCU after the firmware upgrade process.

    I want to know if this can be done or will I face challenges with this approach?

    Thank you,

    Kris.

  • Hi Kris,

    Unfortunately I am not able say whether this approach may work. Definitely this is not something is supported.

    But I afraid that bootloader itself will not allow this. Because after uploading content SPI flash by external programmer is this state detected by bootloader and filesystem in sFlash is created. Probably at this state will be information about your MAC address destroyed. But I may to be wrong, I am not 100% sure.

    Maybe it can be better chance in case of you create image with size 1/2 of your real size of SPI flash (e.g. image size 4MB but flash chip with size 8MB). I think at this case is better chance that this 2nd part will not be changed by bootloader.

    At your approach is an additional challenge. Direct reading from sFlash from application processor. As I know this approach is not supported by TI. I think it may to be technically possible, but I did not test this at CC3220. I know that at previous generation (CC3200) this approach worked. To direct sFlash access you need to disable NWP (sl_Stop()), set properly pinmux and use 2nd SPI peripheral to SPI flash memory access via commands in datasheet. But you will need to do this research by yourself.

    In case of you are using SPI flash with OTP area (e.g. MX25R3235FM1IH0) it may to be one interesting option where store your information. At default is OTA area of a sFlash used to store keys for vendor device authentication. But maybe you can find a way how store there your MAC. Advantage will be that MAC address will be permanent. But you will still need to be able directly read sFlash.

    From my point of view is this topic pretty interesting. If you will have any results or questions let me know.

    Jan

  • Hi Kris,

    Jan is correct, the bootloader will not support appending additional data to the gang image. Your best option may be after programming the image, allow the device to boot and connect serially to trigger a sl_ API command or write the MAC address to a file in the file system.

    I'm not sure I fully understand why some of the other options Jan suggested would not work for you. Can you explain your plan for production and test, and what you're trying to optimize?

    Best regards,

    Sarah

  • Hello Hnz and Sarah,

    I understood that writing MAC to sFlash and reading it from application more complicated than using sl_API. I am getting the MAC address by using a TCP connection to a server. 

    The weird thing is just after I change MAC address using sl_NetCfgSet() API. 

    Status = sl_NetCfgSet(SL_NETCFG_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)MAC_Address);

    and next time when the NWP tries to connect with a new MAC. it gets a "Device disconnected from the AP on an ERROR".

    with the pDiscntEvtData->ReasonCode is 202

    which is  #define SL_WLAN_DISCONNECT_AUTH_TIMEOUT (202) from wlan.h

    I dont understand why changing MAC address will result in AUTH_TIMEOUT.

    I tried reflashing the code few times, without changing the MAC address it always connects normally, but as soon as I change the MAC address, I get the same error back.

    Do you know why am I getting this error, and how to get through this?

    Thank you,

    Kris.

  • Hello,

    Does anyone have any update on this?

    Thank you,

    Kris.

  • Hi Kris,

    • What servicepack are you using?
    • Are you resetting the NWP after changing the MAC address?
    • Are you disconnecting using sl_WlanDisconnect? How are you re-connecting?
    • Do you have any connection policies enabled?

    Best regards,

    Sarah

  • Hi Sarah,

    • What servicepack are you using?

    I am using simplelink_cc32xx_sdk_3_30_01_02

    • Are you resetting the NWP after changing the MAC address?

    Yes, I am using     sl_Stop(SL_STOP_TIMEOUT); followed by sl_Start(0, 0, 0);

    • Are you disconnecting using sl_WlanDisconnect? How are you re-connecting?

      I am using sl_WlanConnect((signed char*)ap_ssid, ap_ssid_len, 0, &secParams, 0); to connect and using sl_WlanDisconnect(); before attempting a connection.

    • Do you have any connection policies enabled?

    Earlier I had fast connection enabled in the connection policy, I also tried by disabling it with

    sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION, SL_WLAN_CONNECTION_POLICY(0,0,0,0),NULL,0);

    Thank you,

    Kris.

  • One more observation is after changing the MAC address and seeing connection errors, if I write back the original MAC address (MAC used while creating and programming Image), the connection happens normally without any error.

    Thank you,

    Kris.

  • Hi Kris,

    Do you always connect the AP once before changing the MAC address? If so, can you test without? Sniffer captures and NWP logs would also be helpful here.

    Best regards,

    Sarah

  • Hi Sarah,

    No, the Target board comes out of Hibernate mode and NWP starts, I change the MAC address as soon as the NWP starts. I made sure that the auto-connect and fast-connect are disabled.

    I attached both sniffer and application prints(I am assuming the NWP_logs means application prints here, if not, please let me know how to take them). Please have a look.

    AP mac address is 26:21:DC:93:8D:5F and target board MAC address is 11:22:33:11:22:33.

    
    ********************************************************************************
                      OTA APP Application - Version 0.10.00.03
    ********************************************************************************
    
    WakeupSource = 7
    Device MAC is 11:22:33:11:22:33
    
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    unable to send to msg queue
    
    
    ********************************************************************************
                      OTA APP Application - Version 0.10.00.03
    ********************************************************************************
    
    WakeupSource = 7
    Device MAC is 11:22:33:11:22:33
    
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    unable to send to msg queue
    
    
    ********************************************************************************
                      OTA APP Application - Version 0.10.00.03
    ********************************************************************************
    
    WakeupSource = 7
    Device MAC is 11:22:33:11:22:33
    
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    unable to send to msg queue
    
    
    ********************************************************************************
                      OTA APP Application - Version 0.10.00.03
    ********************************************************************************
    
    WakeupSource = 7
    Device MAC is 11:22:33:11:22:33
    
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    unable to send to msg queue
    
    
    ********************************************************************************
                      OTA APP Application - Version 0.10.00.03
    ********************************************************************************
    
    WakeupSource = 7
    Device MAC is 11:22:33:11:22:33
    
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    unable to send to msg queue
    
    
    ********************************************************************************
                      OTA APP Application - Version 0.10.00.03
    ********************************************************************************
    
    WakeupSource = 7
    Device MAC is 11:22:33:11:22:33
    
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    Device disconnected from the AP on an ERROR ReasonCode: 202
    unable to send to msg queue
    capture_6.rar

  • Hi Kris,

    How to capture NWP log is described at link at the last answer from Sarah.

    Jan

  • Hi Sarah,

    I am using simplelink_cc32xx_sdk_3_30_01_02, from the link you pointed it asks to modify the file "CC3220SF_LAUNCHXL.c" which was in previous SDKs.

    In  simplelink_cc32xx_sdk_3_30_01_02 SDK the file "CC3220SF_LAUNCHXL.c" is replaced with ti_driver_config.c file and is automatically generated by CCSV9 in compile time.

    Could you please provide some pointers on how to get those logs on the simplelink_cc32xx_sdk_3_30_01_02 by using CCSv9.

    Thank you,

    Kris.

  • Hi Kris,

    Copy the existing ti_drivers_config.c and .h into your project, then left-click the .syscfg script and select Exclude from Build. Then you can make changes directly to the .c file without SysConfig overwriting it. There are some more details here: http://dev.ti.com/tirex/explore/node?node=AO3dBAhu05HBWXd.SPxt0g__fc2e6sr__LATEST

    Ideally, we'd like to see NWP logs and sniffer logs captured during the same test so we can compare the activity. In the meantime, I'll take a look at the logs you've shared and see if anything stands out.

    Best regards,

    Sarah

  • Hi Sarah,

    The procedure in the link you sent suggests enabling UART0 to get network processor logs. But on my target board is configured to access onlyUART1 which is pin 55 (UART12_Tx) and Pin 57 (UART1_Rx). So instead of muxing Pin 62 (UART0_Tx) I muxed pin 55 (UART1_Tx). 

    See the below changes I made.Pleae le me know if I am missing anything.

    ti_drivers_config.c:

    ============================================================================

    void Board_init(void)
    {
    /* ==== /ti/drivers/Power initialization ==== */
    PRCMCC3200MCUInit();
    Power_init();

    MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK); // Added to get NWP logs

    MAP_PinTypeUART(PIN_55, PIN_MODE_1);  // Added to get NWP logs

    Board_initHook();
    }
    ============================================================================

    I compiled the code and observe the same results as in the previous file which I sent you earlier with the sniffer log

  • Hi Kristin,

    Pin 62 is a dedicated NWP log pin. Please use this pin and enable the UART0 clock. Using the terminal settings, you should get a .log output that mostly looks like junk, but will have some readable text like "/sys/servicepack.ucf". This is the log I need to determine what is happening in the network processor.

    Best regards,

    Sarah

  • Hi Sarah,

    I configured the UART to UART0, with pin 62 (GPIO_07) . 

    UART params

    ParameterValue
    Baud rate 921600
    Data bits 8
    Stop bits 1
    Parity None
    Flow Control None

    added below code in ti_drivers_config.c

    ============================================================================

    void Board_init(void)
    {
    /* ==== /ti/drivers/Power initialization ==== */
    PRCMCC3200MCUInit();
    Power_init();

    MAP_PinTypeUART(PIN_62, PIN_MODE_1); //Added to capture NWP logs
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);  //Added to capture NWP logs

    Board_initHook();
    }

    ============================================================================

    when I run the applicationn and change mac address. I only see the application prints which I put in application. I dont see any NWP prints(even junk) on console and the output log.

    Is there a way to configure the NWP with a specific configuration after which I can change MAC address?

    Or do you guys have any function which changes the MAC address regardless of the NWP configuration?

    Thank you,

    Kris.

  • Hi Kris,

    You need to connect pin 62 directly to a serial to USB converter. Pin 62 should not be used for any other purpose while collecting NWP logs.

    I am successfully able to change my MAC address and connect to an AP using the code snippets provided in the NWP Programmer's Guide. If you cannot connect after changing your MAC address, it may be due to the behavior of your AP. That is why we need NWP logs and sniffer captures from your setup to verify.

    Best regards,

    Sarah

  • Hi Sarah,

    Thank you for all the help, I finally figured out why it was not working for me. I thought to share it here so that others wont face the same problem.

    I was trying to write the MAC address which was 11:22:33:11:22:33

    I observed the sniffer logs where my target board was communicating with AP before changing MAC address and not after changing MAC address.

    I found that the AP was responding to probe requests from both the MAC addresses. but when the target board reqests authentication request, the AP only replied back to the original MAC and did not reply to the changed MAC. 

    The packet content was exact same apart from the RSSI, timestamp fields.

    So instead of using 11:22:33:11:22:33 as the MAC address, I changed it to one of the launchpads MAC address which was turned off. With this, I saw that the target board was able to communicate and send data across access points with the new MAC address.

    I don't know why an access point would only respond to a selected range of MAC addresses. But for now solved my problem.

    Thank you,

    Kris.

  • Thanks Kris! I'm glad you got it working.