CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 12
BPI_F3
Author: Peter Sauer
Date: February 15, 2025
German version of this article.
Slowly but surely, more and more SoCs based on the RISC-V architecture are entering the market. Since Dart now also supports RISC-V, I felt the desire to evaluate a RISC-V-based board as part of my project dart_periphery.
The choice fell on a Banana Pi BPI-F3, which was purchased through Aliexpress directly from the manufacturer SinoVoip Co., Limited. The board, packaged in a simple box without any accessories or documentation, was delivered within just under three weeks without any issues.
Armbian is supported for this board as a rolling release in the form of a development version. Under Armbian, interfaces such as I2C, SPI, etc. can be conveniently managed using the armbian-config
tool. However, this tool is not yet available for the current RISC-V version.
Therefore, the I2C interface must be manually integrated. The following steps were adapted from a post in the Banana Pi forum. Root privileges are required!
cd /boot/dtb/spacemit
cp k1-bananapi-f3.dtb k1-x_deb1.dtb.org
dtc -I dtb -O dts -o k1-bananapi-f3.dts k1-bananapi-f3.dtb
nano k1-bananapi-f3.dts
Now the status in the I2C-4 block must be changed from disabled
to okay
...
//i2c4
i2c@d4012800 {
.....
status = "okay";
};
... and then the changes must be written back to the device tree.
dtc -I dts -O dtb -o k1-bananapi-f3.dtb k1-bananapi-f3.dts
After a reboot and loading the i2c-dev
module, the following device should now be available: /dev/i2c-4
.
modprobe i2c-dev
ls /dev/i2*
/dev/i2c-0 /dev/i2c-2 /dev/i2c-4 /dev/i2c-8
Now the i2c-dev
module is added to the existing list of modules to be loaded at startup.
echo 'i2c-dev' >> /etc/modules-load.d/bananapif3.conf
But be careful: an OS update, which is available daily through the nightly build in this rolling release, will overwrite the following files:
/boot/dtb/spacemit/k1-bananapi-f3.dtb
/etc/modules-load.d/bananapif3.conf
Finally, the I2C-4 device is made available to my user peter
through the i2c
group.
groupadd i2c
usermod -aG i2c peter
echo 'KERNEL=="/dev/i2c-4", GROUP="i2c", MODE="0660"' > /etc/udev/rules.d/99-i2c.rules
apt-get install i2c-tools
reboot
After the reboot, I log in with my user peter
and list all devices on the I2C-4 bus.
peter@bananapif3:~$ i2cdetect -y -r 4
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
At address 0x68
on the I2C bus, there is a DS3231 real-time clock, which is now controlled using dart_periphery
. The example code is then adjusted to use I2C bus number 4 and to indicate that a DS3231 with a temperature sensor is being used.
void main() {
// Select the right I2C bus number /dev/i2c-?
// 1 for Raspberry Pi, 0 for NanoPi (Armbian), 2 Banana Pi (Armbian)
var i2c = I2C(4); // Banana Pi BPI-F3
try {
print("dart_periphery Version: $dartPeripheryVersion");
print("c-periphery Version : ${getCperipheryVersion()}");
print('I2C info: ${i2c.getI2Cinfo()}');
print("DS1307 real time clock");
var rtc = DS1307(i2c,true); // for DS3231 set DS1307(i2c, true)
Start example
peter@bananapif3:~/dart_periphery/example$ dart i2c_ds1307.dart
Output
dart_periphery Version: 0.9.15
c-periphery Version : v2.4.2
I2C info: I2C (fd=9)
DS1307 real time clock
Get current RTC date and time
2025-02-14 18:43:50.000
RTC on board temperature sensor: 24.75
Set RTC to current sytem time?
Do you want to continue? (yes/no):
``