Auto connect JLink when application start up

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Auto connect JLink when application start up

404 Views
LuBiq
Contributor II

I want to capture the initial state of the application. Is there any solution to make FreeMASTER connect target board immediately and automatically when application start up?

0 Kudos
Reply
2 Replies

377 Views
iulian_stan
NXP Employee
NXP Employee

Hi @LuBiq,

You can achieve this behavior by simulating a loop in the initialization phase of your application that would wait for a global variable (trigger).

After you connect to the target using FreeMASTER, you can change that variable value to continue application execution. Ex:

volatile char wait = 1; // Trigger variable (to be chnaged from FreeMASTER)
void main() {
  while (wait) {
    // Wait for trigger to change
  }
  // Application logic
} 

 

Note: this approach will work only with BDM plugin as other plugins require some initializations before you'll be able to connect to the target.

336 Views
LuBiq
Contributor II

I find a very simple solution.

(1) After building, start the application via debug. The application will be suspended at the first code in main() by a breakpoint.

(2) Start communication in FreeMASTER.

(3) Disable all breakpoints, application begins to run.

Can this solution meet my requirement?

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2265624%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EAuto%20connect%20JLink%20when%20application%20start%20up%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2265624%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20want%20to%20capture%20the%20initial%20state%20of%20the%20application.%20Is%20there%20any%20solution%20to%20make%20FreeMASTER%20connect%20target%20board%20immediately%20and%20automatically%20when%20application%20start%20up%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2266415%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Auto%20connect%20JLink%20when%20application%20start%20up%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2266415%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20find%20a%20very%20simple%20solution.%3C%2FP%3E%3CP%3E(1)%20After%20building%2C%20start%20the%20application%20via%20debug.%20The%20application%20will%20be%20suspended%20at%20the%20first%20code%20in%20main()%20by%20a%20breakpoint.%3C%2FP%3E%3CP%3E(2)%20Start%20communication%20in%20FreeMASTER.%3C%2FP%3E%3CP%3E(3)%20Disable%20all%20breakpoints%2C%20application%20begins%20to%20run.%3C%2FP%3E%3CP%3ECan%20this%20solution%20meet%20my%20requirement%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2265807%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Auto%20connect%20JLink%20when%20application%20start%20up%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2265807%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F258053%22%20target%3D%22_blank%22%3E%40LuBiq%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EYou%20can%20achieve%20this%20behavior%20by%20simulating%20a%20loop%20in%20the%20initialization%20phase%20of%20your%20application%20that%20would%20wait%20for%20a%20global%20variable%20(trigger).%3C%2FP%3E%0A%3CP%3EAfter%20you%20connect%20to%20the%20target%20using%20FreeMASTER%2C%20you%20can%20change%20that%20variable%20value%20to%20continue%20application%20execution.%20Ex%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3Evolatile%20char%20wait%20%3D%201%3B%20%2F%2F%20Trigger%20variable%20(to%20be%20chnaged%20from%20FreeMASTER)%0Avoid%20main()%20%7B%0A%20%20while%20(wait)%20%7B%0A%20%20%20%20%2F%2F%20Wait%20for%20trigger%20to%20change%0A%20%20%7D%0A%20%20%2F%2F%20Application%20logic%0A%7D%20%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3ENote%3A%20this%20approach%20will%20work%20only%20with%20BDM%20plugin%20as%20other%20plugins%20require%20some%20initializations%20before%20you'll%20be%20able%20to%20connect%20to%20the%20target.%3C%2FP%3E%3C%2FLINGO-BODY%3E