Skip to content

Comments

Porting px4 to the evl4 kernel of aarch64 architecture#2

Draft
yexuanyang wants to merge 2 commits intoEOS-team:sitl_devfrom
yexuanyang:sitl_dev_eos
Draft

Porting px4 to the evl4 kernel of aarch64 architecture#2
yexuanyang wants to merge 2 commits intoEOS-team:sitl_devfrom
yexuanyang:sitl_dev_eos

Conversation

@yexuanyang
Copy link
Collaborator

Hello everyone! I am trying to port px4 to evl4 kernel. Now it can run with PX4_SIM_MODEL=shell environment variable set, I will add some benchmarks to measure the jitter in Tasks and WorkItems in the future.

The following are the operations that can be run on my machine:

  • Create a cmake build directory:

    /usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCONFIG:STRING=px4_sitl_evl4 -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/aarch64-linux-gnu-g++ --no-warn-unused-cli -S/root/PX4-Autopilot -B/root/PX4-Autopilot/build/px4_sitl_evl4 -G Ninja
  • cmake starts building:

    /usr/bin/cmake --build /root/PX4-Autopilot/build/px4_sitl_evl4 --config RelWithDebInfo --target all --
  • Run px4:

    cd /root/PX4-Autopilot/build/px4_sitl_evl4/rootfs
    export PX4_SIM_MODEL=shell
    ../bin/px4

@yexuanyang yexuanyang requested a review from ruiqurm March 23, 2025 14:47
@yexuanyang yexuanyang self-assigned this Mar 23, 2025
@yexuanyang yexuanyang force-pushed the sitl_dev_eos branch 2 times, most recently from dfb113f to ea5c7b9 Compare March 24, 2025 05:23
@ruiqurm ruiqurm assigned Ncerzzk and ruiqurm and unassigned yexuanyang Mar 24, 2025
Copy link
Collaborator

@ruiqurm ruiqurm left a comment

Choose a reason for hiding this comment

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

Awesome job on this PR! I’ve left a few comments with some questions.
One thing I noticed is about naming — currently, nullptr is passed to all named elements like mutex, thread, etc. Would it be possible to assign meaningful names to these elements? That would make debugging easier.
No rush though — this can definitely be addressed in a future update.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that evl_usleep cannot sleep for durations longer than one second. You may want to try evl_sleep_until instead.(I am not sure the evl_sleep_until if the API can be used to sleep for more than one second either)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I will change it to a loop using system_usleep.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please check the purpose of this macro? Should we use a real-time sleep function here, or is it acceptable to use a standard sleep instead?

Copy link
Collaborator Author

@yexuanyang yexuanyang Mar 25, 2025

Choose a reason for hiding this comment

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

px4_sleep use the system_sleep when lockstepscheduler doesn't set absolute time, it is the only place calling system_sleep, but px4_sleep is commonly used. I think it is only use when lockstepscheduler is not start. But it will use in drivers while loop, like gps driver. GPS driver use px4_sleep in GPS::run().
I use a real-time sleep here, just in case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So the most use case is in debuging? I think just use usleep is ok.

@yexuanyang
Copy link
Collaborator Author

Awesome job on this PR! I’ve left a few comments with some questions. One thing I noticed is about naming — currently, nullptr is passed to all named elements like mutex, thread, etc. Would it be possible to assign meaningful names to these elements? That would make debugging easier. No rush though — this can definitely be addressed in a future update.

Well, when the mutex has a name, it must be an unique name. Obviously, it is easy to think about using getpid() to get so called unique name, but, some threads need to create more than one mutex or event, so the name may not be unique.
I just pick nullptr to avoid the problem, if in some scenes need to debug with these name, I will try to find a solution to give them an suffix UUID with meaningful prefix string.

@yexuanyang yexuanyang force-pushed the sitl_dev_eos branch 2 times, most recently from 545a810 to b95d256 Compare March 27, 2025 07:19
Currently, you can run px4 using the libevl api instead of the posix interface
by setting the environment variable PX4_SIM_MODEL=shell.

Use Makefile to build px4_sitl_evl4:

```bash
make px4_sitl_evl4
```

The following are the operations that can be run on my machine:

- Create a cmake build directory:

```bash
/usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCONFIG:STRING=px4_sitl_evl4 -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/aarch64-linux-gnu-g++ --no-warn-unused-cli -S/root/PX4-Autopilot -B/root/PX4-Autopilot/build/px4_sitl_evl4 -G Ninja
```

- cmake starts building:

```bash
/usr/bin/cmake --build /root/PX4-Autopilot/build/px4_sitl_evl4 --config RelWithDebInfo --target all --
```

- Run px4:

```bash
cd /root/PX4-Autopilot/build/px4_sitl_evl4/rootfs
export PX4_SIM_MODEL=shell
../bin/px4
```

Signed-off-by: yexuanyang <myemailyyxg@gmail.com>
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.

3 participants