diff --git a/boards/sparkfun/micromod/doc/index.rst b/boards/sparkfun/micromod/doc/index.rst index 507ef52e42688..4d7c6bda72413 100644 --- a/boards/sparkfun/micromod/doc/index.rst +++ b/boards/sparkfun/micromod/doc/index.rst @@ -1,4 +1,4 @@ -.. _boardname_linkname: +.. _sparkfun_micromod: SparkFun MicroMod board Processor ################################# diff --git a/boards/sparkfun/samd21_dev_breakout/Kconfig.sparkfun_samd21_breakout b/boards/sparkfun/samd21_dev_breakout/Kconfig.sparkfun_samd21_breakout new file mode 100644 index 0000000000000..eabd0a616bd53 --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/Kconfig.sparkfun_samd21_breakout @@ -0,0 +1,5 @@ +# Copyright The Zephyr Project Contributors +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_SPARKFUN_SAMD21_BREAKOUT + select SOC_SAMD21G18A diff --git a/boards/sparkfun/samd21_dev_breakout/board.cmake b/boards/sparkfun/samd21_dev_breakout/board.cmake new file mode 100644 index 0000000000000..54ba64c75e339 --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/board.cmake @@ -0,0 +1,6 @@ + +# SPDX-License-Identifier: Apache-2.0 + +include(${ZEPHYR_BASE}/boards/common/bossac.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) diff --git a/boards/sparkfun/samd21_dev_breakout/board.yml b/boards/sparkfun/samd21_dev_breakout/board.yml new file mode 100644 index 0000000000000..07937a872d10f --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/board.yml @@ -0,0 +1,6 @@ +board: + name: sparkfun_samd21_breakout + full_name: Sparkfun SAMD21 Dev Breakout + vendor: sparkfun + socs: + - name: samd21g18a diff --git a/boards/sparkfun/samd21_dev_breakout/doc/img/sparkfun_samd21_breakout.webp b/boards/sparkfun/samd21_dev_breakout/doc/img/sparkfun_samd21_breakout.webp new file mode 100644 index 0000000000000..c9865aaf85c86 Binary files /dev/null and b/boards/sparkfun/samd21_dev_breakout/doc/img/sparkfun_samd21_breakout.webp differ diff --git a/boards/sparkfun/samd21_dev_breakout/doc/index.rst b/boards/sparkfun/samd21_dev_breakout/doc/index.rst new file mode 100644 index 0000000000000..84757c0ef1975 --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/doc/index.rst @@ -0,0 +1,139 @@ +.. zephyr:board:: sparkfun_samd21_breakout + +Overview +******** + +The SparkFun SAMD21 dev breakout board is an arduino form factor development board. +Designed to be a more powerful arduino. It shares the arduino form factor and gpio +footprint. Based on the ATSAMD21G18 MCU, it runs a 32-Bit Arm Cortex-M0+ at up to 48MHz. +More information can be found on the `SAMD21 dev breakout specification website`_. + +Hardware +******** + +- ATSAMD21G18 32-bit/48MHz ARM Cortex-M0+ +- 256KB Flash Memory +- 32KB SRAM +- 32KB of EEPROM (emulated in Flash) +- 30 GPIO Count with Arduino R3 footprint + +- 6x Configurable SERCOM ports + + - USART with full-duplex and single-wire half-duplex configuration + - I2C up to 3.4 MHz + - SPI + - LIN client + +- One 12-bit, 350ksps Analog-to-Digital Converter (ADC) with up to 20 channels + + - Differential and single-ended input + - 1/2x to 16x programmable gain stage + - Automatic offset and gain error compensation + - Oversampling and decimation in hardware to support 13-bit, 14-bit, 15-bit, or 16-bit resolution + +- One two-channel Inter-IC Sound (I2S) interface +- 32-bit Real Time Counter (RTC) with clock/calendar function +- Watchdog Timer (WDT) +- CRC-32 generator + +- One full-speed (12 Mbps) Universal Serial Bus (USB) 2.0 interface + + - Embedded host and device function + - Eight endpoint + +Supported Features +================== + +.. zephyr::board-supported-hw:: + +Connections and IOs +=================== + +LED +--- + +* Led0 (blue) = D13 + +Serial IO +--------- + +* sparkfun_spi = sercom4 +* sparkfun_i2c = sercom3 +* sparkfun_serial = sercom0 +* sparkfun_dac = dac0 +* sparkfun_adc = adc + +Programming and Debugging +************************* + +.. zephyr:board-supported-runners:: + +Applications for the ``sparkfun_samd21_breakout/samd21g18a`` board target can be +built, flashed, and debugged in the usual way. See +:ref:`build_an_application` and :ref:`application_run` for more details on +building and running. + +Flashing +======== + +To enter flash mode, connect the board via the micro USB to the host, press the +reset button twice. The onboard blue led should slowly fade, indicating flash mode. + +Flashing Application +******************** +This board utilizes the UF2 bootloader, which flashes firmware via uploaded a file +to board via mass-storage device. See `uf2-samdx1 bootloader info`_. + + +Flashing Bootloader +******************* +If flashing the bootloader you can use a Jeff Probe/Black Magic Debugger to connect +via SWD. Note this can also be used to recover a bricked board. Bootloader source +code repo is available at: `uf2-samdx1 bootloader repo`_. + +Build bootloader for sparkfun samd21 dev board: + +.. code-block:: console + + git clone https://github.com/adafruit/uf2-samdx1 + cd uf2-samdx1 + make BOARD=sparkfun-samd21-dev + +Place commands to flash bootloader into a ``gdb_init`` file: + +.. code-block:: console + + target extended-remote /dev/ttyACM # check in dmesg + monitor swdp_scan # make sure this works too, cable could be upside down + attach 1 + load + +Connect the debug probe and run: + +.. code-block:: console + + # Run gdb with your gdb_init script: + arm-none-eabi-gdb bootloader-sparkfun-samd21-dev-.elf -x gdb_init + +Debugging +========= +Using the Jeff Probe/Black Magic Debugger, you can connect SWD and run gdb +through the serial connection. See above for example instructions for flashing the bootloader. +Otherwise, use west to debug. + +Debug with west: + +.. code-block:: console + + west debug -r blackmagicprobe + + +References +********** + +.. target-notes:: + + +.. _SAMD21 dev breakout specification website: https://www.sparkfun.com/sparkfun-samd21-dev-breakout.html +.. _uf2-samdx1 bootloader repo: https://github.com/adafruit/uf2-samdx1 +.. _uf2-samdx1 bootloader info: https://learn.sparkfun.com/tutorials/arm-programming/bootloaders diff --git a/boards/sparkfun/samd21_dev_breakout/pre_dt_board.cmake b/boards/sparkfun/samd21_dev_breakout/pre_dt_board.cmake new file mode 100644 index 0000000000000..641b50c5cd2bc --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/pre_dt_board.cmake @@ -0,0 +1,7 @@ +# Copyright The Zephyr Project Contributors +# SPDX-License-Identifier: Apache-2.0 + +# Suppress "unique_unit_address_if_enabled" to handle the following overlaps: +# - /soc/pinmux@41004400 & /soc/gpio@41004400 +# - /soc/pinmux@41004480 & /soc/gpio@41004480 +list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled") diff --git a/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout-pinctrl.dtsi b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout-pinctrl.dtsi new file mode 100644 index 0000000000000..88a67f3218fe3 --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout-pinctrl.dtsi @@ -0,0 +1,43 @@ +/* + * Copyright The Zephyr Project Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +&pinctrl { + dac_default: dac_default { + group1 { + pinmux = ; + }; + }; + + sercom3_i2c_default: sercom3_i2c_default { + group1 { + pinmux = , + ; + }; + }; + + sercom4_spi_default: sercom4_spi_default { + group1 { + pinmux = , + , + ; + }; + }; + + sercom0_uart_default: sercom0_uart_default { + group1 { + pinmux = , + ; + }; + }; + + usb_dc_default: usb_dc_default { + group1 { + pinmux = , + ; + }; + }; +}; diff --git a/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout.dts b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout.dts new file mode 100644 index 0000000000000..d4a7be2cf962d --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout.dts @@ -0,0 +1,131 @@ +/* + * Copyright The Zephyr Project Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include +#include "sparkfun_samd21_breakout-pinctrl.dtsi" +#include "sparkfun_samd21_breakout_connector.dtsi" + +/ { + model = "Sparkfun SAMD21 Dev Breakout"; + compatible = "sparkfun,samd21"; + + chosen { + zephyr,console = &sercom0; + zephyr,shell-uart = &sercom0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,i2c = &sercom3; + zephyr,code-partition = &code_partition; + }; + + leds { + compatible = "gpio-leds"; + + led: led_0 { + gpios = <&porta 17 GPIO_ACTIVE_HIGH>; // d13 + label = "LED"; + }; + + rx_led: led_1 { + gpios = <&portb 3 GPIO_ACTIVE_LOW>; + label = "RX_LED"; + }; + + tx_led: led_2 { + gpios = <&porta 27 GPIO_ACTIVE_LOW>; + label = "TX_LED"; + }; + }; + + /* These aliases are provided for compatibility with samples */ + aliases { + led0 = &led; + led1 = &rx_led; + led2 = &tx_led; + }; +}; + +&cpu0 { + clock-frequency = <48000000>; +}; + +&sercom0 { + status = "okay"; + compatible = "atmel,sam0-uart"; + current-speed = <115200>; + rxpo = <1>; + txpo = <0>; + + pinctrl-0 = <&sercom0_uart_default>; + pinctrl-names = "default"; +}; + +&sercom4 { + status = "okay"; + compatible = "atmel,sam0-spi"; + dipo = <1>; + dopo = <1>; + #address-cells = <1>; + #size-cells = <0>; + + pinctrl-0 = <&sercom4_spi_default>; + pinctrl-names = "default"; +}; + +&sercom3 { + status = "okay"; + compatible = "atmel,sam0-i2c"; + clock-frequency = ; + #address-cells = <1>; + #size-cells = <0>; + + pinctrl-0 = <&sercom3_i2c_default>; + pinctrl-names = "default"; +}; + +zephyr_udc0: &usb0 { + status = "okay"; + + pinctrl-0 = <&usb_dc_default>; + pinctrl-names = "default"; +}; + +&dac0 { + status = "okay"; + + pinctrl-0 = <&dac_default>; + pinctrl-names = "default"; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "uf2"; + reg = <0x00000000 DT_SIZE_K(8)>; + read-only; + }; + + code_partition: partition@2000 { + label = "code"; + reg = <0x2000 DT_SIZE_K(256-8-16)>; + read-only; + }; + + /* + * The final 16 KiB is reserved for the application. + * Storage partition may be used by FCB or LittleFS. + */ + storage_partition: partition@3c000 { + label = "storage"; + reg = <0x0003c000 DT_SIZE_K(16)>; + }; + }; +}; diff --git a/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout.yaml b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout.yaml new file mode 100644 index 0000000000000..02ac04642557b --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout.yaml @@ -0,0 +1,20 @@ +identifier: sparkfun_samd21_breakout +name: Sparkfun SAMD21 Dev Breakout +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +flash: 256 +ram: 32 +supported: + - dma + - dac + - gpio + - hwinfo + - i2c + - spi + - uart + - usb_device + - watchdog +vendor: sparkfun diff --git a/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout_connector.dtsi b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout_connector.dtsi new file mode 100644 index 0000000000000..ecd1a2a8ba781 --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout_connector.dtsi @@ -0,0 +1,33 @@ +/* + * Copyright The Zephyr Project Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + sparkfun_d: connector { + compatible = "sparkfun,samd21-gpio"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &porta 11 0>, /* D0 */ + <1 0 &porta 10 0>, /* D1 */ + <2 0 &porta 14 0>, /* D2 */ + <3 0 &porta 9 0>, /* D3 */ + <4 0 &porta 8 0>, /* D4 */ + <5 0 &porta 15 0>, /* D5 */ + <6 0 &porta 20 0>, /* D6 */ + <7 0 &porta 21 0>, /* D7 */ + <8 0 &porta 6 0>, /* D8 */ + <9 0 &porta 7 0>, /* D9 */ + <10 0 &porta 18 0>, /* D10 */ + <11 0 &porta 16 0>, /* D11 */ + <12 0 &porta 19 0>, /* D12 */ + <13 0 &porta 17 0>; /* D13 */ + }; +}; + +sparkfun_spi: &sercom4 {}; +sparkfun_i2c: &sercom3 {}; +sparkfun_serial: &sercom0 {}; +sparkfun_dac: &dac0 {}; +sparkfun_adc: &adc {}; diff --git a/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout_defconfig b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout_defconfig new file mode 100644 index 0000000000000..7fb548bde3404 --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/sparkfun_samd21_breakout_defconfig @@ -0,0 +1,14 @@ +# Copyright The Zephyr Project Contributors +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_ATMEL_SAMD_XOSC32K=y +CONFIG_SOC_ATMEL_SAMD_XOSC32K_AS_MAIN=y + +CONFIG_BUILD_OUTPUT_UF2=y +CONFIG_BOOTLOADER_BOSSA=y +CONFIG_BOOTLOADER_BOSSA_ADAFRUIT_UF2=y + +CONFIG_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_INTERRUPT_DRIVEN=y diff --git a/boards/sparkfun/samd21_dev_breakout/support/openocd.cfg b/boards/sparkfun/samd21_dev_breakout/support/openocd.cfg new file mode 100644 index 0000000000000..bf169676693b0 --- /dev/null +++ b/boards/sparkfun/samd21_dev_breakout/support/openocd.cfg @@ -0,0 +1,18 @@ +source [find interface/jlink.cfg] + +transport select swd + +set CHIPNAME atsamd21g18a +source [find target/at91samdXX.cfg] + +reset_config trst_only + +$_TARGETNAME configure -event gdb-attach { + echo "Debugger attaching: halting execution" + reset halt +} + +$_TARGETNAME configure -event gdb-detach { + echo "Debugger detaching: resuming execution" + resume +} diff --git a/tests/drivers/dac/dac_api/src/test_dac.c b/tests/drivers/dac/dac_api/src/test_dac.c index d988bfde7312d..9f53777370a5a 100644 --- a/tests/drivers/dac/dac_api/src/test_dac.c +++ b/tests/drivers/dac/dac_api/src/test_dac.c @@ -59,6 +59,7 @@ defined(CONFIG_BOARD_ARDUINO_MKRZERO) || \ defined(CONFIG_BOARD_ARDUINO_ZERO) || \ defined(CONFIG_BOARD_LPCXPRESSO55S36) || \ + defined(CONFIG_BOARD_SPARKFUN_SAMD21_BREAKOUT) || \ defined(CONFIG_BOARD_SAME54_XPRO) || \ defined(CONFIG_BOARD_BL652_DVK) || \ defined(CONFIG_BOARD_BL653_DVK) || \