Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
bf9e541d
Commit
bf9e541d
authored
9 years ago
by
James Goppert
Browse files
Options
Downloads
Patches
Plain Diff
Got romfs generation working.
parent
81538749
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+14
-3
14 additions, 3 deletions
CMakeLists.txt
cmake/Toolchain-arm-none-eabi.cmake
+2
-2
2 additions, 2 deletions
cmake/Toolchain-arm-none-eabi.cmake
cmake/px4_impl_nuttx.cmake
+80
-18
80 additions, 18 deletions
cmake/px4_impl_nuttx.cmake
src/CMakeLists.txt
+4
-4
4 additions, 4 deletions
src/CMakeLists.txt
with
100 additions
and
27 deletions
CMakeLists.txt
+
14
−
3
View file @
bf9e541d
...
...
@@ -109,12 +109,20 @@ set(package-contact "px4users@googlegroups.com")
# cmake modules
#
# set module path
list
(
APPEND CMAKE_MODULE_PATH
${
CMAKE_SOURCE_DIR
}
/cmake
)
if
(
EXISTS px4_impl_
${
OS
}
_
${
BOARD
}
)
include
(
px4_impl_
${
OS
}
_
${
BOARD
}
)
# prefer board implementation module over os implmementation module
set
(
board_impl_module px4_impl_
${
OS
}
_
${
BOARD
}
)
set
(
os_impl_module px4_impl_
${
OS
}
)
if
(
EXISTS
${
board_impl_module
}
)
set
(
impl_module
${
board_impl_module
}
)
else
()
include
(
px4_impl_
${
OS
}
)
set
(
impl_module
${
os_impl_module
}
)
endif
()
include
(
${
impl_module
}
)
# require px4 module interface
set
(
px4_required_functions
px4_os_prebuild_targets
px4_os_add_flags
...
...
@@ -125,6 +133,9 @@ foreach(cmd ${px4_required_functions})
endif
()
endforeach
()
# other modules
enable_testing
()
#=============================================================================
# parameters
#
...
...
This diff is collapsed.
Click to expand it.
cmake/Toolchain-arm-none-eabi.cmake
+
2
−
2
View file @
bf9e541d
...
...
@@ -41,12 +41,12 @@ foreach(tool objcopy nm ld)
string
(
TOUPPER
${
tool
}
TOOL
)
find_program
(
${
TOOL
}
arm-none-eabi-
${
tool
}
)
if
(
NOT
${
TOOL
}
)
message
(
FATAL_ERROR
"could not find
${
TOOL
}
"
)
message
(
FATAL_ERROR
"could not find
${
tool
}
"
)
endif
()
endforeach
()
# os tools
foreach
(
tool grep rm nm genromfs
)
foreach
(
tool
echo patch
grep rm
mkdir
nm genromfs
awk cp touch make unzip
)
string
(
TOUPPER
${
tool
}
TOOL
)
find_program
(
${
TOOL
}
${
tool
}
)
if
(
NOT
${
TOOL
}
)
...
...
This diff is collapsed.
Click to expand it.
cmake/px4_impl_nuttx.cmake
+
80
−
18
View file @
bf9e541d
...
...
@@ -42,6 +42,7 @@
# * px4_nuttx_generate_builtin_commands
# * px4_nuttx_add_export
# * px4_nuttx_generate_romfs
# * px4_bin_to_obj
#
# Required OS Inteface Functions
#
...
...
@@ -187,8 +188,8 @@ function(px4_nuttx_add_export)
string
(
REPLACE
"/"
"_"
patch_name
"
${
patch
}
-
${
CONFIG
}
"
)
message
(
STATUS
"nuttx-patch:
${
patch
}
"
)
add_custom_command
(
OUTPUT nuttx_patch_
${
patch_name
}
.stamp
COMMAND
patch
-p0 -N <
${
CMAKE_SOURCE_DIR
}
/
${
patch
}
COMMAND
touch
nuttx_patch_
${
patch_name
}
.stamp
COMMAND
${
PATCH
}
-p0 -N <
${
CMAKE_SOURCE_DIR
}
/
${
patch
}
COMMAND
${
TOUCH
}
nuttx_patch_
${
patch_name
}
.stamp
DEPENDS
${
DEPENDS
}
)
add_custom_target
(
nuttx_patch_
${
patch_name
}
...
...
@@ -198,35 +199,35 @@ function(px4_nuttx_add_export)
# copy
add_custom_command
(
OUTPUT nuttx_copy_
${
CONFIG
}
.stamp
COMMAND
mkdir
-p
${
CMAKE_BINARY_DIR
}
/
${
CONFIG
}
COMMAND
cp
-r
${
CMAKE_SOURCE_DIR
}
/NuttX
${
nuttx_src
}
COMMAND
rm
-rf
${
nuttx_src
}
/.git
COMMAND
touch
nuttx_copy_
${
CONFIG
}
.stamp
COMMAND
${
MKDIR
}
-p
${
CMAKE_BINARY_DIR
}
/
${
CONFIG
}
COMMAND
${
CP
}
-r
${
CMAKE_SOURCE_DIR
}
/NuttX
${
nuttx_src
}
COMMAND
${
RM
}
-rf
${
nuttx_src
}
/.git
COMMAND
${
TOUCH
}
nuttx_copy_
${
CONFIG
}
.stamp
DEPENDS
${
DEPENDS
}
)
add_custom_target
(
__nuttx_copy_
${
CONFIG
}
DEPENDS nuttx_copy_
${
CONFIG
}
.stamp __nuttx_patch_
${
CONFIG
}
)
# export
add_custom_command
(
OUTPUT
${
CONFIG
}
.export
COMMAND
echo
Configuring NuttX for
${
CONFIG
}
COMMAND
make
-C
${
nuttx_src
}
/nuttx -j
${
THREADS
}
COMMAND
${
ECHO
}
Configuring NuttX for
${
CONFIG
}
COMMAND
${
MAKE
}
-C
${
nuttx_src
}
/nuttx -j
${
THREADS
}
-r --quiet distclean
COMMAND
cp
-r
${
CMAKE_SOURCE_DIR
}
/nuttx-configs/
${
CONFIG
}
COMMAND
${
CP
}
-r
${
CMAKE_SOURCE_DIR
}
/nuttx-configs/
${
CONFIG
}
${
nuttx_src
}
/nuttx/configs
COMMAND cd
${
nuttx_src
}
/nuttx/tools &&
./configure.sh
${
CONFIG
}
/nsh
COMMAND
echo
Exporting NuttX for
${
CONFIG
}
COMMAND
make
-C
${
nuttx_src
}
/nuttx -j
${
THREADS
}
COMMAND
${
ECHO
}
Exporting NuttX for
${
CONFIG
}
COMMAND
${
MAKE
}
-C
${
nuttx_src
}
/nuttx -j
${
THREADS
}
-r CONFIG_ARCH_BOARD=
${
CONFIG
}
export
COMMAND
cp
-r
${
nuttx_src
}
/nuttx/nuttx-export.zip
COMMAND
${
CP
}
-r
${
nuttx_src
}
/nuttx/nuttx-export.zip
${
CONFIG
}
.export
DEPENDS
${
DEPENDS
}
__nuttx_copy_
${
CONFIG
}
)
# extract
add_custom_command
(
OUTPUT nuttx_export_
${
BOARD
}
.stamp
COMMAND
rm
-rf
${
nuttx_src
}
/nuttx-export
COMMAND
unzip
${
BOARD
}
.export -d
${
nuttx_src
}
COMMAND
touch
nuttx_export_
${
BOARD
}
.stamp
COMMAND
${
RM
}
-rf
${
nuttx_src
}
/nuttx-export
COMMAND
${
UNZIP
}
${
BOARD
}
.export -d
${
nuttx_src
}
COMMAND
${
TOUCH
}
nuttx_export_
${
BOARD
}
.stamp
DEPENDS
${
DEPENDS
}
${
BOARD
}
.export
)
add_custom_target
(
${
OUT
}
...
...
@@ -234,6 +235,63 @@ function(px4_nuttx_add_export)
endfunction
()
#=============================================================================
#
# px4_bin_to_obj
#
# The functions create an object file from a binary image.
#
# Usage:
# px4_bin_to_boj(OBJ <out-obj> VAR <in-variable> BIN <in-bin>)
#
# Input:
# BIN : the bin file
# VAR : the variable name
#
# Output:
# OBJ : the object file
#
# Example:
# px4_bin_to_obj(OBJ my_obj VAR romfs BIN my_bin)
#
function
(
px4_bin_to_obj
)
px4_parse_function_args
(
NAME px4_bin_to_obj
ONE_VALUE BIN OBJ VAR
REQUIRED BIN OBJ VAR
ARGN
${
ARGN
}
)
string
(
REPLACE
"/"
" "
_tmp
${
BIN
}
)
string
(
REPLACE
"/"
" "
sym
${
_tmp
}
)
message
(
STATUS
"sym:
${
sym
}
"
)
separate_arguments
(
CMAKE_C_FLAGS
)
add_custom_command
(
OUTPUT
${
OBJ
}
COMMAND
${
TOUCH
}
${
OBJ
}
.c
COMMAND
${
CMAKE_C_COMPILER
}
${
CMAKE_C_FLAGS
}
-c
${
OBJ
}
.c -o
${
OBJ
}
.c.o
COMMAND
${
LD
}
-r -o
${
OBJ
}
.bin.o
${
OBJ
}
.c.o -b binary
${
BIN
}
COMMAND
${
NM
}
-p --radix=x
${
OBJ
}
.bin.o
|
${
GREP
}
${
sym
}
_size
|
${
GREP
}
-o ^[0-9a-fA-F]*
|
${
AWK
}
"{print
\"
const unsigned int
${
VAR
}
_len = 0x
\"
$1
\"
;
\"
}"
>
${
OBJ
}
.c
COMMAND
${
CMAKE_C_COMPILER
}
${
CMAKE_C_FLAGS
}
-c
${
OBJ
}
.c -o
${
OBJ
}
.c.o
COMMAND
${
LD
}
-r -o
${
OBJ
}
${
OBJ
}
.c.o
${
OBJ
}
.bin.o
COMMAND
${
OBJCOPY
}
${
OBJ
}
--redefine-sym
${
sym
}
_start=
${
VAR
}
--strip-symbol
${
sym
}
_size
--strip-symbol
${
sym
}
_end
--rename-section .data=.rodata
COMMAND
${
RM
}
${
OBJ
}
.c
${
OBJ
}
.c.o
${
OBJ
}
.bin.o
DEPENDS
${
BIN
}
VERBATIM
)
set
(
${
OBJ
}
${
OBJ
}
PARENT_SCOPE
)
endfunction
()
#=============================================================================
#
# px4_nuttx_generate_romfs
...
...
@@ -264,15 +322,19 @@ function(px4_nuttx_generate_romfs)
set
(
romfs_temp_dir
${
CMAKE_BINARY_DIR
}
/
${
ROOT
}
)
set
(
romfs_src_dir
${
CMAKE_SOURCE_DIR
}
/
${
ROOT
}
)
add_custom_command
(
OUTPUT
${
OUT
}
add_custom_command
(
OUTPUT
romfs.bin
COMMAND cmake -E remove_directory
${
romfs_temp_dir
}
COMMAND cmake -E copy_directory
${
romfs_src_dir
}
${
romfs_temp_dir
}
#TODO add romfs cleanup and pruning
COMMAND
${
GENROMFS
}
-f
${
OUT
}
-d
${
romfs_temp_dir
}
-V
"NSHInitVol"
COMMAND
${
GENROMFS
}
-f
${
CMAKE_CURRENT_BINARY_DIR
}
/romfs.bin
-d
${
romfs_temp_dir
}
-V
"NSHInitVol"
DEPENDS
${
romfs_files
}
WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_custom_target
(
gen_romfs DEPENDS
${
OUT
}
)
px4_bin_to_obj
(
OBJ
${
OUT
}
BIN
${
CMAKE_CURRENT_BINARY_DIR
}
/romfs.bin
VAR romfs
)
endfunction
()
...
...
This diff is collapsed.
Click to expand it.
src/CMakeLists.txt
+
4
−
4
View file @
bf9e541d
...
...
@@ -45,8 +45,11 @@ if (${OS} STREQUAL "nuttx")
OUT builtin_commands.c
MODULE_LIST
${
module_list
}
)
px4_nuttx_generate_romfs
(
OUT romfs.o
ROOT
${
CMAKE_SOURCE_DIR
}
/ROMFS/px4fmu_common
)
# add executable
add_executable
(
main builtin_commands.c
)
add_executable
(
main builtin_commands.c
romfs.o
)
set
(
nuttx_export_dir
${
CMAKE_BINARY_DIR
}
/
${
BOARD
}
/NuttX/nuttx-export
)
set
(
main_link_flags
"-T
${
nuttx_export_dir
}
/build/ld.script"
...
...
@@ -67,9 +70,6 @@ if (${OS} STREQUAL "nuttx")
px4_add_upload
(
OUT upload OS
${
OS
}
BOARD
${
BOARD
}
BUNDLE
${
CMAKE_CURRENT_BINARY_DIR
}
/fw_main.px4
)
px4_nuttx_generate_romfs
(
OUT
${
CMAKE_CURRENT_BINARY_DIR
}
/romfs.img
ROOT
${
CMAKE_SOURCE_DIR
}
/ROMFS/px4fmu_common
)
endif
()
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment