FreeMASTER Lite Tutorial & Example Code Issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

FreeMASTER Lite Tutorial & Example Code Issue

跳至解决方案
4,229 次查看
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.

标记 (1)
0 项奖励
回复
1 解答
4,124 次查看
sjc230
Contributor II

@iulian_stan 

Thanks for the update.

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

Stephen

 

在原帖中查看解决方案

0 项奖励
回复
9 回复数
4,200 次查看
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 项奖励
回复
4,192 次查看
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 项奖励
回复
4,189 次查看
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 项奖励
回复
4,180 次查看
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 项奖励
回复
4,168 次查看
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 项奖励
回复
4,161 次查看
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 项奖励
回复
4,177 次查看
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 项奖励
回复
3,019 次查看
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 项奖励
回复
4,125 次查看
sjc230
Contributor II

@iulian_stan 

Thanks for the update.

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

Stephen

 

0 项奖励
回复