I2Cslave functions are buggy [5.15.5] [FRDM-KL82Z]

Hi there,

following issues when running Mbed OS 5.15.5 on a FRDM-KL82Z and an Aardvark as the Master.

slave.read() also takes the slave address and stores it.
slave.read((char *)Hashed_Data, 10);
Hashed_Data[0] holds the slave address instead of the first data byte, which can be seen on Master side when using
slave.write((char *)Hashed_Data, 100);

Also requesting a write to Master, every other transfer fails.

#include "MKL82Z7.h"
#include "PinNames.h"
#include "mbed.h"

volatile int g_I2C_operation, g_I2C_status;
unsigned char Hashed_Data[100] = {0};

const char message[] = "Slave!";
I2CSlave slave(I2C_SDA, I2C_SCL);

int main() {
printf("Start \n\r");
while (1) {

g_I2C_operation = slave.receive();

switch (g_I2C_operation) {
case I2CSlave::WriteAddressed:
  g_I2C_status = slave.read((char *)Hashed_Data, 10);
  printf("%d", g_I2C_status);
case I2CSlave::ReadAddressed:
  g_I2C_status = slave.write((char *)Hashed_Data, 100);
  printf("%d", g_I2C_status);

this is just an example, the actual project is using Hashed_Data[65000] but I don’t see this working properly anytime soon.

after talking with some colleagues, it seems reading address is common for some IPs, I wasn’t used to that yet.
In terms of every other Master-Read transfer hanging, there’s a low-level issue regarding error handling, i.e. when the Master requests more bytes than the Slave expects to writ, slave I2C starts to hang, eventually leading to a hardfault.
The top level workaround was easy (simple statemachine on master and slave side), but I believe someone should look into that nonetheless.

Next issue, why is there a 11.2ms clock-stretch after finished slave.write() regardless of message length?
I have tried this with several Master devices now, and don’t see a workaround.

Excuse me, but this is madness.

--- fsl_i2c.c	2020-09-24 10:45:40.000000000 +0200
+++ fsl_i2c_clock_fix.c	2020-09-24 09:54:10.000000000 +0200
@@ -1328,7 +1328,7 @@
     /* Read dummy to release bus. */
     dummy = base->D;
-    result = I2C_MasterWriteBlocking(base, txBuff, txSize, kI2C_TransferDefaultFlag);
+    result = I2C_MasterWriteBlocking(base, txBuff, txSize, kI2C_TransferNoStopFlag);
     /* Switch to receive mode. */
     base->C1 &= ~(I2C_C1_TX_MASK | I2C_C1_TXAK_MASK);