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

Support for RP2040 MCU #18083

Merged
merged 77 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
1f406de
cmake: add NuttX configure depends for dependency glob
dagar May 26, 2021
96eaa44
Add a default.cmake file for the custom hardware myfc and provide onl…
vxj9800 Jul 14, 2021
de02823
Add firmware.prototype file for myfc
vxj9800 Jul 14, 2021
1c9b584
Add necessary compiler flags for arm cortex-m0+, the architecture of …
vxj9800 Jul 14, 2021
6c3d95e
Add necessary compiler flags for arm cortex-m0+, the architecture of …
vxj9800 Jul 14, 2021
0488b3c
Add defconfig file for myfc
vxj9800 Jul 14, 2021
a6b5f6d
Provide basic nuttx configuration parameters
vxj9800 Jul 14, 2021
21a162e
Add script.ld file for myfc
vxj9800 Jul 14, 2021
efccea5
Prepare linker script for rp2040 based myfc
vxj9800 Jul 14, 2021
62ec989
Add CONFIG_ARCH_CHIP_RP2040 to let the build system know which chip i…
vxj9800 Jul 14, 2021
8dfff4c
Add CMakeLists.txt in platforms/nuttx/src/px4/rpi folder and add the …
vxj9800 Jul 14, 2021
e31a2e2
Add a file in the root directory with name addNewChipSupport.md conta…
vxj9800 Jul 14, 2021
ee7cd33
Add a CMakeLists.txt file in PX4-Autopilot/platforms/nuttx/src/px4/rp…
vxj9800 Jul 15, 2021
52b7aba
Create src folder in PX4-Autopilot/boards/myboard/myfc folder and put…
vxj9800 Jul 15, 2021
4f45dec
Update addNewChipSupport.md file
vxj9800 Jul 15, 2021
ba3d6e7
Add board.h in PX4-Autopilot/boards/myboard/myfc/nuttx-config/include…
vxj9800 Jul 15, 2021
6490f37
Copy clocking definitions from nuttx's pi-pico board's board.h file s…
vxj9800 Jul 15, 2021
53fbee7
Add a step in addNewChipSupport.md about copying necessary board.h co…
vxj9800 Jul 15, 2021
f8c47b2
Add board_config.h to provide PX4 side of the configuration information
vxj9800 Jul 15, 2021
ccdb35b
Add micro_hal.h files and add __BEGIN_DECLS to board_config.h
vxj9800 Jul 15, 2021
2cfa410
Add pin_config.c file in the base layer so that the code is not lost
vxj9800 Jul 15, 2021
d1e1e8f
Correct file name in addNewChipSupport.md
vxj9800 Jul 15, 2021
2c2f347
Add an empty function in microhal to avoid errors related to px4_arch…
vxj9800 Jul 16, 2021
67a4f36
Get hrt files from stm32_common and paste in rpi_common to resolve co…
vxj9800 Jul 18, 2021
bb4972c
Update hrt.c file to work with rp2040 and activate hrt in board_config.h
vxj9800 Jul 18, 2021
c2647dc
Copy version folder from stm32_common to rpi_common and update functi…
vxj9800 Jul 18, 2021
c97eeac
Copy board_reset folder from stm32_common to rpi_common and update fu…
vxj9800 Jul 19, 2021
7500312
Copy board_critmon folder from stm32_common to rpi_common and copy bo…
vxj9800 Jul 19, 2021
bc289f3
Modify defconfig to configure nsh on usb
vxj9800 Jul 19, 2021
0e5cd3f
Add init folder whith rc.* files in myfc folder in the hope that the …
vxj9800 Jul 19, 2021
2e8885b
Copy most of defconfig from omnibusf4sd to resolve romfs library erro…
vxj9800 Jul 20, 2021
7285908
Remove CONFIG_BOARD_CRASHDUMP from defconfig to resolve BBSRAM relate…
vxj9800 Jul 20, 2021
0ca25d3
Add rp2040_boardearlyinitialize() function in init.c to resolve funct…
vxj9800 Jul 20, 2021
9537f36
Remove CONFIG_RTC=y from defconfig because nuttx's rp2040 arch doesn'…
vxj9800 Jul 20, 2021
95aef2b
Remove CONFIG_MM_REGIONS=2 from defconfig because nuttx's rp2040 arch…
vxj9800 Jul 20, 2021
ce8a728
Remove addNewChipSupport.md file
vxj9800 Jul 22, 2021
db98f23
Move board_critmon from rp2040 to rpi_common
vxj9800 Jul 22, 2021
563c751
Update micro_hal.h to support px4_arch_gpio macros
vxj9800 Jul 23, 2021
b784c11
Remove defconfig.old file
vxj9800 Jul 23, 2021
2905104
Activate functions in led.c file and rectify errors
vxj9800 Jul 23, 2021
a407f7e
Add i2c by adding i2c.cpp in board/src folder and uncommenting it in …
vxj9800 Jul 23, 2021
2fc41ec
Activate spi in drivers_board with necessary files in px4 base layer
vxj9800 Jul 24, 2021
d1df6d4
Add support for ADC and rectify the errors in SPI implementation
vxj9800 Jul 24, 2021
6aa6e9f
Try to run the binary on device and resolve RP2040_FLASH_BOOT related…
vxj9800 Jul 25, 2021
9b75543
Add files related to px4io_serial
vxj9800 Jul 27, 2021
2464850
Remove the STM32 register definitions from px4io_serial.cpp
vxj9800 Jul 28, 2021
8750fb2
Add the checksum boot string and flash.ld file to allow proper boot-u…
vxj9800 Aug 10, 2021
a314e58
Activate some SYSTEMCMDS in default.cmake
vxj9800 Aug 11, 2021
15c6881
Move macro based implementations of configgpio and gpiosetevent from …
vxj9800 Aug 12, 2021
a853220
Add possible board configuration changes like the ones related to SPI…
vxj9800 Aug 13, 2021
20ecf58
Remove rp2040 specific config variables from defconfig because these …
vxj9800 Aug 17, 2021
d7cfda2
Activate logger module and add BBSRAM related defines to micro_hal an…
vxj9800 Aug 17, 2021
04bcdda
Correct spi.cpp and i2c.cpp files, activate certain things in default…
vxj9800 Aug 17, 2021
116f2bf
Acknowledge hrt interrupt
vxj9800 Aug 18, 2021
095463d
Correct errors in init.c related to spi
vxj9800 Aug 18, 2021
2c63ae7
Stop using cromfs to avoid hardfault and activate work_queue. The pro…
vxj9800 Aug 24, 2021
b95c063
Debug errors with spi and make bmp280 and mpu9250 sensors work
vxj9800 Aug 24, 2021
c10dc57
Activate i2cdetect and make sure i2c is working fine
vxj9800 Aug 25, 2021
73ef95b
Make corrections in led.c and micro_hal.h
vxj9800 Aug 25, 2021
b462272
Activate usb_connected and correct an error in led.c
vxj9800 Aug 25, 2021
925181e
Start working on io_timers by adding files io_timer_hw_description.h …
vxj9800 Aug 26, 2021
b7d6eeb
Add io_timer.c and define necessary register addresses for the timers
vxj9800 Aug 26, 2021
75f72a9
Implement PPM RC input. Testing required.
vxj9800 Aug 26, 2021
333fdaf
Activate valid commands, modules and drivers
vxj9800 Aug 26, 2021
1d68f9c
Use a separate isr for hrt_ppm becaues the gpio based isr call provid…
vxj9800 Aug 27, 2021
d0c8356
Update rp2040_setgpioevent function. Nuttx allows only one type of gp…
vxj9800 Aug 27, 2021
8cb3c5b
Remove hrt_ppm bugs. Testing done.
vxj9800 Aug 27, 2021
3885797
Finish implementing io_timer and pwm_servo. Testing required.
vxj9800 Sep 5, 2021
46942e0
Remove error related to c++ object initialization by adding KEEP in t…
vxj9800 Oct 20, 2021
97813b9
Change the board folder name to something meaningful
vxj9800 Oct 20, 2021
0f38b14
Resolve errors after rebasing the branch
vxj9800 Oct 20, 2021
936033f
Change board folder name
vxj9800 Oct 21, 2021
1296694
Some basic changes in comments of the board files
vxj9800 Oct 22, 2021
3251ebe
Update comments in px4 base layer files
vxj9800 Oct 22, 2021
4cd9632
Merge remote-tracking branch 'px4/master' into rp2040-support
dagar Oct 29, 2021
93bf2e1
raspberry pi pico cleanup
dagar Oct 29, 2021
3202250
add new raspberrypi_pico board to builds
dagar Oct 29, 2021
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
1 change: 1 addition & 0 deletions .ci/Jenkinsfile-compile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pipeline {
"nxp_ucans32k146_canbootloader",
"nxp_ucans32k146_default",
"omnibus_f4sd_default",
"raspberrypi_pico_default",
"px4_fmu-v2_default",
"px4_fmu-v2_fixedwing",
"px4_fmu-v2_multicopter",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/compile_nuttx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
nxp_fmurt1062-v1,
nxp_ucans32k146,
omnibus_f4sd,
raspberrypi_pico,
px4_fmu-v2,
px4_fmu-v3,
px4_fmu-v4,
Expand Down
5 changes: 5 additions & 0 deletions .vscode/cmake-variants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,8 @@ CONFIG:
buildType: MinSizeRel
settings:
CONFIG: nxp_fmuk66-v3_default
raspberrypi_pico_default:
short: raspberrypi_pico
buildType: MinSizeRel
settings:
CONFIG: raspberrypi_pico_default
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@
"workbench.settings.enableNaturalLanguageSearch": false,
"yaml.schemas": {
"${workspaceFolder}/validation/module_schema.yaml": "${workspaceFolder}/src/modules/*/module.yaml"
}
},
"cortex-debug.openocdPath": "${env:PICO_SDK_PATH}/../openocd/src/openocd" // Added for rp2040
}
52 changes: 52 additions & 0 deletions boards/raspberrypi/pico/default.px4board
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
CONFIG_BOARD_TOOLCHAIN="arm-none-eabi"
CONFIG_BOARD_ARCHITECTURE="cortex-m0plus"
CONFIG_BOARD_CONSTRAINED_FLASH=y
CONFIG_BOARD_CONSTRAINED_MEMORY=y
CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS2"
CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS1"
CONFIG_DRIVERS_ADC_BOARD_ADC=y
CONFIG_DRIVERS_BAROMETER_BMP280=y
CONFIG_DRIVERS_GPS=y
CONFIG_DRIVERS_IMU_INVENSENSE_MPU9250=y
CONFIG_DRIVERS_MAGNETOMETER_HMC5883=y
CONFIG_DRIVERS_PWM_OUT=y
CONFIG_DRIVERS_RC_INPUT=y
CONFIG_MODULES_ATTITUDE_ESTIMATOR_Q=y
CONFIG_MODULES_BATTERY_STATUS=y
CONFIG_MODULES_COMMANDER=y
CONFIG_MODULES_DATAMAN=y
CONFIG_MODULES_EKF2=y
CONFIG_MODULES_EVENTS=y
CONFIG_MODULES_FLIGHT_MODE_MANAGER=y
CONFIG_MODULES_GYRO_CALIBRATION=y
CONFIG_MODULES_LAND_DETECTOR=y
CONFIG_MODULES_LOAD_MON=y
CONFIG_MODULES_LOGGER=y
CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y
CONFIG_MODULES_MAVLINK=y
CONFIG_MODULES_MC_ATT_CONTROL=y
CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y
CONFIG_MODULES_MC_POS_CONTROL=y
CONFIG_MODULES_MC_RATE_CONTROL=y
CONFIG_MODULES_NAVIGATOR=y
CONFIG_MODULES_RC_UPDATE=y
CONFIG_MODULES_SENSORS=y
CONFIG_SYSTEMCMDS_DMESG=y
CONFIG_SYSTEMCMDS_DUMPFILE=y
CONFIG_SYSTEMCMDS_ESC_CALIB=y
CONFIG_SYSTEMCMDS_I2CDETECT=y
CONFIG_SYSTEMCMDS_LED_CONTROL=y
CONFIG_SYSTEMCMDS_MIXER=y
CONFIG_SYSTEMCMDS_MOTOR_TEST=y
CONFIG_SYSTEMCMDS_NSHTERM=y
CONFIG_SYSTEMCMDS_PARAM=y
CONFIG_SYSTEMCMDS_PERF=y
CONFIG_SYSTEMCMDS_PWM=y
CONFIG_SYSTEMCMDS_REBOOT=y
CONFIG_SYSTEMCMDS_REFLECT=y
CONFIG_SYSTEMCMDS_TOP=y
CONFIG_SYSTEMCMDS_TUNE_CONTROL=y
CONFIG_SYSTEMCMDS_UORB=y
CONFIG_SYSTEMCMDS_USB_CONNECTED=y
CONFIG_SYSTEMCMDS_VER=y
CONFIG_SYSTEMCMDS_WORK_QUEUE=y
13 changes: 13 additions & 0 deletions boards/raspberrypi/pico/firmware.prototype
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"board_id": 42,
"magic": "RASPBERRYPIPICO",
"description": "Firmware for the raspberry pi Pico board",
"image": "",
"build_time": 0,
"summary": "RaspberrypiPico",
"version": "0.1",
"image_size": 0,
"image_maxsize": 1032192,
"git_identity": "",
"board_revision": 0
}
18 changes: 18 additions & 0 deletions boards/raspberrypi/pico/init/rc.board_defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
#
# board specific defaults
#------------------------------------------------------------------------------

# system_power unavailable
param set-default CBRK_SUPPLY_CHK 894281

# Disable safety switch by default
param set-default CBRK_IO_SAFETY 22027

# use the Q attitude estimator, it works w/o mag or GPS.
# param set-default SYS_MC_EST_GROUP 3
# param set-default ATT_ACC_COMP 0
# param set-default ATT_W_ACC 0.4000
# param set-default ATT_W_GYRO_BIAS 0.0000

# param set-default SYS_HAS_MAG 0
7 changes: 7 additions & 0 deletions boards/raspberrypi/pico/init/rc.board_mavlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
#
# board specific MAVLink startup script.
#------------------------------------------------------------------------------

# Start MAVLink on the USB port
mavlink start -d /dev/ttyACM0
12 changes: 12 additions & 0 deletions boards/raspberrypi/pico/init/rc.board_sensors
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
#
# board specific sensors init
#------------------------------------------------------------------------------

board_adc start

# try starting an mpu9250 IMU on external SPI
mpu9250 start -S

# try starting a bmp280 barometer on external SPI
bmp280 start -S
25 changes: 25 additions & 0 deletions boards/raspberrypi/pico/nuttx-config/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.

config RP2040_FLASH_CHIP
string "flash chip name"
default "w25q080"
---help---
Name of NOR flash device connected to RP2040 SoC.
(Used to choose the secondary boot loader.)
Basically this option should not be changed.

config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
129 changes: 129 additions & 0 deletions boards/raspberrypi/pico/nuttx-config/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/****************************************************************************
*
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/

#ifndef __ARCH_BOARD_BOARD_H
#define __ARCH_BOARD_BOARD_H

/************************************************************************************
* Included Files
************************************************************************************/

#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif

/* Clocking *****************************************************************/

#define MHZ 1000000

#define BOARD_XOSC_FREQ (12 * MHZ)
#define BOARD_PLL_SYS_FREQ (125 * MHZ)
#define BOARD_PLL_USB_FREQ (48 * MHZ)

#define BOARD_REF_FREQ (12 * MHZ)
#define BOARD_SYS_FREQ (125 * MHZ)
#define BOARD_PERI_FREQ (125 * MHZ)
#define BOARD_USB_FREQ (48 * MHZ)
#define BOARD_ADC_FREQ (48 * MHZ)
#define BOARD_RTC_FREQ 46875

#define BOARD_UART_BASEFREQ BOARD_PERI_FREQ

#define BOARD_TICK_CLOCK (1 * MHZ)

/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 2 LEDs on board the
* omnibusf4sd. The following definitions describe how NuttX controls the LEDs:
*/

// #define LED_STARTED 0 /* LED1 */
// #define LED_HEAPALLOCATE 1 /* LED2 */
// #define LED_IRQSENABLED 2 /* LED1 */
// #define LED_STACKCREATED 3 /* LED1 + LED2 */
// #define LED_INIRQ 4 /* LED1 */
// #define LED_SIGNAL 5 /* LED2 */
// #define LED_ASSERTION 6 /* LED1 + LED2 */
// #define LED_PANIC 7 /* LED1 + LED2 */

/* Alternate function pin selections ************************************************/

/*
* UARTs.
* UART0TX: GPIO0
* UART0RX: GPIO1
* UART1TX: GPIO8
* UART1RX: GPIO9
*/
#define CONFIG_RP2040_UART0_GPIO 0 /* TELEM */

#define CONFIG_RP2040_UART1_GPIO 8 /* GPS */

/*
* I2C (external)
*
* I2C1SCL: GPIO7
* I2C1SDA: GPIO6
*
* TODO:
* The optional _GPIO configurations allow the I2C driver to manually
* reset the bus to clear stuck slaves. They match the pin configuration,
* but are normally-high GPIOs.
*/
#define CONFIG_RP2040_I2C1_GPIO 6

/* SPI0:
* SPIDEV_FLASH (probably micro sd card)
* CS: GPIO5 -- should be configured in sec/spi.cpp (probably)
* CLK: GPIO2
* MISO: GPIO4
* MOSI: GPIO3
*/

#define GPIO_SPI0_SCLK ( 2 | GPIO_FUN(RP2040_GPIO_FUNC_SPI) )
#define GPIO_SPI0_MISO ( 4 | GPIO_FUN(RP2040_GPIO_FUNC_SPI) )
#define GPIO_SPI0_MOSI ( 3 | GPIO_FUN(RP2040_GPIO_FUNC_SPI) )

/* SPI1:
* MPU9250 and BMP280
* CS: GPIO13 for MPU9250, GPIO14 for BMP280 -- should be configured in sec/spi.cpp (probably)
* CLK: GPIO10
* MISO: GPIO12
* MOSI: GPIO11
*/

#define GPIO_SPI1_SCLK ( 10 | GPIO_FUN(RP2040_GPIO_FUNC_SPI) )
#define GPIO_SPI1_MISO ( 12 | GPIO_FUN(RP2040_GPIO_FUNC_SPI) )
#define GPIO_SPI1_MOSI ( 11 | GPIO_FUN(RP2040_GPIO_FUNC_SPI) )


#endif /* __ARCH_BOARD_BOARD_H */
Loading