ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects

Home Page:http://throwtheswitch.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unit testing on Target Hardware XC8 pic18. Programming target failed

shabu19 opened this issue · comments

Hi,
The Scenario
I am working on unit testing with unity using Ceedling. So far, I have been able to run my tests on Simulator. Now I want to run my tests on target hardware. I am trying to incorporate unit test in an already existing released project. I added some modules and test files to my project.

The Development
When I try to run these tests on simulator using Ceedling, they run fine (and generates test_build.elf or hex file in the test->out folder). The mdb commands from sim are as follow

device PIC18F25K22
hwtool sim
set oscillator.frequency            32
set oscillator.frequencyunit        Mega
set oscillator.rcfrequency          31
set oscillator.rcfrequencyunit      Kilo
set uart1io.uartioenabled           true
set uart1io.output                  stdout
set uart1io.outputfile              test/simulation/out.txt
set breakoptions.wdtwarnings        Ignore

program C:\Users\shahbaz.khan\MPLABXProjects\unit_testing\rm3_wifi_ceedling_ut\build\ceedling\generated\test\out\test_build.elf

Run
Sleep 5000
Quit

I build the project from MPLABX (while excluding all the unity/test files) and then I tried to debug the project using command line and it works well. I launched MPLABX debugger (simply running command: mdb.bat) from cmd and run following commands.

device PIC18F25K22
Hwtool icd4
set AutoSelectMemRanges manual
set memories.programmemory true
set memories.programmemory.start 0x0000
set memories.programmemory.end 0x3FFF
set programoptions.eraseb4program true
set programoptions.pgcconfig pulldown
set programoptions.pgcresistor.value 4.7
set programoptions.pgdconfig pulldown
set programoptions.pgdresistor.value 4.7
set programoptions.pgmentry.voltage high
set programoptions.pgmspeed Med

program C:\Users\shahbaz.khan\MPLABXProjects\unit_testing\project_x\dist\default\production\rm3_wifi_ceedling_ut.production.hex

run
write pin RA2 high
sleep 5000
quit

The Problem
As I already have the test_build.hex file from the testing using ceedling, I am trying to use that build file to flash it in the target hardware using the exact same commands as above and only changing the file path (build file from ceedling) to program command as

program C:\Users\shahbaz.khan\MPLABXProjects\unit_testing\project_x\build\ceedling\generated\test\out\test_build.elf

I get the follwoing errors

Programming target...
The requested operation cannot continue with the following configuration bit setting(s):

Watchdog Timer Enable bits = On

Would you like MPLAB to change the config setting(s) and continue?

NOTE: This will change configuration memory for this session only. It will not change the configuration bit settings in your code [yes/no]

>y

Erasing...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x3fff
configuration memory
EEData memory
User Id Memory

Script GetVersionDE failed with status Type = runScript, Script name = GetVersionDE, Status = 0xa00
.
The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding. The most common causes for this failure are oscillator and/or PGC/PGD settings.
Program failed.

Why is this a Ceedling problem? It best points at the Configuration problem for the MPLAB.