Mailbox_test does not blink

Hi!

I’m very interested in using the RTOS core together with the Linux one. To get started, I downloaded the image v1.1.1, flashed in on an SD card and I followed the instructions on this page to build and run the mailbox_test application.

So I built the application, sent it to the board and it would fail with this error : open failed! fd = -1.
I also renamed the blink.sh file so that the LED does not blink anymore when the system starts.

According to the code, it failed while trying to open /dev/cvi-rtos-cmdqu which indeed did not exist. So I guess the kernel is not built with the mailbox driver enabled.

So I added CONFIG_CVI_MAILBOX=y in build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig, build the image, flash it on my SD card aaand it mostly works:

[root@milkv-duo]~# ./mailbox_test 
RT: [43.048849]prvQueueISR
RT: [43.051192]recv cmd(19) from C906B, param_ptr [0x00000002]
RT: [43.056926]recv cmd(19) from C906B...send [0x00000004] to C906B
C906B: cmd.param_ptr = 0x4
RT: [47.063961]prvQueueISR
RT: [47.066304]recv cmd(19) from C906B, param_ptr [0x00000003]
RT: [47.072038]recv cmd(19) from C906B...send [0x00000004] to C906B
C906B: cmd.param_ptr = 0x3

Except that the blue led does not turn ON and OFF .

Am I missing something obvious?

Thanks!

1 Like
Hi!

Just tested it with the latest image I had lying around (built it recently from an old arduino branch before they rebased it on top of current develop branch): the mailbox example works on my Duo 64M. Are you using a Duo S, btw?

Now, after rebuilding the whole image (yes, both U-Boot, FreeRTOS firmware, and everything) against current develop branch and placing it onto a TF card, and testing it with the mailbox example, I can confirm:

It is working now and it was working a while ago. Unfortunately, there might be something on your end which prevents it from working right.

UPD0: It must be Duo S you’re using, I tested the Duo S image, and it doesn’t have the CMDQU driver, and probably its FreeRTOS firmware doesn’t have the counterpart as well. Now building the V2 image (RISC-V for Duo S) to test.

UPD1: Haha, yes indeed. And you mentioned this didn’t help. Therefore, there might be something else.

UPD2: Tested the duo-buildroot-sdk-v2, it does have the cvi-rtos-cmdqu driver, but it is apparently missing the libwiringx.so component, which is used in the mailbox example. :slight_smile:

3 Likes

On the duo-s, the led is connected on another pin.

The pin in the freertos part is hardcoded in duo-buildroot-sdk/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h at develop · milkv-duo/duo-buildroot-sdk · GitHub /.c

2 Likes

Thanks for your answer and for testing the demo on your end!

You’re right, I forgot to mention I’m using the duo-s board.

So yes, the kernel is not built with support for the mailbox feature, but it’s quite easy to rebuild it with the optiok enabled.

Then, the mailbox app seems to work fine (the logs from the Linux and RT cores are the same than the ones in the documentation) except that the LED does not turn on and off.

Maybe this test program was built to run on the duo (not - s) and that some changes must be applied to run on the duo-s (like the pin number, for example)?

I’ll try to figure the pin mapping out and see if I can make it to work!

I’m still interested to know if someone managed to run it on the duo-s as well :wink:

1 Like

Thanks for confirming that the pin mapping might be different on both boards!

I’ll try to figure that out and keep you up to date with my results :+1:

1 Like

Also for duo 256m the GPIO pin connected to de led is different, didn’t know why the examples weren’t working thks :dizzy: .

1 Like

Ok, I managed to make the LED turn ON and OFF:

  • According to the doc, the blue LED is connected to XGPIOA[29].
  • According to the pin mapping, XPGIOA is located at address 0x03020000

Then the changes are pretty straightforward:

  • Edit the value of GPIO2 in freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h from 0x03022000 to 0x03020000
  • Edit the file freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c to change the value 24 to 29.

If you haven’t done it before, don’t forget to enable the mailbox driver in the kernel : Add CONFIG_CVI_MAILBOX=y at the end of build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig

Flash the image on the SD card, build the mailbox_test app, send it to the board, run it, and the LED will simply turn ON and then OFF :slight_smile:

The full patch :

Index: freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c b/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c
--- a/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c	(revision 99f93483206a0691a3b5d1afe0aa5db4816c4e6d)
+++ b/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.c	(date 1721411187522)
@@ -2,10 +2,10 @@
 
 void duo_led_control(int enable)
 {
-	*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DDR) = 1 << 24;
+	*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DDR) = 1 << 29;
 
 	if (enable) {
-		*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DR) = 1 << 24;
+		*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DR) = 1 << 29;
 	} else {
 		*(uint32_t*)(GPIO2 | GPIO_SWPORTA_DR) = 0;
 	}
Index: build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig b/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig
--- a/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig	(revision 99f93483206a0691a3b5d1afe0aa5db4816c4e6d)
+++ b/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig	(date 1721242787541)
@@ -237,3 +237,4 @@
 # CONFIG_ENABLE_MUST_CHECK is not set
 # CONFIG_FRAME_POINTER is not set
 # CONFIG_DEBUG_MISC is not set
+CONFIG_CVI_MAILBOX=y
Index: freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h b/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h
--- a/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h	(revision 99f93483206a0691a3b5d1afe0aa5db4816c4e6d)
+++ b/freertos/cvitek/task/comm/src/riscv64/milkv_duo_io.h	(date 1721412752113)
@@ -7,7 +7,7 @@
  * GPIO_SWPORTA_DR register to control the GPIO output level.
  */
 
-#define GPIO2 0x03022000
+#define GPIO2 0x03020000
 #define GPIO_SWPORTA_DR 0x000
 #define GPIO_SWPORTA_DDR 0x004
1 Like