Skip to content

Commit

Permalink
DuoS EMMC Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishwaldo committed May 24, 2024
1 parent 902d60e commit 60bf893
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 56 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: pause
if: (github.event_name != 'pull_request' && steps.filter.outputs.src == 'true') || startsWith(github.event.ref, 'refs/tags/v')
run: sleep 120

build-image:
strategy:
matrix:
boards: [licheervnano, duo256, duos]
storage: [sd]
include:
- boards: duos
storage: emmc
runs-on: ubuntu-latest
needs: build-docker-image
steps:
Expand All @@ -67,23 +73,23 @@ jobs:
image: ghcr.io/fishwaldo/sophgo-sg200x-debian:master
options: --privileged -v ${{ github.workspace }}/images/:/output -v ${{ github.workspace }}/configs/:/configs/
run: |
make BOARD=${{ matrix.boards }} image
make BOARD=${{ matrix.boards }} STORAGE_TYPE=${{ matrix.storage }} image
chmod 777 /output/
- name: Pack
run: |
cd images/
ls -lah
if [ -f ${{ matrix.boards }}_sd.img ]; then
lz4 -9 -f ${{ matrix.boards }}_sd.img ${{ matrix.boards }}_sd.img.lz4
rm ${{ matrix.boards }}_sd.img
if [ -f ${{ matrix.boards }}_${{ matrix.storage }}.img ]; then
lz4 -9 -f ${{ matrix.boards }}_${{ matrix.storage }}.img ${{ matrix.boards }}_${{ matrix.storage }}.img.lz4
rm ${{ matrix.boards }}_${{ matrix.storage }}.img
fi
tar czvf ${{ matrix.boards }}_debs.tar.gz *.deb
tar czvf ${{ matrix.boards }}-${{ matrix.storage }}_debs.tar.gz *.deb
rm *.deb
echo "PACKAGE=${{ github.workspace }}/images/*" >> $GITHUB_ENV
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: image-files-${{ matrix.boards }}
name: image-files-${{ matrix.boards }}-${{ matrix.storage }}
path: |
${{env.PACKAGE}}
release:
Expand Down
56 changes: 31 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
# Debian Images for Sophgo cv181x/sg200x based boards

This repository builds debian sid images for Sophgo cv181x/sg200x based boards such as MilkV Duo256/DuoS (SD Version only) and Sipeed LicheeRvNano.
This repository builds debian sid images for Sophgo cv181x/sg200x based boards such as MilkV Duo256/DuoS and Sipeed LicheeRvNano.

(Note, we don't support the MilkV Duo, as it does not have enough ram to run Debian)

The images aim to be as close to possible to debian best practices as possible

## Image Info
## Flashing the Image

### Duo256, DuoS, and LicheeRVNano
To flash from linux, either build your own image, or download a image from the releases page, and then run the following command:
```
sudo dd if=image/(board)_sd.img of=/dev/sdX bs=4M status=progress
```

From windows, you can use tools such as balena etcher

where the (board)_sd.img is the image file you want to flash, and /dev/sdX is the device you want to flash to.
(if you build for a different board, the image file name will be different)

### DuoS with EMMC
To flash the DuoS with EMMC, you need to use the vendor tools to flash the image to the EMMC. You can follow the
instructions at https://milkv.io/docs/duo/getting-started/duos#emmc-version-firmware-burning but instead of downloading
the milkv-duos-emmc-v1.1.0-2024-0410.zip file, you download the duos_emmc.zip from the releases on this repository.

if you already have a image installed, but wish to upgrade, when u-boot loads up, interupt the boot process by pressing any
key and typing the following commands:
```
cvi_update
```

The flashing should then continue


## Image Info
Logins: root/rv and debian/rv

(root login is disabled via SSH, login via debian, and SU to root if needed)

### USB Gadget Support

by default, a rndis interface is started on the USB port, and the IP address is
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

Expand All @@ -31,29 +55,24 @@ systemctl enable usb-gadget-acm
After executing these commands, you need to reboot.

### DuoS - USB Type A Port

After disabling the usb-gadgets, if you want to use the USB Type A Ports, then you need to turn them on:

```
systemctl enable usb-switch
```

and reboot afterwards.

### Wifi on DuoS/LicheeRVNano

For the LicheeRVNano/DuoS board, Wifi is enabled. To connect to your wifi network, execute the following command and select "Activate a connection" and select your wifi network:
```
nmtui
```

### Ethernet

For Boards with eithernet, they should automatically get a IP address if your network has a DHCP Server. You can configure the
ethernet port in nmtui

### Camera/ISP/Panel Support

The images are based on the vendor 5.10 kernel, but exclude the following drivers:
- mipi-rx/csi drivers
- mipi-tx/dsi drivers
Expand All @@ -65,17 +84,14 @@ The images are based on the vendor 5.10 kernel, but exclude the following driver
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

### Ardunio/Freertos Support

The images also include the remoteproc and mailbox drivers so you can load up ardunio/freertos images on the small C906 core.

### Additional Packages

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
https://sophgo.my-ho.st:8443/ which pulls down the compiled debian packages from the above github repository occasionally.


## Building the Image

To build a stock image with no modifications:
```
podman run --privileged -it --rm -v ./configs/:/configs -v ./image:/output ghcr.io/fishwaldo/sophgo-sg200x-debian:master make BOARD=licheervnano image
Expand All @@ -86,19 +102,12 @@ Replace the licheervnano with the board you want to build for:
- duos
- licheervnano

The Docker image will build the image and place it in the image directory

## Flashing the Image

To flash from linux, either build your own image, or download a image from the releases page, and then run the following command:
If you want to create a image for the DuoS with EMMC, you can add "STORAGE_TYPE=emmc" to the make commannd:
```
sudo dd if=image/licheervnano_sd.img of=/dev/sdX bs=4M status=progress
podman run --privileged -it --rm -v ./configs/:/configs -v ./image:/output ghcr.io/fishwaldo/sophgo-sg200x-debian:master make BOARD=duos STORAGE_TYPE=emmc image
```

From windows, you can use tools such as balena etcher

where the licheervnano_sd.img is the image file you want to flash, and /dev/sdX is the device you want to flash to.
(if you build for a different board, the image file name will be different)
The Docker image will build the image and place it in the image directory

addition make targets are available when building:
- image - builds the image
Expand All @@ -121,10 +130,7 @@ docker run --privileged -it --rm -v ./configs/:/configs -v ./image:/output -v ./
```
inside the container, packages are build in the /builder/ directory, and the rootfs is placed at /rootfs/ directory



# TODO
- Add support for the DuoS EMMC Board
- DeviceTree Overlay Support
- 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)
- Add support for the TPU drivers
Expand Down
134 changes: 134 additions & 0 deletions configs/duos/dts/cv181x_milkv_duos_emmc.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/dts-v1/;
#include "cv181x_base_riscv.dtsi"
#include "cv181x_asic_bga.dtsi"
#include "cv181x_asic_emmc.dtsi"
#include "cv181x_default_memmap.dtsi"

#include "dt-bindings/leds/common.h"
#ifndef __UBOOT__
#include <dt-bindings/mailbox/cvitek-mailbox.h>
#endif


&mipi_rx{
snsr-reset = <&portc 17 GPIO_ACTIVE_LOW>, <&portc 17 GPIO_ACTIVE_LOW>, <&portc 17 GPIO_ACTIVE_LOW>;
};

&dac{
/delete-property/ mute-gpio-l;
/delete-property/ mute-gpio-r;
};

&i2c0 {
status = "disabled";
};

&spi3 {
status = "okay";

spidev@0 {
status = "okay";
};
};

&usb {
vbus-gpio = <&portb 6 0>;
};

&wifisd {
status = "okay";
cap-sd-highspeed;
sd-uhs-sdr25;
sd-uhs-ddr50;
sd-uhs-sdr104;
min-frequency = <400000>;
max-frequency = <187500000>;
};

&wifi_pin {
compatible = "cvitek,wifi-pin";
poweron-gpio = <&porta 15 GPIO_ACTIVE_HIGH>;
wakeup-gpio = <&porte 7 GPIO_ACTIVE_HIGH>;
};

&uart4 {
status = "okay";
};

&soc_thermal_0 {
cooling-maps {
map0 {
trip = <&soc_thermal_trip_0>;
cooling-device = <&cv181x_cooling THERMAL_NO_LIMIT 1>;
};
map1 {
trip = <&soc_thermal_trip_1>;
cooling-device = <&cv181x_cooling THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
};
};
};

&porta {
wifi_pwr {
gpio-hog;
gpios = <15 GPIO_ACTIVE_HIGH>;
output-high;
};
};

/ {
model = "Milk-V DuoS";

/delete-node/ wifi_pin;
/delete-node/ bt_pin;

leds {
compatible = "gpio-leds";
led0 {
gpios = <&porta 29 GPIO_ACTIVE_LOW>;
linux,default-trigger = "heartbeat";
function = LED_FUNCTION_HEARTBEAT;
label = "blue";
};
led1 {
gpios = <&porte 6 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "netdev";
function = LED_FUNCTION_HEARTBEAT;
label = "orange";
};
led2 {
gpios = <&porte 8 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "stmmac-0:00:link";
function = LED_FUNCTION_HEARTBEAT;
label = "green";
};
};


#ifndef __UBOOT__
mbox: mbox@0x01900000 {
compatible = "cvitek,sg200x-mailbox";
reg = <0x0 0x01900000 0x0 0x1000>;
reg-names = "mailbox";
interrupts = <101 IRQ_TYPE_LEVEL_HIGH>;
interrupt-parent = <&plic0>;
status = "okay";
#mbox-cells = <4>;
};

cv181x-c906_1 {
compatible = "cvitek,cv181x-c906_1";
memory-region = <&fast_image &vdev0vring0 &vdev0vring1 &vdev0buffer>;
firmware = "c906-mcu.elf";
resets = <&rst RST_C906_1>;
reset-names = "sw_reset";
clocks = <&clk CV181X_CLK_C906_1>;
clock-names = "clk_c906_1";
mboxes = <&mbox 0 CVITEK_MBOX_DIRECTION_TX CVITEK_MBOX_C906_1 1>, <&mbox 1 CVITEK_MBOX_DIRECTION_RX CVITEK_MBOX_C906_1 1>;
mbox-names = "vq_tx", "vq_rx";
status = "okay";
};
#endif

};

3 changes: 2 additions & 1 deletion configs/duos/dts/cv181x_milkv_duos_sd.dts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/dts-v1/;
#include "cv181x_base_riscv.dtsi"
#include "cv181x_asic_bga.dtsi"
#include "cv181x_asic_sd.dtsi"
//#include "cv181x_asic_sd.dtsi"
#include "cv181x_asic_emmc.dtsi"
#include "cv181x_default_memmap.dtsi"

#include "dt-bindings/leds/common.h"
Expand Down
3 changes: 3 additions & 0 deletions configs/duos/partition_emmc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<physical_partition type="emmc">
<partition label="ROOTFS" size_in_kb="940374" readonly="false" file="sdcard.img" type="ext4" />
</physical_partition>
6 changes: 3 additions & 3 deletions configs/duos/settings.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CHIP=cv181x
STORAGE_TYPE?=sd
UBOOT_CHIP=cv181x
UBOOT_BOARD=milkv_duos_sd
UBOOT_BOARD=milkv_duos_$(STORAGE_TYPE)
BOOT_CPU=riscv
ARCH=riscv
DDR_CFG=ddr3_1866_x16
PARTITION_FILE=partition_sd.xml
STORAGE_TYPE=sd
PARTITION_FILE=partition_$(STORAGE_TYPE).xml

PACKAGES += " duo-pinmux wireless-regdb wpasupplicant cvi-pinmux-cv181x bluez"

Expand Down
21 changes: 12 additions & 9 deletions configs/duos/u-boot/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ CONFIG_DEFAULT_DEVICE_TREE="cv181x_asic"
CONFIG_IDENT_STRING=" cvitek_cv181x"
CONFIG_ARCH_RV64I=y
CONFIG_RISCV_SMODE=y
CONFIG_TARGET_CVITEK_CV181X=y
CONFIG_DISTRO_DEFAULTS=y
# CONFIG_ANDROID_BOOT_IMAGE is not set
CONFIG_FIT=y
# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
CONFIG_BOOTDELAY=1
CONFIG_SYS_PROMPT="cv181x_c906# "
CONFIG_CMD_CONFIG=y
# CONFIG_CMD_CONSOLE is not set
CONFIG_CMD_SBI=y
# CONFIG_CMD_XIMG is not set
# CONFIG_CMD_EDITENV is not set
# CONFIG_CMD_CRC32 is not set
Expand All @@ -22,26 +24,27 @@ CONFIG_SYS_PROMPT="cv181x_c906# "
CONFIG_CMD_MMC=y
# CONFIG_CMD_ITEST is not set
CONFIG_CMD_CACHE=y
CONFIG_CMD_CVI_SD_UPDATE=y
# CONFIG_ISO_PARTITION is not set
# CONFIG_EFI_PARTITION is not set
CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0"
CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_UDP_FUNCTION_FASTBOOT=y
CONFIG_FASTBOOT_BUF_ADDR=0x84000000
CONFIG_FASTBOOT_FLASH=y
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
CONFIG_MMC=y
CONFIG_SUPPORT_EMMC_RPMB=y
CONFIG_SUPPORT_EMMC_BOOT=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_SDMA=y
CONFIG_MMC_SDHCI_CVITEK=y
CONFIG_MTD=y
# CONFIG_PHY_SMSC is not set
CONFIG_PHY_CVITEK=y
CONFIG_DM_ETH=y
CONFIG_ETH_DESIGNWARE=y
CONFIG_PHY_CVITEK=y
CONFIG_SYS_NS16550=y
CONFIG_SPI=y
CONFIG_LZ4=y
CONFIG_LZMA=y
# CONFIG_TOOLS_LIBCRYPTO is not set
CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_FAT_INTERFACE="mmc"
CONFIG_ENV_FAT_DEVICE_AND_PART="0"
CONFIG_ENV_FAT_FILE="uboot.env"

Loading

0 comments on commit 60bf893

Please sign in to comment.