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

NuttX enable SPI DMA per board #12436

Closed
wants to merge 1 commit into from
Closed

NuttX enable SPI DMA per board #12436

wants to merge 1 commit into from

Conversation

dagar
Copy link
Member

@dagar dagar commented Jul 9, 2019

  • airmind/mindpx-v2
  • auav/esc35-v1
  • auav/x21
  • av/x-v1
  • bitcraze/crazyflie
  • holybro/kakutef7
  • intel/aerofc-v1
  • nxp/fmuk66-v3
  • omnibus/f4sd
  • px4/cannode-v1
  • px4/esc-v1
  • px4/fmu-v2
  • px4/fmu-v3
  • px4/fmu-v4
  • px4/fmu-v4pro
  • px4/fmu-v5
  • px4/fmu-v5x
  • px4/io-v2
  • thiemar/s2740vc-v1

@dagar dagar added this to the Release v1.10.0 milestone Jul 9, 2019
@dagar dagar force-pushed the pr-imu_dma branch 2 times, most recently from 17eb2b7 to 4c209bd Compare July 9, 2019 02:19
@dagar dagar requested a review from davids5 July 9, 2019 02:31
@dagar dagar changed the title [WIP]: start enabling SPI DMA per board (IMUs) NuttX enable SPI DMA per board Jul 9, 2019
@dagar dagar marked this pull request as ready for review July 9, 2019 02:32
@dagar dagar requested a review from a team July 9, 2019 03:10
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.

@dagar

Did you check all the DMAMAPs to ensure there was no overlap burred in a nuttx driver?

The 512 and 1024 magic number are not helpful and do not tie to the granularity of the allocator. How about define the block size and add a comment to describe the limitations.

What is the formula for changing the BOARD_DMA_ALLOC_POOL_SIZE ? Can it be driven from the defconfig?

boards/aerotenna/ocpoc/src/CMakeLists.txt Outdated Show resolved Hide resolved
@dagar dagar force-pushed the pr-imu_dma branch 2 times, most recently from d6c6646 to eacae78 Compare July 9, 2019 19:44
@jorge789
Copy link

jorge789 commented Jul 9, 2019

Tested on PixRacer V4:

Modes Tested
Position Mode: Good.
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
No issues noted, good flight in general.

Logs:
https://review.px4.io/plot_app?log=3ca5d59f-e633-4281-ac5f-21974ae98f80

https://review.px4.io/plot_app?log=e48ab5c9-1a1d-4095-be23-23e55a800ef4

Logs: Comparison to master
https://review.px4.io/plot_app?log=29892ab0-32ee-40d8-a5fa-1636ab1f62df

https://review.px4.io/plot_app?log=b7466023-f8d2-4366-83b6-d4cef75e549f

Tested on Pixhawk 2 Cube V3:

Modes Tested
Position Mode: Good.
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
No issues noted, good flight in general.

Logs:
https://review.px4.io/plot_app?log=4e7bffaf-0bb3-4b09-87e6-4304a56c2669

https://review.px4.io/plot_app?log=f467fd1d-c1ae-447a-ac57-815f05f02cfe

Logs: Comparison to master
https://review.px4.io/plot_app?log=1ee0bdfc-0a9e-4a47-8dec-593e8565d45a

@dannyfpv
Copy link

dannyfpv commented Jul 9, 2019

Tested on Pixhawk4 v5 f-450
GPS issue, please see pictures below.
Tested on Master firmware and no issues.

Screen Shot 2019-07-09 at 9 51 25 AM

Screen Shot 2019-07-09 at 9 51 25 AM

@dagar

@Junkim3DR
Copy link

Junkim3DR commented Jul 9, 2019

Tested on Pixhawk 4 Mini V5:

Modes Tested:
Position Mode: Untested.
Altitude Mode: Untested.
Stabilized Mode: Untested
Mission Plan Mode (Automated): Untested
RTL: Untested

Notes:
The vehicle did not have GPS Lock and was not able to be flown.

Screenshot of Issue
Screen Shot 2019-07-09 at 11 39 50 AM

Log:

Tested on Pixhawk Pro v4:

Modes Tested:

  • Position Mode: Good.
  • Altitude Mode: Good.
  • Stabilized Mode: Good.
  • Mission Plan Mode (Automated): Good.
  • RTL: Good.

Procedure:
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint activate RTL and see landing behaviour.

Notes:
No issues noted, good flight in general.

Logs:

Tested on NXP FMUK66 v3:

Modes Tested:

  • Position Mode: Good.
  • Altitude Mode: Good.
  • Stabilized Mode: Good.
  • Mission Plan Mode (Automated): Good.
  • RTL: Good.

Procedure:
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint activate RTL and see landing behaviour.

Notes:
No issues noted, good flight in general.

Logs:

@dagar
Copy link
Member Author

dagar commented Jul 26, 2019

Added holybro/kakutef7 to the list.

@dagar dagar force-pushed the pr-imu_dma branch 8 times, most recently from 6bc8c50 to b1d6225 Compare August 6, 2019 05:07
@dagar
Copy link
Member Author

dagar commented Oct 7, 2019

This is currently a problem on stm32f7 with the DCACHE and DMA capable check where the SPI transfer buffer is being incorrectly considered non-DMA capable if it's not sized as a cache line multiple.

@dakejahl
Copy link
Contributor

dakejahl commented Oct 9, 2019

Why don't we just add a check to ensure we always allocate the right amount + padding to get us to the multiple of 4 bytes

The SPI transfer can still just use the actual size of the data it wants. i.e

	/*
	 * Fetch the full set of measurements from the MPU9250 in one pass
	 */
	MPUReport *mpu_report = (MPUReport *)_dma_data_buffer;

	if ((!_magnetometer_only || _mag.is_passthrough()) && _register_wait == 0) {
		if (_whoami == MPU_WHOAMI_9250 || _whoami == MPU_WHOAMI_6500) {
			if (OK != read_reg_range(MPUREG_INT_STATUS, MPU9250_HIGH_BUS_SPEED, _dma_data_buffer, sizeof(MPUReport))) {
				perf_end(_sample_perf);
				return;
			}

		}

		check_registers();

		if (check_duplicate(&mpu_report->accel_x[0])) {
			return;
		}
	}

@dagar
Copy link
Member Author

dagar commented Oct 13, 2019

Why don't we just add a check to ensure we always allocate the right amount + padding to get us to the multiple of 4 bytes

The SPI transfer can still just use the actual size of the data it wants. i.e

The problem is the DCACHE alignment check for the buffer end within NuttX.

On stm32f7 spi_exchange() is checking if the buffer is DMA capable.
https://github.com/PX4/NuttX/blob/d8da511082646d83a54c6905daca13f0a1a609f0/arch/arm/src/stm32f7/stm32_spi.c#L1681-L1682

The DMA capable check includes the buffer end.
https://github.com/PX4/NuttX/blob/d8da511082646d83a54c6905daca13f0a1a609f0/arch/arm/src/stm32f7/stm32_dma.c#L928

@dakejahl
Copy link
Contributor

So all DMA spi transfers must be multiples of 4 bytes? That seems wrong.

@dagar
Copy link
Member Author

dagar commented Oct 15, 2019

So all DMA spi transfers must be multiples of 4 bytes? That seems wrong.

Yes, the check in its current form is bogus.

  1. The memory must be DMA capable (not CCM on F4 or DTCM on F7)
  2. On F7 with DCACHE the buffer must be DCACHE aligned (32 bytes) both start and end (we now have writethrough disabled).

One idea David and I have discussed is to change the notion of "DMA capable" within NuttX, possibly similar to the DMA allocator we have in PX4. Then instead of the DMA capable checking memory range, etc it would be based on originating from this particular allocator.

@stale
Copy link

stale bot commented Jan 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Jan 13, 2020
@dagar dagar closed this Jan 22, 2020
@julianoes julianoes deleted the pr-imu_dma branch January 23, 2020 15:57
@julianoes julianoes restored the pr-imu_dma branch January 23, 2020 15:57
@julianoes
Copy link
Contributor

I suppose I should leave these branches around 🤷‍♂️.

@LorenzMeier LorenzMeier deleted the pr-imu_dma branch January 18, 2021 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants