Skip to content

Commit 36c109b

Browse files
committed
duo256 fixes, plus cooling maps, and add the sophgo-sg200x-packages debian repository
1 parent b42b474 commit 36c109b

File tree

16 files changed

+170
-132
lines changed

16 files changed

+170
-132
lines changed

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,105 @@
1+
# Debian Images for Sophgo cv1800/sg200x based boards
12

3+
This repository builds debian sid images for Sophgo cv1800/sg200x based boards such as MilkV Duo/Duo256 and Sipeed LicheeRvNano.
4+
5+
The images aim to be as close to possible to debian best practices as possible
6+
7+
## Image Info
8+
9+
Logins: root/rv and debain/rv
10+
11+
(root login is disabled via SSH, login via debian, and SU to root if needed)
12+
13+
by default, a rndis interface is started on the USB port, and the IP address is
14+
10.42.0.1 - It also starts a DHCP Server on that interface, so your PC should automatically get an IP address in the 10.42.0.x range
15+
16+
To Disable the rndis interface, you can run the following command:
17+
```
18+
systemctl disable usb-gadget-rndis
19+
```
20+
21+
There is also a option to start a serial port (ACM) interface instead of the rndis interface, to do this, you can run the following command:
22+
```
23+
systemctl disable usb-gadget-rndis
24+
systemctl enable usb-gadget-acm
25+
```
26+
27+
After executing these commands, you need to reboot.
28+
29+
For the LicheeRVNano board, Wifi is enabled. To connect to your wifi network, execute the following command and select "Activate a connection" and select your wifi network:
30+
```
31+
nmtui
32+
```
33+
34+
for Boards with eithernet, they should automatically get a IP address if your network has a DHCP Server.
35+
36+
The images are based on the vendor 5.10 kernel, but exclude the following drivers:
37+
- mipi-rx/csi drivers
38+
- mipi-tx/dsi drivers
39+
- TPU Drivers
40+
- Any of the Video Encoding Drivers
41+
42+
(this is mainly due to compatibility reasons with the glibc version in debian and musl version used in the vendor images)
43+
44+
The images, by default, do not allocate any memory for the ION heap, as they are unused in this image, so you get the full memory of each device
45+
46+
The images also include the remoteproc and mailbox drivers so you can load up ardunio/freertos images on the small C906 core.
47+
48+
This image also adds the debian repository for https://github.com/Fishwaldo/sophgo-sg200x-packages so you can install additional repositories. The debian repository is hosted at
49+
https://sophgo.my-ho.st:8443/ which pulls down the compiled debian packages from the above github repository occasionally.
50+
51+
52+
## Building the Image
53+
54+
To build a stock image with no modifications:
55+
```
56+
podman run --privileged -it --rm -v ./configs/:/configs -v ./image:/output -v ghcr.io/fishwaldo/sophgo-sg200x-debian:master make BOARD=licheervnano image
57+
```
58+
59+
Replace the licheervnano with the board you want to build for:
60+
- duo256
61+
- licheervnano
62+
63+
The Docker image will build the image and place it in the image directory
64+
65+
## Flashing the Image
66+
67+
To flash from linux, either build your own image, or download a image from the releases page, and then run the following command:
68+
```
69+
sudo dd if=image/licheervnano_sd.img of=/dev/sdX bs=4M status=progress
70+
```
71+
72+
From windows, you can use tools such as balena etcher
73+
74+
where the licheervnano_sd.img is the image file you want to flash, and /dev/sdX is the device you want to flash to.
75+
(if you build for a different board, the image file name will be different)
76+
77+
addition make targets are available when building:
78+
- image - builds the image
79+
- clean - cleans the build directory
80+
- linux - build a kernel debian package
81+
- fsbl - build the fsbl debain package (that includes cvitek-fsbl, opensbi and u-boot)
82+
83+
## Customizing the Image
84+
The configs directory contains patches, configuration and device tree files that are used to build the image.
85+
86+
The configs/common directory contains the common configuration for all boards, and the configs/licheervnano and configs/duo256 directories contain the board specific configuration.
87+
88+
To add packages to the image, either add the package name in PACKAGES variable of configs/settings.mk or if the packae is specific to a board, add it to the configs/<board>/settings.mk file
89+
90+
Patches for the kernel, opensbi, u-boot or fsbl can be placed in configs/common/patches/ or configs/<board>/patches/ depending what they are for.
91+
92+
To assist with developing the image, you can get a shell in the docker container by running:
93+
```
94+
docker run --privileged -it --rm -v ./configs/:/configs -v ./image:/output -v ./scripts/:/builder builder /bin/bash
95+
```
96+
inside the container, packages are build in the /builder/ directory, and the rootfs is placed at /rootfs/ directory
97+
98+
99+
100+
# TODO
101+
- Add support for the DuoS board
102+
- DeviceTree Overlay Support
103+
- Add support for the MIPI-CSI/DSI drivers (Sample applications would be in the sophgo-sg200x-packages repository if they do not depend upon a musl libc version)
104+
- Add support for the TPU drivers
105+
- Possibly mainline kernel support via the sophgo linux for-next repositories

configs/common/dts/cv181x_riscv/cv181x_base_riscv.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
thermal:thermal@030E0000 {
368368
interrupts = <16 IRQ_TYPE_LEVEL_HIGH>;
369369
interrupt-names = "tempsen";
370+
interrupt-parent = <&plic0>;
370371
};
371372

372373
};

configs/common/dts/sg200x/cv181x_default_memmap.dtsi

Lines changed: 0 additions & 25 deletions
This file was deleted.

configs/common/dts/sg200x_riscv/sg200x_base_riscv.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@
372372
thermal:thermal@030E0000 {
373373
interrupts = <16 IRQ_TYPE_LEVEL_HIGH>;
374374
interrupt-names = "tempsen";
375+
interrupt-parent = <&plic0>;
375376
};
376377

377378
};

configs/common/patches/linux/0009-add-cooling-driver.patch

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
From 1d4f23538a75fd635ec284967f7bb45ac98e9f98 Mon Sep 17 00:00:00 2001
1+
From 3906608b67bc4074e19abc87b617939325a12483 Mon Sep 17 00:00:00 2001
22
From: Justin Hammond <justin@dynam.ac>
3-
Date: Wed, 10 Apr 2024 17:34:57 +0800
4-
Subject: [PATCH] add cooling driver
3+
Date: Fri, 12 Apr 2024 17:49:29 +0800
4+
Subject: [PATCH] Add cvitek-cooling driver
55

66
---
77
drivers/thermal/Kconfig | 6 +
88
drivers/thermal/Makefile | 1 +
9-
drivers/thermal/cv181x_cooling.c | 278 +++++++++++++++++++++++++++++++
10-
3 files changed, 285 insertions(+)
9+
drivers/thermal/cv181x_cooling.c | 279 +++++++++++++++++++++++++++++++
10+
3 files changed, 286 insertions(+)
1111
create mode 100644 drivers/thermal/cv181x_cooling.c
1212

1313
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
@@ -39,10 +39,10 @@ index e35f57cc2000..6ef07777fa55 100644
3939
\ No newline at end of file
4040
diff --git a/drivers/thermal/cv181x_cooling.c b/drivers/thermal/cv181x_cooling.c
4141
new file mode 100644
42-
index 000000000000..bcf6b1b71a64
42+
index 000000000000..fdfd396ca3d4
4343
--- /dev/null
4444
+++ b/drivers/thermal/cv181x_cooling.c
45-
@@ -0,0 +1,278 @@
45+
@@ -0,0 +1,279 @@
4646
+#include <linux/err.h>
4747
+#include <linux/module.h>
4848
+#include <linux/of.h>
@@ -138,23 +138,23 @@ index 000000000000..bcf6b1b71a64
138138
+{
139139
+ struct cooling_device *cvcdev = cdev->devdata;
140140
+
141-
+ dev_info(&cdev->device, "set cur_state=%ld\n", state);
142-
+ dev_info(&cdev->device, "clk_cpu=%ld Hz\n", clk_get_rate(cvcdev->clk_cpu));
143-
+ dev_info(&cdev->device, "clk_tpu_axi=%ld Hz\n", clk_get_rate(cvcdev->clk_tpu));
141+
+ dev_dbg(&cdev->device, "set cur_state=%ld\n", state);
142+
+ dev_dbg(&cdev->device, "clk_cpu=%ld Hz\n", clk_get_rate(cvcdev->clk_cpu));
143+
+ dev_dbg(&cdev->device, "clk_tpu_axi=%ld Hz\n", clk_get_rate(cvcdev->clk_tpu));
144144
+
145145
+ mutex_lock(&cvcdev->lock);
146146
+
147147
+ if (state <= cvcdev->max_clk_state && state != cvcdev->clk_state) {
148-
+ dev_info(&cdev->device, "dev_freq[%ld].cpu_freq=%ld\n", state, cvcdev->dev_freqs[state].cpu_freq);
149-
+ dev_info(&cdev->device, "dev_freq[%ld].tpu_freq=%ld\n", state, cvcdev->dev_freqs[state].tpu_freq);
148+
+ dev_dbg(&cdev->device, "dev_freq[%ld].cpu_freq=%ld\n", state, cvcdev->dev_freqs[state].cpu_freq);
149+
+ dev_dbg(&cdev->device, "dev_freq[%ld].tpu_freq=%ld\n", state, cvcdev->dev_freqs[state].tpu_freq);
150150
+
151151
+ if (cvcdev->dev_freqs[state].cpu_freq != clk_get_rate(cvcdev->clk_cpu)) {
152-
+ dev_info(&cdev->device, "set cpu freq=%ld\n", cvcdev->dev_freqs[state].cpu_freq);
152+
+ dev_dbg(&cdev->device, "set cpu freq=%ld\n", cvcdev->dev_freqs[state].cpu_freq);
153153
+ clk_set_rate(cvcdev->clk_cpu, cvcdev->dev_freqs[state].cpu_freq);
154154
+ }
155155
+
156156
+ if (cvcdev->dev_freqs[state].tpu_freq != clk_get_rate(cvcdev->clk_tpu)) {
157-
+ dev_info(&cdev->device, "set tpu freq=%ld\n", cvcdev->dev_freqs[state].tpu_freq);
157+
+ dev_dbg(&cdev->device, "set tpu freq=%ld\n", cvcdev->dev_freqs[state].tpu_freq);
158158
+ clk_set_rate(cvcdev->clk_tpu, cvcdev->dev_freqs[state].tpu_freq);
159159
+ }
160160
+
@@ -303,7 +303,7 @@ index 000000000000..bcf6b1b71a64
303303
+
304304
+static const struct of_device_id cooling_match[] = {
305305
+ {.compatible = "sophgo,cooling"},
306-
+ {.compatible = "cvitek,cv181x-cooling"},
306+
+ {.compatible = "cvitek,cv181x-cooling"},
307307
+ {},
308308
+};
309309
+MODULE_DEVICE_TABLE(of, cooling_match);

configs/duo256/dts/cv181x_milkv_duo256m_sd.dts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636
status = "disabled";
3737
};
3838

39+
&soc_thermal_0 {
40+
cooling-maps {
41+
map0 {
42+
trip = <&soc_thermal_trip_0>;
43+
cooling-device = <&cv181x_cooling THERMAL_NO_LIMIT 1>;
44+
};
45+
map1 {
46+
trip = <&soc_thermal_trip_1>;
47+
cooling-device = <&cv181x_cooling THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
48+
};
49+
};
50+
};
51+
3952
/ {
4053
model = "Milk-V Duo256M";
4154

configs/duo256/linux/defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ CONFIG_THERMAL=y
253253
CONFIG_THERMAL_NETLINK=y
254254
CONFIG_THERMAL_WRITABLE_TRIPS=y
255255
CONFIG_THERMAL_EMULATION=y
256-
CONFIG_CV180X_COOLING=m
256+
CONFIG_CV180X_COOLING=y
257257
CONFIG_WATCHDOG=y
258258
CONFIG_CVITEK_WATCHDOG=y
259259
CONFIG_MEDIA_SUPPORT=y

configs/duo256/settings.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ DDR_CFG=ddr3_1866_x16
77
PARTITION_FILE=partition_sd.xml
88
STORAGE_TYPE=sd
99

10-
#PACKAGES += " wireless-regdb wpasupplicant"
10+
PACKAGES += " duo-pinmux"
1111
#IMAGE_ADDITIONS += "aic8800-firmware"

configs/licheervnano/dts/sg2002_licheervnano_sd.dts

Lines changed: 14 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@
1111
#include <dt-bindings/mailbox/cvitek-mailbox.h>
1212
#endif
1313

14-
&i2c0 {
15-
status = "disabled";
16-
/delete-property/ scl-pinmux;
17-
/delete-property/ sda-pinmux;
18-
/delete-property/ scl-gpios;
19-
/delete-property/ sda-gpios;
20-
};
21-
22-
&i2c1 {
23-
status = "disabled";
24-
/delete-property/ scl-pinmux;
25-
/delete-property/ sda-pinmux;
26-
/delete-property/ scl-gpios;
27-
/delete-property/ sda-gpios;
28-
};
29-
3014
&sd {
3115
min-frequency = <400000>; // 400Khz
3216
//max-frequency = <50000000>; // 50Mhz
@@ -35,55 +19,11 @@
3519
//max-frequency = <5000000>; // 5Mhz
3620
};
3721

38-
&cvi_vo {
39-
reset-gpio = <&porte 0 1>;
40-
pwm-gpio = <&portb 0 1>;
41-
/delete-property/ power-ct-gpio;
42-
status = "okay";
43-
};
44-
45-
&mipi_tx {
46-
reset-gpio = <&porte 0 1>;
47-
pwm-gpio = <&porte 0 1>;
48-
/delete-property/ power-ct-gpio;
49-
status = "okay";
50-
};
5122

5223
&uart1 {
5324
status = "okay";
5425
};
55-
&uart2 {
56-
status = "okay";
57-
};
58-
59-
60-
&pwm0 {
61-
status = "okay";
62-
};
63-
64-
&pwm1 {
65-
status = "okay";
66-
};
67-
68-
&pwm2 {
69-
status = "okay";
70-
};
71-
72-
&i2c2 {
73-
status = "disabled";
74-
/delete-property/ scl-pinmux;
75-
/delete-property/ sda-pinmux;
76-
/delete-property/ scl-gpios;
77-
/delete-property/ sda-gpios;
78-
};
7926

80-
&i2c3 {
81-
status = "disabled";
82-
/delete-property/ scl-pinmux;
83-
/delete-property/ sda-pinmux;
84-
/delete-property/ scl-gpios;
85-
/delete-property/ sda-gpios;
86-
};
8727

8828
&i2c4 {
8929
statuc = "okay";
@@ -103,21 +43,25 @@
10343
/delete-property/ mute-gpio-r;
10444
};
10545

106-
&fb_reserved {
107-
status = "okay";
108-
};
109-
110-
&cvi_fb {
111-
status = "okay";
112-
};
113-
114-
&mipi_rx {
115-
snsr-reset = <&porte 1 GPIO_ACTIVE_LOW>;
46+
&soc_thermal_0 {
47+
cooling-maps {
48+
map0 {
49+
trip = <&soc_thermal_trip_0>;
50+
cooling-device = <&cooling THERMAL_NO_LIMIT 1>;
51+
};
52+
map1 {
53+
trip = <&soc_thermal_trip_1>;
54+
cooling-device = <&cooling THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
55+
};
56+
};
11657
};
11758

11859
/ {
11960
model = "LicheeRv Nano";
12061

62+
/delete-node/ wifi_pin;
63+
/delete-node/ bt_pin;
64+
12165
gpio-keys {
12266
compatible = "gpio-keys";
12367
key-user {
@@ -157,15 +101,6 @@
157101
interrupt-parent = <&plic0>;
158102
};
159103

160-
// for maixcam
161-
i2c5: i2c-gpio-a24-a23 {
162-
compatible = "i2c-gpio";
163-
scl-gpios = <&porta 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
164-
sda-gpios = <&porta 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
165-
i2c-gpio,delay-us = <5>;
166-
status = "disabled";
167-
};
168-
169104
leds {
170105
compatible = "gpio-leds";
171106
led0 {

configs/licheervnano/linux/defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ CONFIG_THERMAL=y
253253
CONFIG_THERMAL_NETLINK=y
254254
CONFIG_THERMAL_WRITABLE_TRIPS=y
255255
CONFIG_THERMAL_EMULATION=y
256-
CONFIG_CV180X_COOLING=m
256+
CONFIG_CV180X_COOLING=y
257257
CONFIG_WATCHDOG=y
258258
CONFIG_CVITEK_WATCHDOG=y
259259
CONFIG_MEDIA_SUPPORT=y

0 commit comments

Comments
 (0)