How can I apply patches about Nuttx

#1

Hi all,

I found some recent patches and updates for Nuttx here https://github.com/PX4/NuttX and would like to update
my local branch.
Is this is something can be done by simply replacing contents of /platforms/nuttx/Nuttx folder with new one?
The reason for this is to make sure nuttx runs more reliable with no further delays in running apps.
I see some jitter in time dt in some estimators, controllers.

Kyu

#2

Hi Kyu,

From what I know, you could just go into the nuttx directory and get the latest like that:

cd platforms/nuttx/NuttX/nuttx
git fetch
git checkout master
git merge

This would mean that you’re using the latest master of PX4/NuttX, however, it also means that you’re running an untested state (if it even compiles). Generally, NuttX updates will go into the Firmware after a while, usually after a release is out and riskier changes can get in again.

If you plan to do serious testing and/or want to help with NuttX updates, make sure to also coordinate with @david_s5 who is usually driving this.

#3

Hi @JulianOes,
Thanks for your comment. I was able to update nuttx and successfully build after
git submodule update --init --recursive
Seems like flying itself is just as before though CPU usage downed a little bit.

Kyu

#4

If you do:

Then you’re essentially resetting the change you just did in the submodule and you are not testing any changes.
Try git status to check what your source tree looks like and what submodules you have checked out, or use export GIT_SUBMODULES_ARE_EVIL=1 to prevent the git submodule auto check to come up.

#5

@Kyuhyong_You,

I will be working on a branch over the next few weeks that will build PX4 on the most recent NuttX master.

2 Likes
#6

Ok I checked my branch on platforms/nuttx/NuttX/nuttx
and it returns

HEAD detached at 0ac630e
nothing to commit, working directory clean

So I redo

git fetch
git checkout master

and I got these error

Previous HEAD position was 0ac630e… [BACKPORT] Merged in david_s5/nuttx/master_kinetis_usb_fixes (pull request #634)
Switched to branch ‘master’
Your branch is behind ‘origin/master’ by 8 commits, and can be fast-forwarded.
(use “git pull” to update your local branch)

So I git pull again end up getting

Updating d8cf3bf…5da7dba
Fast-forward
arch/arm/src/armv7-m/dwt.h | 210 ++++++++++±--------
arch/arm/src/armv7-m/itm.h | 137 ++++++±-----
arch/arm/src/armv7-m/tpi.h | 220 +++++++++++±--------
arch/arm/src/armv7-m/up_itm.c | 4 ±
arch/arm/src/armv7-m/up_itm_syslog.c | 2 ±
arch/arm/src/lpc54xx/lpc54_lowputc.c | 60 ±----
arch/arm/src/max326xx/common/max326_start.c | 4 +
…/src/max326xx/max32660/max32660_clockconfig.c | 4 ±
arch/arm/src/max326xx/max32660/max32660_gpio.c | 4 ±
arch/arm/src/max326xx/max32660/max32660_gpio.h | 2 ±
arch/arm/src/max326xx/max32660/max32660_lowputc.c | 24 ±-
arch/arm/src/max326xx/max32660/max32660_serial.c | 12 ±
configs/max32660-evsys/README.txt | 64 ++++±
configs/max32660-evsys/scripts/Make.defs | 4 +
configs/max32660-evsys/scripts/sram.ld | 115 +++++++++++
configs/stm32f4discovery/src/stm32_critmon.c | 9 ±
net/socket/net_clone.c | 6 +
net/socket/net_close.c | 2 ±
net/socket/net_sockets.c | 6 ±
net/socket/socket.h | 4 ±
wireless/bluetooth/bt_att.c | 9 ±
21 files changed, 551 insertions(+), 351 deletions(-)
create mode 100644 configs/max32660-evsys/scripts/sram.ld

Then I can git checkout master

Already on ‘master’
Your branch is up-to-date with ‘origin/master’.

To rebuild I make clean and did $ export GIT_SUBMODULES_ARE_EVIL=1 thing followed by make again
Now it gives bunch of submodule skipping message as follows

GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules tools/gencpp update.
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules tools/genmsg update.
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules src/lib/DriverFramework update.
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules ecl update.
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules matrix update.
– PX4 ECL: Very lightweight Estimation & Control Library v0.9.0-521-g3077e6a
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules devices update.
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules /home/dronedev/workspace/pitta/px4/fw/cf_px4_origin/mavlink/include/mavlink/v2.0 update.
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules nuttx update.
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules apps update.
– NuttX: crazyflie nsh cortex-m4
– ROMFS: px4fmu_common
– Configuring done
– Generating done
– Build files have been written to: /home/dronedev/workspace/pitta/px4/fw/cf_px4_origin/build/crazyflie_default
[10/506] git submodule ecl
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules ecl update.
[11/506] git submodule devices
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules devices update.
[12/506] git submodule /home/dronedev/…x4_origin/mavlink/include/mavlink/v2.0
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules /home/dronedev/workspace/pitta/px4/fw/cf_px4_origin/mavlink/include/mavlink/v2.0 update.
[12/506] git submodule apps
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules apps update.
[12/506] git submodule nuttx
GIT_SUBMODULES_ARE_EVIL is defined - Skipping submodules nuttx update.
[506/506] Creating /home/dronedev/work…razyflie_default/crazyflie_default.px4

Anyway it can rebuild just fine but not sure if I did all things right.
Is there any way to check the current build or version of nuttx in nsh?
@JulianOes Thank you for helping me out.

Kyu


Added
I still see git status shows
HEAD detached at 0ac630e
Which is not what current master shows as 166d898

#7

Ok, I would start fresh like this:

cd Firmware
git checkout master
git pull
git submodule update --init --recursive

All is clean now:

git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Then I would go into the Nuttx directory and get the latest master there:

cd platforms/nuttx/NuttX/nuttx
git checkout master
git pull

NuttX is now at 5da7dba like you.

Then I go back and the status looks like this:

cd ../../../..

git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   platforms/nuttx/NuttX/nuttx (new commits)

So, this tells me the NuttX submodule has now new commits, so is different from what the reference is by default.

Now it’s probably a good idea to do a clean builld:

export GIT_SUBMODULES_ARE_EVIL=1
make clean
make px4fmu-v2_default

The build fails, presumably there were some changes that need some work for the Firmware:

[  3%] Copying NuttX/nuttx to /home/julianoes/src/Firmware-master/build/px4_fmu-v2_default/NuttX
cp: cannot create directory 'build/px4_fmu-v2_default/NuttX/nuttx/configs/stm32butterfly2/include': File exists
cp: cannot create directory 'build/px4_fmu-v2_default/NuttX/nuttx/configs/stm32f334-disco/include': File exists
cp: cannot create directory 'build/px4_fmu-v2_default/NuttX/nuttx/configs/stm32f334-disco/nsh': File exists
cp: cannot create directory 'build/px4_fmu-v2_default/NuttX/nuttx/configs/stm32f334-disco/scripts': File exists
cp: cannot create directory 'build/px4_fmu-v2_default/NuttX/nuttx/configs/stm32f3discovery/include': File exists
cp: cannot create directory 'build/px4_fmu-v2_default/NuttX/nuttx/configs/stm32f3discovery/nsh': File exists
...

Now it’s probably a good idea to wait for @david_s5 to create a branch to try this, as he wrote above:

I will be working on a branch over the next few weeks that will build PX4 on the most recent NuttX master.

#8

Hi @JulianOes and @Kyuhyong_You

From 7.22 to 7.27+ Nuttx There are a lot of deltas in features and functionality and the way nuttx is configured and it’s build works. I have got one board to the link stage. Once that is resolved, I need to test. Then filter the deltas by board and apply and test those changes. Then I will push a WIP set of branches. (Nuttx:nuttx, apps and PX4 on 7.27+)

2 Likes