diff --git a/boards/Kconfig b/boards/Kconfig index 5db3570d49..28d583728b 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -1398,6 +1398,14 @@ config ARCH_BOARD_RASPBERRYPI_PICO ---help--- This is a port to the Raspberry Pi Pico board. +config ARCH_BOARD_PIMORONI_TINY2040 + bool "Pimoroni Tiny2040 board" + depends on ARCH_CHIP_RP2040 + ---help--- + This is a port to the Pimoroni Tiny2040 board. + Support is derived from Raspberry Pi Pico support. + STATUS: Work has just began on this port. + config ARCH_BOARD_RX65N bool "RX65N renesas board" depends on ARCH_CHIP_R5F565NEDDFC @@ -2489,6 +2497,7 @@ config ARCH_BOARD default "qemu-i486" if ARCH_BOARD_QEMU_I486 default "intel64-qemu" if ARCH_BOARD_INTEL64_QEMU default "raspberrypi-pico" if ARCH_BOARD_RASPBERRYPI_PICO + default "pimoroni-tiny2040" if ARCH_BOARD_PIMORONI_TINY2040 default "rx65n" if ARCH_BOARD_RX65N default "rx65n-rsk1mb" if ARCH_BOARD_RX65N_RSK1MB default "rx65n-rsk2mb" if ARCH_BOARD_RX65N_RSK2MB @@ -2816,6 +2825,9 @@ endif if ARCH_BOARD_RASPBERRYPI_PICO source "boards/arm/rp2040/raspberrypi-pico/Kconfig" endif +if ARCH_BOARD_PIMORONI_TINY2040 +source "boards/arm/rp2040/pimoroni-tiny2040/Kconfig" +endif if ARCH_BOARD_ARDUINO_DUE source "boards/arm/sam34/arduino-due/Kconfig" endif diff --git a/boards/arm/rp2040/pimoroni-tiny2040/Kconfig b/boards/arm/rp2040/pimoroni-tiny2040/Kconfig new file mode 100644 index 0000000000..5c8bab8ca5 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/Kconfig @@ -0,0 +1,65 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_PIMORONI_TINY2040 + +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. + +config RP2040_UART0_GPIO + int "UART0 GPIO pin assign (0,12,16,28 or -1:no assign)" + default 0 + range -1 29 + depends on RP2040_UART0 + +config RP2040_UART1_GPIO + int "UART1 GPIO pin assign (4,8,20,24 or -1:no assign)" + default -1 + range -1 29 + depends on RP2040_UART1 + +config RP2040_I2C0_GPIO + int "I2C0 GPIO pin assign (0,4,8,12,16,20,24,28 or -1:no assign)" + default -1 + range -1 29 + depends on RP2040_I2C0 + +config RP2040_I2C1_GPIO + int "I2C1 GPIO pin assign (2,6,10,14,18,22,26 or -1:no assign)" + default -1 + range -1 29 + depends on RP2040_I2C1 + +config RP2040_SPI0_GPIO + int "SPI0 GPIO pin assign (0,4,16,20 or -1:no assign)" + default -1 + range -1 29 + depends on RP2040_SPI0 + +config RP2040_SPI1_GPIO + int "SPI1 GPIO pin assign (8,12,24,28 or -1:no assign)" + default -1 + range -1 29 + depends on RP2040_SPI1 + +endif diff --git a/boards/arm/rp2040/pimoroni-tiny2040/README.txt b/boards/arm/rp2040/pimoroni-tiny2040/README.txt new file mode 100644 index 0000000000..04ce9d17b5 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/README.txt @@ -0,0 +1,130 @@ +README +====== + +This directory contains the port of NuttX to the Pimoroni Tiny 2040. +See https://shop.pimoroni.com/products/tiny-2040?variant=39560012234835 +for information about Pimoroni Tiny 2040. + +The Pimoroni Tiny 2040 has two buttons (RESET and BOOT) allowing to boot +from ROM without disconnecting the device. + +Currently only the following devices are supported. + + Supported: + - UART (console port) + - GPIO 0 (UART0 TX) and GPIO 1 (UART0 RX) are used for the console. + - I2C (not tested on Tiny 2040) + - SPI + - DMAC + - USB device + - MSC, CDC/ACM serial and these composite device are supported. + - CDC/ACM serial device can be used for the console. + - PIO (RP2040 Programmable I/O) + - Flash ROM Boot + - SRAM Boot + - If Pico SDK is available, nuttx.uf2 file which can be used in + BOOTSEL mode will be created. + + Not supported: + - All other devices + +Installation +============ + +1. Download Raspberry Pi Pico SDK + + $ git clone -b 1.1.2 https://github.com/raspberrypi/pico-sdk.git + +2. Set PICO_SDK_PATH environment variable + + $ export PICO_SDK_PATH= + +3. Configure and build NuttX + + $ git clone https://github.com/apache/incubator-nuttx.git nuttx + $ git clone https://github.com/apache/incubator-nuttx-apps.git apps + $ cd nuttx + $ make distclean + $ ./tools/configure.sh pimoroni-tiny2040:nsh + $ make V=1 + +4. Connect Pimoroni Tiny 2040 board to USB port. While pressing the + BOOT button, shortly press the RESET button. On releasing the BOOT + button the board boots from internal ROM and will be detected as + USB Mass Storage Device. Then copy "nuttx.uf2" into the device. + (Same manner as the standard Pico SDK applications installation.) + +5. To access the console, GPIO 0 and 1 pins must be connected to the + device such as USB-serial converter. + + `usbnsh` configuration provides the console access by USB CDC/ACM serial + devcice. The console is available by using a terminal software on the USB + host. + +Defconfigs +========== + +- nsh + Minimum configuration with NuttShell + +- nshsram + Load NuttX binary to SRAM + +- smp + Enable SMP mode. Both Core 0 and Core 1 are used by NuttX. + +- spisd + SD card support (SPI connection) + Connection: + SD card slot ----- Pimoroni Tiny 2040 + (Pin 9) DAT2 (NC) + (Pin 1) DAT3/CS ----- GP5 (SPI0 CSn) (Pin 11) + (Pin 2) CMD /DI ----- GP7 (SPI0 TX) (Pin 9) + (Pin 3) VSS ----- GND (Pin 2 or 8) + (Pin 4) VDD ----- 3V3 OUT (Pin 3) + (Pin 5) CLK/SCK ----- GP6 (SPI0 SCK) (Pin 10) + (Pin 6) VSS ----- GND (Pin 2 or 8) + (Pin 7) DAT0/DO ----- GP4 (SPI0 RX) (Pin 12) + (Pin 8) DAT1 (NC) + * Card hot swapping is not supported. + +- usbnsh + USB CDC/ACM serial console with NuttShell + +- usbmsc + USB MSC and CDC/ACM support + `msconn` and `sercon` commands enable the MSC and CDC/ACM devices. + The MSC support provides the interface to the SD card with SPI, + so the SD card slot connection like spisd configuration is required. + +- composite + USB composite device (MSC + CDC/ACM) support + `conn` command enables the composite device. + +- gpio + GPIO driver and example application 'gpio' based on nsh configuration. + Following GPIO are configured in include/board.h: + GPIO18 (out): onboard RGB LED (red) + GPIO19 (out): onboard RGB LED (green) + GPIO20 (out): onboard RGB LED (blue) + GPIO23 (in) : onboard BOOT (USER) button + * No interrupt pin configured. + +License exceptions +================== + +The following files are originated from the files in Pico SDK. +So, the files are licensed under 3-Clause BSD same as Pico SDK. + +- arch/arm/src/rp2040/rp2040_clock.c +- arch/arm/src/rp2040/rp2040_pll.c +- arch/arm/src/rp2040/rp2040_xosc.c + - These are created by referring the Pico SDK clock initialization. + +- arch/arm/src/rp2040/rp2040_pio.c +- arch/arm/src/rp2040/rp2040_pio.h +- arch/arm/src/rp2040/rp2040_pio_instructions.h + - These provide the similar APIs to Pico SDK's hardware_pio APIs. + +- arch/arm/src/rp2040/hardware/*.h + - These are generated from rp2040.svd originally provided in Pico SDK. diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/composite/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/composite/defconfig new file mode 100644 index 0000000000..79781c5dc5 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/composite/defconfig @@ -0,0 +1,75 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_COMPOSITE=y +CONFIG_COMPOSITE_IAD=y +CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS=y +CONFIG_COMPOSITE_PRODUCTID=0x2022 +CONFIG_COMPOSITE_SERIALSTR="12345" +CONFIG_COMPOSITE_VENDORID=0x03eb +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_USBSERIAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MMCSD=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI0_GPIO=4 +CONFIG_RP2040_SPI=y +CONFIG_RP2040_SPISD=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_COMPOSITE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBDEV_COMPOSITE=y +CONFIG_USBMSC=y +CONFIG_USBMSC_COMPOSITE=y +CONFIG_USBMSC_NOT_STALL_BULKEP=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/gpio/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/gpio/defconfig new file mode 100644 index 0000000000..86231fb370 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/gpio/defconfig @@ -0,0 +1,51 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEV_GPIO=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_GPIO=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/nsh/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/nsh/defconfig new file mode 100644 index 0000000000..6518543103 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/nsh/defconfig @@ -0,0 +1,49 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/nshsram/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/nshsram/defconfig new file mode 100644 index 0000000000..e48fb3c815 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/nshsram/defconfig @@ -0,0 +1,49 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_RP2040_FLASH_BOOT is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/smp/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/smp/defconfig new file mode 100644 index 0000000000..5a087a823b --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/smp/defconfig @@ -0,0 +1,55 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SDCLONE_DISABLE=y +CONFIG_SMP=y +CONFIG_SMP_NCPUS=2 +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SYSTEM=y +CONFIG_SYSTEM_TASKSET=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_SMP=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/spisd/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/spisd/defconfig new file mode 100644 index 0000000000..53822fd3f1 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/spisd/defconfig @@ -0,0 +1,61 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MMCSD=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI0_GPIO=4 +CONFIG_RP2040_SPI=y +CONFIG_RP2040_SPISD=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/usbmsc/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/usbmsc/defconfig new file mode 100644 index 0000000000..00d0df5bfa --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/usbmsc/defconfig @@ -0,0 +1,68 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_USBSERIAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MMCSD=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI0_GPIO=4 +CONFIG_RP2040_SPI=y +CONFIG_RP2040_SPISD=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_CDCACM=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_SYSTEM_USBMSC=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBMSC=y +CONFIG_USBMSC_NOT_STALL_BULKEP=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/configs/usbnsh/defconfig b/boards/arm/rp2040/pimoroni-tiny2040/configs/usbnsh/defconfig new file mode 100644 index 0000000000..7cf9836b67 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/configs/usbnsh/defconfig @@ -0,0 +1,53 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DEV_CONSOLE is not set +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_RP2040_UART0 is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pimoroni-tiny2040" +CONFIG_ARCH_BOARD_PIMORONI_TINY2040=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_CONSOLE=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_NSH_USBCONSOLE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=11 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y diff --git a/boards/arm/rp2040/pimoroni-tiny2040/include/board.h b/boards/arm/rp2040/pimoroni-tiny2040/include/board.h new file mode 100644 index 0000000000..8931e45b82 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/include/board.h @@ -0,0 +1,121 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/include/board.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_BOARD_H +#define __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "rp2040_i2cdev.h" +#include "rp2040_spidev.h" +#include "rp2040_i2sdev.h" + +#include "rp2040_spisd.h" + +#ifndef __ASSEMBLY__ +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* 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) + +/* GPIO definitions *********************************************************/ + +#define BOARD_GPIO_LED_PIN_R 18 +#define BOARD_GPIO_LED_PIN_G 19 +#define BOARD_GPIO_LED_PIN_B 20 + +#define BOARD_GPIO_BOOT_PIN 23 + +#define BOARD_NGPIOOUT 3 +#define BOARD_NGPIOIN 1 +#define BOARD_NGPIOINT 0 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_boardearlyinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardearlyinitialize(void); + +/**************************************************************************** + * Name: rp2040_boardinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardinitialize(void); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_BOARD_H */ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2cdev.h b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2cdev.h new file mode 100644 index 0000000000..9a68ff8d59 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2cdev.h @@ -0,0 +1,75 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2cdev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_I2CDEV_H +#define __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_I2CDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifndef __ASSEMBLY__ +# include +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_i2cdev_initialize + * + * Description: + * Initialize i2c driver and register the /dev/i2c device. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_I2C_DRIVER +int board_i2cdev_initialize(int bus); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_I2CDEV_H */ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2sdev.h b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2sdev.h new file mode 100644 index 0000000000..a525ee81ca --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2sdev.h @@ -0,0 +1,75 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_i2sdev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_I2SDEV_H +#define __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_I2SDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifndef __ASSEMBLY__ +# include +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_i2sdev_initialize + * + * Description: + * Initialize i2s driver and register the /dev/audio/pcm0 device. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_I2S +int board_i2sdev_initialize(int bus); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_I2SDEV_H */ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spidev.h b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spidev.h new file mode 100644 index 0000000000..9ac312ecbf --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spidev.h @@ -0,0 +1,69 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spidev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_SPIDEV_H +#define __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_SPIDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_spidev_initialize + * + * Description: + * Initialize spi driver and register the /dev/spi device. + * + ****************************************************************************/ + +int board_spidev_initialize(int bus); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_SPIDEV_H */ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spisd.h b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spisd.h new file mode 100644 index 0000000000..183b35f6ea --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spisd.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/include/rp2040_spisd.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_SPISD_H +#define __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_SPISD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_spisd_initialize + * + * Description: + * Initialize the SPI-based SD card. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_SPISD +int board_spisd_initialize(int minor, int bus); +#endif + +/**************************************************************************** + * Name: board_spisd_status + * + * Description: + * Get the status whether SD Card is present or not. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_SPISD +uint8_t board_spisd_status(FAR struct spi_dev_s *dev, uint32_t devid); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_PIMORONI_TINY2040_INCLUDE_RP2040_SPISD_H */ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs b/boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs new file mode 100644 index 0000000000..0139eb4e53 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs @@ -0,0 +1,65 @@ +############################################################################ +# boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/tools/rp2040/Config.mk +include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs + +ifeq ($(CONFIG_RP2040_FLASH_BOOT),y) + LDSCRIPT = pimoroni-tiny2040-flash.ld +else + LDSCRIPT = pimoroni-tiny2040-sram.ld +endif + +ifeq ($(CONFIG_CYGWIN_WINTOOL),y) + ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}" +else + ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif diff --git a/boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-flash.ld b/boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-flash.ld new file mode 100644 index 0000000000..278777d5de --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-flash.ld @@ -0,0 +1,112 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-flash.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +MEMORY +{ + flash (rx) : ORIGIN = 0x10000000, LENGTH = 8192K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 264K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .flash_begin : { + __flash_binary_start = .; + } > flash + + .boot2 : { + __boot2_start__ = .; + KEEP (*(.boot2)) + __boot2_end__ = .; + } > flash + + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .ram_vectors (COPY) : { + *(.ram_vectors) + } > sram + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-sram.ld b/boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-sram.ld new file mode 100644 index 0000000000..bd69cdfe23 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-sram.ld @@ -0,0 +1,97 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/scripts/pimoroni-tiny2040-sram.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +MEMORY +{ + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 264K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + rp2040_start.o(.text) + . = ALIGN(256); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > sram + + .init_section : { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > sram + + .ARM.extab : { + *(.ARM.extab*) + } > sram + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > sram + __exidx_end = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/Make.defs b/boards/arm/rp2040/pimoroni-tiny2040/src/Make.defs new file mode 100644 index 0000000000..5c2b70fc97 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/Make.defs @@ -0,0 +1,41 @@ +############################################################################ +# boards/arm/rp2040/pimoroni-tiny2040/src/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = rp2040_boardinitialize.c +CSRCS += rp2040_appinit.c +CSRCS += rp2040_bringup.c + +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += rp2040_reset.c +endif + +ifeq ($(CONFIG_SPI),y) +CSRCS += rp2040_spi.c +endif + +ifeq ($(CONFIG_DEV_GPIO),y) +CSRCS += rp2040_gpio.c +endif + +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board) diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_appinit.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_appinit.c new file mode 100644 index 0000000000..1c5383af24 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_appinit.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_appinit.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "rp2040_tiny2040.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef OK +# define OK 0 +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return rp2040_bringup(); +#endif +} diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c new file mode 100644 index 0000000000..714e43534a --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c @@ -0,0 +1,175 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "rp2040_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_boardearlyinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardearlyinitialize(void) +{ + rp2040_gpio_initialize(); + + /* Disable IE on GPIO 26-29 */ + + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(26)); + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(27)); + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(28)); + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(29)); + + /* Set all board RGB LED pins to HIGH: + * LEDs turned off (driven from external pull-up) + */ + + rp2040_gpio_init(BOARD_GPIO_LED_PIN_R); + rp2040_gpio_setdir(BOARD_GPIO_LED_PIN_R, true); + rp2040_gpio_put(BOARD_GPIO_LED_PIN_R, true); + + rp2040_gpio_init(BOARD_GPIO_LED_PIN_G); + rp2040_gpio_setdir(BOARD_GPIO_LED_PIN_G, true); + rp2040_gpio_put(BOARD_GPIO_LED_PIN_G, true); + + rp2040_gpio_init(BOARD_GPIO_LED_PIN_B); + rp2040_gpio_setdir(BOARD_GPIO_LED_PIN_B, true); + rp2040_gpio_put(BOARD_GPIO_LED_PIN_B, true); + + /* Set default UART pin */ + +#if defined(CONFIG_RP2040_UART0) && CONFIG_RP2040_UART0_GPIO >= 0 + rp2040_gpio_set_function(CONFIG_RP2040_UART0_GPIO, + RP2040_GPIO_FUNC_UART); /* TX */ + rp2040_gpio_set_function(CONFIG_RP2040_UART0_GPIO + 1, + RP2040_GPIO_FUNC_UART); /* RX */ +#ifdef CONFIG_SERIAL_OFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART0_GPIO + 2, + RP2040_GPIO_FUNC_UART); /* CTS */ +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART0_GPIO + 3, + RP2040_GPIO_FUNC_UART); /* RTS */ +#endif +#endif + +#if defined(CONFIG_RP2040_UART1) && CONFIG_RP2040_UART1_GPIO >= 0 + rp2040_gpio_set_function(CONFIG_RP2040_UART1_GPIO, + RP2040_GPIO_FUNC_UART); /* TX */ + rp2040_gpio_set_function(CONFIG_RP2040_UART1_GPIO + 1, + RP2040_GPIO_FUNC_UART); /* RX */ +#ifdef CONFIG_SERIAL_OFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART1_GPIO + 2, + RP2040_GPIO_FUNC_UART); /* CTS */ +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART1_GPIO + 3, + RP2040_GPIO_FUNC_UART); /* RTS */ +#endif +#endif +} + +/**************************************************************************** + * Name: rp2040_boardinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardinitialize(void) +{ + /* Set default I2C pin */ + +#if defined(CONFIG_RP2040_I2C0) && CONFIG_RP2040_I2C0_GPIO >= 0 + rp2040_gpio_set_function(CONFIG_RP2040_I2C0_GPIO, + RP2040_GPIO_FUNC_I2C); /* SDA */ + rp2040_gpio_set_function(CONFIG_RP2040_I2C0_GPIO + 1, + RP2040_GPIO_FUNC_I2C); /* SCL */ + + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_GPIO, true, false); /* Pull up */ + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_GPIO + 1, true, false); +#endif + +#if defined(CONFIG_RP2040_I2C1) && CONFIG_RP2040_I2C1_GPIO >= 0 + rp2040_gpio_set_function(CONFIG_RP2040_I2C1_GPIO, + RP2040_GPIO_FUNC_I2C); /* SDA */ + rp2040_gpio_set_function(CONFIG_RP2040_I2C1_GPIO + 1, + RP2040_GPIO_FUNC_I2C); /* SCL */ + + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_GPIO, true, false); /* Pull up */ + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_GPIO + 1, true, false); +#endif + + /* Set default SPI pin */ + +#if defined(CONFIG_RP2040_SPI0) && CONFIG_RP2040_SPI0_GPIO >= 0 + rp2040_gpio_set_function(CONFIG_RP2040_SPI0_GPIO, + RP2040_GPIO_FUNC_SPI); /* RX */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI0_GPIO + 2, + RP2040_GPIO_FUNC_SPI); /* SCK */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI0_GPIO + 3, + RP2040_GPIO_FUNC_SPI); /* TX */ + + /* CSn is controlled by board-specific logic */ + + rp2040_gpio_init(CONFIG_RP2040_SPI0_GPIO + 1); /* CSn */ + rp2040_gpio_setdir(CONFIG_RP2040_SPI0_GPIO + 1, true); + rp2040_gpio_put(CONFIG_RP2040_SPI0_GPIO + 1, true); +#endif + +#if defined(CONFIG_RP2040_SPI1) && CONFIG_RP2040_SPI1_GPIO >= 0 + rp2040_gpio_set_function(CONFIG_RP2040_SPI1_GPIO, + RP2040_GPIO_FUNC_SPI); /* RX */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI1_GPIO + 2, + RP2040_GPIO_FUNC_SPI); /* SCK */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI1_GPIO + 3, + RP2040_GPIO_FUNC_SPI); /* TX */ + + /* CSn is controlled by board-specific logic */ + + rp2040_gpio_init(CONFIG_RP2040_SPI1_GPIO + 1); /* CSn */ + rp2040_gpio_setdir(CONFIG_RP2040_SPI1_GPIO + 1, true); + rp2040_gpio_put(CONFIG_RP2040_SPI1_GPIO + 1, true); +#endif +} diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c new file mode 100644 index 0000000000..755dfb9241 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c @@ -0,0 +1,123 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include + +#include "rp2040_tiny2040.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_bringup + ****************************************************************************/ + +int rp2040_bringup(void) +{ + int ret = 0; + +#ifdef CONFIG_RP2040_I2C_DRIVER + #ifdef CONFIG_RP2040_I2C0 + ret = board_i2cdev_initialize(0); + if (ret < 0) + { + _err("ERROR: Failed to initialize I2C0.\n"); + } + #endif + + #ifdef CONFIG_RP2040_I2C1 + ret = board_i2cdev_initialize(1); + if (ret < 0) + { + _err("ERROR: Failed to initialize I2C1.\n"); + } + #endif +#endif + +#ifdef CONFIG_RP2040_SPI_DRIVER + #ifdef CONFIG_RP2040_SPI0 + ret = board_spidev_initialize(0); + if (ret < 0) + { + _err("ERROR: Failed to initialize SPI0.\n"); + } + #endif + + #ifdef CONFIG_RP2040_SPI1 + ret = board_spidev_initialize(1); + if (ret < 0) + { + _err("ERROR: Failed to initialize SPI1.\n"); + } + #endif +#endif + +#ifdef CONFIG_RP2040_SPISD + /* Mount the SPI-based MMC/SD block driver */ + + ret = board_spisd_initialize(0, CONFIG_RP2040_SPISD_SPI_CH); + if (ret < 0) + { + _err("ERROR: Failed to initialize SPI device to MMC/SD: %d\n", + ret); + } +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); + } +#endif + +#ifdef CONFIG_RP2040_I2S + ret = board_i2sdev_initialize(0); + if (ret < 0) + { + _err("ERROR: Failed to initialize I2S.\n"); + } +#endif + +#ifdef CONFIG_DEV_GPIO + ret = rp2040_dev_gpio_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); + return ret; + } +#endif + + return ret; +} diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_gpio.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_gpio.c new file mode 100644 index 0000000000..dc3c346d12 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_gpio.c @@ -0,0 +1,404 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_gpio.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "arm_arch.h" +#include "chip.h" +#include "rp2040_gpio.h" + +#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF) + +/* Output pins: + * GPIO18/19/20 in an onboard RGB LED any other outputs could be used. + */ + +#define GPIO_OUT1 BOARD_GPIO_LED_PIN_R +#define GPIO_OUT2 BOARD_GPIO_LED_PIN_G +#define GPIO_OUT3 BOARD_GPIO_LED_PIN_B + +/* Input pins: + * GPIO23 in connected to BOOT/USER button any other inputs could be used. + */ + +#define GPIO_IN1 BOARD_GPIO_BOOT_PIN + +/* Interrupt pins: + * None configured + */ + +#define GPIO_IRQPIN1 -1 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct rp2040gpio_dev_s +{ + struct gpio_dev_s gpio; + uint8_t id; +}; + +struct rp2040gpint_dev_s +{ + struct rp2040gpio_dev_s rp2040gpio; + pin_interrupt_t callback; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); +static int gpout_write(FAR struct gpio_dev_s *dev, bool value); +#endif + +#if BOARD_NGPIOIN > 0 +static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value); +#endif + +#if BOARD_NGPIOINT > 0 +static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value); +static int gpint_attach(FAR struct gpio_dev_s *dev, + pin_interrupt_t callback); +static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static const struct gpio_operations_s gpout_ops = +{ + .go_read = gpout_read, + .go_write = gpout_write, + .go_attach = NULL, + .go_enable = NULL, +}; + +/* This array maps the GPIO pins used as OUTPUT */ + +static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] = +{ + GPIO_OUT1, + GPIO_OUT2, + GPIO_OUT3 +}; + +static struct rp2040gpio_dev_s g_gpout[BOARD_NGPIOOUT]; +#endif + +#if BOARD_NGPIOIN > 0 +static const struct gpio_operations_s gpin_ops = +{ + .go_read = gpin_read, + .go_write = NULL, + .go_attach = NULL, + .go_enable = NULL, +}; + +/* This array maps the GPIO pins used as INPUT */ + +static const uint32_t g_gpioinputs[BOARD_NGPIOIN] = +{ + GPIO_IN1 +}; + +static struct rp2040gpio_dev_s g_gpin[BOARD_NGPIOIN]; +#endif + +#if BOARD_NGPIOINT > 0 +static const struct gpio_operations_s gpint_ops = +{ + .go_read = gpint_read, + .go_write = NULL, + .go_attach = gpint_attach, + .go_enable = gpint_enable, +}; + +/* This array maps the GPIO pins used as INTERRUPT INPUT */ + +static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = +{ + GPIO_IRQPIN1, +}; + +static struct rp2040gpint_dev_s g_gpint[BOARD_NGPIOINT]; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gpout_read + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +{ + FAR struct rp2040gpio_dev_s *rp2040gpio = + (FAR struct rp2040gpio_dev_s *)dev; + + DEBUGASSERT(rp2040gpio != NULL && value != NULL); + DEBUGASSERT(rp2040gpio->id < BOARD_NGPIOOUT); + gpioinfo("Reading...\n"); + + *value = rp2040_gpio_get(g_gpiooutputs[rp2040gpio->id]); + return OK; +} + +/**************************************************************************** + * Name: gpout_write + ****************************************************************************/ + +static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +{ + FAR struct rp2040gpio_dev_s *rp2040gpio = + (FAR struct rp2040gpio_dev_s *)dev; + + DEBUGASSERT(rp2040gpio != NULL); + DEBUGASSERT(rp2040gpio->id < BOARD_NGPIOOUT); + gpioinfo("Writing %d\n", (int)value); + + rp2040_gpio_put(g_gpiooutputs[rp2040gpio->id], value); + return OK; +} +#endif + +/**************************************************************************** + * Name: gpin_read + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 +static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) +{ + FAR struct rp2040gpio_dev_s *rp2040gpio = + (FAR struct rp2040gpio_dev_s *)dev; + + DEBUGASSERT(rp2040gpio != NULL && value != NULL); + DEBUGASSERT(rp2040gpio->id < BOARD_NGPIOIN); + gpioinfo("Reading... pin %d\n", (int)g_gpioinputs[rp2040gpio->id]); + + *value = rp2040_gpio_get(g_gpioinputs[rp2040gpio->id]); + return OK; +} +#endif + +/**************************************************************************** + * Name: rp2040gpio_interrupt + ****************************************************************************/ + +#if BOARD_NGPIOINT > 0 +static int rp2040gpio_interrupt(int irq, void *context, void *arg) +{ + FAR struct rp2040gpint_dev_s *rp2040gpint = + (FAR struct rp2040gpint_dev_s *)arg; + + DEBUGASSERT(rp2040gpint != NULL && rp2040gpint->callback != NULL); + gpioinfo("Interrupt! callback=%p\n", rp2040gpint->callback); + + rp2040gpint->callback(&rp2040gpint->rp2040gpio.gpio, + rp2040gpint->rp2040gpio.id); + return OK; +} + +/**************************************************************************** + * Name: gpint_read + ****************************************************************************/ + +static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) +{ + FAR struct rp2040gpint_dev_s *rp2040gpint = + (FAR struct rp2040gpint_dev_s *)dev; + + DEBUGASSERT(rp2040gpint != NULL && value != NULL); + DEBUGASSERT(rp2040gpint->rp2040gpio.id < BOARD_NGPIOINT); + gpioinfo("Reading int pin...\n"); + + *value = rp2040_gpio_get(g_gpiointinputs[rp2040gpint->rp2040gpio.id]); + return OK; +} + +/**************************************************************************** + * Name: gpint_attach + ****************************************************************************/ + +static int gpint_attach(FAR struct gpio_dev_s *dev, + pin_interrupt_t callback) +{ + FAR struct rp2040gpint_dev_s *rp2040gpint = + (FAR struct rp2040gpint_dev_s *)dev; + int irq = g_gpiointinputs[rp2040gpint->rp2040gpio.id]; + int ret; + + gpioinfo("Attaching the callback\n"); + + /* Make sure the interrupt is disabled */ + + rp2040_gpio_disable_irq(irq); + ret = rp2040_gpio_irq_attach(irq, + RP2040_GPIO_INTR_EDGE_LOW, + rp2040gpio_interrupt, + &g_gpint[rp2040gpint->rp2040gpio.id]); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: gpint_attach() failed: %d\n", ret); + return ret; + } + + gpioinfo("Attach %p\n", callback); + rp2040gpint->callback = callback; + return OK; +} + +/**************************************************************************** + * Name: gpint_enable + ****************************************************************************/ + +static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +{ + FAR struct rp2040gpint_dev_s *rp2040gpint = + (FAR struct rp2040gpint_dev_s *)dev; + int irq = g_gpiointinputs[rp2040gpint->rp2040gpio.id]; + + if (enable) + { + if (rp2040gpint->callback != NULL) + { + gpioinfo("Enabling the interrupt\n"); + + /* Configure the interrupt for rising edge */ + + rp2040_gpio_enable_irq(irq); + } + } + else + { + gpioinfo("Disable the interrupt\n"); + rp2040_gpio_disable_irq(irq); + } + + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_dev_gpio_init + ****************************************************************************/ + +int rp2040_dev_gpio_init(void) +{ + int i; + int pincount = 0; + +#if BOARD_NGPIOOUT > 0 + for (i = 0; i < BOARD_NGPIOOUT; i++) + { + /* Setup and register the GPIO pin */ + + g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN; + g_gpout[i].gpio.gp_ops = &gpout_ops; + g_gpout[i].id = i; + gpio_pin_register(&g_gpout[i].gpio, g_gpiooutputs[i]); + + /* Configure the pins that will be used as output */ + + rp2040_gpio_init(g_gpiooutputs[i]); + rp2040_gpio_setdir(g_gpiooutputs[i], true); + + /* Set board RGB LED pins to HIGH: + * LEDs off (driven from ext. pull-up) + */ + + rp2040_gpio_put(g_gpiooutputs[i], true); + + pincount++; + } +#endif + + pincount = 0; + +#if BOARD_NGPIOIN > 0 + for (i = 0; i < BOARD_NGPIOIN; i++) + { + /* Setup and register the GPIO pin */ + + g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN; + g_gpin[i].gpio.gp_ops = &gpin_ops; + g_gpin[i].id = i; + gpio_pin_register(&g_gpin[i].gpio, g_gpioinputs[i]); + + /* Configure the pins that will be used as INPUT */ + + rp2040_gpio_init(g_gpioinputs[i]); + + pincount++; + } +#endif + + pincount = 0; + +#if BOARD_NGPIOINT > 0 + for (i = 0; i < BOARD_NGPIOINT; i++) + { + /* Setup and register the GPIO pin */ + + g_gpint[i].rp2040gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN; + g_gpint[i].rp2040gpio.gpio.gp_ops = &gpint_ops; + g_gpint[i].rp2040gpio.id = i; + gpio_pin_register(&g_gpint[i].rp2040gpio.gpio, g_gpiointinputs[i]); + + /* Configure the pins that will be used as interrupt input */ + + rp2040_gpio_init(g_gpiointinputs[i]); + + /* pull-up = false : pull-down = true */ + + rp2040_gpio_set_pulls(g_gpiointinputs[i], false, true); + + pincount++; + } +#endif + + return OK; +} +#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_reset.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_reset.c new file mode 100644 index 0000000000..36ccfe89c1 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_reset.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_reset.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_spi.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_spi.c new file mode 100644 index 0000000000..70d167989d --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_spi.c @@ -0,0 +1,124 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_spi.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "arm_arch.h" +#include "chip.h" +#include "rp2040_gpio.h" +#include "hardware/rp2040_spi.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_spi0/1select and rp2040_spi0/1status + * + * Description: + * The external functions, rp2040_spi0/1select and rp2040_spi0/1status + * must be provided by board-specific logic. + * They are implementations of the select and status methods of the SPI + * interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h). + * All other methods (including rp2040_spibus_initialize()) are provided by + * common RP2040 logic. To use this common SPI logic on your board: + * + * 1. Provide logic in rp2040_boardinitialize() to configure SPI chip + * select pins. + * 2. Provide rp2040_spi0/1select() and rp2040_spi0/1status() + * functions in your board-specific logic. + * These functions will perform chip selection and status operations + * using GPIOs in the way your board is configured. + * 3. Add a calls to rp2040_spibus_initialize() in your low level + * application initialization logic + * 4. The handle returned by rp2040_spibus_initialize() may then be used to + * bind the SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_SPI0 +void rp2040_spi0select(FAR struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %d CS: %s\n", (int)devid, + selected ? "assert" : "de-assert"); + + rp2040_gpio_put(CONFIG_RP2040_SPI0_GPIO + 1, !selected); +} + +uint8_t rp2040_spi0status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t ret = 0; + +# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 0) + ret = board_spisd_status(dev, devid); +# endif + return ret; +} + +#ifdef CONFIG_SPI_CMDDATA +int rp2040_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + return -ENODEV; +} +#endif +#endif + +#ifdef CONFIG_RP2040_SPI1 +void rp2040_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %d CS: %s\n", (int)devid, + selected ? "assert" : "de-assert"); + + rp2040_gpio_put(CONFIG_RP2040_SPI1_GPIO + 1, !selected); +} + +uint8_t rp2040_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t ret = 0; + +# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 1) + ret = board_spisd_status(dev, devid); +# endif + return ret; +} + +#ifdef CONFIG_SPI_CMDDATA +int rp2040_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + return -ENODEV; +} +#endif +#endif diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_tiny2040.h b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_tiny2040.h new file mode 100644 index 0000000000..259b39b23b --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_tiny2040.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_tiny2040.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_PIMORONI_TINY2040_SRC_RP2040_TINY2040_H +#define __BOARDS_ARM_RP2040_PIMORONI_TINY2040_SRC_RP2040_TINY2040_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +int rp2040_bringup(void); + +#ifdef CONFIG_DEV_GPIO +int rp2040_dev_gpio_init(void); +#endif + +#endif /* __BOARDS_ARM_RP2040_PIMORONI_TINY2040_SRC_RP2040_TINY2040_H */