I can compile firmware from sources for my FC (WSL); this is good, thanks to the developers! However, I have not found the correct way to enable features that are disabled by default. For example, for speedybeef4v3, the MODE_GUIDED_NOGPS_ENABLED is 0, AHRS_EXT_VECTORNAV is 0 as well. There are a lot of other definitions that may actually work but are disabled. How do I compile and enable them? I found build_options.py, but I don’t understand how to use it to compile with features enabled.
Currently I made script that partially works. But I can’t enable guided no GPS this way (duplicate define):
import json
import subprocess
import sys
import build_options
features_json = r'''{
"selected_features": [
"EKF3", "EKF3_EXTNAV",
"EKF3_OPTFLOW", "EKF3_WINDEST", "VISUALODOM"
]
}'''
# 2) Parse the JSON:
data = json.loads(features_json)
selected_features = data["selected_features"]
board_name = "speedybeef4v3"
label_to_feature = {}
for feat in build_options.BUILD_OPTIONS:
label_to_feature[feat. Label] = feat
enable_flags = []
missing_labels = []
for label in selected_features:
# e.g. label == "AHRS_EXT", "FrSky SPort", "Bidirectional FrSky Telemetry", etc.
if label in label_to_feature:
feature_obj = label_to_feature[label]
# e.g. "enable-AHRS_EXT"
waf_arg = "--" + feature_obj.config_option()
enable_flags.append(waf_arg)
print ("// enabling :", feature_obj.label, "-", feature_obj.description)
print ('#ifdef', feature_obj.define)
print ('#undef', feature_obj.define)
print ('#endif')
print ('#define', feature_obj.define, 1)
print ('')
else:
missing_labels.append(label)
if missing_labels:
print("WARNING: Some features were not found in build_options.BUILD_OPTIONS:")
for lbl in missing_labels:
print(f" - {lbl}")
# Decide if you want to exit or continue. We'll just continue here.
###############################################################################
# Assemble the waf commands
###############################################################################
# Example:
# ./waf configure --board=speedybeef4v3 --enable-AHRS_EXT --enable-FrSky-SPort ...
configure_cmd = [
"./waf",
"configure",
f"--board={board_name}",
] + enable_flags
build_cmd = [
"./waf",
"copter", # or plane, rover, etc.
]
###############################################################################
# Helper function to run commands
###############################################################################
def run_command(cmd):
print("Running:", " ".join(cmd))
subprocess.check_call(cmd)
###############################################################################
# Run the build
###############################################################################
try:
run_command(configure_cmd)
run_command(build_cmd)
except subprocess.CalledProcessError as exc:
print(f"Error: build failed with code {exc.returncode}")
sys.exit(exc.returncode)
print("Build completed successfully!")
I’ll admit I might not fully understand the question, but have you tried the Custom Firmware builder?
You can easily add or remove features to a build. No fuss, no muss.
Of course, I was doing that) However, I have deep problems; I need to add additional debug messages to understand the reason for the problem and debug. I provide vision coordinates on the controller, which is usually not used for that. This partially works but not completely as expected. So I need to compile from sources to modify and test. I have strange messages (AHRS status changes strangely without obvious reason), and also provided coordinates partially accepted and partially rejected; I don’t understand why; I need to go deeper.
Hi @AndrewShpagin,
I’ve asked @peterbarker, @shiv-tyagi and @khancyr if they can answer your question. We have the BUILD.md linked from our Building the Code developer wiki page but I don’t think it has what you’re looking for.
Have you considered creating an extra.hwdef
file instead? That takes the defines directly, and you can undef DEFINENAME
to get past some redefinition issues. You pass the extra.hwdef on the command line with --extra-hwdef
.