Commit Graph

10235 Commits

Author SHA1 Message Date
Benoît Thébaudeau
afe5d0403d cc2538: Build without the Contiki target library
The GNU linker ld searches and processes libraries and object files in
the order they are specified. Library files are archive files whose
members are object files. The linker handles an archive file by scanning
through it for members that define symbols that have so far been
referenced but not defined. But an ordinary object file is linked in the
usual fashion.

The C library is implicitly linked after all object files and libraries
specified on the command line.

Because of that, if the C library depends on the Contiki target library,
e.g. for the implementation of system calls, then these dependencies are
not linked, which results in undefined references. Actually, the Contiki
target library also needs the C library, hence a circular dependency
between these libraries, which means that explicitly adding -lc anywhere
on the command line can not help. The only solution in that case is to
pass these libraries to ld between --start-group and --end-group.
Archives grouped in this way are searched repeatedly by the linker until
no new undefined references are created.

This archive grouping option has a significant performance cost for the
linking stage. Moreover, having to use it and to pass -lc explicitly on
the command line is unusual, which is disturbing and more complicated
for users needing the C library to depend on the Contiki target library.
The same would be true for circular dependencies between the Contiki
target library and any other library.

Another issue with the Contiki target library is that it may alter the
apparent behavior of the weak vs. strong symbols, because of the way ld
handles archives, which may make it discard archive object files
containing strong versions of referenced symbols:
 - If a symbol has a weak and a strong version in this library, both
   inside the same object file, then the linker uses the strong
   definition.
 - If a weak symbol in this library has a strong counterpart in an
   object file outside, then the linker uses the strong definition.
 - If a strong symbol in this library is inside an object file
   containing other referenced symbols, and has a weak counterpart
   anywhere, then the linker uses the strong definition.
 - If a strong symbol in this library is the only symbol referenced in
   its object file, and has a weak counterpart in an object file
   outside, then the linker uses the strong definition if this library
   is linked first, and the weak one otherwise.
 - If a strong symbol in this library is the only symbol referenced in
   its object file, and has a weak counterpart in another object file in
   this library, then the linker uses the definition from the first of
   these objects added when creating this archive.
 - If a symbol has a weak and a strong version, one in this library, and
   the other in another library, then the rules are the same as if both
   were in the Contiki target library.

The existence of cases where the linker uses a weak symbol despite the
presence of its strong counterpart in the sources compiled then passed
to the linker is very error-prone, all the more this behavior depends on
the order the object and archive files are passed on the command lines,
which may just result from the order of source files in lists where it
apparently does not matter. Such cases would be needed in the future,
e.g. to define weak default implementations of some system calls that
can be overridden by platform-specific implementations, both ending up
in the Contiki target library. There was already such a case used to
define the UART and USB ISRs as weak aliases of default_handler(),
relying on this implicit unusual behavior to keep default_handler() if
the UART or USB driver was unused, which was dangerous.

Since the Contiki target library was only used as an intermediate file
during the build, the current commit fixes these issues by simply
directly using the object files instead of building an intermediate
archive from them.

The CONTIKI_OBJECTFILES make variable would be incomplete if it were
used as a simple prerequisite in the %.elf rule in Makefile.cc2538,
because other object files are added to it after this rule. That's why
.SECONDEXPANSION is used to defer its expansion. Another solution would
have been to split Makefile.cc2538, with the variable assignments kept
in it, and the rule definitions moved to Makefile.customrules-cc2538,
but this would have required to add Makefile.customrules-<target> files
to all CC2538 platforms, only to include Makefile.customrules-cc2538.
The solution used here is much simpler.

Because the UART and USB ISRs were weak aliases of default_handler(),
this change would imply that these ISRs would always be used by the
linker instead of default_handler(), even if their drivers were
configured as unused with UART_CONF_ENABLE and USB_SERIAL_CONF_ENABLE,
which would be wrong. This commit fixes this issue by removing these
weak aliases and putting either these ISRs or default_handler() in the
vector table, depending on the configuration. Weak aliases are elegant,
but Contiki's build system does not currently allow to automatically
build or not source files depending on the configuration, so keeping
these weak aliases would have required to add #if constructs somewhere
in the source code, which would have broken their elegance and made them
pointless.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-05 21:55:51 +02:00
Adam Dunkels
7caf588457 Merge pull request #1096 from bthebaudeau/remove-MODULESSUBST
Makefile.include: Remove unused MODULESSUBST
2015-06-03 10:39:56 +02:00
Antonio Lignan
5bede26b3a Merge pull request #1071 from bthebaudeau/cc2538-crypto
cc2538: Add crypto drivers and examples for AES-CCM and SHA-256
2015-06-02 23:54:33 +02:00
Benoît Thébaudeau
e8a268cd15 cc2538: aes: Add support for 192- and 256-bit keys
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:56 +02:00
Benoît Thébaudeau
801315e819 cc2538: aes: Make it possible to have several keys stored at once
Several keys can be kept at the same time in the key store, and several
keys can be loaded at once. Give access to these features.

The ccm-test example is also improved to better demonstrate the use of
the key store.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:07 +02:00
Benoît Thébaudeau
b92a5afcc4 cc2538: ccm: Make it possible to use the interrupt
Using the AES interrupt allows the user process not to waste time
polling for the completion of the operation. This time can be used by
the user process to do something else, or to let the system enter PM0.

Since the system is now free to perform various operations during a
crypto operation, a protection of the crypto resource is added, and PM1+
is prohibited in order not to stall crypto operations.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:07 +02:00
Benoît Thébaudeau
117dc4e5e3 cc2538: Add crypto drivers and examples for AES-CCM and SHA-256
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:06 +02:00
Antonio Lignan
c03536f04e Merge pull request #1094 from OlegHahm/fix_z1-bsl-nopic
Fix z1-bsl-nopic
2015-06-02 00:41:52 +02:00
Benoît Thébaudeau
ecf6765bfd Makefile.include: Remove unused MODULESSUBST
The commit bddd96d5c8 "Removed all module
makefiles. Instead, all .c files in a module directory are compiled."
made the MODULESSUBST variable useless, but it did not remove it, so do
it now.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-01 22:09:58 +02:00
Oleg Hahm
fbeea78749 fix mixture of spaces and tabs for z1-bsl-nopic 2015-06-01 17:34:18 +02:00
Oleg Hahm
116ade0e63 z1-bsl-nopic requires Python 2 2015-06-01 17:34:00 +02:00
Benoît Thébaudeau
aba0b8ab40 Merge pull request #1085 from alignan/pull/remote
New Zolertia Re-Mote platform (CC2538 + CC1120)
2015-05-30 00:11:57 +02:00
Antonio Lignan
330e450ba4 Zolertia Re-Mote platform ported to Contiki, developed whitin RERUM FP7 European project (grant #609094).
The port was done jointly by Zolertia and George Oikonomou (University of Bristol).
2015-05-29 22:04:43 +02:00
Nicolas Tsiftes
5a26d25647 Merge pull request #918 from cetic/pr-multi-dodag-support
Multi DODAG support
2015-05-26 16:32:10 +02:00
Nicolas Tsiftes
be891c0554 Merge pull request #915 from cetic/pr-rpl-default-route-infinite
Allow rpl default route lifetime to be infinite
2015-05-26 16:26:58 +02:00
Benoît Thébaudeau
8c952e8026 Merge pull request #1082 from g-oikonomou/cc2538/readme-cdc
Update the CC2538DK README about a Win CDC driver
2015-05-26 00:29:50 +02:00
George Oikonomou
b86c26fff8 Update the CC2538DK README about a Win CDC driver
* The current version of the README points to a wrong URL
  for the LUFA Virtual Serial driver.
* A driver is nowadays provided by TI with CC2538
  Foundation Firmware

Thus, this pull updates the LUFA driver URL and also provides a
link to CC2538 Foundation Firmware
2015-05-25 22:06:25 +01:00
George Oikonomou
deb3ea4e9c Merge pull request #1075 from bthebaudeau/cc2538-data-bss-init
cc2538: Fix and improve .data/.bss initialization
2015-05-23 18:50:57 +01:00
Benoît Thébaudeau
1cd3c9e7e5 cc2538: Initialize .data/.bss using ROM functions
This is safer because the previous code assumed that the start and end
VMAs of .data and .bss were word-aligned, which is not always the case,
so the initialization code could write data outside these sections. The
ROM functions support any address boundary.

This is faster because the ROM functions are ultra optimized, using
realignment and the LDM/STM instructions, which is much better than the
previous simple loops of single word accesses.

This is smaller because the ROM functions don't require to add any code
to the target device other than simple function calls.

This makes the code simpler and more maintainable because standard
functions are not reimplemented and no assembly is used.

Note that this is also faster and smaller than the corresponding
functions from the standard string library.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-05-23 18:50:52 +02:00
Benoît Thébaudeau
609c615303 cc2538: Move the stack out of .bss
The initialization code clearing .bss is allowed to use the stack, so
the stack can not be in .bss, or this code will badly fail if it uses
the stack.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-05-23 18:50:52 +02:00
Benoît Thébaudeau
0de729572b cc2538: Word-align .data LMA
In order to be fast, the reset_handler() function uses word accesses to
initialize the .data output section. However, most toolchains do not
automatically force the alignment of an output section LMA to use the
maximum alignment of all its input sections. Because of that, assuming
that .data contains some words, the LMA of the .data output section was
not word-aligned in some cases, resulting in an initialization performed
using slow unaligned word accesses.

This commit forces the alignment of the LMA of the .data output section
with a word boundary in order to always use fast aligned word accesses
to read the .data load area.

Note that this solution is better than using ALIGN_WITH_INPUT, both
because the latter is a new feature incompatible with older toolchains,
and because it could create a big gap between _etext and the LMA of
.data if strongly-aligned data were added to .data, although only a word
alignment is required here.

The same considerations apply to the VMA of .data. However, it is
already automatically word-aligned, both because .data contains words,
and because the end VMA of the previous output section (.socdata) is
word-aligned. Moreover, if the VMA of .data were forcibly word-aligned,
then a filled gap could appear at the beginning of this section if
strongly-aligned data were added to it, thus wasting flash memory.
Consequently, it's better not to change anything for the VMA of .data,
all the more it's very unlikely that it does not contain any word and
that the end VMA of .socdata becomes non-word-aligned, and this would
only result in a slower initialization.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-05-23 18:12:54 +02:00
Benoît Thébaudeau
0d260f61a0 cc2538: Fix .data LMA/VMA mismatch with some toolchains
Some toolchains, like Sourcery CodeBench Lite 2013.05-23 arm-none-eabi
(http://sourcery.mentor.com/public/gnu_toolchain/arm-none-eabi/)
automatically force the alignment of an output section LMA to use the
maximum alignment of all its input sections. This toolchain uses GNU
binutils 2.23, and this automatic behavior is the same as the manual
behavior of the ALIGN_WITH_INPUT feature of GNU binutils 2.24+.

This behavior is not an issue per se, but it creates a gap between
_etext and the LMA of the .data output section if _etext does not have
the same alignment, while reset_handler() initialized this section by
copying the data from _etext to its VMA, hence an offset in the
addresses of loaded data, and missing data.

This commit fixes this issue by making reset_handler() directly use the
LMA of the .data section using LOADADDR(.data), rather than assuming
that _etext is this LMA.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-05-23 18:12:53 +02:00
Antonio Lignan
630b7f8963 Merge pull request #1084 from ludov04/master
Z1: tmp102: simple: fixed wrong cast
2015-05-22 21:59:31 +02:00
Matthieu Baerts
78b6b50194 Z1: tmp102: simple: fixed wrong cast
When using this code:

    (int8_t)tmp102_read_temp_x100() / 100

Only the first value is casted into a int8_t type.

tmp102_read_temp_x100() returns the temperature in Celcius * 100. Most of
the time this value will be lower than -2^7 and higher than 2^7 (+/- 1.27°C).

The cast is not needed but a comment about this implicit cast has been added.
2015-05-22 18:15:26 +02:00
Laurent Deru
9782a760b1 rpl_process_dio: Update parent rank 2015-05-22 17:21:53 +02:00
Laurent Deru
ccd3c58280 rpl_select_parent: Update dag rank according to new parent 2015-05-22 17:21:53 +02:00
Laurent Deru
fc8415e1ad Allow rpl default route lifetime to be infinite 2015-05-22 13:00:06 +02:00
Antonio Lignan
2cee62eb33 Merge pull request #1074 from g-oikonomou/cc26xx/contrib/new-cc26xxware
Update to latest CC26xxware and add it as a submodule
2015-05-21 10:01:00 +02:00
Nicolas Tsiftes
36d5c5dd27 Merge pull request #1077 from rajithr/patch-1
Remove redundant assignment
2015-05-20 19:45:25 +02:00
rajithr
0d8de9022c Remove redundant assignment 2015-05-20 15:37:32 +05:30
Benoît Thébaudeau
a6c5a49a88 Merge pull request #1065 from uknoblic/cc2538_speed
CC2538: Allow for configuration of processor clocks
2015-05-19 22:48:25 +02:00
Ulf Knoblich
d8efa8428c cc2538: Allow for configuration of processor speed 2015-05-19 18:55:55 +02:00
Fredrik Österlind
d1f976886f Merge pull request #1040 from atiselsts/cooja_multichannel
Improve multichannel support in Cooja
2015-05-19 08:59:06 +02:00
Adam Dunkels
730bda2001 Merge pull request #883 from cmorty/pull/global-macros
Move MAX, MIN and ABS to contiki-macros
2015-05-18 21:33:00 +02:00
Benoît Thébaudeau
b8ff3251e1 Merge pull request #1042 from uknoblic/cc2538_spi
CC2538: added support for SSI1
2015-05-18 20:36:45 +02:00
Simon Duquennoy
2157077f43 Merge pull request #1054 from cmorty/pull/regression_tools
Add regression-test for tools
2015-05-18 10:29:30 +02:00
Ulf Knoblich
a388a1bcd7 CC2538: added support for SSI1 2015-05-18 10:02:55 +02:00
Moritz 'Morty' Strübe
038ee9f82b Add to regrssion: compile-tool sto .travis.yml 2015-05-18 09:12:53 +02:00
Moritz 'Morty' Strübe
0dab6926b3 Move MAX, MIN and ABS to sys/cc.h 2015-05-18 08:53:17 +02:00
George Oikonomou
b861b8f277 Do not try to build cc26xxware documentation 2015-05-17 15:01:02 +01:00
George Oikonomou
541688235c Update the CC26xx README in terms of CC26xxware 2015-05-17 15:01:02 +01:00
George Oikonomou
f680d5dcc5 Do not fetch CC26xxware manually for travis tests 2015-05-17 15:01:02 +01:00
George Oikonomou
5d20e76346 Adjust the build system to use CC26xxware as a sub-module 2015-05-17 15:01:01 +01:00
George Oikonomou
40e82395c4 Pull CC26xxware as a submodule 2015-05-17 15:01:01 +01:00
George Oikonomou
b4067560ba Remove references to obsolete peripheral clock scaling functions 2015-05-17 15:01:01 +01:00
George Oikonomou
ab4249a709 Adjust retention calls
* Rename VIMS-related calls
* Remove obsolete ones
2015-05-17 15:01:01 +01:00
George Oikonomou
b38d32b281 Rename AON WUC power status macros 2015-05-17 15:01:01 +01:00
George Oikonomou
8b1f2ef33c Reset I2C with HAPI call instead of register access 2015-05-17 15:01:00 +01:00
George Oikonomou
8673bbdd55 Update linker script to accommodate for larger CCFG size 2015-05-17 15:01:00 +01:00
George Oikonomou
7a5b670f76 Remove references to IOC_JTAG_DISABLE 2015-05-17 14:09:52 +01:00