... | ... | @@ -6,21 +6,30 @@ |
|
|
|
|
|
Chances are that you need a unique node ID for each target device. One way to get such an ID is by defining the symbol `FLOCKLAB_NODE_ID` in your code:
|
|
|
```
|
|
|
// must be global
|
|
|
// must be global (variable will be placed into the .data section)
|
|
|
uint16_t FLOCKLAB_NODE_ID = 0xbeef; // any value is ok, will be overwritten by FlockLab
|
|
|
volatile uint16_t node_id; // must be volatile
|
|
|
|
|
|
// somewhere in the code
|
|
|
node_id = FLOCKLAB_NODE_ID;
|
|
|
```
|
|
|
FlockLab will then automatically change (by binary patching) this value to the target ID (if specified, otherwise the observer ID is used) before uploading the image to the targets .
|
|
|
Note that some compilers might still remove the symbol `FLOCKLAB_NODE_ID`. To make sure it still exists in the final binary, you can use `objdump` to display the symbol table:
|
|
|
FlockLab will then automatically change (by binary patching) this value to the target ID (if specified, otherwise the observer ID is used) before uploading the image to the targets.
|
|
|
Note that some compilers might still remove the symbol `FLOCKLAB_NODE_ID`. To make sure is included in the final binary, you can use `objdump` to display the symbol table:
|
|
|
```
|
|
|
objdump -t [elf_file] | grep FLOCKLAB
|
|
|
objdump -t [elf_file] | grep FLOCKLAB_NODE_ID
|
|
|
```
|
|
|
If you want to assign a specific node ID to each target, you can do this by using the `targetIds` field in the [XML configuration file](Man/XmlConfig#target-configuration).
|
|
|
Note that assigning node IDs is only supported if you submit your target images in the file format ELF. For Intel hex files, binary patching is currently not supported.
|
|
|
|
|
|
Note that depending on your compiler, the data section in the ELF may be empty, and thus binary patching will fail (this is e.g. the case if you use the SEGGER compiler for the platform nRF5). As a workaround, you need to place the variable into the read-only memory section by making it constant:
|
|
|
```
|
|
|
// must be global (variable will be placed into the .rodata section)
|
|
|
const uint16_t FLOCKLAB_NODE_ID = 0xbeef;
|
|
|
|
|
|
// somewhere in the code (note: conversion to volatile forces the compiler to keep the constant in the symbol table)
|
|
|
node_id = *(volatile uint16_t*)&FLOCKLAB_NODE_ID;
|
|
|
```
|
|
|
|
|
|
<br />
|
|
|
|
|
|
## How to assign node IDs with hex files
|
... | ... | |