OpenOCD + GDB
This commit is contained in:
		
							
								
								
									
										24
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								flake.nix
									
									
									
									
									
								
							@@ -26,6 +26,8 @@
 | 
				
			|||||||
            rootFileContent = builtins.readFile rootdir.outPath;
 | 
					            rootFileContent = builtins.readFile rootdir.outPath;
 | 
				
			||||||
          in
 | 
					          in
 | 
				
			||||||
          pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
 | 
					          pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ocdInterface = mcu/tigard-swd.cfg;
 | 
				
			||||||
      in
 | 
					      in
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        devenv.shells.mcu = {
 | 
					        devenv.shells.mcu = {
 | 
				
			||||||
@@ -34,6 +36,7 @@
 | 
				
			|||||||
          packages = with pkgs; [
 | 
					          packages = with pkgs; [
 | 
				
			||||||
            gnumake
 | 
					            gnumake
 | 
				
			||||||
            cmake
 | 
					            cmake
 | 
				
			||||||
 | 
					            pkgsCross.arm-embedded.buildPackages.gdb # ARM one is broken
 | 
				
			||||||
            gcc-arm-embedded
 | 
					            gcc-arm-embedded
 | 
				
			||||||
            python3
 | 
					            python3
 | 
				
			||||||
            picotool
 | 
					            picotool
 | 
				
			||||||
@@ -43,6 +46,27 @@
 | 
				
			|||||||
          env = {
 | 
					          env = {
 | 
				
			||||||
            PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
 | 
					            PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          scripts = {
 | 
				
			||||||
 | 
					            build.exec = ''
 | 
				
			||||||
 | 
					              cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D PICO_STDIO_SEMIHOSTING=1
 | 
				
			||||||
 | 
					              cmake --build build --parallel
 | 
				
			||||||
 | 
					            '';
 | 
				
			||||||
 | 
					            build-rel.exec = ''
 | 
				
			||||||
 | 
					              cmake -S . -B build-release -D CMAKE_BUILD_TYPE=Release
 | 
				
			||||||
 | 
					              cmake --build build-release --parallel
 | 
				
			||||||
 | 
					            '';
 | 
				
			||||||
 | 
					            clean.exec = ''
 | 
				
			||||||
 | 
					              rm -rf build/ build-release/
 | 
				
			||||||
 | 
					            '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ocd.exec = ''
 | 
				
			||||||
 | 
					              openocd -f ${ocdInterface} -f target/rp2040.cfg
 | 
				
			||||||
 | 
					            '';
 | 
				
			||||||
 | 
					            gdb.exec = ''
 | 
				
			||||||
 | 
					              arm-none-eabi-gdb -x .gdbinit build/qclk.elf
 | 
				
			||||||
 | 
					            '';
 | 
				
			||||||
 | 
					          };
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								mcu/.gdbinit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								mcu/.gdbinit
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					target extended-remote localhost:3333
 | 
				
			||||||
 | 
					monitor arm semihosting enable
 | 
				
			||||||
 | 
					monitor reset init
 | 
				
			||||||
 | 
					monitor debug_level -2
 | 
				
			||||||
							
								
								
									
										1
									
								
								mcu/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								mcu/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1 +1,2 @@
 | 
				
			|||||||
/build/
 | 
					/build/
 | 
				
			||||||
 | 
					/build-release/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,14 +6,14 @@ include(pico_sdk_import.cmake)
 | 
				
			|||||||
project(test_project C CXX ASM)
 | 
					project(test_project 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_C_COMPILER_WORKS ON)
 | 
					 | 
				
			||||||
set(CMAKE_CXX_COMPILER_WORKS ON)
 | 
					 | 
				
			||||||
pico_sdk_init()
 | 
					pico_sdk_init()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(qclk
 | 
					add_executable(qclk
 | 
				
			||||||
  main.c
 | 
					  main.c
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pico_enable_stdio_usb(qclk 1)
 | 
					pico_enable_stdio_usb(qclk 1)
 | 
				
			||||||
pico_enable_stdio_uart(qclk 1)
 | 
					pico_enable_stdio_uart(qclk 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pico_add_extra_outputs(qclk)
 | 
					pico_add_extra_outputs(qclk)
 | 
				
			||||||
target_link_libraries(qclk pico_stdlib)
 | 
					target_link_libraries(qclk pico_stdlib)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								mcu/main.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								mcu/main.c
									
									
									
									
									
								
							@@ -1,13 +1,16 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include "pico/stdlib.h"
 | 
					
 | 
				
			||||||
#include "hardware/gpio.h"
 | 
					#include "hardware/gpio.h"
 | 
				
			||||||
 | 
					#include "pico/stdlib.h"
 | 
				
			||||||
#include "pico/binary_info.h"
 | 
					#include "pico/binary_info.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const uint LED_PIN = 25;
 | 
					const uint PIN_DIGIT_BASE = 18;
 | 
				
			||||||
 | 
					const uint PIN_SEGMENT_BASE = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const uint DIGITS = 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main() {
 | 
					int main() {
 | 
				
			||||||
  bi_decl(bi_program_description("This is a test binary."));
 | 
					  bi_decl(bi_program_description("qCLK driver."));
 | 
				
			||||||
  bi_decl(bi_1pin_with_name(LED_PIN, "On-board LED"));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  stdio_init_all();
 | 
					  stdio_init_all();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								mcu/tigard-swd.cfg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								mcu/tigard-swd.cfg
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					adapter driver ftdi
 | 
				
			||||||
 | 
					transport select swd
 | 
				
			||||||
 | 
					ftdi_vid_pid 0x0403 0x6010
 | 
				
			||||||
 | 
					ftdi_channel 1
 | 
				
			||||||
 | 
					adapter speed 2000
 | 
				
			||||||
 | 
					ftdi_layout_init 0x0028 0x002b
 | 
				
			||||||
 | 
					ftdi_layout_signal SWD_EN -data 0
 | 
				
			||||||
 | 
					ftdi_layout_signal nSRST -data 0x0020
 | 
				
			||||||
		Reference in New Issue
	
	Block a user