0
votes

I was trying example Simulink code for BeagleBone Blue named Counting Steps Using BeagleBone Blue Hardware. The web side is this.

https://www.mathworks.com/help/supportpkg/beagleboneblue/ref/counting-steps-using-beagleboneblue-hardware-example.html

When I try to send the code to Beagle, I get this error below.

Also, I would like to use I2C bus with BeagleBone Blue and control Beagle with Matlab (2019b) and Simulink. If I add any I2C block to Simulink model and try to send the code to Beagle I get the same error. It seems like the created C code is wrong. Does anybody know how to fix this?

Error executing command "touch -c /home/debian/beagleboneblue_countstep_ert_rtw/*.*;make  -f beagleboneblue_countstep.mk all -C /home/debian/beagleboneblue_countstep_ert_rtw". Details:

STDERR: MW_I2C.c: In function ‘EXT_I2C_writeH’:
MW_I2C.c:140:20: error: storage size of ‘msg’ isn’t known
     struct i2c_msg msg;
                    ^~~
MW_I2C.c: In function ‘EXT_I2C_readH’:
MW_I2C.c:177:20: error: storage size of ‘msg’ isn’t known
     struct i2c_msg msg;
                    ^~~
MW_I2C.c:183:21: error: ‘I2C_M_RD’ undeclared (first use in this function)
         msg.flags = I2C_M_RD;
                     ^~~~~~~~
MW_I2C.c:183:21: note: each undeclared identifier is reported only once for each function it appears in
MW_I2C.c: In function ‘MW_I2C_MasterRead’:
MW_I2C.c:261:28: warning: passing argument 1 of ‘EXT_I2C_readH’ makes integer from pointer without a cast [-Wint-conversion]
     status = EXT_I2C_readH(I2CModuleHandle, SlaveAddress, data, DataLength);
                            ^~~~~~~~~~~~~~~
MW_I2C.c:169:5: note: expected ‘int’ but argument is of type ‘MW_Handle_Type {aka void *}’
 int EXT_I2C_readH(
     ^~~~~~~~~~~~~
MW_I2C.c: In function ‘MW_I2C_MasterWrite’:
MW_I2C.c:273:29: warning: passing argument 1 of ‘EXT_I2C_writeH’ makes integer from pointer without a cast [-Wint-conversion]
     status = EXT_I2C_writeH(I2CModuleHandle, SlaveAddress, data, DataLength);
                             ^~~~~~~~~~~~~~~
MW_I2C.c:132:5: note: expected ‘int’ but argument is of type ‘MW_Handle_Type {aka void *}’
 int EXT_I2C_writeH(
     ^~~~~~~~~~~~~~
MW_I2C.c: In function ‘MW_I2C_Close’:
MW_I2C.c:302:24: warning: passing argument 1 of ‘EXT_I2C_terminateH’ makes integer from pointer without a cast [-Wint-conversion]
     EXT_I2C_terminateH(I2CModuleHandle);
                        ^~~~~~~~~~~~~~~
MW_I2C.c:221:5: note: expected ‘int’ but argument is of type ‘MW_Handle_Type {aka void *}’
 int EXT_I2C_terminateH(int fd)
     ^~~~~~~~~~~~~~~~~~
make: *** [MW_I2C.c.o] Error 1

STDOUT: make: Entering directory '/home/debian/beagleboneblue_countstep_ert_rtw'
gcc -c -MMD -MP -MF"MW_I2C.c.dep" -MT"MW_I2C.c.o" -O0  -D_roboticscape_in_use_ -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0  -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=64 -DRT -DMODEL=beagleboneblue_countstep -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -I./ -o "MW_I2C.c.o" "MW_I2C.c"
beagleboneblue_countstep.mk:446: recipe for target 'MW_I2C.c.o' failed
make: Leaving directory '/home/debian/beagleboneblue_countstep_ert_rtw'

Thanks in advance

1
The messages are pretty clear. eg the first one, "storage size of msg isn't known". That should be pretty easy to track down, but since your code is not included, not sure how to help. Just read through each on, and look at the area of code it is about. Double check argument inputs to function calls are correct, etc. A minimal reproducible example here would help.ryyker
Somewhat related, at least for some of the errors... "some header files of “i2c-dev” library got re-organized and our I2C source code is not compatible with the same. MATLAB IO server" Look here for how they address this, maybe something similar will help you.ryyker

1 Answers

0
votes

Thanks @ryyker for his answer in the comments.

https://itectec.com/matlab/matlab-using-raspbian-buster-os-why-do-i-get-build-errors-related-to-i2c-when-creating-a-raspi-object-or-building-a-model-with-i2c-blocks/

To fix the error in Simulink for I2C blocks: Enter below command at the MATLAB prompt and edit the source code as shown in attached screenshot:

I used this fix but for BeagleBone Blue. The difference was just in this command.

edit(fullfile(codertarget.bbblue.internal.getSpPkgRootDir,'src','MW_I2C.c'))

Here is the picture of the I2C fix

The file change was the same as with Raspi.