I was trying example Simulink code for BeagleBone Blue named Counting Steps Using BeagleBone Blue Hardware. The web side is this.
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
Thanks @ryyker for his answer in the comments.
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.