I am trying to unit test (using unity+ceedling) some STM32 code on my linux machine, but every time I access any register the code fails with this error:
> Produced no final test result counts in $stdout:
Segmentation fault (core dumped)
> And exited with status: [0] (count of failed tests).
> This is often a symptom of a bad memory access in source or test code
For example this code will result in PASSED 1/1 (note that I am testing function that returns a+b and has nothing to do with STM peripherals).
#include "unity.h"
#include "sum2nums.h"
#include "stm32f4xx.h"
void test_Sum(){
TEST_ASSERT_EQUAL_UINT32(5, Sum(3, 2));
}
But this code will produced the error mentioned above.
#include "unity.h"
#include "sum2nums.h"
#include "stm32f4xx.h"
void test_Sum(){
GPIOA->MODER = 1U;
TEST_ASSERT_EQUAL_UINT32(5, Sum(3, 2));
}
Is it even possible to test it this way or do I have to use QEMU (and how to do so without using Eclipse or any other IDE)? Note that Ceedling uses gcc, if I'd use arm-none-eabi it would produce hex file and I couldn't run that on my PC.