summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-10-05 21:51:28 +0200
committerChristian Pointner <equinox@spreadspace.org>2022-10-05 21:51:28 +0200
commitb20983a5a6b934bbfe3b40766fa50aea7272ca91 (patch)
treecaf435e18cc4f263f1f167f0f0e024119dcde835
parentcontrib: add flash nuke u2f file (diff)
add sdk based blink example
-rw-r--r--.gitignore2
-rw-r--r--README1
-rw-r--r--contrib/Makefile20
-rw-r--r--rules.mk3
-rw-r--r--sdk-blink/CMakeLists.txt25
-rw-r--r--sdk-blink/Makefile39
-rw-r--r--sdk-blink/blink.c23
-rw-r--r--sdk.cmake26
8 files changed, 134 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index d360dda..c5cb777 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+/contrib/pico-sdk-*/
+/contrib/pico-sdk-*.tar.gz
/contrib/picoprobe.u2f
/contrib/flash_nuke.u2f
/contrib/openocd
diff --git a/README b/README
index 7cd3e49..6d0ee97 100644
--- a/README
+++ b/README
@@ -1,6 +1,7 @@
Dependencies
============
+cmake
make
automake
autoconf
diff --git a/contrib/Makefile b/contrib/Makefile
index 7250d5a..70488a8 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -20,6 +20,8 @@
## along with spreadspace rppico utils. If not, see <http://www.gnu.org/licenses/>.
##
+SDK_VERSION := 1.4.0
+SDK_SHA256SUM := 951d1d316d9a01c734c5ec53e766a2d03fb44f405a2494bac9a8a7c178e25918
CHIBIOS_VERSION := 21.11.2
CHIBIOS_SHA256SUM := ba74eec6230b66d79c0f0a26e9af00ca46756cb47f7b4a229eb228cbff3a8b48
FMPP_VERSION := 0.9.16
@@ -29,8 +31,22 @@ GCC_HOST := $(shell uname -m)-$(shell uname | tr '[:upper:]' '[:lower:]')
GCC_SHA256SUM := 97dbb4f019ad1650b732faffcc881689cedc14e2b7ee863d390e0a41ef16c9a3
-all: download-picoprobe download-flash_nuke clone-openocd download-chibios download-gcc
-clean: clean-picoprobe clean-flash_nuke clean-openocd clean-chibios clean-gcc
+all: download-sdk download-picoprobe download-flash_nuke clone-openocd download-chibios download-gcc
+clean: clean-sdk clean-picoprobe clean-flash_nuke clean-openocd clean-chibios clean-gcc
+
+
+
+
+download-sdk: pico-sdk-${SDK_VERSION}.tar.gz
+
+pico-sdk-${SDK_VERSION}.tar.gz:
+ wget "https://github.com/raspberrypi/pico-sdk/archive/refs/tags/${SDK_VERSION}.tar.gz" -O "$@"
+ echo "${SDK_SHA256SUM} $@" | sha256sum -c
+ tar -xzf $@
+
+clean-sdk:
+ rm -f pico-sdk-${SDK_VERSION}.tar.gz
+ rm -rf pico-sdk-${SDK_VERSION}
download-picoprobe: picoprobe.u2f
diff --git a/rules.mk b/rules.mk
index f068838..96745eb 100644
--- a/rules.mk
+++ b/rules.mk
@@ -20,9 +20,6 @@
## along with spreadspace rppico utils. If not, see <http://www.gnu.org/licenses/>.
##
-program: build/$(PROJECT).elf
- $(OPENOCD)/src/openocd -s $(OPENOCD)/tcl -f interface/picoprobe.cfg -f target/rp2040.cfg -c "program build/$(PROJECT).elf verify reset exit"
-
gdb-server:
$(OPENOCD)/src/openocd -s $(OPENOCD)/tcl -f interface/picoprobe.cfg -f target/rp2040.cfg -c "tcl_port disabled; telnet_port disabled; gdb_port 4242;"
# $(OPENOCD)/src/openocd -s $(OPENOCD)/tcl -f interface/picoprobe.cfg -f target/rp2040.cfg -c "tcl_port disabled; telnet_port disabled; gdb_port 4242; rp2040.core0 configure -rtos chibios; rp2040.core1 configure -rtos chibios;"
diff --git a/sdk-blink/CMakeLists.txt b/sdk-blink/CMakeLists.txt
new file mode 100644
index 0000000..c365501
--- /dev/null
+++ b/sdk-blink/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.12)
+
+include(../sdk.cmake)
+
+project(blink C CXX ASM)
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 17)
+
+pico_sdk_init()
+
+add_compile_options(-Wall
+ -Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
+ -Wno-unused-function # we have some for the docs that aren't called
+ -Wno-maybe-uninitialized
+ )
+
+add_executable(blink
+ blink.c
+ )
+
+# pull in common dependencies
+target_link_libraries(blink pico_stdlib)
+
+# create map/bin/hex file etc.
+pico_add_extra_outputs(blink)
diff --git a/sdk-blink/Makefile b/sdk-blink/Makefile
new file mode 100644
index 0000000..4a6a8f4
--- /dev/null
+++ b/sdk-blink/Makefile
@@ -0,0 +1,39 @@
+##
+## spreadspace rppico utils
+##
+##
+## Copyright (C) 2022 Christian Pointner <equinox@spreadspace.org>
+##
+## This file is part of spreadspace rppico utils.
+##
+## spreadspace rppico utils is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## any later version.
+##
+## spreadspace rppico utils is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with spreadspace rppico utils. If not, see <http://www.gnu.org/licenses/>.
+##
+
+PROJECT := blink
+include ../defines.mk
+
+all: build
+.PHONY: build clean
+
+build/Makefile:
+ mkdir -p build
+ cd build; cmake ..
+
+build: build/Makefile
+ make -C build
+
+clean:
+ rm -rf build
+
+include ../rules.mk
diff --git a/sdk-blink/blink.c b/sdk-blink/blink.c
new file mode 100644
index 0000000..d478d78
--- /dev/null
+++ b/sdk-blink/blink.c
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "pico/stdlib.h"
+
+int main() {
+#ifndef PICO_DEFAULT_LED_PIN
+#warning blink example requires a board with a regular LED
+#else
+ const uint LED_PIN = PICO_DEFAULT_LED_PIN;
+ gpio_init(LED_PIN);
+ gpio_set_dir(LED_PIN, GPIO_OUT);
+ while (true) {
+ gpio_put(LED_PIN, 1);
+ sleep_ms(250);
+ gpio_put(LED_PIN, 0);
+ sleep_ms(250);
+ }
+#endif
+}
diff --git a/sdk.cmake b/sdk.cmake
new file mode 100644
index 0000000..77c0098
--- /dev/null
+++ b/sdk.cmake
@@ -0,0 +1,26 @@
+##
+## spreadspace rppico utils
+##
+##
+## Copyright (C) 2022 Christian Pointner <equinox@spreadspace.org>
+##
+## This file is part of spreadspace rppico utils.
+##
+## spreadspace rppico utils is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## any later version.
+##
+## spreadspace rppico utils is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with spreadspace rppico utils. If not, see <http://www.gnu.org/licenses/>.
+##
+
+set(PICO_SDK_PATH ../contrib/pico-sdk-1.4.0)
+SET(PICO_TOOLCHAIN_PATH ../contrib/gcc-arm-none-eabi-10.3-2021.10)
+
+include(${PICO_SDK_PATH}/pico_sdk_init.cmake)