mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-08-15 23:50:23 +02:00
Added chaps for operators
This commit is contained in:
@@ -1,5 +1,2 @@
|
|||||||
.idea
|
|
||||||
_deps
|
|
||||||
cmake-*
|
|
||||||
build
|
build
|
||||||
.DS_Store
|
!.vscode/*
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
[]
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[]
|
|
||||||
+20
-16
@@ -1,18 +1,22 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Pico",
|
"name": "Pico",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceFolder}/**",
|
"${workspaceFolder}/**",
|
||||||
"${env:PICO_SDK_PATH}/**"
|
"${userHome}/.pico-sdk/sdk/2.2.0/**"
|
||||||
],
|
],
|
||||||
"defines": [],
|
"forcedInclude": [
|
||||||
"compilerPath": "${env:PICO_INSTALL_PATH}/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe",
|
"${workspaceFolder}/build/generated/pico_base/pico/config_autogen.h",
|
||||||
"cStandard": "c11",
|
"${userHome}/.pico-sdk/sdk/2.2.0/src/common/pico_base_headers/include/pico.h"
|
||||||
"cppStandard": "c++11",
|
],
|
||||||
"intelliSenseMode": "linux-gcc-arm",
|
"defines": [],
|
||||||
"configurationProvider": "ms-vscode.cmake-tools"
|
"compilerPath": "${userHome}/.pico-sdk/toolchain/14_2_Rel1/bin/arm-none-eabi-gcc.exe",
|
||||||
}
|
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
|
||||||
],
|
"cStandard": "c17",
|
||||||
"version": 4
|
"cppStandard": "c++14",
|
||||||
|
"intelliSenseMode": "linux-gcc-arm"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "Pico",
|
||||||
|
"compilers": {
|
||||||
|
"C": "${command:raspberry-pi-pico.getCompilerPath}",
|
||||||
|
"CXX": "${command:raspberry-pi-pico.getCxxCompilerPath}"
|
||||||
|
},
|
||||||
|
"environmentVariables": {
|
||||||
|
"PATH": "${command:raspberry-pi-pico.getEnvPath};${env:PATH}"
|
||||||
|
},
|
||||||
|
"cmakeSettings": {
|
||||||
|
"Python3_EXECUTABLE": "${command:raspberry-pi-pico.getPythonPath}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
+8
-8
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"marus25.cortex-debug",
|
"marus25.cortex-debug",
|
||||||
"ms-vscode.cmake-tools",
|
"ms-vscode.cpptools",
|
||||||
"ms-vscode.cpptools",
|
"ms-vscode.cpptools-extension-pack",
|
||||||
"ms-vscode.cpptools-extension-pack",
|
"ms-vscode.vscode-serial-monitor",
|
||||||
"ms-vscode.vscode-serial-monitor"
|
"raspberry-pi.raspberry-pi-pico"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Vendored
+48
-56
@@ -1,58 +1,50 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Pico Debug (Cortex-Debug)",
|
"name": "Pico Debug (Cortex-Debug)",
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
|
||||||
"executable": "${command:cmake.launchTargetPath}",
|
"executable": "${command:raspberry-pi-pico.launchTargetPath}",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"type": "cortex-debug",
|
"type": "cortex-debug",
|
||||||
"servertype": "openocd",
|
"servertype": "openocd",
|
||||||
"gdbPath": "arm-none-eabi-gdb",
|
"serverpath": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||||
"device": "RP2040",
|
"gdbPath": "${command:raspberry-pi-pico.getGDBPath}",
|
||||||
"configFiles": [
|
"device": "${command:raspberry-pi-pico.getChipUppercase}",
|
||||||
"interface/cmsis-dap.cfg",
|
"configFiles": [
|
||||||
"target/rp2040.cfg"
|
"interface/cmsis-dap.cfg",
|
||||||
],
|
"target/${command:raspberry-pi-pico.getTarget}.cfg"
|
||||||
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
|
],
|
||||||
"runToEntryPoint": "main",
|
"svdFile": "${userHome}/.pico-sdk/sdk/2.2.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd",
|
||||||
"openOCDLaunchCommands": [
|
"runToEntryPoint": "main",
|
||||||
"adapter speed 1000"
|
// Fix for no_flash binaries, where monitor reset halt doesn't do what is expected
|
||||||
]
|
// Also works fine for flash binaries
|
||||||
},
|
"overrideLaunchCommands": [
|
||||||
{
|
"monitor reset init",
|
||||||
"name": "Pico Debug (Cortex-Debug with external OpenOCD)",
|
"load \"${command:raspberry-pi-pico.launchTargetPath}\""
|
||||||
"cwd": "${workspaceFolder}",
|
],
|
||||||
"executable": "${command:cmake.launchTargetPath}",
|
"openOCDLaunchCommands": [
|
||||||
"request": "launch",
|
"adapter speed 5000"
|
||||||
"type": "cortex-debug",
|
]
|
||||||
"servertype": "external",
|
},
|
||||||
"gdbTarget": "localhost:3333",
|
{
|
||||||
"gdbPath": "arm-none-eabi-gdb",
|
"name": "Pico Debug (Cortex-Debug with external OpenOCD)",
|
||||||
"device": "RP2040",
|
"cwd": "${workspaceRoot}",
|
||||||
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
|
"executable": "${command:raspberry-pi-pico.launchTargetPath}",
|
||||||
"runToEntryPoint": "main"
|
"request": "launch",
|
||||||
},
|
"type": "cortex-debug",
|
||||||
{
|
"servertype": "external",
|
||||||
"name": "Pico Debug (C++ Debugger)",
|
"gdbTarget": "localhost:3333",
|
||||||
"type": "cppdbg",
|
"gdbPath": "${command:raspberry-pi-pico.getGDBPath}",
|
||||||
"request": "launch",
|
"device": "${command:raspberry-pi-pico.getChipUppercase}",
|
||||||
"cwd": "${workspaceFolder}",
|
"svdFile": "${userHome}/.pico-sdk/sdk/2.2.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd",
|
||||||
"program": "${command:cmake.launchTargetPath}",
|
"runToEntryPoint": "main",
|
||||||
"MIMode": "gdb",
|
// Fix for no_flash binaries, where monitor reset halt doesn't do what is expected
|
||||||
"miDebuggerPath": "arm-none-eabi-gdb",
|
// Also works fine for flash binaries
|
||||||
"miDebuggerServerAddress": "localhost:3333",
|
"overrideLaunchCommands": [
|
||||||
"debugServerPath": "openocd",
|
"monitor reset init",
|
||||||
"debugServerArgs": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 1000\"",
|
"load \"${command:raspberry-pi-pico.launchTargetPath}\""
|
||||||
"serverStarted": "Listening on port .* for gdb connections",
|
]
|
||||||
"filterStderr": true,
|
},
|
||||||
"stopAtEntry": true,
|
]
|
||||||
"hardwareBreakpoints": {
|
|
||||||
"require": true,
|
|
||||||
"limit": 4
|
|
||||||
},
|
|
||||||
"preLaunchTask": "Flash",
|
|
||||||
"svdPath": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-22
@@ -1,30 +1,40 @@
|
|||||||
{
|
{
|
||||||
// These settings tweaks to the cmake plugin will ensure
|
"cmake.showSystemKits": false,
|
||||||
// that you debug using cortex-debug instead of trying to launch
|
"cmake.options.statusBarVisibility": "hidden",
|
||||||
// a Pico binary on the host
|
"cmake.options.advanced": {
|
||||||
"cmake.statusbar.advanced": {
|
"build": {
|
||||||
"debug": {
|
"statusBarVisibility": "hidden"
|
||||||
"visibility": "hidden"
|
|
||||||
},
|
},
|
||||||
"launch": {
|
"launch": {
|
||||||
"visibility": "hidden"
|
"statusBarVisibility": "hidden"
|
||||||
},
|
},
|
||||||
"build": {
|
"debug": {
|
||||||
"visibility": "hidden"
|
"statusBarVisibility": "hidden"
|
||||||
},
|
|
||||||
"buildTarget": {
|
|
||||||
"visibility": "hidden"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cmake.buildBeforeRun": true,
|
"cmake.configureOnEdit": false,
|
||||||
"cmake.configureOnOpen": true,
|
"cmake.automaticReconfigure": false,
|
||||||
"cmake.configureSettings": {
|
"cmake.configureOnOpen": false,
|
||||||
"CMAKE_MODULE_PATH": "${env:PICO_INSTALL_PATH}/pico-sdk-tools"
|
|
||||||
},
|
|
||||||
"cmake.generator": "Ninja",
|
"cmake.generator": "Ninja",
|
||||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
|
"cmake.cmakePath": "${userHome}/.pico-sdk/cmake/v3.31.5/bin/cmake",
|
||||||
"C_Cpp.errorSquiggles": "enabled",
|
"C_Cpp.debugShortcut": false,
|
||||||
"files.associations": {
|
"terminal.integrated.env.windows": {
|
||||||
"stdlib.h": "c"
|
"PICO_SDK_PATH": "${env:USERPROFILE}/.pico-sdk/sdk/2.2.0",
|
||||||
}
|
"PICO_TOOLCHAIN_PATH": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1",
|
||||||
|
"Path": "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.2.0-a4/picotool;${env:USERPROFILE}/.pico-sdk/cmake/v3.31.5/bin;${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}"
|
||||||
|
},
|
||||||
|
"terminal.integrated.env.osx": {
|
||||||
|
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
||||||
|
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
|
||||||
|
"PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
||||||
|
},
|
||||||
|
"terminal.integrated.env.linux": {
|
||||||
|
"PICO_SDK_PATH": "${env:HOME}/.pico-sdk/sdk/2.2.0",
|
||||||
|
"PICO_TOOLCHAIN_PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1",
|
||||||
|
"PATH": "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}"
|
||||||
|
},
|
||||||
|
"raspberry-pi-pico.cmakeAutoConfigure": true,
|
||||||
|
"raspberry-pi-pico.useCmakeTools": false,
|
||||||
|
"raspberry-pi-pico.cmakePath": "${HOME}/.pico-sdk/cmake/v3.31.5/bin/cmake",
|
||||||
|
"raspberry-pi-pico.ninjaPath": "${HOME}/.pico-sdk/ninja/v1.12.1/ninja"
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+100
-27
@@ -1,29 +1,102 @@
|
|||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "Flash",
|
"label": "Compile Project",
|
||||||
"type": "shell",
|
"type": "process",
|
||||||
"command": "openocd",
|
"isBuildCommand": true,
|
||||||
"args": [
|
"command": "${userHome}/.pico-sdk/ninja/v1.12.1/ninja",
|
||||||
"-f",
|
"args": ["-C", "${workspaceFolder}/build"],
|
||||||
"interface/cmsis-dap.cfg",
|
"group": "build",
|
||||||
"-f",
|
"presentation": {
|
||||||
"target/rp2040.cfg",
|
"reveal": "always",
|
||||||
"-c",
|
"panel": "dedicated"
|
||||||
"adapter speed 1000; program {${command:cmake.launchTargetPath}} verify reset exit"
|
},
|
||||||
],
|
"problemMatcher": "$gcc",
|
||||||
"problemMatcher": []
|
"windows": {
|
||||||
},
|
"command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe"
|
||||||
{
|
}
|
||||||
"label": "Build",
|
},
|
||||||
"type": "cmake",
|
{
|
||||||
"command": "build",
|
"label": "Run Project",
|
||||||
"problemMatcher": "$gcc",
|
"type": "process",
|
||||||
"group": {
|
"command": "${env:HOME}/.pico-sdk/picotool/2.2.0-a4/picotool/picotool",
|
||||||
"kind": "build",
|
"args": [
|
||||||
"isDefault": true
|
"load",
|
||||||
}
|
"${command:raspberry-pi-pico.launchTargetPath}",
|
||||||
}
|
"-fx"
|
||||||
]
|
],
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "dedicated"
|
||||||
|
},
|
||||||
|
"problemMatcher": [],
|
||||||
|
"windows": {
|
||||||
|
"command": "${env:USERPROFILE}/.pico-sdk/picotool/2.2.0-a4/picotool/picotool.exe"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Flash",
|
||||||
|
"type": "process",
|
||||||
|
"command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||||
|
"args": [
|
||||||
|
"-s",
|
||||||
|
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
|
||||||
|
"-f",
|
||||||
|
"interface/cmsis-dap.cfg",
|
||||||
|
"-f",
|
||||||
|
"target/${command:raspberry-pi-pico.getTarget}.cfg",
|
||||||
|
"-c",
|
||||||
|
"adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit"
|
||||||
|
],
|
||||||
|
"problemMatcher": [],
|
||||||
|
"windows": {
|
||||||
|
"command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Rescue Reset",
|
||||||
|
"type": "process",
|
||||||
|
"command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||||
|
"args": [
|
||||||
|
"-s",
|
||||||
|
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
|
||||||
|
"-f",
|
||||||
|
"interface/cmsis-dap.cfg",
|
||||||
|
"-f",
|
||||||
|
"target/${command:raspberry-pi-pico.getChip}-rescue.cfg",
|
||||||
|
"-c",
|
||||||
|
"adapter speed 5000; reset halt; exit"
|
||||||
|
],
|
||||||
|
"problemMatcher": [],
|
||||||
|
"windows": {
|
||||||
|
"command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "RISC-V Reset (RP2350)",
|
||||||
|
"type": "process",
|
||||||
|
"command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||||
|
"args": [
|
||||||
|
"-s",
|
||||||
|
"${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
|
||||||
|
"-c",
|
||||||
|
"set USE_CORE { rv0 rv1 cm0 cm1 }",
|
||||||
|
"-f",
|
||||||
|
"interface/cmsis-dap.cfg",
|
||||||
|
"-f",
|
||||||
|
"target/rp2350.cfg",
|
||||||
|
"-c",
|
||||||
|
"adapter speed 5000; init;",
|
||||||
|
"-c",
|
||||||
|
"write_memory 0x40120158 8 { 0x3 }; echo [format \"Info : ARCHSEL 0x%02x\" [read_memory 0x40120158 8 1]];",
|
||||||
|
"-c",
|
||||||
|
"reset halt; targets rp2350.rv0; echo [format \"Info : ARCHSEL_STATUS 0x%02x\" [read_memory 0x4012015C 8 1]]; exit"
|
||||||
|
],
|
||||||
|
"problemMatcher": [],
|
||||||
|
"windows": {
|
||||||
|
"command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
|
#include "dht11.h"
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
|
||||||
|
dht11_init(4);
|
||||||
|
|
||||||
int x = 5;
|
int x = 5;
|
||||||
int y = 10;
|
int y = 10;
|
||||||
int arithmetic_operator = (x * y);
|
int arithmetic_operator = (x * y);
|
||||||
@@ -20,5 +23,14 @@ int main(void) {
|
|||||||
printf("logical_operator: %d\r\n", logical_operator);
|
printf("logical_operator: %d\r\n", logical_operator);
|
||||||
printf("bitwise_operator: %d\r\n", bitwise_operator);
|
printf("bitwise_operator: %d\r\n", bitwise_operator);
|
||||||
printf("assignment_operator: %d\r\n", assignment_operator);
|
printf("assignment_operator: %d\r\n", assignment_operator);
|
||||||
|
|
||||||
|
float hum, temp;
|
||||||
|
if (dht11_read(&hum, &temp)) {
|
||||||
|
printf("Humidity: %.1f%%, Temperature: %.1f°C\r\n", hum, temp);
|
||||||
|
} else {
|
||||||
|
printf("DHT11 read failed\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep_ms(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,57 @@
|
|||||||
|
# Generated Cmake Pico project file
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
include(pico_sdk_import.cmake)
|
|
||||||
project(0x001a_operators C CXX ASM)
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
# Initialise pico_sdk from installed location
|
||||||
|
# (note this can come from environment, CMake cache etc)
|
||||||
|
|
||||||
|
# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==
|
||||||
|
if(WIN32)
|
||||||
|
set(USERHOME $ENV{USERPROFILE})
|
||||||
|
else()
|
||||||
|
set(USERHOME $ENV{HOME})
|
||||||
|
endif()
|
||||||
|
set(sdkVersion 2.2.0)
|
||||||
|
set(toolchainVersion 14_2_Rel1)
|
||||||
|
set(picotoolVersion 2.2.0-a4)
|
||||||
|
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
|
||||||
|
if (EXISTS ${picoVscode})
|
||||||
|
include(${picoVscode})
|
||||||
|
endif()
|
||||||
|
# ====================================================================================
|
||||||
|
set(PICO_BOARD pico2 CACHE STRING "Board type")
|
||||||
|
|
||||||
|
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||||
|
include(pico_sdk_import.cmake)
|
||||||
|
|
||||||
|
project(0x001a_operators C CXX ASM)
|
||||||
|
|
||||||
|
# Initialise the Raspberry Pi Pico SDK
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
add_executable(0x001a_operators
|
# Add executable. Default name is the project name, version 0.1
|
||||||
main.c
|
|
||||||
)
|
|
||||||
|
|
||||||
pico_enable_stdio_usb(0x001a_operators 1)
|
add_executable(0x001a_operators 0x001a_operators.c dht11.c )
|
||||||
|
|
||||||
|
pico_set_program_name(0x001a_operators "0x001a_operators")
|
||||||
|
pico_set_program_version(0x001a_operators "0.1")
|
||||||
|
|
||||||
|
# Modify the below lines to enable/disable output over UART/USB
|
||||||
pico_enable_stdio_uart(0x001a_operators 1)
|
pico_enable_stdio_uart(0x001a_operators 1)
|
||||||
|
pico_enable_stdio_usb(0x001a_operators 0)
|
||||||
|
|
||||||
|
# Add the standard library to the build
|
||||||
|
target_link_libraries(0x001a_operators
|
||||||
|
pico_stdlib)
|
||||||
|
|
||||||
|
# Add the standard include files to the build
|
||||||
|
target_include_directories(0x001a_operators PRIVATE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
pico_add_extra_outputs(0x001a_operators)
|
pico_add_extra_outputs(0x001a_operators)
|
||||||
|
|
||||||
target_link_libraries(0x001a_operators
|
|
||||||
pico_stdlib
|
|
||||||
)
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,83 @@
|
|||||||
|
"""
|
||||||
|
Verify patched instruction and constant inside a UF2 file.
|
||||||
|
|
||||||
|
Checks:
|
||||||
|
- 0x10000410: should be 26 7a b4 ee (vsub.f32 s14, s14, s11)
|
||||||
|
- 0x10000414: should be a6 7a b4 ee (vsub.f32 s15, s15, s11)
|
||||||
|
- 0x1000042C: should be 00 00 00 41 (float 8.0)
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python verify_uf2.py build/hacked.uf2
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import struct
|
||||||
|
|
||||||
|
UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
|
||||||
|
UF2_MAGIC_START1 = 0x9E5D5157
|
||||||
|
UF2_MAGIC_END = 0x0AB16F30
|
||||||
|
|
||||||
|
def load_uf2(path):
|
||||||
|
blocks = []
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
data = f.read()
|
||||||
|
i = 0
|
||||||
|
while i + 512 <= len(data):
|
||||||
|
blk = data[i:i+512]
|
||||||
|
(m0, m1, flags, tgt_addr, payload_size, block_no,
|
||||||
|
num_blocks, file_size) = struct.unpack("<IIIIIIII", blk[:32])
|
||||||
|
if m0 != UF2_MAGIC_START0 or m1 != UF2_MAGIC_START1:
|
||||||
|
raise ValueError("Not a UF2 file or bad magic at block %d" % (i // 512))
|
||||||
|
if payload_size != 256:
|
||||||
|
raise ValueError("Unexpected payload size %d" % payload_size)
|
||||||
|
if struct.unpack("<I", blk[512-4:512])[0] != UF2_MAGIC_END:
|
||||||
|
raise ValueError("Bad end magic at block %d" % (i // 512))
|
||||||
|
payload = blk[32:32+payload_size]
|
||||||
|
blocks.append((tgt_addr, payload))
|
||||||
|
i += 512
|
||||||
|
return blocks
|
||||||
|
|
||||||
|
def read_at(blocks, addr, length):
|
||||||
|
"""Read 'length' bytes starting at virtual 'addr' from UF2 blocks."""
|
||||||
|
out = bytearray()
|
||||||
|
cur = addr
|
||||||
|
while len(out) < length:
|
||||||
|
# Find block that contains current address
|
||||||
|
hit = None
|
||||||
|
for base, pay in blocks:
|
||||||
|
if base <= cur < base + len(pay):
|
||||||
|
hit = (base, pay)
|
||||||
|
break
|
||||||
|
if not hit:
|
||||||
|
# If missing, fill with 0xFF (flash default) and continue
|
||||||
|
out.append(0xFF)
|
||||||
|
cur += 1
|
||||||
|
continue
|
||||||
|
base, pay = hit
|
||||||
|
out.append(pay[cur - base])
|
||||||
|
cur += 1
|
||||||
|
return bytes(out)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Usage: python verify_uf2.py <path/to.uf2>")
|
||||||
|
sys.exit(1)
|
||||||
|
uf2_path = sys.argv[1]
|
||||||
|
blocks = load_uf2(uf2_path)
|
||||||
|
|
||||||
|
addrs = [0x10000410, 0x10000414, 0x1000042C]
|
||||||
|
labels = ["@10000410", "@10000414", "@1000042C"]
|
||||||
|
|
||||||
|
for label, a in zip(labels, addrs):
|
||||||
|
bytes_ = read_at(blocks, a, 4)
|
||||||
|
print(f"{label}: {bytes_.hex()} ", end="")
|
||||||
|
if a == 0x1000042C:
|
||||||
|
try:
|
||||||
|
print(f"(float {struct.unpack('<f', bytes_)[0]:.6f})")
|
||||||
|
except Exception:
|
||||||
|
print("(not a valid float)")
|
||||||
|
else:
|
||||||
|
print()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* @file dht11.c
|
||||||
|
* @brief Implementation of DHT11 temperature and humidity sensor driver
|
||||||
|
* @author Kevin Thomas
|
||||||
|
* @date 2025
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Kevin Thomas
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dht11.h"
|
||||||
|
#include "hardware/gpio.h"
|
||||||
|
#include "pico/time.h"
|
||||||
|
|
||||||
|
static uint dht_pin;
|
||||||
|
|
||||||
|
void dht11_init(uint8_t pin) {
|
||||||
|
dht_pin = pin;
|
||||||
|
gpio_init(pin);
|
||||||
|
gpio_pull_up(pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dht11_read(float *humidity, float *temperature) {
|
||||||
|
uint8_t data[5] = {0};
|
||||||
|
|
||||||
|
// Start signal
|
||||||
|
gpio_set_dir(dht_pin, GPIO_OUT);
|
||||||
|
gpio_put(dht_pin, 0);
|
||||||
|
sleep_ms(18);
|
||||||
|
gpio_put(dht_pin, 1);
|
||||||
|
sleep_us(40);
|
||||||
|
gpio_set_dir(dht_pin, GPIO_IN);
|
||||||
|
|
||||||
|
// Wait for response
|
||||||
|
uint32_t timeout = 10000;
|
||||||
|
while (gpio_get(dht_pin) == 1) if (--timeout == 0) return false;
|
||||||
|
timeout = 10000;
|
||||||
|
while (gpio_get(dht_pin) == 0) if (--timeout == 0) return false;
|
||||||
|
timeout = 10000;
|
||||||
|
while (gpio_get(dht_pin) == 1) if (--timeout == 0) return false;
|
||||||
|
|
||||||
|
// Read 40 bits
|
||||||
|
for (int i = 0; i < 40; i++) {
|
||||||
|
timeout = 10000;
|
||||||
|
while (gpio_get(dht_pin) == 0) if (--timeout == 0) return false;
|
||||||
|
uint32_t start = time_us_32();
|
||||||
|
timeout = 10000;
|
||||||
|
while (gpio_get(dht_pin) == 1) if (--timeout == 0) return false;
|
||||||
|
uint32_t duration = time_us_32() - start;
|
||||||
|
data[i / 8] <<= 1;
|
||||||
|
if (duration > 40) data[i / 8] |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check checksum
|
||||||
|
if (data[4] != ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) return false;
|
||||||
|
|
||||||
|
*humidity = data[0] + data[1] * 0.1f;
|
||||||
|
*temperature = data[2] + data[3] * 0.1f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* @file dht11.h
|
||||||
|
* @brief Header for DHT11 temperature and humidity sensor driver
|
||||||
|
* @author Kevin Thomas
|
||||||
|
* @date 2025
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Kevin Thomas
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DHT11_H
|
||||||
|
#define DHT11_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the DHT11 driver
|
||||||
|
*
|
||||||
|
* Configures the GPIO pin for the DHT11 sensor. This must be called before
|
||||||
|
* using dht11_read().
|
||||||
|
*
|
||||||
|
* @param pin GPIO pin number connected to DHT11 signal
|
||||||
|
*/
|
||||||
|
void dht11_init(uint8_t pin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read temperature and humidity from DHT11 sensor
|
||||||
|
*
|
||||||
|
* Performs the DHT11 communication protocol to read sensor data.
|
||||||
|
*
|
||||||
|
* @param humidity Pointer to store humidity value (0-100%)
|
||||||
|
* @param temperature Pointer to store temperature value in Celsius
|
||||||
|
* @return true if read successful, false on error or timeout
|
||||||
|
*/
|
||||||
|
bool dht11_read(float *humidity, float *temperature);
|
||||||
|
|
||||||
|
#endif // DHT11_H
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
"""
|
||||||
|
FILE: safe_patch.py
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
Incremental firmware patcher with minimal, conservative steps to bias readings.
|
||||||
|
|
||||||
|
BRIEF:
|
||||||
|
Provides three modes:
|
||||||
|
- pool_only: change only the literal pool constant (scaling effect; least invasive)
|
||||||
|
- temp_only_vadd: convert temperature path to vadd.f32 and set a small negative pool
|
||||||
|
- both_vadd: convert both paths to vadd.f32 and set a small negative pool
|
||||||
|
|
||||||
|
Intended to let you test changes incrementally, keeping humidity stable while
|
||||||
|
you evaluate temperature bias first.
|
||||||
|
|
||||||
|
AUTHOR: Kevin Thomas
|
||||||
|
CREATION DATE: November 1, 2025
|
||||||
|
UPDATE DATE: November 1, 2025
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import struct
|
||||||
|
|
||||||
|
BIN_PATH = "build/0x001a_operators.bin"
|
||||||
|
|
||||||
|
# Offsets
|
||||||
|
OFF_410 = 0x410
|
||||||
|
OFF_414 = 0x414
|
||||||
|
OFF_POOL = 0x42C
|
||||||
|
|
||||||
|
# Original encodings (for visibility only)
|
||||||
|
ORIG_410 = bytes.fromhex("a6ee257a") # vfma.f32 s14, s12, s11
|
||||||
|
ORIG_414 = bytes.fromhex("e6eea57a") # vfma.f32 s15, s13, s11
|
||||||
|
ORIG_POOL = bytes.fromhex("cccccc3d") # 0.1f
|
||||||
|
|
||||||
|
# Encodings for vadd.f32 s14, s14, s11 and vadd.f32 s15, s15, s11
|
||||||
|
VADD_S14_S11 = struct.pack("<I", 0xEEB47A06) # 06 7a b4 ee
|
||||||
|
VADD_S15_S11 = struct.pack("<I", 0xEEB47A86) # 86 7a b4 ee
|
||||||
|
|
||||||
|
|
||||||
|
def read_at(path, offset, n):
|
||||||
|
"""Read bytes from a binary file at a given offset.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
path : str
|
||||||
|
Filesystem path to the binary file.
|
||||||
|
offset : int
|
||||||
|
Byte offset from the start of the file.
|
||||||
|
n : int
|
||||||
|
Number of bytes to read.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
bytes
|
||||||
|
The raw bytes read from the file.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
IOError
|
||||||
|
If the file cannot be opened or read.
|
||||||
|
"""
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
f.seek(offset)
|
||||||
|
return f.read(n)
|
||||||
|
|
||||||
|
|
||||||
|
def write_at(path, offset, data):
|
||||||
|
"""Write bytes into a binary file at a given offset.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
path : str
|
||||||
|
Filesystem path to the binary file.
|
||||||
|
offset : int
|
||||||
|
Byte offset from the start of the file.
|
||||||
|
data : bytes
|
||||||
|
Bytes to write into the file.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
IOError
|
||||||
|
If the file cannot be opened or written.
|
||||||
|
"""
|
||||||
|
with open(path, "rb+") as f:
|
||||||
|
f.seek(offset)
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
|
def fmt_float(b):
|
||||||
|
"""Format a 4-byte sequence as hex and float if possible.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
b : bytes
|
||||||
|
A 4-byte sequence.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
Hexadecimal string with float interpretation if valid.
|
||||||
|
"""
|
||||||
|
hx = b.hex()
|
||||||
|
try:
|
||||||
|
val = struct.unpack("<f", b)[0]
|
||||||
|
return f"{hx} (float {val:.6f})"
|
||||||
|
except Exception:
|
||||||
|
return hx
|
||||||
|
|
||||||
|
|
||||||
|
def patch_pool_only(new_pool_float=-1.0):
|
||||||
|
"""Patch only the pool constant to a new float value.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
new_pool_float : float, optional
|
||||||
|
New float value to write into the pool constant (default -1.0).
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
print("[mode] pool_only")
|
||||||
|
curp = read_at(BIN_PATH, OFF_POOL, 4)
|
||||||
|
print(f"Current @0x1000042C: {fmt_float(curp)} (expected {ORIG_POOL.hex()} == 0.1f)")
|
||||||
|
newb = struct.pack("<f", new_pool_float)
|
||||||
|
write_at(BIN_PATH, OFF_POOL, newb)
|
||||||
|
chkp = read_at(BIN_PATH, OFF_POOL, 4)
|
||||||
|
print(f"Patched @0x1000042C: {fmt_float(chkp)} (target {newb.hex()} == {new_pool_float}f)")
|
||||||
|
|
||||||
|
|
||||||
|
def patch_temp_only_vadd(new_pool_float=-2.0):
|
||||||
|
"""Patch temperature path to vadd and set pool to a small negative.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
new_pool_float : float, optional
|
||||||
|
New float value to write into the pool constant (default -2.0).
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
print("[mode] temp_only_vadd")
|
||||||
|
cur414 = read_at(BIN_PATH, OFF_414, 4)
|
||||||
|
curp = read_at(BIN_PATH, OFF_POOL, 4)
|
||||||
|
print(f"Current @0x10000414: {cur414.hex()} (expected {ORIG_414.hex()})")
|
||||||
|
print(f"Current @0x1000042C: {fmt_float(curp)}")
|
||||||
|
write_at(BIN_PATH, OFF_414, VADD_S15_S11)
|
||||||
|
write_at(BIN_PATH, OFF_POOL, struct.pack("<f", new_pool_float))
|
||||||
|
chk414 = read_at(BIN_PATH, OFF_414, 4)
|
||||||
|
chkp = read_at(BIN_PATH, OFF_POOL, 4)
|
||||||
|
print(f"Patched @0x10000414: {chk414.hex()} (should be {VADD_S15_S11.hex()})")
|
||||||
|
print(f"Patched @0x1000042C: {fmt_float(chkp)} (target {new_pool_float}f)")
|
||||||
|
|
||||||
|
|
||||||
|
def patch_both_vadd(new_pool_float=-2.0):
|
||||||
|
"""Patch both humidity and temperature paths to vadd and set pool.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
new_pool_float : float, optional
|
||||||
|
New float value to write into the pool constant (default -2.0).
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
print("[mode] both_vadd")
|
||||||
|
cur410 = read_at(BIN_PATH, OFF_410, 4)
|
||||||
|
cur414 = read_at(BIN_PATH, OFF_414, 4)
|
||||||
|
curp = read_at(BIN_PATH, OFF_POOL, 4)
|
||||||
|
print(f"Current @0x10000410: {cur410.hex()} (expected {ORIG_410.hex()})")
|
||||||
|
print(f"Current @0x10000414: {cur414.hex()} (expected {ORIG_414.hex()})")
|
||||||
|
print(f"Current @0x1000042C: {fmt_float(curp)}")
|
||||||
|
write_at(BIN_PATH, OFF_410, VADD_S14_S11)
|
||||||
|
write_at(BIN_PATH, OFF_414, VADD_S15_S11)
|
||||||
|
write_at(BIN_PATH, OFF_POOL, struct.pack("<f", new_pool_float))
|
||||||
|
chk410 = read_at(BIN_PATH, OFF_410, 4)
|
||||||
|
chk414 = read_at(BIN_PATH, OFF_414, 4)
|
||||||
|
chkp = read_at(BIN_PATH, OFF_POOL, 4)
|
||||||
|
print(f"Patched @0x10000410: {chk410.hex()} (should be {VADD_S14_S11.hex()})")
|
||||||
|
print(f"Patched @0x10000414: {chk414.hex()} (should be {VADD_S15_S11.hex()})")
|
||||||
|
print(f"Patched @0x1000042C: {fmt_float(chkp)} (target {new_pool_float}f)")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Dispatch patch mode and perform incremental modifications.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
None
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
FileNotFoundError
|
||||||
|
If the binary file specified by BIN_PATH does not exist.
|
||||||
|
"""
|
||||||
|
if not os.path.exists(BIN_PATH):
|
||||||
|
raise FileNotFoundError(f"Binary not found: {BIN_PATH}")
|
||||||
|
mode = (sys.argv[1] if len(sys.argv) > 1 else "pool_only").strip().lower()
|
||||||
|
if mode == "pool_only":
|
||||||
|
patch_pool_only(new_pool_float=-1.0)
|
||||||
|
elif mode == "temp_only_vadd":
|
||||||
|
patch_temp_only_vadd(new_pool_float=-2.0)
|
||||||
|
elif mode == "both_vadd":
|
||||||
|
patch_both_vadd(new_pool_float=-2.0)
|
||||||
|
else:
|
||||||
|
print(f"Unknown mode: {mode}")
|
||||||
|
print("Use: pool_only | temp_only_vadd | both_vadd")
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
print("Patch complete. Convert to UF2 and flash. Test each mode incrementally.")
|
||||||
@@ -3,6 +3,28 @@
|
|||||||
# This can be dropped into an external project to help locate this SDK
|
# This can be dropped into an external project to help locate this SDK
|
||||||
# It should be include()ed prior to project()
|
# It should be include()ed prior to project()
|
||||||
|
|
||||||
|
# Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
# following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
|
||||||
|
# disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
|
||||||
|
# disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
|
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
|
||||||
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
|
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
|
||||||
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
|
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
|
||||||
@@ -18,9 +40,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
|
|||||||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG))
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG})
|
||||||
|
message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG)
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT_TAG "master")
|
||||||
|
message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
|
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
|
||||||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
|
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
|
||||||
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
|
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK")
|
||||||
|
|
||||||
if (NOT PICO_SDK_PATH)
|
if (NOT PICO_SDK_PATH)
|
||||||
if (PICO_SDK_FETCH_FROM_GIT)
|
if (PICO_SDK_FETCH_FROM_GIT)
|
||||||
@@ -29,25 +62,40 @@ if (NOT PICO_SDK_PATH)
|
|||||||
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
||||||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
endif ()
|
endif ()
|
||||||
# GIT_SUBMODULES_RECURSE was added in 3.17
|
FetchContent_Declare(
|
||||||
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
|
pico_sdk
|
||||||
FetchContent_Declare(
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||||
pico_sdk
|
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
|
||||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
)
|
||||||
GIT_TAG master
|
|
||||||
GIT_SUBMODULES_RECURSE FALSE
|
|
||||||
)
|
|
||||||
else ()
|
|
||||||
FetchContent_Declare(
|
|
||||||
pico_sdk
|
|
||||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
|
||||||
GIT_TAG master
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT pico_sdk)
|
if (NOT pico_sdk)
|
||||||
message("Downloading Raspberry Pi Pico SDK")
|
message("Downloading Raspberry Pi Pico SDK")
|
||||||
FetchContent_Populate(pico_sdk)
|
# GIT_SUBMODULES_RECURSE was added in 3.17
|
||||||
|
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
|
||||||
|
FetchContent_Populate(
|
||||||
|
pico_sdk
|
||||||
|
QUIET
|
||||||
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||||
|
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
|
||||||
|
GIT_SUBMODULES_RECURSE FALSE
|
||||||
|
|
||||||
|
SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-src
|
||||||
|
BINARY_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-build
|
||||||
|
SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-subbuild
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
FetchContent_Populate(
|
||||||
|
pico_sdk
|
||||||
|
QUIET
|
||||||
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||||
|
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
|
||||||
|
|
||||||
|
SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-src
|
||||||
|
BINARY_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-build
|
||||||
|
SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-subbuild
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
|
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
|
||||||
endif ()
|
endif ()
|
||||||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user