BSP version 2.0.5 and 1.2.1 compatibility

Dear all,

I am programming the Edge board through the Arduino IDE and been working on two sketches that now I need to combine. Unfortunately, the sketches require different BSPs as stated in the subject.

The sketches are:

i) BLE sketch requiring 2.0.5.

Using 1.2.1, this sketch throws the error already when using

#include <ArduinoBLE.h>

C:\Users\jante\Documents\Arduino\libraries\ArduinoBLE\src/BLETypedCharacteristics.h:60:61: error: ‘word’ was not declared in this scope
class BLEWordCharacteristic : public BLETypedCharacteristic {
^~~~
C:\Users\jante\Documents\Arduino\libraries\ArduinoBLE\src/BLETypedCharacteristics.h:60:65: error: template argument 1 is invalid
class BLEWordCharacteristic : public BLETypedCharacteristic {

ii) The basic HM01B0 sketch requiring 1.2.1 which can be found here https://github.com/sparkfun/SparkFun_HM … inoLibrary

which does not compile with BSP 2.0.5

Could anyone point me in the right direction on how to approach this problem? Is there a way to merge the BSPs or does code need to be rewritten?

THANK YOU for the smallest hint.

I do not have this camera, but downloaded the library and tried to compile it for an Edge board.

It failed, but I have made a number of adjustments/changes and now it compiles without error on 2.0.6

You need to remove the original library and use the attached one (the example sketch has been modified as well)

Not sure that it really works.

About BLE… it will not run on 1.2.1 as it lacks a number of components/drivers needed.

SparkFun_HM01B0_Camera_ArduinoLibrary-master-V2.zip (31 KB)

Thanks, Paul.

The original StopMotion sketch also compiles for me with your modified lib.

By the way, my minimal BLE sketch compiles with 2.0.6 without making any changes in the variant.h file of the BSP.

Now, I will try to send out the pictures via BLE. Let’s see how that goes… :slight_smile:

I guess I got too excited too fast. Indeed, the sketch Paul provided (as well as the original sketch) do compile and upload onto the Edge using Pauls modified HM01B0 lib and BSP 2.0.6.

However, inspecting the serial output or running the python script in the console, reveals that the camera does not start properly.

The output reads:

waiting for first frame
b’\x00’
b’Turned on camera regulator\r\nCamera.begin() failed with code: 1\nCalibrating Auto Exposure…\r\n’

The error code is “1”, i.e. HM01B0_ERR throws the error. Looking at the cpp file in the library:

status = hm01b0_get_modelid(&cfg, &ui16ModelId);
if( ui16ModelId != (uint16_t)HM01B0_MODEL_ID ){ status = HM01B0_ERR; }

It seems that there is a mismatch for the model ID. Paul, as you kindly provided the modified lib, does this give you any leads as to what causes the error?

Thanks.

Jan

As indicated before I do not have this camera, but just ordered one to play around with it. I looked at the code and there is some difference. Tthe error might happen earlier than you indicate as hm01b0_mclk_enable() does not return status in the new code. Put some Serial. print after each of the calls to when it fails.

Okay, thanks for the hint. I need to see how to debug the library, i.e. how to send Serial Prints out of the c++ file that I can see.

hm01b0_c.h (old lib) and hm01b0.h (new lib) are the files that contain the hm01b0_mclk_enable function and others. Comparing them, I notice that in the new lib, the body of the function is not there. I might be misunderstanding something entirely, but if not there, then where in the new lib is the body of these functions specified?

As an example:

NEW lib:

hm01b0_status_e hm01b0_mclk_enable(hm01b0_cfg_t *psCfg);

vs.

OLD lib:
hm01b0_status_e hm01b0_mclk_enable(hm01b0_cfg_t *psCfg)
{
if(psCfg->interface->mclk != NULL){
return psCfg->interface->mclk(psCfg, true, psCfg->interface->arg);
}else{
return HM01B0_ERR_UNIMPLEMENTED;
}
}

I got my camera and connected it. A number of issues:

Many double definitions and different definitions of structures while they have the same name in V1 and V2. Have cut down the original V1 library and use the code and definitions included in V2.0.6.

Power-on the camera with AM_BSP_GPIO_CAMERA_HM01B0_DVDDEN did not work. It is defined as D10 (GPIO10), but this is not defined as a Pinname in V2.06 ( only D1, D36, D38 and D3) Hence it failed. Would need a change in the Target PinNames.h and then a recompile of the MBED-OS library. Now replaced with other calls to set as output and high with different calls without the need to recompile the library.

It now starts and produces output. Have tried the Python interface and get some pictures, but they are not stable and do not make sense yet to me. But sharing the code for now so you can work on it as well. The code is still work in progress more work to be done.

SparkFun_HM01B0_Camera_ArduinoLibrary-master-V2.zip (17.2 KB)

finally… got it running BUT it needs a change in MBED-OS pre-compiled library. The reason is that V2.0.6 is getting regular interrupts to do “something” else . As a result on critical moments where every microsecond counts, the processor is interrupted and you lose the characters (pixel information) that are streamed from the camera. The picture is getting out of sync. By disabling interrupts on the critical moment you capture all the data. I have not tested this in combination with BLE etc.

I have made a version that works for me and you can install it following the information on https://github.com/paulvha/apollo3/tree/master/hb01b0

I will raise a bug report to Sparkfun.

I can follow the steps and the program also runs as you desrcibe it, also the Python script still runs and outputs a single image now.

However, it seems that the new libmbed-os does not seem to be compatible with BLE. Including only:

#include <ArduinoBLE.h>
leads to an error (attached). From the error message it seems that something in the mbed files in the BSP are not correct/sth is missing.

err_BLE.txt (5.55 KB)

I know this issue. solved it before… will post an update later today…

It should work now…

Thank you so much, yes it does!