diff --git a/boards/aerotenna/ocpoc/src/CMakeLists.txt b/boards/aerotenna/ocpoc/src/CMakeLists.txt index 04927ce895..8cc8e0994d 100644 --- a/boards/aerotenna/ocpoc/src/CMakeLists.txt +++ b/boards/aerotenna/ocpoc/src/CMakeLists.txt @@ -32,5 +32,5 @@ ############################################################################ add_library(drivers_board - ${PX4_SOURCE_DIR}/src/drivers/boards/common/board_identity.c # TODO: this is horrible and should be fixed + empty.c ) diff --git a/boards/aerotenna/ocpoc/src/empty.c b/boards/aerotenna/ocpoc/src/empty.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/atlflight/eagle/src/CMakeLists.txt b/boards/atlflight/eagle/src/CMakeLists.txt index 2d765ef150..9d145c02e2 100644 --- a/boards/atlflight/eagle/src/CMakeLists.txt +++ b/boards/atlflight/eagle/src/CMakeLists.txt @@ -32,6 +32,5 @@ ############################################################################ add_library(drivers_board - ${PX4_SOURCE_DIR}/src/drivers/boards/common/board_identity.c # TODO: this is horrible and should be fixed sitl_led.c ) diff --git a/boards/beaglebone/blue/src/CMakeLists.txt b/boards/beaglebone/blue/src/CMakeLists.txt index 02461f039e..22a6c68ee6 100644 --- a/boards/beaglebone/blue/src/CMakeLists.txt +++ b/boards/beaglebone/blue/src/CMakeLists.txt @@ -35,6 +35,5 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") add_library(drivers_board init.c - ${PX4_SOURCE_DIR}/src/drivers/boards/common/board_identity.c # TODO: this is horrible and should be fixed ) diff --git a/boards/emlid/navio2/src/CMakeLists.txt b/boards/emlid/navio2/src/CMakeLists.txt index 04927ce895..8cc8e0994d 100644 --- a/boards/emlid/navio2/src/CMakeLists.txt +++ b/boards/emlid/navio2/src/CMakeLists.txt @@ -32,5 +32,5 @@ ############################################################################ add_library(drivers_board - ${PX4_SOURCE_DIR}/src/drivers/boards/common/board_identity.c # TODO: this is horrible and should be fixed + empty.c ) diff --git a/boards/emlid/navio2/src/empty.c b/boards/emlid/navio2/src/empty.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/parrot/bebop/src/CMakeLists.txt b/boards/parrot/bebop/src/CMakeLists.txt index 04927ce895..8cc8e0994d 100644 --- a/boards/parrot/bebop/src/CMakeLists.txt +++ b/boards/parrot/bebop/src/CMakeLists.txt @@ -32,5 +32,5 @@ ############################################################################ add_library(drivers_board - ${PX4_SOURCE_DIR}/src/drivers/boards/common/board_identity.c # TODO: this is horrible and should be fixed + empty.c ) diff --git a/boards/parrot/bebop/src/empty.c b/boards/parrot/bebop/src/empty.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/px4/raspberrypi/src/CMakeLists.txt b/boards/px4/raspberrypi/src/CMakeLists.txt index 04927ce895..8cc8e0994d 100644 --- a/boards/px4/raspberrypi/src/CMakeLists.txt +++ b/boards/px4/raspberrypi/src/CMakeLists.txt @@ -32,5 +32,5 @@ ############################################################################ add_library(drivers_board - ${PX4_SOURCE_DIR}/src/drivers/boards/common/board_identity.c # TODO: this is horrible and should be fixed + empty.c ) diff --git a/boards/px4/raspberrypi/src/empty.c b/boards/px4/raspberrypi/src/empty.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/px4/sitl/src/CMakeLists.txt b/boards/px4/sitl/src/CMakeLists.txt index d3156ed0dc..848bdb4867 100644 --- a/boards/px4/sitl/src/CMakeLists.txt +++ b/boards/px4/sitl/src/CMakeLists.txt @@ -32,7 +32,6 @@ ############################################################################ add_library(drivers_board - ${PX4_SOURCE_DIR}/src/drivers/boards/common/board_identity.c # TODO: this is horrible and should be fixed sitl_led.c sitl_board_shutdown.c ) diff --git a/platforms/common/CMakeLists.txt b/platforms/common/CMakeLists.txt index 9a5f459b4e..9e1817f73d 100644 --- a/platforms/common/CMakeLists.txt +++ b/platforms/common/CMakeLists.txt @@ -40,6 +40,7 @@ if (NOT "${PX4_PLATFORM}" MATCHES "qurt" AND NOT "${PX4_BOARD}" MATCHES "io-v2") endif() add_library(px4_platform + board_identity.c module.cpp px4_getopt.c px4_cli.cpp diff --git a/src/drivers/boards/common/board_identity.c b/platforms/common/board_identity.c similarity index 100% rename from src/drivers/boards/common/board_identity.c rename to platforms/common/board_identity.c diff --git a/platforms/nuttx/src/px4/common/CMakeLists.txt b/platforms/nuttx/src/px4/common/CMakeLists.txt index dfb2352bb6..2c37ee6a84 100644 --- a/platforms/nuttx/src/px4/common/CMakeLists.txt +++ b/platforms/nuttx/src/px4/common/CMakeLists.txt @@ -43,6 +43,7 @@ if (NOT ${PX4_BOARD} MATCHES "px4_io") ) target_link_libraries(px4_layer PRIVATE + arch_version nuttx_apps # up_cxxinitialize nuttx_sched drivers_boards_common_arch diff --git a/platforms/nuttx/src/px4/nxp/k66/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/k66/CMakeLists.txt index 7f95fdb519..638cb798e9 100644 --- a/platforms/nuttx/src/px4/nxp/k66/CMakeLists.txt +++ b/platforms/nuttx/src/px4/nxp/k66/CMakeLists.txt @@ -37,6 +37,7 @@ add_subdirectory(../kinetis/led_pwm led_pwm) add_subdirectory(../kinetis/hrt hrt) add_subdirectory(../kinetis/io_pins io_pins) add_subdirectory(../kinetis/tone_alarm tone_alarm) +add_subdirectory(../kinetis/version version) diff --git a/platforms/nuttx/src/px4/nxp/kinetis/version/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/kinetis/version/CMakeLists.txt new file mode 100644 index 0000000000..8afe6cfb29 --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/kinetis/version/CMakeLists.txt @@ -0,0 +1,37 @@ +############################################################################ +# +# Copyright (c) 2015-2019 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_library(arch_version + board_identity.c +) + diff --git a/src/drivers/boards/common/kinetis/board_identity.c b/platforms/nuttx/src/px4/nxp/kinetis/version/board_identity.c similarity index 98% rename from src/drivers/boards/common/kinetis/board_identity.c rename to platforms/nuttx/src/px4/nxp/kinetis/version/board_identity.c index 733dc5b1a6..19b78d05ba 100644 --- a/src/drivers/boards/common/kinetis/board_identity.c +++ b/platforms/nuttx/src/px4/nxp/kinetis/version/board_identity.c @@ -51,12 +51,12 @@ static const uint16_t soc_arch_id = PX4_SOC_ARCH_ID; void board_get_uuid(uuid_byte_t uuid_bytes) { uint32_t *chip_uuid = (uint32_t *) KINETIS_SIM_UIDH; - uint32_t *uuid_words = (uint32_t *) uuid_bytes; + uint8_t *uuid_words = uuid_bytes; for (unsigned int i = 0; i < PX4_CPU_UUID_WORD32_LENGTH; i++) { uint32_t current_uuid_bytes = SWAP_UINT32(chip_uuid[i]); memcpy(uuid_words, ¤t_uuid_bytes, sizeof(uint32_t)); - ++uuid_words; + uuid_words += sizeof(uint32_t); } } diff --git a/platforms/nuttx/src/px4/stm/stm32_common/version/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32_common/version/CMakeLists.txt new file mode 100644 index 0000000000..8afe6cfb29 --- /dev/null +++ b/platforms/nuttx/src/px4/stm/stm32_common/version/CMakeLists.txt @@ -0,0 +1,37 @@ +############################################################################ +# +# Copyright (c) 2015-2019 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_library(arch_version + board_identity.c +) + diff --git a/src/drivers/boards/common/stm32/board_identity.c b/platforms/nuttx/src/px4/stm/stm32_common/version/board_identity.c similarity index 95% rename from src/drivers/boards/common/stm32/board_identity.c rename to platforms/nuttx/src/px4/stm/stm32_common/version/board_identity.c index c60e8de512..83d4390f5f 100644 --- a/src/drivers/boards/common/stm32/board_identity.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/version/board_identity.c @@ -104,10 +104,12 @@ int board_get_uuid32_formated(char *format_buffer, int size, int board_get_mfguid(mfguid_t mfgid) { uint32_t *chip_uuid = (uint32_t *) STM32_SYSMEM_UID; - uint32_t *rv = (uint32_t *) &mfgid[0]; + uint8_t *rv = &mfgid[0]; for (unsigned i = 0; i < PX4_CPU_UUID_WORD32_LENGTH; i++) { - *rv++ = SWAP_UINT32(chip_uuid[(PX4_CPU_UUID_WORD32_LENGTH - 1) - i]); + uint32_t uuid_bytes = SWAP_UINT32(chip_uuid[(PX4_CPU_UUID_WORD32_LENGTH - 1) - i]); + memcpy(rv, &uuid_bytes, sizeof(uint32_t)); + rv += sizeof(uint32_t); } return PX4_CPU_MFGUID_BYTE_LENGTH; @@ -137,13 +139,12 @@ int board_get_px4_guid(px4_guid_t px4_guid) *pb++ = 0; } - uint32_t *rv = (uint32_t *) pb; uint32_t *chip_uuid = (uint32_t *) STM32_SYSMEM_UID; for (unsigned i = 0; i < PX4_CPU_UUID_WORD32_LENGTH; i++) { uint32_t uuid_bytes = SWAP_UINT32(chip_uuid[(PX4_CPU_UUID_WORD32_LENGTH - 1) - i]); - memcpy(rv, &uuid_bytes, sizeof(uint32_t)); - ++rv; + memcpy(pb, &uuid_bytes, sizeof(uint32_t)); + pb += sizeof(uint32_t); } return PX4_GUID_BYTE_LENGTH; diff --git a/platforms/nuttx/src/px4/stm/stm32f4/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f4/CMakeLists.txt index 5acfab9f87..88b3ebd935 100644 --- a/platforms/nuttx/src/px4/stm/stm32f4/CMakeLists.txt +++ b/platforms/nuttx/src/px4/stm/stm32f4/CMakeLists.txt @@ -38,6 +38,7 @@ add_subdirectory(../stm32_common/hrt hrt) add_subdirectory(../stm32_common/led_pwm led_pwm) add_subdirectory(../stm32_common/io_pins io_pins) add_subdirectory(../stm32_common/tone_alarm tone_alarm) +add_subdirectory(../stm32_common/version version) add_subdirectory(px4io_serial) diff --git a/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt index 5a32338306..282db7a0c8 100644 --- a/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt +++ b/platforms/nuttx/src/px4/stm/stm32f7/CMakeLists.txt @@ -39,6 +39,7 @@ add_subdirectory(../stm32_common/hrt hrt) add_subdirectory(../stm32_common/led_pwm led_pwm) add_subdirectory(../stm32_common/io_pins io_pins) add_subdirectory(../stm32_common/tone_alarm tone_alarm) +add_subdirectory(../stm32_common/version version) add_subdirectory(px4io_serial) diff --git a/src/drivers/boards/common/kinetis/CMakeLists.txt b/src/drivers/boards/common/kinetis/CMakeLists.txt index ae962c7023..6e9e12d0c0 100644 --- a/src/drivers/boards/common/kinetis/CMakeLists.txt +++ b/src/drivers/boards/common/kinetis/CMakeLists.txt @@ -32,7 +32,6 @@ ############################################################################ add_library(drivers_boards_common_arch - board_identity.c board_mcu_version.c board_reset.c ) diff --git a/src/drivers/boards/common/stm32/CMakeLists.txt b/src/drivers/boards/common/stm32/CMakeLists.txt index 609ea41988..6d7ef77d4f 100644 --- a/src/drivers/boards/common/stm32/CMakeLists.txt +++ b/src/drivers/boards/common/stm32/CMakeLists.txt @@ -32,7 +32,6 @@ ############################################################################ add_library(drivers_boards_common_arch - board_identity.c board_mcu_version.c board_reset.c board_critmon.c