Skip to content

Commit

Permalink
Merge pull request #2577 from paparazzi/fix-various
Browse files Browse the repository at this point in the history
A second set of small fixes with:
- remove compile error in dshot driver (remove wrong and unused assert)
- fix file name report for chibios SD logger
- build file binary in OBJDIR for chibios to prevent linking at each upload command
- allow upside-down initialization for the float DCM filter
- fix makefile script to get the number of CPU core
- LTO is optional in board makefiles
  • Loading branch information
gautierhattenberger committed Sep 10, 2020
2 parents 9b13fc7 + 620a809 commit 3b42d6d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Makefile.ac
Expand Up @@ -61,7 +61,7 @@ NPROCS := 1
J ?= AUTO
ifeq ($J,AUTO)
ifeq ($(UNAME),Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
NPROCS := $(shell grep -c '^processor' /proc/cpuinfo)
else ifeq ($(UNAME),Darwin)
NPROCS := $(shell sysctl hw.ncpu | awk '{print $$2}')
endif # $(UNAME)
Expand Down
2 changes: 1 addition & 1 deletion conf/boards/chimera_1.0.makefile
Expand Up @@ -21,7 +21,7 @@ MCU=cortex-m7
USE_FPU=softfp
USE_FPU_OPT= -mfpu=fpv5-d16

USE_LTO=yes
USE_LTO ?= yes

$(TARGET).CFLAGS += -DSTM32F7 -DPPRZLINK_ENABLE_FD -DUSE_HARD_FAULT_RECOVERY

Expand Down
2 changes: 1 addition & 1 deletion conf/boards/tawaki_common.makefile
Expand Up @@ -20,7 +20,7 @@ MCU=cortex-m7
USE_FPU=softfp
USE_FPU_OPT= -mfpu=fpv5-d16

USE_LTO=yes
USE_LTO ?= yes

$(TARGET).CFLAGS += -DSTM32F7 -DPPRZLINK_ENABLE_FD -DUSE_HARD_FAULT_RECOVERY

Expand Down
23 changes: 12 additions & 11 deletions conf/chibios/chibios_rules.mk
Expand Up @@ -66,14 +66,19 @@ endif
#ifeq ($(BUILDDIR),.)
# BUILDDIR = build
#endif
OUTFILES = $(BUILDDIR)/$(PROJECT).elf \
$(BUILDDIR)/$(PROJECT).hex \
$(BUILDDIR)/$(PROJECT).bin \
$(BUILDDIR)/$(PROJECT).dmp \
$(BUILDDIR)/$(PROJECT).list

# Various directories
OBJDIR = $(BUILDDIR)/obj
LSTDIR = $(BUILDDIR)/lst

OUTFILES = $(OBJDIR)/$(PROJECT).elf \
$(OBJDIR)/$(PROJECT).hex \
$(OBJDIR)/$(PROJECT).bin \
$(OBJDIR)/$(PROJECT).dmp \
$(OBJDIR)/$(PROJECT).list

ifdef SREC
OUTFILES += $(BUILDDIR)/$(PROJECT).srec
OUTFILES += $(OBJDIR)/$(PROJECT).srec
endif

# Source files groups and paths
Expand All @@ -88,10 +93,6 @@ ASRC = $(ACSRC) $(ACPPSRC)
TSRC = $(TCSRC) $(TCPPSRC)
SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)))

# Various directories
OBJDIR = $(BUILDDIR)/obj
LSTDIR = $(BUILDDIR)/lst

# Object files groups
ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o)))
ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o)))
Expand Down Expand Up @@ -119,7 +120,7 @@ ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS) $(UPDEFS)
LDFLAGS = $(MCFLAGS) $(OPT) -nostartfiles $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--library-path=$(RULESPATH)/ld,--script=$(LDSCRIPT)$(LDOPT)
LDFLAGS = $(MCFLAGS) $(OPT) -nostartfiles $(LLIBDIR) -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--library-path=$(RULESPATH)/ld,--script=$(LDSCRIPT)$(LDOPT)

# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(strip $(TSRC)),)
Expand Down
3 changes: 0 additions & 3 deletions sw/airborne/arch/chibios/modules/actuators/esc_dshot.c
Expand Up @@ -121,9 +121,6 @@ static size_t getTimerWidth(const PWMDriver *pwmp);
*/
void dshotStart(DSHOTDriver *driver, const DSHOTConfig *config)
{
_Static_assert((void *) &driver->dsdb == (void *) &driver->dsdb.widths16);
_Static_assert((void *) &driver->dsdb.widths32 == (void *) &driver->dsdb.widths16);

memset((void *) &driver->dsdb, 0, sizeof(driver->dsdb));
const size_t timerWidthInBytes = getTimerWidth(config->pwmp);

Expand Down
12 changes: 10 additions & 2 deletions sw/airborne/modules/loggers/sdlog_chibios.c
Expand Up @@ -104,6 +104,7 @@ static enum {
/** sdlog filenames
*/
static char chibios_sdlog_filenames[68];
static char NO_FILE_NAME[] = "none";

#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
Expand All @@ -112,7 +113,14 @@ static void send_sdlog_status(struct transport_tx *trans, struct link_device *de
uint8_t status = (uint8_t) chibios_sdlog_status;
uint8_t errno = (uint8_t) sdLogGetStorageStatus();
uint32_t used = (uint32_t) sdLogGetNbBytesWrittenToStorage();
pprz_msg_send_LOGGER_STATUS(trans, dev, AC_ID, &status, &errno, &used, strlen(chibios_sdlog_filenames), chibios_sdlog_filenames);
uint8_t size = strlen(chibios_sdlog_filenames);
char *filenames = chibios_sdlog_filenames;
if (size == 0) {
// when no file opened
filenames = NO_FILE_NAME;
size = strlen(filenames);
}
pprz_msg_send_LOGGER_STATUS(trans, dev, AC_ID, &status, &errno, &used, size, filenames);
}
#endif

Expand Down Expand Up @@ -250,7 +258,7 @@ static void thd_startlog(void *arg)
SDLOG_CONTIGUOUS_STORAGE_MEM, LOG_PREALLOCATION_DISABLED, tmpFilename, sizeof(tmpFilename)) != SDLOG_OK) {
sdOk = false;
}
chsnprintf(chibios_sdlog_filenames, sizeof(chibios_sdlog_filenames), ", %s", tmpFilename);
chsnprintf(chibios_sdlog_filenames, sizeof(chibios_sdlog_filenames), "%s, %s", chibios_sdlog_filenames, tmpFilename);
#endif
}

Expand Down
16 changes: 11 additions & 5 deletions sw/airborne/subsystems/ahrs/ahrs_float_dcm.c
Expand Up @@ -117,14 +117,20 @@ void ahrs_dcm_init(void)
}

bool ahrs_dcm_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel,
struct FloatVect3 *lp_mag)
struct FloatVect3 *lp_mag __attribute__((unused)))
{
/* Compute an initial orientation using euler angles */
ahrs_float_get_euler_from_accel_mag(&ahrs_dcm.ltp_to_imu_euler, lp_accel, lp_mag);
/* Compute an initial orientation in quaternion (and then back to euler angles) so it works upside-down as well */
struct FloatQuat quat;
#if USE_MAGNETOMETER
ahrs_float_get_quat_from_accel_mag(&quat, lp_accel, lp_mag);
#else
ahrs_float_get_quat_from_accel(&quat, lp_accel);
#endif
float_eulers_of_quat(&ahrs_dcm.ltp_to_imu_euler, &quat);

/* Convert initial orientation in quaternion and rotation matrice representations. */
/* Convert initial orientation from quaternion to rotation matrix representations. */
struct FloatRMat ltp_to_imu_rmat;
float_rmat_of_eulers(&ltp_to_imu_rmat, &ahrs_dcm.ltp_to_imu_euler);
float_rmat_of_quat(&ltp_to_imu_rmat, &quat);

/* set filter dcm */
set_dcm_matrix_from_rmat(&ltp_to_imu_rmat);
Expand Down
2 changes: 2 additions & 0 deletions sw/airborne/subsystems/ahrs/ahrs_float_utils.h
Expand Up @@ -35,6 +35,8 @@

#include "std.h" // for ABS

/** Computer orientation in euler angles from accel and mag
* This is not working when the IMU is upside-down, then use the quaternion based function */
static inline void ahrs_float_get_euler_from_accel_mag(struct FloatEulers *e, struct FloatVect3 *accel,
struct FloatVect3 *mag)
{
Expand Down

0 comments on commit 3b42d6d

Please sign in to comment.