Substantial updates based on changes in pdp1-fw

Closes #6
Closes #7
main
alexis 2 months ago
parent 0e5b500a73
commit e976df424b

3
.gitmodules vendored

@ -4,3 +4,6 @@
[submodule "subprojects/ch32v10x"]
path = subprojects/ch32v10x
url = https://gitea.alexisvl.rocks/alexisvl/ch32v10x-meson.git
[submodule "xutil"]
path = subprojects/xutil
url = https://gitea.alexisvl.rocks/alexisvl/xutil.git

@ -42,6 +42,8 @@ RUN ./configure --prefix=/usr/local \
make install && \
rm -rf /build
RUN apt-get install -y cmake
# groupadd will fail if the GID already exists, as is the case for macOS hosts
# where "staff" is gid 20. That's ok. We just need the group to exist.
RUN groupadd --gid ${gid} usergrp ; \

@ -10,7 +10,8 @@ LOCALHOST ?= localhost
MESON_FILE := meson.build
MESON_CROSS ?= meson_cross_riscv.txt
MESON_DIR ?= mbuild
MESON_TARGET ?= main
MESON_DIR ?= mbuild_${MESON_TARGET}
OPENOCD_DIR ?= $(dir $(shell command -v openocd))/..
@ -19,7 +20,7 @@ TRANSLATE_COMPILE_COMMANDS := \
sed -i -e "s%riscv32-unknown-elf-gcc %\0 -isystem=$$(readlink -f ./.docker_includes) %" ${MESON_DIR}/compile_commands.json
all: .have_docker
${DOCKER_CMD} ${DOCKER_IMAGE} make lall
${DOCKER_CMD} ${DOCKER_IMAGE} make MESON_TARGET=${MESON_TARGET} lall
${TRANSLATE_COMPILE_COMMANDS}
wipe: clean all
@ -27,15 +28,15 @@ lall: ${MESON_DIR}
meson compile -C ${MESON_DIR}
${MESON_DIR}: ${MESON_FILE} ${MESON_CROSS}
meson setup $@ --cross-file ${MESON_CROSS}
meson setup $@ --cross-file -D build_target=${MESON_TARGET} ${MESON_CROSS}
rb: .have_docker
${DOCKER_CMD} ${DOCKER_IMAGE} make lrb
${DOCKER_CMD} ${DOCKER_IMAGE} make MESON_TARGET=${MESON_TARGET} lrb
${TRANSLATE_COMPILE_COMMANDS}
lrb:
rm -rf ${MESON_DIR}
meson setup ${MESON_DIR} --cross-file ${MESON_CROSS}
meson setup ${MESON_DIR} --cross-file ${MESON_CROSS} -D build_target=${MESON_TARGET}
meson compile -C ${MESON_DIR}
clean:
@ -52,7 +53,7 @@ flash: all
-f ./wch-riscv.cfg \
-c init -c halt \
-c "program $(shell readlink -f ${MESON_DIR}/firmware-for-make.hex) verify reset" \
-c resume -c exit
-c wlink_reset_resume -c exit
openocd:
${OPENOCD_DIR}/bin/openocd \

@ -1,28 +1,79 @@
###############################################################################
# MESON SETUP
project(
'firmware',
['c'],
default_options: ['optimization=2', 'cpp_std=c++17', 'b_staticpic=false']
['c', 'cpp'],
default_options: ['optimization=2', 'cpp_std=c++20', 'b_staticpic=false',
'b_lto=false', 'warning_level=3', 'default_library=static']
)
###############################################################################
# MAIN BUILD CONFIGURATION
flash_origin = 0
flash_size = 0
stack_size = 2048
bsp = 'bsp-BOARD'
target = get_option('build_target')
target_name = meson.project_name() + '_' + target
if target == 'main'
sources = [
'src/main.c',
]
includes = [
'src',
]
endif
###############################################################################
# SYSTEM DEPENDENCIES
## END USER MUST MODIFY: KEEP ONLY THE 10x or 30x BLOCK
ch32v10x_proj = subproject('ch32v10x')
ch32v10x_proj = subproject('ch32v10x', default_options: [
f'flash_size=@flash_size@',
f'flash_origin=@flash_origin@',
f'stack_size=@stack_size@',
])
ch32v10x_dep = ch32v10x_proj.get_variable('ch32v10x_dep')
ch32v10x_sys_dep = ch32v10x_proj.get_variable('ch32v10x_sys_dep')
dependencies = [ch32v10x_dep, ch32v10x_sys_dep]
## END USER MUST MODIFY: KEEP ONLY THE 10x or 30x BLOCK
ch32v30x_proj = subproject('ch32v30x', default_options: ['variant=CH32V307'])
ch32v30x_proj = subproject('ch32v30x', default_options: [
'variant=CH32V307',
f'flash_size=@flash_size@',
f'flash_origin=@flash_origin@',
f'stack_size=@stack_size@',
])
ch32v30x_dep = ch32v30x_proj.get_variable('ch32v30x_dep')
ch32v30x_sys_dep = ch32v30x_proj.get_variable('ch32v30x_sys_dep')
dependencies = [ch32v30x_dep, ch32v30x_sys_dep]
sources = [
'src/main.c',
]
bsp_proj = subproject(bsp)
dependencies += bsp_proj.get_variable('bsp_dep')
info_dep = vcs_tag(
command: ['git', 'describe', '--always', '--dirty'],
fallback: 'no-git',
input: 'version.h.in',
output: 'version.h',
replace_string: 'GITINFO',
)
sources += info_dep
###############################################################################
# APPLICATION DEPENDENCIES
xutil_proj = subproject('xutil', default_options: [
'with_cpp=true',
'with_task=false',
])
dependencies += xutil_proj.get_variable('xutil_dep')
includes = [
'src',
]
###############################################################################
# BUILD TARGETS
_incl_dirs = include_directories(includes)
@ -31,21 +82,21 @@ objdump = find_program('objdump')
size = find_program('size')
main = executable(
meson.project_name() + '.elf',
target_name + '.elf',
sources,
include_directories: _incl_dirs,
dependencies: dependencies,
)
main_hex = custom_target(
meson.project_name() + '.hex',
target_name + '.hex',
command: [
objcopy,
'-O', 'ihex',
'@INPUT@', '@OUTPUT@'
],
input: main,
output: meson.project_name() + '.hex',
output: target_name + '.hex',
build_by_default: true,
)
@ -66,13 +117,13 @@ elf_for_make = custom_target(
)
main_disas = custom_target(
meson.project_name() + '.disas',
target_name + '.disas',
command: [
objdump,
'-SC', '@INPUT@'
'-SC', '--visualize-jumps', '@INPUT@'
],
input: main,
output: meson.project_name() + '.disas',
output: target_name + '.disas',
build_by_default: true,
capture: true,
)

@ -19,6 +19,6 @@ size = gcc_target + '-size'
[built-in options]
c_args = ['-mabi=' + abi, '-march=' + arch, '--specs=nano.specs']
cpp_args = ['-mabi=' + abi, '-march=' + arch, '--specs=nano.specs']
cpp_args = ['-mabi=' + abi, '-march=' + arch, '--specs=nano.specs', '-fuse-cxa-atexit', '-fno-rtti', '-fno-exceptions', '-fno-threadsafe-statics']
c_link_args = ['-mabi=' + abi, '-march=' + arch, '--specs=nano.specs']
cpp_link_args = ['-mabi=' + abi, '-march=' + arch, '--specs=nano.specs']
cpp_link_args = ['-mabi=' + abi, '-march=' + arch, '--specs=nano.specs', '-nostdlib', '-lc_nano', '-lgcc', '-fno-rtti', '-fno-exceptions', '-fno-threadsafe-statics']

@ -0,0 +1 @@
option('build_target', type: 'combo', choices: ['main'])

@ -0,0 +1 @@
Subproject commit f8de04ffe98e923aaf8b9b84319dc1809ae1bb7a
Loading…
Cancel
Save