Follow up question!! As i have mentioned I am working with the generic STM32F103C8 bluepills boards, converted one board to act as a blackmagic probe. I am using a upload.gdb file and “upload_protocol=gdb” in the platform.ini file. The compiling and uploading works just fine.
I have run into two problems while trying to implement unit testing with this board / framework combination.
-
Local host testing is not working.
This is my platform.ini file
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = mbed
upload_protocol = gdb
[env:local]
platform = native
framework = mbed
This is my upload.gdb file
target extended-remote /dev/cu.usbmodemBFDEA5F1
monitor swdp_scan
attach 1
load
quit
yes
When I run “pio test --environment=local” this is what I get in the console output.
krishis-MacBook-Pro:DigitalMeter krishi$ pio test --environment=local
PlatformIO Plus (https://pioplus.com) v0.2.3
Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items
====================================================== [test::*] Building... (1/2) ======================================================
[Sun Oct 16 00:13:47 2016] Processing local (platform: native, framework: mbed)
-----------------------------------------------------------------------------------------------------------------------------------------
Please wait...
Please specify `board` in `platformio.ini` to use with 'mbed' framework
======================================================= [ERROR] Took 0.54 seconds =======================================================
=============================================================== [SUMMARY] ===============================================================
Environment local [ERROR]
Environment bluepill_f103c8 [SKIP]
======================================================= [ERROR] Took 0.54 seconds =======================================================
When I add “board = bluepill_f103c8” option to the local environment this is what I get.
krishis-MacBook-Pro:DigitalMeter krishi$ pio test --environment=local
PlatformIO Plus (https://pioplus.com) v0.2.3
Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items
====================================================== [test::*] Building... (1/2) ======================================================
[Sun Oct 16 00:14:12 2016] Processing local (platform: native, board: bluepill_f103c8, framework: mbed)
-----------------------------------------------------------------------------------------------------------------------------------------
Please wait...
Error: Unknown board ID 'bluepill_f103c8'
======================================================= [ERROR] Took 0.54 seconds =======================================================
=============================================================== [SUMMARY] ===============================================================
Environment local [ERROR]
Environment bluepill_f103c8 [SKIP]
======================================================= [ERROR] Took 0.54 seconds =======================================================
I am guessing I goofed up some switch / setting somewhere.
The second is to do with the target testing. When I try to run the unit tests on the live target the console is getting through till the third step and is stuck at the third step “testing”
This is my console output.
PlatformIO Plus (https://pioplus.com) v0.2.3
Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items
====================================================== [test::*] Building... (1/3) ======================================================
[Sun Oct 16 00:24:27 2016] Processing bluepill_f103c8 (upload_protocol: gdb, platform: ststm32, board: bluepill_f103c8, framework: mbed)
-----------------------------------------------------------------------------------------------------------------------------------------
Please wait...
=============================================================== [SUMMARY] ===============================================================
Environment local [SKIP]
Environment bluepill_f103c8 [SUCCESS]
====================================================== [SUCCESS] Took 2.67 seconds ======================================================
===================================================== [test::*] Uploading... (2/3) =====================================================
[Sun Oct 16 00:24:30 2016] Processing bluepill_f103c8 (upload_protocol: gdb, platform: ststm32, board: bluepill_f103c8, framework: mbed)
-----------------------------------------------------------------------------------------------------------------------------------------
Please wait...
Target voltage: Not Implemented!
Available Targets:
No. Att Driver
1 STM32F1 medium density
=============================================================== [SUMMARY] ===============================================================
Environment local [SKIP]
Environment bluepill_f103c8 [SUCCESS]
====================================================== [SUCCESS] Took 6.16 seconds ======================================================
====================================================== [test::*] Testing... (3/3) ======================================================
If you don't see any output for the first 10 secs, please reset board (press reset button)
The console is stuck at that point without any progress, inspite of resetting the target board.
I am having to CTRL + C to abort the operation at that point.
I am guessing that this is owing to my misuse of the embedded target testing protocol, which is not designed for testing using gdb?? Or is it arduino specific?? Or am I not seeing something obvious that is right in front of me…
I have not tested using a St-Link adapter ( I do not have it presently with me, I shall report back my findings with the St-Link programmer in a day or two.)
Thanks again for your time!! 
PS: Forgot to attach my source files
Here is my source
main.cpp
#include "mbed.h"
#ifndef UNIT_TEST
DigitalOut myled(PC_13);
int main(void)
{
while(1) {
myled=1;
wait(1);
myled=0;
wait(1);
}
}
#endif
And here is my test file
test_main.cpp
#include "mbed.h"
#include "unity.h"
#ifdef UNIT_TEST
DigitalOut myled(PC_13);
void test_led_write_high(void)
{
myled.write(1);
TEST_ASSERT_EQUAL(myled.read(), 1);
}
void test_led_write_low(void)
{
myled.write(0);
TEST_ASSERT_EQUAL(myled.read(), 0);
}
int main(void)
{
UNITY_BEGIN();
for(int i=0;i<10;i++)
{
RUN_TEST(test_led_write_high);
wait(0.5);
RUN_TEST(test_led_write_low);
wait(0.5);
i++;
}
UNITY_END();
}
#endif