Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data logging programme hangs if DAPLink does not have micro:bit specific features #137

Open
microbit-carlos opened this issue Jul 21, 2021 · 6 comments
Assignees
Milestone

Comments

@microbit-carlos
Copy link
Collaborator

microbit-carlos commented Jul 21, 2021

This MakeCode programme hangs at the data logging block, so the micro:bit only shows the sad face image, it never reaches the beating heart:

Screenshot2021_07_20_110233

microbit-dl-simple.hex.zip

All micro:bits from factory include the I2C functionality, but if somebody builds DAPLink from source they can build the version without it (technically, this is the only version merged in DAPLink upstream right now, the V2 functionality is still in a PR), or users could be using J-Link instead:
https://www.segger.com/products/debug-probes/j-link/models/other-j-links/bbc-microbit-j-link-upgrade/

This DAPLink image can be used for testing:
kl27z_microbit_if.hex.zip

@JohnVidler
Copy link
Collaborator

Ideally we should panic rather than hang if the i2c comms for logging data are not working.

Some kind of sensible default timeout should be set in CODAL to stop this a forever-wait.

@microbit-carlos
Copy link
Collaborator Author

The latest CODAL also does an I2C transaction on uBit.init() (or thereabouts), so for non-DAPLink users (right now, that's only J-Link users I think), that has the potential to affect all micro:bit programmes, and not only those using DAPLink-I2C-specific features.

@JohnVidler JohnVidler added this to the v0.2.41 milestone Jun 16, 2022
@JohnVidler
Copy link
Collaborator

May be related to #191 once we implement the panic code.

@microbit-carlos
Copy link
Collaborator Author

We need to consider that MAINTENACE mode in DAPLink doesn't have I2C features,.

So, if we panic when we fail to establish I2C comms, then a micro:bit programme would panic in MAINTENACE mode during uBit.ini(), which we don't want, as it should only panic at the point the user is using DAPLink I2C specific features like datalogging:

#if CONFIG_ENABLED(DEVICE_BLE) && ( CONFIG_ENABLED(MICROBIT_BLE_PAIRING_MODE) || CONFIG_ENABLED(MICROBIT_BLE_ENABLED))
MicroBitVersion version = power.getVersion();
#endif

In this case we would either have:
a) Bubble up error codes and figure out at what layers to panic
- In this example it cannot panic inside power.getVersion(), but that is a user facing uBit API.
b) Remove this board ID check from uBit.init(), and panic at the layer that first detects DAPLink is not responding to I2C.
- #208
c) Other?

@JohnVidler JohnVidler modified the milestones: v0.2.41, v0.2.42 Aug 8, 2022
@martinwork
Copy link
Collaborator

Couldn't the log data call timeout, and not log the data, From memory, it may be that it isn't actually hanging, but the timeout becomes very long (say 20 * 20 * 10s) when I2C is not responding.

@microbit-carlos microbit-carlos modified the milestones: v0.2.43, v0.2.44 Sep 15, 2022
@JohnVidler
Copy link
Collaborator

After some discussion, we've decided to handle this by only attempting calls which will panic when we actually need to access the flash rather than querying version like so:

bleManager.init( ManagedString( microbit_friendly_name()), getSerial(), messageBus, storage, true, version.board);
on startup.

This way we only panic when we actually do something with DAPLink, with an exception for when we have the ERASE FLASH flag set in codal config, but DAPLink is unreachable, we should NOT panic, otherwise setting that config will immediately halt the board.

@JohnVidler JohnVidler modified the milestones: v0.2.44, v0.2.45 Oct 17, 2022
@JohnVidler JohnVidler added p2 and removed p1 labels Oct 17, 2022
@microbit-carlos microbit-carlos modified the milestones: v0.2.45, v0.2.48 Jan 18, 2023
microbit-carlos added a commit to microbit-carlos/codal-microbit-v2 that referenced this issue Jan 27, 2023
Before PR lancaster-university#114 the string was "BBC micro:bit V2.0", with that PR
it was updated to indicate "BBC micro:bit V2.0" for board ID 0x9904
and "V2.X" to any unknown board ID (currently V2.2 boards would still
appear as "V2.X").

lancaster-university#114

There is no need for BLE apps or devices to distinguish between
different V2 versions, just as we currently don't differentiate between
V1.3 and V1.5.

Hardcoding this in CODAL to be "BBC micro:bit V2" also removes
an I2C call to the interface chip on uBit.init(), which help us better support
unofficial interface chip firmwares, like Segger's J-Link.

Fixes lancaster-university#208

Related to lancaster-university#137
@microbit-carlos microbit-carlos modified the milestones: v0.2.48, v0.2.49 Jan 27, 2023
JohnVidler pushed a commit that referenced this issue Jan 30, 2023
)

There is no need for BLE apps or devices to distinguish between
different V2 versions, just as we currently don't differentiate between
V1.3 and V1.5.

Fixes #208

Related to #137
@microbit-carlos microbit-carlos modified the milestones: v0.2.49, v0.2.50 Feb 15, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.50, v0.2.51 Mar 2, 2023
@microbit-carlos microbit-carlos added p3 and removed p2 labels Mar 9, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.51, v0.2.52 Mar 27, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.52, v0.2.53 May 5, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.56, v0.2.59 Jun 15, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.59, v0.2.61 Jul 25, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.62, v0.2.63 Sep 20, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.65, v0.2.66 Nov 3, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.66, v0.2.67 Nov 14, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.69, datalog May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants