FreeMASTER Lite Tutorial & Example Code Issue

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

FreeMASTER Lite Tutorial & Example Code Issue

Jump to solution
3,414 Views
sjc230
Contributor II

I'm currently trying to work through the following tutorial:
https://www.nxp.com/design/training/getting-started-with-freemaster-lite-and-json-rpc-protocol:GETTI...

I'm using the following product:
https://www.nxp.com/design/development-boards/automotive-motor-control-solutions/arm-based-solutions...

My goal is to try to get FreeMASTER Lite to work with this device from a Raspberry Pi with a Linux based OS.

Currently I have a Windows 10 pc with a VM of Ubuntu 20.4. I have everything installed on the Win10 pc, as well as everything installed on Ubuntu VM (except FreeMASTER Communications Driver, which I could not locate for Linux. Is there a Linux version available).

I have changed the "connection" variable in the example code to match my device.

Using Win10: When going through the example code provided with FreeMASTER Lite (FML_Python.ipynb), all of the code works, until ln[13], at which point I get the following error:

---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-13-c73f0bac6521> in <module>
----> 1 data = await SendRequest(jrpc, 'GetConfigParamString', "VS", 20)
2 print('Application version: ' + data)

<ipython-input-4-c6ba3a234475> in SendRequest(jrpc, method, *args)
4 return response.data.result['data']
5 else:
----> 6 raise Exception(response.data.result['error'])

Exception: {'code': 2147483907, 'message': "Can't detect board."}

I've been unable to fix this. Assistance would be appreciated.

Tags (1)
0 Kudos
1 Solution
3,309 Views
sjc230
Contributor II

@iulian_stan 

Thanks for the update.

After replacing the dll, I was able to control the motor.

Stephen

 

View solution in original post

0 Kudos
9 Replies
3,385 Views
iulian_stan
NXP Employee
NXP Employee

Hi @sjc230,

FreeMASTER Driver is a communication library that implements the communication protocol on the target MCU side. Applications distributed with MCSPTE1AK144 development kit already include it and no action is required on that side. 

Your error `Exception: {'code': 2147483907, 'message': "Can't detect board."}` tells me that FreeMASTER tool was not able to detect the target board - this is a bit strange because in this case previous call

 

await SendRequest(jrpc, 'IsBoardDetected')
print('Board detected')

 

should've failed with the same error. Going further, `GetConfigParamString` would fail anyway because MCAT example applications use an older version of FreeMASTER Driver that does not implement some API calls. Could you replace 'GetConfigParamString' calls with:

 

data = await SendRequest(jrpc, 'GetDetectedBoardInfo')
print('Detected board info: ' + data)

 

It should return a similar result you can see in the tutorial @16:20.

Note `protVer` property is equal to `3`. `GetConfigParamString` was added in version 4. You can find full list of API calls in {FreeMASTER_install_dir}/html/documentation/PCM.html.

Capture3.PNG

To summarize: calls to `GetConfigParamString` would fail either way. Try replacing it with `GetDetectedBoardInfo`. All other calls from the Jupyter notebook should work with your application.

Another note on your goal - although FreeMASTER Lite supports Linux, the binaries are built for a x86 platform, and I would expect it to fail if you were to run it on ARM (Raspberry PI).

0 Kudos
3,377 Views
sjc230
Contributor II

@iulian_stan 

Thanks for the assistance.  I implemented the recommended code and it worked.  I had some initial problems with it, but it was due to a loose connection on the board.

 

0 Kudos
3,374 Views
sjc230
Contributor II

@iulian_stan 

I've exported the freemaster configuration file as shown in the tutorial.  I would like to change the motorspeed on the board via RPC. The variable I'm interested in (according to various posts in the community) from the config file is as follows:

{
"name": "Speed Required",
"addr": "drvFOC.pospeControl.wRotElReq",
"size": 4,
"type": "float"
},

Note that when I enumerate the symbols on the board, one of those symbols is "drvFOC"

If I use "drvFOC.pospeControl.wRotElReq" when creating the variable, "drvFOC.pospeControl.wRotElReq" becomes the alias, but no actual address is assigned.  An I cannot read or write to it.  How do I get this address?

{'name': 'Speed Required', 'type': 'float', 'size': 4, 'alias': 'drvFOC.pospeControl.wRotElReq'}

If I use "drvFOC" only as the variable address, it becomes the alias and an actual address is assigned. and I can read/write.

{'name': 'Speed Required', 'addr': 536873776, 'type': 'float', 'size': 4, 'alias': 'drvFOC'}
0 Kudos
3,365 Views
iulian_stan
NXP Employee
NXP Employee

Hi @sjc230,

I suspect it's a FreeMASTER Lite bug.

An workaround for this issue is to use known symbol + offset. I used FreeMASTER project (.pmp) to check the addresses of 'drvFoc' and 'drvFOC.pospeControl.wRotElReq' and got the offset of 368 (this value is a constant that shows 'wRotElReq' offset inside the structure).
You can update variable information as follows:

{
"name": "Speed Required",
"addr": "drvFOC + 368",
"size": 4,
"type": "float"
},

 

We will further investigate this issue and post updates in this thread.
Apologies for the inconveniences.

0 Kudos
3,353 Views
sjc230
Contributor II

@iulian_stan 

Thanks for the information.  I have a freemaster project setup.  I can locate the variables under the project menu, but cannot locate the actual addresses.  In the address window of the variables, it has the "virtual address".  Example: "cntrState.usrControl.switchAppOnOffState".  How did you get the actual address in the projcet?

Thanks

Stephen

0 Kudos
3,346 Views
iulian_stan
NXP Employee
NXP Employee

The way FreeMASTER handles symbolic information (variables addresses) is described in the FreeMASTER User Guide ch. 5.2. To summarize - there are 2 options:

  1. TSA (Target-Side Addressing) this is a functionality that allows developers exposes variable information directly from the embedded application (see more information in Driver User Guide.pdf, ch. 2.2.7). It is already implemented in PMSM project. You just need to establish a connection to the target board and FreeMASTER tool will read all information automatically. Then, you should be able to see the numeric value above the address field.
    Capture3.PNG
  2.  ELF file - this one will extract the information from the executable file (considering debug data is not stripped) and does not require an active connection to the target board. It can be loaded from Project → Options → MAP Files
    Capture4.PNGAfter the file is loaded, addresses should be displayed just like in the previous screen-shot.
0 Kudos
3,362 Views
iulian_stan
NXP Employee
NXP Employee

This bug was confirmed. You can apply the attached patch (by overwriting `freemaster.dll` inside FreeMASTER Lite folder). Official fix will be available in next FreeMASTER release.

0 Kudos
2,204 Views
UserTetraWise
Contributor I

Hello,

 

I am having similar issue: "can't detect board" on Freemaster Lite on Linux platform. Is there anything I am missing?. Thank you.

Regards,

TetraWise

 

Checking Error if any, from Received Data on method IsBoardDetected :
Ok(result={'success': True, 'data': False}, id=2)
False

0 Kudos
3,310 Views
sjc230
Contributor II

@iulian_stan 

Thanks for the update.

After replacing the dll, I was able to control the motor.

Stephen

 

0 Kudos