Skip to content

Commit

Permalink
restore UAVCAN bootloader support
Browse files Browse the repository at this point in the history
 - essentially reverting PX4#7878 minus the obsolete board support
  • Loading branch information
dagar authored Apr 19, 2020
1 parent 7c533e5 commit a3ad710
Show file tree
Hide file tree
Showing 30 changed files with 6,658 additions and 3 deletions.
2 changes: 0 additions & 2 deletions platforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@
############################################################################

add_subdirectory(common)


2 changes: 1 addition & 1 deletion platforms/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

set(SRCS)

if (NOT "${PX4_PLATFORM}" MATCHES "qurt" AND NOT "${PX4_BOARD}" MATCHES "io-v2")
if (NOT "${PX4_PLATFORM}" MATCHES "qurt" AND NOT "${PX4_BOARD}" MATCHES "io-v2" AND NOT "${PX4_BOARD_LABEL}" MATCHES "bootloader")
list(APPEND SRCS
px4_log.cpp
)
Expand Down
11 changes: 11 additions & 0 deletions platforms/nuttx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ if("${PX4_BOARD_LABEL}" STREQUAL "bootloader")
bootloader_lib
drivers_board
)
elseif("${PX4_BOARD_LABEL}" STREQUAL "canbootloader")
set(SCRIPT_PREFIX ${PX4_BOARD_LABEL}_)
add_subdirectory(src/canbootloader)
list(APPEND nuttx_libs
canbootloader
drivers_board
)

target_link_libraries(px4 PRIVATE
-Wl,-wrap,sched_process_timer -Wl,-wrap,sem_post -Wl,-wrap,sem_wait
)
else()
if(NOT "${PX4_BOARD_LINKER_PREFIX}" STREQUAL "")
set(SCRIPT_PREFIX ${PX4_BOARD_LINKER_PREFIX}-)
Expand Down
48 changes: 48 additions & 0 deletions platforms/nuttx/src/canbootloader/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
############################################################################
#
# Copyright (c) 2020 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(canbootloader
arch/stm32/board_identity.c
arch/stm32/drivers/can/driver.c
common/boot_app_shared.c
fs/flash.c
protocol/uavcan.c
sched/timer.c
uavcan/main.c
util/crc.c
util/random.c
)

include_directories(include)
target_include_directories(canbootloader INTERFACE include)
target_compile_options(canbootloader PRIVATE -Wno-error)
56 changes: 56 additions & 0 deletions platforms/nuttx/src/canbootloader/arch/stm32/board_identity.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/****************************************************************************
*
* Copyright (C) 2017 PX4 Development Team. All rights reserved.
* Author: @author David Sidrane <[email protected]>
*
* 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.
*
****************************************************************************/

/**
* @file board_identity.c
* Implementation of STM32 based Board identity API
*/

#include <px4_config.h>
#include <stdio.h>
#include <string.h>

#define SWAP_UINT32(x) (((x) >> 24) | (((x) & 0x00ff0000) >> 8) | (((x) & 0x0000ff00) << 8) | ((x) << 24))

int board_get_mfguid(mfguid_t mfgid)
{
uint32_t *chip_uuid = (uint32_t *) STM32_SYSMEM_UID;
uint32_t *rv = (uint32_t *) &mfgid[0];

for (int i = 0; i < PX4_CPU_UUID_WORD32_LENGTH; i++) {
*rv++ = SWAP_UINT32(chip_uuid[(PX4_CPU_UUID_WORD32_LENGTH - 1) - i]);
}

return PX4_CPU_MFGUID_BYTE_LENGTH;
}
Loading

0 comments on commit a3ad710

Please sign in to comment.