contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.72k stars 2.58k forks source link

Question: cc26xx web demo IPv6 address assignment method #1283

Closed xianlin closed 9 years ago

xianlin commented 9 years ago

This is a question:

I read that 6lowpan ip address assignment has dynamic, static and hybrid (refer here).

I wonder in the cc26xx-web-demo example, which IP address assignment method is being used? and in which line/part of the code is the setting for this IP assignment. Anyone kind share your know how on this? Thank you.

tonnenpinguin commented 9 years ago

As far as I know the IP address is copied from cc26xx's info page if you do not change this setting in your project-conf.h. The IP address is set as part of the initialization code in contiki-main.c (check the respective platform folder for that file). So I guess you can call it static ip address assignment.

xianlin commented 9 years ago

@tonnenpinguin thank your for sharing.

I saw the code on line 130 but I cannot understand what is the info page.

The definition of "info page" i can found is at \cpu\cc253x\cc253x.h line 670

/*---------------------------------------------------------------------------
 * Information Page (Read Only)
 *---------------------------------------------------------------------------*/
SFRX(X_INFOPAGE,  0x7800); /* Start of Information Page */
SFRX(X_IEEE_ADDR, 0x780C); /* Start of unique IEEE Address */

And at \cpu\cc26xx-cc13xx\ieee-addr.h line 44.

\defgroup cc26xx-ieee-addr CC13xx/CC26xx IEEE Address Control
 *
 * Driver for the retrieval of an IEEE address from flash
 *
 * The user can specify a hardcoded IEEE address through the
 * IEEE_ADDR_CONF_HARDCODED configuration macro.
 *
 * If the user does not hard-code an address, then one will be read from either
 * the primary location (InfoPage) or from the secondary location (on flash).
 *
 * In order to allow the user to easily program nodes with addresses, the
 * secondary location is given priority: If it contains a valid address then
 * it will be chosen in favour of the one on InfoPage.
 *
 * In this context, an address is valid if at least one of the 8 bytes does not
 * equal 0xFF. If all 8 bytes are 0xFF, then the primary location will be used.
 *
 * In all cases, the address is assumed to be written little-endian.
 *
 * Lastly, it is possible to override the 2 LSB's of the address by using the
 * NODE_ID make variable.

After googling, I found the below post says that the content of the info page can be read by using Windows program Smart RF Program 2 and the sensor tag MAC address can be retrieved using \cpu\cc26xx-cc13xx\ieee-addr.c: https://e2e.ti.com/support/wireless_connectivity/f/158/p/440083/1579447

So cc26xx-web-demo used this MAC address and generated a unique IPv6 IP address for each sensortag instead of getting DHCP IPv6 address from a DHCP server. I would say this is static ip address assignment.

My question now is: Where is this info page location? Is it on the MCU main memory (not external flash)?

tonnenpinguin commented 9 years ago

The Info Page is located in the internal flash. As you found out correctly it can be read using TI's smartRF Flash Programmer 2. There you can also see the absolute flash address that the MAC address can be read from. For more information about how the IPv6 address can be calculated from the MAC address please refer to this link! If you need more info about what information the info page contains please check out the factory config chapter (section 9.2) of cc2650's technical reference manual.

xianlin commented 9 years ago

@tonnenpinguin , thank you and that solved my problem. we can close this issue now.