Skip to content

Commit

Permalink
Merge pull request #7 from rgrr/feature/version-number
Browse files Browse the repository at this point in the history
Version number at several places
  • Loading branch information
rgrr committed Dec 29, 2022
2 parents 886a532 + b5567d8 commit db3cf62
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 33 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ project(picoprobe)

pico_sdk_init()


if (PICOPROBE_VERSION)
add_definitions(-DPICOPROBE_VERSION=0x${PICOPROBE_VERSION})
endif()
if (OPTIMIZE_FOR_OPENOCD)
add_definitions(-DOPTIMIZE_FOR_OPENOCD=${OPTIMIZE_FOR_OPENOCD})
endif()
if (PICOPROBE_VERSION)
add_definitions(-DGIT_HASH="${GIT_HASH}")
endif()


add_executable(picoprobe
src/cdc_uart.c
src/dap_util.c
Expand Down
50 changes: 38 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
# Makefile to build YAPicoprobe
#

VERSION := 0103
OPTIMIZE_FOR_OPENOCD ?= 0


GIT_HASH := $(shell git rev-parse --short HEAD)

CMAKE_FLAGS = -DPICOPROBE_VERSION=$(VERSION)
CMAKE_FLAGS += -DOPTIMIZE_FOR_OPENOCD=$(OPTIMIZE_FOR_OPENOCD)
CMAKE_FLAGS += -DGIT_HASH=$(GIT_HASH)
CMAKE_FLAGS += -DCMAKE_EXPORT_COMPILE_COMMANDS=True


.PHONY: clean
clean:
cd build && ninja clean
ninja -C build -v clean


.PHONY: all
all:
cd build && ninja -v all
ninja -C build -v all


.PHONY: cmake-create-debug
cmake-create-debug:
mkdir -p build
cd build && cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=True ..
# don't know if this is required
cd build && sed -i 's/arm-none-eabi-gcc/gcc/' compile_commands.json
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug $(CMAKE_FLAGS)
# don't know if this is required
@cd build && sed -i 's/arm-none-eabi-gcc/gcc/' compile_commands.json


.PHONY: cmake-create-release
cmake-create-release:
mkdir -p build
cd build && cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=True ..
# don't know if this is required
cd build && sed -i 's/arm-none-eabi-gcc/gcc/' compile_commands.json
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release $(CMAKE_FLAGS)
# don't know if this is required
@cd build && sed -i 's/arm-none-eabi-gcc/gcc/' compile_commands.json


.PHONY: clean-build
clean-build:
rm -rfv build
mkdir -p build


.PHONY: flash
flash: all
@echo "Waiting for RPi bootloader..."
@until [ -f /media/pico/INDEX.HTM ]; do sleep 1; done; echo "ready!"
@until [ -f /media/pico/INDEX.HTM ]; do sleep 0.1; done; echo "ready!"
cp build/picoprobe.uf2 /media/pico
@echo "ok."


.PHONY: create-images
create-images:
$(MAKE) clean-build
$(MAKE) cmake-create-debug OPTIMIZE_FOR_OPENOCD=1
$(MAKE) all
mkdir -p images
rm images/*.uf2
cp build/picoprobe.uf2 images/yapicoprobe-$(VERSION)-$(GIT_HASH)-openocd.uf2
@
$(MAKE) cmake-create-debug OPTIMIZE_FOR_OPENOCD=0
$(MAKE) all
cp build/picoprobe.uf2 images/yapicoprobe-$(VERSION)-$(GIT_HASH).uf2
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ So there is unfortunately one more Picoprobe around, the YAPicoprobe.
* MSC - drag-n-drop support a la [DAPLink](https://github.com/ARMmbed/DAPLink) for the RP2040 Pico / PicoW
* CDC - virtual com port for logging of the target
* UART connection between target and probe is redirected
* RTT terminal channel is automatically redirected into this CDC (if there is no DAPv2/MSC connection)
* RTT terminal channel is automatically redirected into this CDC (if there is no CMSIS-DAPv2/MSC connection)
* CDC - virtual com port for logging of the probe
* LED for state indication

## Other Benefits
* no more Zadig fiddling
* easy upload of a firmware image to the target via the probe
* no more reset push button required for the target to put into BOOTSEL mode
* no more Zadig fiddling because the underlying protocols of CMSIS-DAPv1 and v2 are driver-less
* easy drag-n-drop (or copy) upload of a firmware image to the target via the probe
* no more reset push button (or disconnect/connect cycle) to put the target into BOOTSEL mode

## Minus
* custom Picoprobe protocol has been dropped
Expand All @@ -36,7 +36,7 @@ Picoprobe documentation can be found in the [Pico Getting Started Guide](https:/

Wires between probe and target board are the same as before, but the UART wires can be omitted if RTT is used for logging on the target device.

I recommend to use a simple Pico board as the probe. The PicoW does not add any features, instead the LED indicator does not work there.
I recommend to use a simple Raspberry Pi Pico board as the probe. The Pico W board does not add any features, instead the LED indicator does not work there.


## Tool Compatibility
Expand Down
Binary file added images/yapicoprobe-0103-cfff336-openocd.uf2
Binary file not shown.
Binary file added images/yapicoprobe-0103-cfff336.uf2
Binary file not shown.
1 change: 1 addition & 0 deletions src/daplink/cmsis-dap/debug_cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef DEBUG_CM_H
#define DEBUG_CM_H

#include "DAP_config.h"
#include "DAP.h"

// SWD register access
Expand Down
5 changes: 4 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ int main(void)

// now we can "print"
picoprobe_info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
picoprobe_info(" Welcome to Yet Another Picoprobe v%02x.%02x\n", PICOPROBE_VERSION >> 8, PICOPROBE_VERSION & 0xff);
picoprobe_info(" Welcome to Yet Another Picoprobe v%02x.%02x-" GIT_HASH "\n", PICOPROBE_VERSION >> 8, PICOPROBE_VERSION & 0xff);
#if OPTIMIZE_FOR_OPENOCD
picoprobe_info(" OpenOCD optimized version\n");
#endif
picoprobe_info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");

sw_lock_init();
Expand Down
15 changes: 13 additions & 2 deletions src/msc/msc_drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,19 @@
#define CLUSTERS(BYTES) (((BYTES) + BPB_BytsPerClus - 1) / BPB_BytsPerClus)
#define AFAT12(C1,C2) (C1) & 0xff, (((C1) & 0xf00) >> 8) + (((C2) & 0x0f) << 4), (((C2) & 0xff0) >> 4)

#if OPTIMIZE_FOR_OPENOCD
#define SPEC_VERSION "-openocd"
#else
#define SPEC_VERSION
#endif
#if defined(GIT_HASH)
#define _GIT_HASH "-" GIT_HASH
#else
#define GIT_HASH
#endif

#define README_CONTENTS \
"This is Yet Another Picoprobe v%02x.%02x.\r\n\r\n\
"This is Yet Another Picoprobe v%02x.%02x" _GIT_HASH SPEC_VERSION ".\r\n\r\n\
- CURRENT.UF2 mirrors the flash content of the target\r\n\
- INFO_UF2.TXT holds some information about probe and target\r\n\
- drop a UF2 file to flash the target device\r\n"
Expand All @@ -71,7 +82,7 @@
#define INDEXHTM_SIZE (sizeof(INDEXHTM_CONTENTS) + 28 - 1)

#define INFOUF2_CONTENTS \
"UF2 Target Programmer v%02x.%02x for RP2040\r\n\
"UF2 Target Programmer v%02x.%02x" _GIT_HASH SPEC_VERSION " for RP2040\r\n\
Model: Yet Another Picoprobe\r\n\
Board-ID: RPI-RP2\r\n"
#define INFOUF2_SIZE (sizeof(INFOUF2_CONTENTS) - (4 + 1))
Expand Down
24 changes: 12 additions & 12 deletions src/picoprobe_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@
#define PICOPROBE_H_


#define PICOPROBE_VERSION 0x0103
#if !defined(PICOPROBE_VERSION)
#define PICOPROBE_VERSION 0x0103
#endif

/// which means: pyocd will not work.
#ifndef OPTIMIZE_FOR_OPENOCD
#define OPTIMIZE_FOR_OPENOCD 0
#endif

#define INCLUDE_RTT_CONSOLE



#if !defined(NDEBUG)
Expand Down Expand Up @@ -70,12 +80,10 @@
#define PROBE_PIN_OFFSET 2
#define PROBE_PIN_SWCLK (PROBE_PIN_OFFSET + 0) // 2
#define PROBE_PIN_SWDIO (PROBE_PIN_OFFSET + 1) // 3
#define PROBE_PIN_RESET 6 // Target reset config
#define PROBE_MAX_KHZ 20000U
#define PROBE_DEFAULT_KHZ 12500U

// Target reset config
#define PROBE_PIN_RESET 6

// UART config (UART target -> probe)
#define PICOPROBE_UART_TX 4
#define PICOPROBE_UART_RX 5
Expand All @@ -93,12 +101,4 @@
#endif
#endif

/// which means: pyocd will not work.
#ifndef OPTIMIZE_FOR_OPENOCD
#define OPTIMIZE_FOR_OPENOCD 0
#endif


#define INCLUDE_RTT_CONSOLE

#endif
2 changes: 1 addition & 1 deletion src/sw_dp_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

/* Slight hack - we're not bitbashing so we need to set baudrate off the DAP's delay cycles.
* Ideally we don't want calls to udiv everywhere... */
#define MAKE_KHZ(fast, delay) (fast ? 100000 : (CPU_CLOCK / 2000) / (delay * DELAY_SLOW_CYCLES + IO_PORT_WRITE_CYCLES))
#define MAKE_KHZ(fast, delay) ((fast) ? 100000 : (CPU_CLOCK / 2000) / ((delay) * DELAY_SLOW_CYCLES + IO_PORT_WRITE_CYCLES))
volatile uint32_t cached_delay = 0;


Expand Down

0 comments on commit db3cf62

Please sign in to comment.