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

Conversation

niklaut
Copy link
Contributor

@niklaut niklaut commented Jul 18, 2024

Solved Problem

We built a smol FMU without SD card only with FRAM as minimal file system. Also doesn't have the revision resistors only EEPROM.

Solution

  1. LittleFS manages the FRAM as /mnt/microsd and mounts it as /fs/microsd. We chose to keep the paths the same for compatibility. The rcS needs minor updates to allow the hardfault handler to still work.
  2. The FRAM can do 30MHz writes, but the RamTron only does 10MHz by default. Adding a new BOARD_SPI_RAMTRON_SPEED_MHZ define to make that configurable.
  3. LittleFS requires more stack in a couple of tasks (this is probably not the best solution).
  4. Our board does not have a resistor for revisions, it only stores it in the EEPROM. Adding a new BOARD_HAS_ONLY_EEPROM_VERSIONING define to enable that behavior.

Changelog Entry

For release notes:

Feature Allow using FRAM as file system storage
Feature Allow using only EEPROM for versioning

Alternatives

All changes are backward compatible, except for:

  • the stack increases due to LittleFS is dependent on configuration. Not sure how to handle that without impacting other boards.

Test coverage

  • Lot's of hardware testing on our board

@niklaut niklaut marked this pull request as ready for review July 18, 2024 12:40
@niklaut niklaut requested review from dagar and davids5 July 18, 2024 12:46
Copy link
Member

@davids5 davids5 left a comment

Choose a reason for hiding this comment

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

@niklaut Can we do the bmi changes as a separate PR single commit?

I would like to have a way to abstract the stack size change Maybe in board common define some 0 value defaults that will be added to values or replace them

#!defined(PX4_LOGGER_STACK_FS_ADJST)
#define PX4_LOGGER_STACK_FS_ADJST 0
#endif

PX4_STACK_ADJUSTED(3700+PX4_LOGGER_STACK_FS_ADJST),

Or

#!defined(PX4_LOGGER_STACK_SIZE)
#define PX4_LOGGER_STACK_SIZE 3700
#endif

PX4_STACK_ADJUSTED(PX4_LOGGER_STACK_SIZE),

ROMFS/px4fmu_common/init.d/rcS Outdated Show resolved Hide resolved
@niklaut niklaut force-pushed the skynode-s-upstreaming branch from 5942b3e to 0909e20 Compare July 18, 2024 16:35
@niklaut
Copy link
Contributor Author

niklaut commented Jul 18, 2024

Removed the BMI changes, those can be done separately. Added a overridable logger stack define.

@dagar
Copy link
Member

dagar commented Jul 18, 2024

manages the FRAM as /mnt/microsd and mounts it as /fs/microsd

Please let's just abstract the path rather than fake it.

@dagar
Copy link
Member

dagar commented Jul 18, 2024

This could be moved to kconfig.

#define PX4_STORAGEDIR PX4_ROOTFSDIR "/fs/microsd"

If there are any parts of the init scripting that are hard to adapt I'd propose pushing more of it into board/platform init code (driven by kconfig). I was planning to do this eventually either way.

@@ -76,6 +76,10 @@
# endif
#endif

#ifndef BOARD_SPI_RAMTRON_SPEED_MHZ
#define BOARD_SPI_RAMTRON_SPEED_MHZ 10
Copy link
Member

Choose a reason for hiding this comment

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

kconfig

Copy link
Contributor Author

@niklaut niklaut Aug 5, 2024

Choose a reason for hiding this comment

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

I tried to understand how the RAMTRON speed is set in the code:

  1. It's currently hardcoded to start initialization at 10MHz and if it fails tries 9 times again down to 1MHz.
  2. Once the initialization succeeds and the part is detected, the speed is taken from the table (Between 25 and 40MHz) and set to priv->speed.
  3. This table speed is then simply overwritten and set to between 1 and 10MHz.

So RAMTRON has is always running at slower than max speed.

I don't understand what the use case is for dynamically determining the max speed? The RAMTRON is not hot pluggable so unless your PCBs differ in quality, the max speed should always be the same.

I think the speed should be config option in the px4_mft_device_t struct and defaulted to use the max device speed. But that seems to be a larger refactoring, so I now hacked it to start at 30MHz, since I spent my timebox on this already.

Copy link
Member

Choose a reason for hiding this comment

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

I believe it was just desperation for the extremely rare case parameters were failing to restore in the field and we had nothing to go on.

@PetervdPerk-NXP
Copy link
Member

@dagar @niklaut
Can we push to get this pr in
#23003
It allows us to be flexible for use cases like this.

@dagar
Copy link
Member

dagar commented Jul 24, 2024

I've merged #23003.

@niklaut
Copy link
Contributor Author

niklaut commented Aug 5, 2024

Please let's just abstract the path rather than fake it.

It would break a lot of external code that has the /fs/microsd path hardcoded in, so we have to fake it.

@niklaut niklaut force-pushed the skynode-s-upstreaming branch from 0909e20 to 8b2aebe Compare August 5, 2024 13:46
@PetervdPerk-NXP
Copy link
Member

PetervdPerk-NXP commented Aug 5, 2024

Please let's just abstract the path rather than fake it.

It would break a lot of external code that has the /fs/microsd path hardcoded in, so we have to fake it.

We can de-hardcode /fs/microsd by adding it into rc.filepaths and then use the macro. Most other entries have been replaced by the kconfig symbol in #23003

@niklaut
Copy link
Contributor Author

niklaut commented Aug 5, 2024

Sure, but not in this PR and certainly not in the time I have allocated for this. :-(

@niklaut niklaut force-pushed the skynode-s-upstreaming branch from 8b2aebe to cca47b4 Compare August 5, 2024 15:02
@niklaut niklaut requested review from dagar and davids5 August 8, 2024 14:57
@niklaut
Copy link
Contributor Author

niklaut commented Aug 14, 2024

Ping?

@niklaut niklaut force-pushed the skynode-s-upstreaming branch from cca47b4 to ed5a7e6 Compare August 14, 2024 09:27
@niklaut niklaut force-pushed the skynode-s-upstreaming branch from ed5a7e6 to ebe64d5 Compare August 14, 2024 13:06
@davids5
Copy link
Member

davids5 commented Aug 16, 2024

@niklaut I restarted https://github.com/PX4/PX4-Autopilot/actions/runs/10388157561/job/28763193102?pr=23424
If it fails again please have a look at what might have broken it

@davids5
Copy link
Member

davids5 commented Aug 19, 2024

@dagar CI is happy now. Ok to merge?

@@ -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?

@dagar
Copy link
Member

dagar commented Aug 19, 2024

I disagree with faking the path, but hopefully we'll still be able to untangle it later pushing more of this into board init and a parameter backend.

@dagar dagar merged commit ecfdbd2 into PX4:main Aug 19, 2024
91 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants