Merge pull request #91 from dji-sdk/release/v3.3

FIX: fixed the problem of occasionally obtaining abnormal camera parmmeters
This commit is contained in:
DJI
2023-03-12 20:35:30 +08:00
committed by GitHub
32 changed files with 729 additions and 8 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ extern "C" {
#define DJI_VERSION_MINOR 3 /*!< DJI SDK minor version num, when add functionality in a backwards compatible manner changes. Range from 0 to 99. */
#define DJI_VERSION_MODIFY 0 /*!< DJI SDK modify version num, when have backwards compatible bug fixes changes. Range from 0 to 99. */
#define DJI_VERSION_BETA 0 /*!< DJI SDK version beta info, release version will be 0, when beta version release changes. Range from 0 to 255. */
#define DJI_VERSION_BUILD 1702 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */
#define DJI_VERSION_BUILD 1703 /*!< DJI SDK version build info, when jenkins trigger build changes. Range from 0 to 65535. */
/* Exported types ------------------------------------------------------------*/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -86,7 +86,7 @@ start:
<< "| [i] Start power management sample - you will see notification when aircraft power off |\n"
<< "| [j] Start data transmission sample - you can send or recv custom data on MSDK demo |\n"
<< "| [l] Run camera manager sample - shoot photo by the selected camera mounted position |\n"
<< "| [m] Run camera manager download sample - download camera media file (not support on M3E/M3T) |\n"
<< "| [m] Run camera manager download sample - download camera media file (not support on M3E/M3T) |\n"
<< std::endl;
std::cin >> inputChar;
@@ -176,6 +176,7 @@ void TIM1_UP_TIM10_IRQHandler(void)
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
}
#if USE_USB_HOST_UART
/**
* @brief This function handles USB On The Go FS global interrupt.
*/
@@ -192,6 +193,7 @@ void OTG_FS_IRQHandler(void)
/* USER CODE END OTG_FS_IRQn 1 */
}
#endif
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
@@ -177,7 +177,7 @@ HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t
{
/*Initialization of SectorError variable*/
*SectorError = 0xFFFFFFFFU;
if(pEraseInit->TypeErase == FLASH_TYPEERASE_MASSERASE)
{
/*Mass erase to be done*/
@@ -185,7 +185,7 @@ HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
/* if the erase operation is completed, disable the MER Bit */
FLASH->CR &= (~FLASH_MER_BIT);
}
@@ -201,11 +201,11 @@ HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
/* If the erase operation is completed, disable the SER and SNB Bits */
CLEAR_BIT(FLASH->CR, (FLASH_CR_SER | FLASH_CR_SNB));
if(status != HAL_OK)
if(status != HAL_OK)
{
/* In case of error, stop erase procedure and return the faulty sector*/
*SectorError = index;
@@ -214,7 +214,7 @@ HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t
}
}
/* Flush the caches to be sure of the data consistency */
FLASH_FlushCaches();
FLASH_FlushCaches();
}
/* Process Unlocked */
@@ -27,9 +27,12 @@
/* Includes ------------------------------------------------------------------*/
#include "hal_uart.h"
#include "uart.h"
#include "usbh_cdc.h"
#include "dji_platform.h"
#if USE_USB_HOST_UART
#include "usbh_cdc.h"
#endif
/* Private constants ---------------------------------------------------------*/
#define COMMUNICATION_UART_NUM UART_NUM_3
@@ -0,0 +1,150 @@
#THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
cmake_minimum_required(VERSION 3.5)
# project settings
project(dji_sdk_demo_rtos C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
set(DEVICE STM32F407IG)
set(DEVICE_FAMILY STM32F40_41xxx)
set(USE_BOOTLOADER NO)
if (USE_BOOTLOADER MATCHES YES)
add_definitions(-DUSE_BOOTLOADER)
endif ()
add_definitions(-DUSE_HAL_DRIVER)
add_definitions(-DSTM32F407xx)
add_definitions(-DUSE_CMSIS_RTOS=1)
add_definitions(-DHSE_VALUE=8000000)
#add_definitions(-DUSE_USB_HOST_UART=1)
#Uncomment for hardware floating point
add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
#Uncomment for software floating point
#add_compile_options(-mfloat-abi=soft)
add_compile_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0)
# uncomment to mitigate c++17 absolute addresses warnings
#set(ADDITIONAL_CORE_FLAGS "-Wno-unused-function -Wno-missing-braces")
#set(CORE_FLAGS "-mthumb -mcpu=cortex-m4 -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb-interwork --specs=nano.specs --specs=nosys.specs ${ADDITIONAL_CORE_FLAGS}")
set(CMAKE_C_FLAGS "${CORE_FLAGS} -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections -u _printf_float --specs=nosys.specs -g3 -gdwarf-2" CACHE INTERNAL "c compiler flags")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Maximum optimization for speed")
add_compile_options(-Ofast)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
message(STATUS "Maximum optimization for speed, debug info included")
add_compile_options(-Ofast -g)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
message(STATUS "Maximum optimization for size")
add_compile_options(-Os)
else ()
message(STATUS "Minimal optimization, debug info included")
# add_compile_options(-Og -g)
endif ()
include_directories(
../../../common/osal
../../hal
../../application
../../bootloader
../../drivers/BSP
../../drivers/STM32F4xx_HAL_Driver/Inc
../../drivers/STM32F4xx_HAL_Driver/Inc/Legacy
../../drivers/CMSIS/Device/ST/STM32F4xx/Include
../../drivers/CMSIS/Include
../../middlewares/Third_Party/FreeRTOS/Source/include
../../middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
../../middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F
../../../../../module_sample
../../drivers/USB_HOST/Target
../../drivers/USB_HOST/App
../../middlewares/ST/STM32_USB_Host_Library/Core/Inc
../../middlewares/ST/STM32_USB_Host_Library/Class/CDC/Inc
)
add_definitions(-DUSE_HAL_DRIVER -DSTM32F407xx)
file(GLOB_RECURSE SOURCES
"../../../common/*.c"
"../../hal/*.c"
"../../application/*.c"
"../../drivers/BSP/*.c"
"../../drivers/USB_HOST/*.*"
"../../middlewares/ST/*.*"
"../../drivers/STM32F4xx_HAL_Driver/*.*"
"../../drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c"
"../../middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c"
"../../drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s"
"../../middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c"
"../../middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c"
"../../middlewares/Third_Party/FreeRTOS/Source/croutine.c"
"../../middlewares/Third_Party/FreeRTOS/Source/event_groups.c"
"../../middlewares/Third_Party/FreeRTOS/Source/list.c"
"../../middlewares/Third_Party/FreeRTOS/Source/queue.c"
"../../middlewares/Third_Party/FreeRTOS/Source/tasks.c"
"../../middlewares/Third_Party/FreeRTOS/Source/timers.c"
"../../../../../module_sample/camera_emu/test_payload_cam_emu_base.c"
"../../../../../module_sample/gimbal_emu/*.c"
"../../../../../module_sample/xport/*.c"
"../../../../../module_sample/payload_collaboration/*.c"
"../../../../../module_sample/fc_subscription/*.c"
"../../../../../module_sample/data_transmission/*.c"
"../../../../../module_sample/widget/*.c"
"../../../../../module_sample/positioning/*.c"
"../../../../../module_sample/time_sync/*.c"
"../../../../../module_sample/upgrade/*.c"
"../../../../../module_sample/utils/*.c"
"../../../../../module_sample/power_management/*.c"
)
if (USE_BOOTLOADER MATCHES YES)
set(FLASH_START 0x08010000)
set(FLASH_SIZE 448k)
else ()
set(FLASH_START 0x08000000)
set(FLASH_SIZE 1024k)
endif ()
set(RAM_SIZE 128k)
set(CCMRAM_SIZE 64k)
set(HEAP_SIZE 0x800)
set(STACK_SIZE 0x800)
configure_file(linker_script/stm32f407igt.ld.in ${CMAKE_CURRENT_BINARY_DIR}/stm32f407igt.ld)
get_filename_component(LINKER_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/stm32f407igt.ld ABSOLUTE)
add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
add_link_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_link_options(-T ${LINKER_SCRIPT})
include_directories(../../../../../../../out/include)
link_directories(${CMAKE_CURRENT_LIST_DIR}/../../../../../../../out/lib/arm-none-eabi-gcc)
link_libraries(${CMAKE_CURRENT_LIST_DIR}/../../../../../../../out/lib/arm-none-eabi-gcc/libpayloadsdk.a)
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMENT "Building ${HEX_FILE}
Building ${BIN_FILE}")
configure_file(${CMAKE_CURRENT_LIST_DIR}/download_script/download.jlink.in ${CMAKE_CURRENT_BINARY_DIR}/download.jlink)
configure_file(${CMAKE_CURRENT_LIST_DIR}/download_script/download.sh.in ${CMAKE_CURRENT_BINARY_DIR}/download.sh)
configure_file(${CMAKE_CURRENT_LIST_DIR}/debug_script/gdbserver.sh.in ${CMAKE_CURRENT_BINARY_DIR}/gdbserver.sh)
execute_process(COMMAND chmod 777 download.sh WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND chmod 777 gdbserver.sh WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
@@ -0,0 +1,2 @@
#!/bin/bash
JLinkGDBServerCLExe -device ${DEVICE} -speed 8100 -if SWD -s -halt -noir -x ${CMAKE_CURRENT_LIST_DIR}/debug_script/init.gdb -rtos GDBServer/RTOSPlugin_FreeRTOS
@@ -0,0 +1,7 @@
device ${DEVICE}
r
loadbin ${PROJECT_NAME}.bin, ${FLASH_START}
verifybin ${PROJECT_NAME}.bin, ${FLASH_START}
r
g
qc
@@ -0,0 +1,9 @@
#!/bin/bash
if [ ! -n "$1" ] ;then
JLinkExe -device ${DEVICE} -speed 1000 -if SWD -CommanderScript ${CMAKE_CURRENT_BINARY_DIR}/download.jlink
echo "use default jlink device"
else
JLinkExe -usb $1 -device ${DEVICE} -speed 1000 -if SWD -CommanderScript ${CMAKE_CURRENT_BINARY_DIR}/download.jlink
echo "use selected jlink device, sn:"$1
fi
exit 0
@@ -0,0 +1,190 @@
/* Default STM32F4xx linker script.
*
* Modify memory sections according to the targeted platform.
*/
MEMORY
{
FLASH (rx) : ORIGIN = ${FLASH_START}, LENGTH = ${FLASH_SIZE}
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE}
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = ${CCMRAM_SIZE}
}
/* Reset_Handler : Entry of reset handler */
ENTRY(Reset_Handler)
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It defines following symbols, which code can use without definition.
* __exidx_start
* __exidx_end
* __etext
* _sdata
* __preinit_array_start
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* _edata
* _sbss
* __bss_start__
* __bss_end__
* _ebss
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* _sidata
* _siccmram
*/
_estack = ORIGIN(RAM) + LENGTH(RAM);
_Min_Heap_Size = ${HEAP_SIZE};
_Min_Stack_Size = ${STACK_SIZE};
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
.data : AT (__etext)
{
_sdata = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
_edata = .;
} > RAM
_siccmram = LOADADDR(.ccmram);
/* CCM-RAM section
*
* IMPORTANT NOTE!
* If initialized variables will be placed in this section,
* the startup code needs to be modified to copy the init-values.
*/
.ccmram :
{
. = ALIGN(4);
_sccmram = .; /* create a global symbol at ccmram start */
*(.ccmram)
*(.ccmram*)
. = ALIGN(4);
_eccmram = .; /* create a global symbol at ccmram end */
} >CCMRAM AT> FLASH
.bss :
{
. = ALIGN(4);
_sbss = .;
__bss_start__ = _sbss;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
__bss_end__ = _ebss;
} > RAM
.heap (COPY):
{
__end__ = .;
PROVIDE(end = .);
PROVIDE( _end = . );
*(.heap*)
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > RAM
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(_estack = __StackTop);
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}
@@ -0,0 +1,134 @@
#THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
cmake_minimum_required(VERSION 3.5)
# project settings
project(dji_sdk_demo_bootloader C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
add_definitions(-DUSE_HAL_DRIVER)
add_definitions(-DSTM32F407xx)
add_definitions(-DUSE_CMSIS_RTOS=1)
add_definitions(-DHSE_VALUE=8000000)
set(DEVICE STM32F407IG)
set(DEVICE_FAMILY STM32F40_41xxx)
#Uncomment for hardware floating point
add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
#Uncomment for software floating point
#add_compile_options(-mfloat-abi=soft)
add_compile_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0)
# uncomment to mitigate c++17 absolute addresses warnings
#set(ADDITIONAL_CORE_FLAGS "-Wno-unused-function -Wno-missing-braces")
#set(CORE_FLAGS "-mthumb -mcpu=cortex-m4 -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb-interwork --specs=nano.specs --specs=nosys.specs ${ADDITIONAL_CORE_FLAGS}")
set(CMAKE_C_FLAGS "${CORE_FLAGS} -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections -g3 -gdwarf-2" CACHE INTERNAL "c compiler flags")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Maximum optimization for speed")
add_compile_options(-Ofast)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
message(STATUS "Maximum optimization for speed, debug info included")
add_compile_options(-Ofast -g)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
message(STATUS "Maximum optimization for size")
add_compile_options(-Os)
else ()
message(STATUS "Minimal optimization, debug info included")
add_compile_options(-Og -g)
endif ()
include_directories(
../../../common
../../../common/osal
../../hal
../../application
../../bootloader
../../drivers/BSP
../../drivers/STM32F4xx_HAL_Driver/Inc
../../drivers/STM32F4xx_HAL_Driver/Inc/Legacy
../../drivers/CMSIS/Device/ST/STM32F4xx/Include
../../drivers/CMSIS/Include
../../middlewares/Third_Party/FreeRTOS/Source/include
../../middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F
)
add_definitions(-DUSE_HAL_DRIVER -DSTM32F407xx)
file(GLOB_RECURSE SOURCES
"../../../common/*.c"
"../../hal/*.c"
"../../bootloader/*.c"
"../../drivers/BSP/*.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c"
"../../drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c"
"../../drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c"
"../../drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s"
"../../middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c"
"../../middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c"
"../../middlewares/Third_Party/FreeRTOS/Source/croutine.c"
"../../middlewares/Third_Party/FreeRTOS/Source/event_groups.c"
"../../middlewares/Third_Party/FreeRTOS/Source/list.c"
"../../middlewares/Third_Party/FreeRTOS/Source/queue.c"
"../../middlewares/Third_Party/FreeRTOS/Source/tasks.c"
"../../middlewares/Third_Party/FreeRTOS/Source/timers.c"
)
#[[ LINK SCRIPT ]]
set(FLASH_START 0x08000000)
set(FLASH_SIZE 1024k)
set(RAM_SIZE 128k)
set(CCMRAM_SIZE 64k)
set(HEAP_SIZE 0x800)
set(STACK_SIZE 0x800)
include_directories(../../../../../../../out/include)
configure_file(linker_script/stm32f407igt.ld.in ${CMAKE_CURRENT_BINARY_DIR}/stm32f407igt.ld)
get_filename_component(LINKER_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/stm32f407igt.ld ABSOLUTE)
add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
add_link_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_link_options(-T ${LINKER_SCRIPT})
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMENT "Building ${HEX_FILE}
Building ${BIN_FILE}")
configure_file(${CMAKE_CURRENT_LIST_DIR}/download_script/download.jlink.in ${CMAKE_CURRENT_BINARY_DIR}/download.jlink)
configure_file(${CMAKE_CURRENT_LIST_DIR}/download_script/download.sh.in ${CMAKE_CURRENT_BINARY_DIR}/download.sh)
configure_file(${CMAKE_CURRENT_LIST_DIR}/debug_script/gdbserver.sh.in ${CMAKE_CURRENT_BINARY_DIR}/gdbserver.sh)
execute_process(COMMAND chmod 777 download.sh WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND chmod 777 gdbserver.sh WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
@@ -0,0 +1,15 @@
Config items of CLion project:
1. Go to https://segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack
For x64 ubuntu:
Download <J-Link Software and Documentation pack for Linux, DEB installer, 64-bit>, double click the downloaded file to install.
2. Go to https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads
Download toolchain, for x64 ubuntu is <gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2>
cd /usr/local/
sudo tar xjf ~/Downloads/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
add "export PATH=$PATH:/usr/local/gcc-arm-none-eabi-9-2020-q2-update/bin" to /etc/profile
reboot system
3. Create External Tool named "fw_download", Program is $CMakeCurrentBuildDir$/download.sh and Work Directory is $CMakeCurrentBuildDir$
You can add shortcuts to this external tool to quickly download and run program.
4. Create Embedded GDB Server, setting GDB Server to <cmake build dir>/gdbserver.sh, 'target remote' args to 127.0.0.1:2331
Note: double-check the all above path, and ensure they are correct
@@ -0,0 +1,2 @@
#!/bin/bash
JLinkGDBServerCLExe -device ${DEVICE} -speed 8100 -if SWD -s -halt -noir -x ${CMAKE_CURRENT_LIST_DIR}/debug_script/init.gdb -rtos GDBServer/RTOSPlugin_FreeRTOS
@@ -0,0 +1,7 @@
device ${DEVICE}
r
loadbin ${PROJECT_NAME}.bin, ${FLASH_START}
verifybin ${PROJECT_NAME}.bin, ${FLASH_START}
r
g
qc
@@ -0,0 +1,9 @@
#!/bin/bash
if [ ! -n "$1" ] ;then
JLinkExe -device ${DEVICE} -speed 1000 -if SWD -CommanderScript ${CMAKE_CURRENT_BINARY_DIR}/download.jlink
echo "use default jlink device"
else
JLinkExe -usb $1 -device ${DEVICE} -speed 1000 -if SWD -CommanderScript ${CMAKE_CURRENT_BINARY_DIR}/download.jlink
echo "use selected jlink device, sn:"$1
fi
exit 0
@@ -0,0 +1,189 @@
/* Default STM32F4xx linker script.
*
* Modify memory sections according to the targeted platform.
*/
MEMORY
{
FLASH (rx) : ORIGIN = ${FLASH_START}, LENGTH = ${FLASH_SIZE}
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE}
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = ${CCMRAM_SIZE}
}
/* Reset_Handler : Entry of reset handler */
ENTRY(Reset_Handler)
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It defines following symbols, which code can use without definition.
* __exidx_start
* __exidx_end
* __etext
* _sdata
* __preinit_array_start
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* _edata
* _sbss
* __bss_start__
* __bss_end__
* _ebss
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* _sidata
* _siccmram
*/
_estack = ORIGIN(RAM) + LENGTH(RAM);
_Min_Heap_Size = ${HEAP_SIZE};
_Min_Stack_Size = ${STACK_SIZE};
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
.data : AT (__etext)
{
_sdata = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
_edata = .;
} > RAM
_siccmram = LOADADDR(.ccmram);
/* CCM-RAM section
*
* IMPORTANT NOTE!
* If initialized variables will be placed in this section,
* the startup code needs to be modified to copy the init-values.
*/
.ccmram :
{
. = ALIGN(4);
_sccmram = .; /* create a global symbol at ccmram start */
*(.ccmram)
*(.ccmram*)
. = ALIGN(4);
_eccmram = .; /* create a global symbol at ccmram end */
} >CCMRAM AT> FLASH
.bss :
{
. = ALIGN(4);
_sbss = .;
__bss_start__ = _sbss;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
__bss_end__ = _ebss;
} > RAM
.heap (COPY):
{
__end__ = .;
PROVIDE(end = .);
*(.heap*)
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > RAM
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(_estack = __StackTop);
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}