Communicating with I2C devices using an RTL8710
As it turns out, I was indeed not the only one to notice this issue. In both the 3.5a and 4.0b SDKs (rustl8710 is using the 3.5a SDK), there is a bug in the I2C code. Realtek have released a fix for this bug, but this fix is not included in the SDK downloads, nor listed on the download page, nor listed in the release notes.

Instead, you have to download a fixed library from the FAQ page here: https://www.amebaiot.com/en/ameba-sdk-faq/. For rustl8710, which uses the 3.5a SDK, you'd click on 'Fix 3.5a GCC SDK I2C problem', then download the linked zip file (note: you might need to create an account before you can download the file). This zip file contains a single lib_platform.a, which you'll have to copy over the existing file in component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_platform.a.

After this, use these make commands to rebuild everything:

make clean
make


For me, I2C still doesn't work the first time after flashing. This can be worked around by starting a debug session using make debug, then quitting using q and restarting the debug session using make debug again.