Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt for FMU with only FRAM and EEPROM #23424

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set LOGGER_BUF 8
set PARAM_FILE ""
set PARAM_BACKUP_FILE ""
set RC_INPUT_ARGS ""
set SDCARD_AVAILABLE no
set STORAGE_AVAILABLE no
set SDCARD_EXT_PATH /fs/microsd/ext_autostart
set SDCARD_FORMAT no
set STARTUP_TUNE 1
Expand Down Expand Up @@ -62,11 +62,11 @@ then
umount /fs/microsd

else
set SDCARD_AVAILABLE yes
set STORAGE_AVAILABLE yes
fi
fi

if [ $SDCARD_AVAILABLE = no -o $SDCARD_FORMAT = yes ]
if [ $STORAGE_AVAILABLE = no -o $SDCARD_FORMAT = yes ]
then
echo "INFO [init] formatting /dev/mmcsd0"
set STARTUP_TUNE 15 # tune 15 = SD_ERROR (overridden to SD_INIT if format + mount succeeds)
Expand All @@ -77,7 +77,7 @@ then

if mount -t vfat /dev/mmcsd0 /fs/microsd
then
set SDCARD_AVAILABLE yes
set STORAGE_AVAILABLE yes
set STARTUP_TUNE 14 # tune 14 = SD_INIT
else
echo "ERROR [init] card mount failed"
Expand All @@ -86,16 +86,22 @@ then
echo "ERROR [init] format failed"
fi
fi
else
# Is there a device mounted for storage
if mft query -q -k MTD -s MTD_PARAMETERS -v /mnt/microsd
then
set STORAGE_AVAILABLE yes
fi
fi

if [ $SDCARD_AVAILABLE = yes ]
if [ $STORAGE_AVAILABLE = yes ]
then
if hardfault_log check
then
if hardfault_log check
set STARTUP_TUNE 2 # tune 2 = ERROR_TUNE
if hardfault_log commit
then
set STARTUP_TUNE 2 # tune 2 = ERROR_TUNE
if hardfault_log commit
then
hardfault_log reset
fi
hardfault_log reset
fi
fi

Expand Down Expand Up @@ -172,7 +178,7 @@ else
fi
fi

if [ $SDCARD_AVAILABLE = yes ]
if [ $STORAGE_AVAILABLE = yes ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this would now be exporting the parameters twice to the same storage?

then
param select-backup $PARAM_BACKUP_FILE
fi
Expand Down Expand Up @@ -220,8 +226,8 @@ else

if [ ${VEHICLE_TYPE} == none ]
then
# Look for airframe on SD card
if [ $SDCARD_AVAILABLE = yes ]
# Use external startup file
if [ $STORAGE_AVAILABLE = yes ]
then
. ${R}etc/init.d/rc.autostart_ext
else
Expand Down Expand Up @@ -615,7 +621,7 @@ unset PARAM_FILE
unset PARAM_BACKUP_FILE
unset PARAM_DEFAULTS_VER
unset RC_INPUT_ARGS
unset SDCARD_AVAILABLE
unset STORAGE_AVAILABLE
unset SDCARD_EXT_PATH
unset SDCARD_FORMAT
unset STARTUP_TUNE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static constexpr wq_config_t ttyS9{"wq:ttyS9", 1728, -30};
static constexpr wq_config_t ttyACM0{"wq:ttyACM0", 1728, -31};
static constexpr wq_config_t ttyUnknown{"wq:ttyUnknown", 1728, -32};

static constexpr wq_config_t lp_default{"wq:lp_default", 2000, -50};
static constexpr wq_config_t lp_default{"wq:lp_default", 2350, -50};

static constexpr wq_config_t test1{"wq:test1", 2000, 0};
static constexpr wq_config_t test2{"wq:test2", 2000, 0};
Expand Down
12 changes: 6 additions & 6 deletions platforms/nuttx/src/px4/common/px4_mtd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ static int ramtron_attach(mtd_instance_s &instance)
return ENXIO;
#else

/* start the RAMTRON driver, attempt 10 times */
/* start the RAMTRON driver at 30MHz */

int spi_speed_mhz = 10;
unsigned long spi_speed_hz = 30'000'000;

for (int i = 0; i < 10; i++) {
for (int i = 0; spi_speed_hz > 0; i++) {
/* initialize the right spi */
struct spi_dev_s *spi = px4_spibus_initialize(px4_find_spi_bus(instance.devid));

Expand All @@ -90,7 +90,7 @@ static int ramtron_attach(mtd_instance_s &instance)

/* this resets the spi bus, set correct bus speed again */
SPI_LOCK(spi, true);
SPI_SETFREQUENCY(spi, spi_speed_mhz * 1000 * 1000);
SPI_SETFREQUENCY(spi, spi_speed_hz);
SPI_SETBITS(spi, 8);
SPI_SETMODE(spi, SPIDEV_MODE3);
SPI_SELECT(spi, instance.devid, false);
Expand All @@ -108,7 +108,7 @@ static int ramtron_attach(mtd_instance_s &instance)
}

// try reducing speed for next attempt
spi_speed_mhz--;
spi_speed_hz -= 1'000'000;
px4_usleep(10000);
}

Expand All @@ -118,7 +118,7 @@ static int ramtron_attach(mtd_instance_s &instance)
return -EIO;
}

int ret = instance.mtd_dev->ioctl(instance.mtd_dev, MTDIOC_SETSPEED, (unsigned long)spi_speed_mhz * 1000 * 1000);
int ret = instance.mtd_dev->ioctl(instance.mtd_dev, MTDIOC_SETSPEED, spi_speed_hz);

if (ret != OK) {
// FIXME: From the previous warning call, it looked like this should have been fatal error instead. Tried
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static char hw_base_info[HW_INFO_SIZE] = {0};
/****************************************************************************
* Protected Functions
****************************************************************************/

#if !defined(BOARD_HAS_ONLY_EEPROM_VERSIONING)
static int dn_to_ordinal(uint16_t dn)
{
/* Table is scaled for 12, so if ADC is in 16 bit mode
Expand Down Expand Up @@ -111,6 +111,7 @@ static int dn_to_ordinal(uint16_t dn)

return -1;
}
#endif /* BOARD_HAS_ONLY_EEPROM_VERSIONING */

/************************************************************************************
* Name: read_id_dn
Expand Down Expand Up @@ -143,7 +144,7 @@ static int dn_to_ordinal(uint16_t dn)
* -EIO - FAiled to init or read the ADC
*
************************************************************************************/

#if !defined(BOARD_HAS_ONLY_EEPROM_VERSIONING)
static int read_id_dn(int *id, uint32_t gpio_drive, uint32_t gpio_sense, int adc_channel)
{
int rv = -EIO;
Expand Down Expand Up @@ -328,9 +329,15 @@ static int read_id_dn(int *id, uint32_t gpio_drive, uint32_t gpio_sense, int adc
stm32_configgpio(gpio_drive);
return rv;
}
#endif /* BOARD_HAS_ONLY_EEPROM_VERSIONING */

static int determine_hw_info(int *revision, int *version)
{
#if defined(BOARD_HAS_ONLY_EEPROM_VERSIONING)
*revision = HW_ID_EEPROM;
*version = HW_ID_EEPROM;
return OK;
#else
int dn;
int rv = read_id_dn(&dn, GPIO_HW_REV_DRIVE, GPIO_HW_REV_SENSE, ADC_HW_REV_SENSE_CHANNEL);

Expand All @@ -344,6 +351,7 @@ static int determine_hw_info(int *revision, int *version)
}

return rv;
#endif
}

/****************************************************************************
Expand Down
8 changes: 8 additions & 0 deletions src/modules/logger/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ menuconfig USER_LOGGER
depends on BOARD_PROTECTED && MODULES_LOGGER
---help---
Put logger in userspace memory

menuconfig LOGGER_STACK_SIZE
int "stack size of logger task"
default 3700
depends on MODULES_LOGGER
---help---
Stack size of the logger task. Some configurations require more stack
than the default.
2 changes: 1 addition & 1 deletion src/modules/logger/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int Logger::task_spawn(int argc, char *argv[])
_task_id = px4_task_spawn_cmd("logger",
SCHED_DEFAULT,
SCHED_PRIORITY_LOG_CAPTURE,
PX4_STACK_ADJUSTED(3700),
PX4_STACK_ADJUSTED(CONFIG_LOGGER_STACK_SIZE),
(px4_main_t)&run_trampoline,
(char *const *)argv);

Expand Down
1 change: 1 addition & 0 deletions src/systemcmds/hardfault_log/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ px4_add_module(
MAIN hardfault_log
COMPILE_FLAGS
-Wno-cast-align # TODO: fix and enable
STACK_MAIN 4096
SRCS
hardfault_log.c
DEPENDS
Expand Down
1 change: 1 addition & 0 deletions src/systemcmds/param/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ px4_add_module(
MAIN param
COMPILE_FLAGS
-Wno-array-bounds
STACK_MAIN 4096
SRCS
param.cpp
DEPENDS
Expand Down
Loading