I have been working on a project targetting the RP2040 for the past few months and used the WIZ-IO-PICO framework. The platform repo was removed from github a few days ago which is where the wiki was hosted. Flying slightly blind here but I don’t believe there was a page about unit testing anyways. I am using a picoprobe for debugging and have a version of openocd precompiled for picoprobe.
I have had semi-hosting ~working~ for a while but have not attempted to use it for unit testing until today. When I use the debug_test
option and debug, the code uploads successfully and the tests are a success. Additionally, if I run the platformio test command in VScode, it runs successfully.
The problem I run into is if I change the code and attempt to run it again without uploading from the debugger. In verbose test mode, the openocd output reports errors verifying the data uploaded to the pcb. I am convinced my issue is with the test_testing_command
. I have looked through a bunch of openOCD documentation, gdbDocs, and dug through the WIZIO-PICO code to try and find the right commands for flashing via picoprobe to no avail. Any pointers would be much appreciated.
unity_config.h
#include "unity.h"
#ifndef UNITY_CONFIG_H
#define UNITY_CONFIG_H
#ifndef NULL
#ifndef __cplusplus
#define NULL (void*)0
#else
#define NULL 0
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
void unityOutputStart();
void unityOutputChar(char);
void unityOutputFlush();
void unityOutputComplete();
#define UNITY_OUTPUT_CHAR(a) unityOutputChar(a)
//#define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */
#define UNITY_OUTPUT_FLUSH() unityOutputFlush()
//#define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */
#define UNITY_OUTPUT_START() unityOutputStart()
#define UNITY_OUTPUT_COMPLETE() unityOutputComplete()
#ifdef __cplusplus
}
#endif
#endif /* UNITY_CONFIG_H */
unity_config.c
#include "unity_config.h"
#include "pico/stdio.h"
#include <stdio.h>
#include <string.h>
#define BUFFER_SIZE 256
static char buffer[BUFFER_SIZE];
static int buffer_index = 0;
int my_putchar(char c) {
buffer[buffer_index++] = c;
if (buffer_index == BUFFER_SIZE || c == '\n') {
// Flush the buffer
puts_raw(buffer);
memset(buffer, '\0', sizeof(buffer));
buffer_index = 0;
}
return c;
}
void unityOutputStart(){
}
void unityOutputChar(char c){
my_putchar(c);
}
void unityOutputFlush(){
}
void unityOutputComplete(){
}
platformio.ini
build_type = test
debug_test = OSAL/test_OSAL
debug_init_break = tbreak _reset_handler
test_framework = unity
test_testing_command =
${platformio.packages_dir}/tool-pico-openocd/windows/picoprobe.exe
-s
${platformio.packages_dir}/tool-pico-openocd
-s
${platformio.packages_dir}/tool-pico-openocd/share/openocd/scripts
-f
share/openocd/scripts/interface/picoprobe.cfg
-f
share/openocd/scripts/target/rp2040.cfg
-c
program ${platformio.build_dir}/APPLICATION.elf verify reset
-c
init
-c
arm semihosting enable
-c
reset halt
-c
resume