diff --git a/README.md b/README.md index ee66898..a6e686f 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ The images, by default, do not allocate any memory for the ION heap, as they are 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 +This image can add 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. @@ -126,9 +126,24 @@ Patches for the kernel, opensbi, u-boot or fsbl can be placed in configs/common/ To assist with developing the image, you can get a shell in the docker container by running: ``` -docker run --privileged -it --rm -v ./configs/:/configs -v ./image:/output -v ./scripts/:/builder builder /bin/bash +sudo ./build_docker.sh +sudo docker run --privileged --rm tonistiigi/binfmt --install all +sudo docker run --privileged -it --rm -v ./configs/:/configs -v ./image:/output -v ./scripts/:/builder -v builder /bin/bash +``` +or +``` +sudo docker run --privileged -it --rm -v ./configs/:/configs -v ./image:/output -v ./scripts/:/builder -v ./keydir/:/keydir builder /bin/bash +``` +to enable secure boot. + +Inside the container, packages are build in the /builder/ directory, and the rootfs is placed at /rootfs/ directory +``` +make BOARD=duos image +``` +or to sign the bootloader +``` +make BOARD=duos SIGN_FIP=1 image ``` -inside the container, packages are build in the /builder/ directory, and the rootfs is placed at /rootfs/ directory # TODO - DeviceTree Overlay Support diff --git a/configs/duos/dts/cv181x_milkv_duos_sd.dts b/configs/duos/dts/cv181x_milkv_duos_sd.dts index 2c1e903..24c0f8b 100644 --- a/configs/duos/dts/cv181x_milkv_duos_sd.dts +++ b/configs/duos/dts/cv181x_milkv_duos_sd.dts @@ -25,10 +25,12 @@ &spi3 { status = "okay"; - - spidev@0 { - status = "okay"; - }; + spidev0: spidev@0 { + compatible = "spidev"; + reg = <0>; /* CS 0 */ + spi-max-frequency = <10000000>; /* e.g. 1 MHz */ + status = "okay"; + }; }; &usb { @@ -55,6 +57,10 @@ status = "okay"; }; +&uart2 { + status = "okay"; +}; + &soc_thermal_0 { cooling-maps { map0 { diff --git a/configs/duos/linux/defconfig b/configs/duos/linux/defconfig index 2d09e77..ab47df2 100644 --- a/configs/duos/linux/defconfig +++ b/configs/duos/linux/defconfig @@ -479,6 +479,10 @@ CONFIG_I2C=y CONFIG_I2C_CHARDEV=y CONFIG_I2C_MUX=y CONFIG_I2C_DESIGNWARE_PLATFORM=y +CONFIG_SPI=y +CONFIG_SPI_DESIGNWARE=y +CONFIG_SPI_DW_MMIO=y +CONFIG_SPI_SPIDEV=y # CONFIG_PTP_1588_CLOCK is not set CONFIG_PINCTRL=y CONFIG_CVITEK_PINCTRL_CV1835=y diff --git a/configs/duos/settings.mk b/configs/duos/settings.mk index 78bf404..58c4e98 100644 --- a/configs/duos/settings.mk +++ b/configs/duos/settings.mk @@ -7,9 +7,9 @@ ARCH=riscv DDR_CFG=ddr3_1866_x16 PARTITION_FILE=partition_$(STORAGE_TYPE).xml -PACKAGES += " duo-pinmux wireless-regdb wpasupplicant cvi-pinmux-cv181x bluez" +PACKAGES += "wireless-regdb wpasupplicant cvi-pinmux-cv181x bluez git zip unzip curl musl-tools" IMAGE_ADDITIONS += "aic8800-firmware" IMAGE_ADDITIONS += "ethernet-leds" IMAGE_ADDITIONS += "usb-switch" -IMAGE_ADDITIONS += "hciattach-service" \ No newline at end of file +IMAGE_ADDITIONS += "hciattach-service" diff --git a/configs/duos/u-boot/defconfig b/configs/duos/u-boot/defconfig index 591ee6c..6314cb7 100644 --- a/configs/duos/u-boot/defconfig +++ b/configs/duos/u-boot/defconfig @@ -46,6 +46,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_SYS_NS16550=y CONFIG_SPI=y +CONFIG_SPI_SPIDEV=y CONFIG_LZ4=y CONFIG_LZMA=y # CONFIG_TOOLS_LIBCRYPTO is not set diff --git a/configs/licheervnano/dts/cv181x_licheervnano_sd.dts b/configs/licheervnano/dts/cv181x_licheervnano_sd.dts new file mode 100644 index 0000000..b5654e6 --- /dev/null +++ b/configs/licheervnano/dts/cv181x_licheervnano_sd.dts @@ -0,0 +1,137 @@ +/dts-v1/; +#include "cv181x_base_riscv.dtsi" +#include "cv181x_asic_qfn.dtsi" +#include "cv181x_asic_sd.dtsi" +#include "cv181x_default_memmap.dtsi" + +#include +#include +#include +#ifndef __UBOOT__ +#include +#endif + +&sd { + min-frequency = <400000>; // 400Khz + //max-frequency = <50000000>; // 50Mhz + max-frequency = <25000000>; // 25Mhz + //max-frequency = <10000000>; // 10Mhz + //max-frequency = <5000000>; // 5Mhz +}; + + +&uart1 { + status = "okay"; +}; + + +&i2c4 { + statuc = "okay"; + gt9xx: gt9xx@14 { + compatible = "goodix,gt911"; + reg = <0x14>; + interrupts = <3 0 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&porte>; + irq-gpios= <&porte 3 0>; + reset-gpios = <&porte 4 0>; + status = "okay"; + }; +}; + +&dac { + status = "okay"; + /delete-property/ mute-gpio-r; +}; + +&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>; + }; + }; +}; + +/ { + model = "LicheeRv Nano"; + + /delete-node/ wifi_pin; + /delete-node/ bt_pin; + + gpio-keys { + compatible = "gpio-keys"; + key-user { + label = "User Key"; + linux,code = ; + debounce-interval = <1>; + gpios = <&porta 30 1>; + }; + }; + + wifisd:wifi-sd@4320000 { + compatible = "cvitek,cv181x-sdio"; + bus-width = <4>; + reg = <0x0 0x4320000 0x0 0x1000>; + reg_names = "core_mem"; + src-frequency = <375000000>; + min-frequency = <400000>; // 400Khz + //max-frequency = <50000000>; // 50Mhz + //max-frequency = <45000000>; // 45Mhz + //max-frequency = <40000000>; // 40Mhz + //max-frequency = <35000000>; // 35Mhz + //max-frequency = <30000000>; // 30Mhz + max-frequency = <25000000>; // 25Mhz + //max-frequency = <20000000>; // 20Mhz + //max-frequency = <15000000>; // 15Mhz + //max-frequency = <10000000>; // 10Mhz + //max-frequency = <5000000>; // 5Mhz + 64_addressing; + reset_tx_rx_phy; + non-removable; + pll_index = <0x7>; + pll_reg = <0x300207C>; + no-mmc; + no-sd; + status = "okay"; + interrupts = <38 IRQ_TYPE_LEVEL_HIGH>; + interrupt-parent = <&plic0>; + }; + + leds { + compatible = "gpio-leds"; + led0 { + gpios = <&porta 14 GPIO_ACTIVE_LOW>; + linux,default-trigger = "heartbeat"; + function = LED_FUNCTION_HEARTBEAT; + }; + }; +#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 +}; + diff --git a/configs/licheervnano/patches/fsbl/0002-add-debug-mode.patch.old b/configs/licheervnano/patches/fsbl/0002-add-debug-mode.patch.old new file mode 100644 index 0000000..b61f95d --- /dev/null +++ b/configs/licheervnano/patches/fsbl/0002-add-debug-mode.patch.old @@ -0,0 +1,38 @@ +From 0e02a58c09c8f520838e372578b14d979a737d18 Mon Sep 17 00:00:00 2001 +From: Justin Hammond +Date: Thu, 18 Apr 2024 13:38:27 +0000 +Subject: [PATCH] add debug mode + +--- + plat/cv180x/bl2/bl2_opt.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/plat/cv180x/bl2/bl2_opt.c b/plat/cv180x/bl2/bl2_opt.c +index c73fa55..013d5de 100644 +--- a/plat/cv180x/bl2/bl2_opt.c ++++ b/plat/cv180x/bl2/bl2_opt.c +@@ -419,6 +419,21 @@ retry_from_flash: + + switch_rtc_mode_2nd_stage(); + ++ if (!(mmio_read_32(GPIO_BASE + 0x050) & (1 << 30))) { ++ NOTICE("=========================================\n"); ++ NOTICE("|| Debug Mode ||\n"); ++ NOTICE("|| ||\n"); ++ NOTICE("=========================================\n"); ++ ++ mmio_setbits_32(0x3003024, 1 << 6); /* reset the small core */ ++ ++ /* pinmux was set for jtag by default */ ++ ++ while(1) ++ ; ++ } ++ ++ + if (monitor_entry) { + NOTICE("Jump to monitor at 0x%lx.\n", monitor_entry); + jump_to_monitor(monitor_entry, loader_2nd_entry); +-- +2.43.0 + diff --git a/configs/licheervnano/settings.mk b/configs/licheervnano/settings.mk index 9e5bb3d..5942357 100644 --- a/configs/licheervnano/settings.mk +++ b/configs/licheervnano/settings.mk @@ -1,5 +1,5 @@ -CHIP=sg200x -UBOOT_CHIP=sg2002 +CHIP=cv181x +UBOOT_CHIP=cv181x UBOOT_BOARD=licheervnano_sd BOOT_CPU=riscv ARCH=riscv diff --git a/configs/licheervnano/u-boot/defconfig b/configs/licheervnano/u-boot/defconfig index a480236..797b15f 100644 --- a/configs/licheervnano/u-boot/defconfig +++ b/configs/licheervnano/u-boot/defconfig @@ -79,4 +79,5 @@ CONFIG_CVI_SOUND_DRIVERS=y CONFIG_SPI=y CONFIG_LZ4=y CONFIG_LZMA=y +CONFIG_TARGET_CVITEK_CV181X=y # CONFIG_TOOLS_LIBCRYPTO is not set diff --git a/configs/settings.mk b/configs/settings.mk index 58ce76d..68c048b 100644 --- a/configs/settings.mk +++ b/configs/settings.mk @@ -1,5 +1,5 @@ -KERNELREV="2" -FSBLVERSION=1.0.0 +KERNELREV="3" +FSBLVERSION=1.1.0 PACKAGES="ca-certificates debian-archive-keyring dosfstools binutils file tree sudo bash-completion u-boot-menu openssh-server network-manager dnsmasq-base libpam-systemd ppp libengine-pkcs11-openssl iptables systemd-timesyncd vim usbutils parted exfatprogs systemd-sysv i2c-tools net-tools ethtool avahi-utils sudo gnupg rsync gpiod u-boot-tools libubootenv-tool" IMAGE_ADDITIONS="usb-gadget" \ No newline at end of file diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 35d0404..d58c5ba 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -14,12 +14,13 @@ RUN apt-get update \ git gperf kmod libexpat-dev \ libgmp-dev libmpc-dev libmpfr-dev libssl-dev \ libtool mmdebstrap openssl parted \ - patchutils python3 python3-dev python3-distutils \ + patchutils python3 python3-dev python3-pip \ python3-setuptools swig gnupg \ systemd-container texinfo zlib1g-dev wget arch-test \ linux-image-generic genimage joe mc zip \ fakeroot git kernel-wedge quilt ccache flex bison \ libssl-dev dh-exec rsync libelf-dev bc gcc-riscv64-unknown-elf \ + && pip3 install --no-cache-dir --break-system-packages pycryptodome \ && git clone --depth 1 https://github.com/milkv-duo/host-tools.git /host-tools \ && rm -rf /host-tools/gcc/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-elf \ && rm -rf /host-tools/gcc/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu \ diff --git a/scripts/Makefile b/scripts/Makefile index 37e02c4..3658972 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -8,11 +8,31 @@ blue:=$(shell tput setaf 4) reset:=$(shell tput sgr0) BUILDDIR := /build/ +KEYDIR := /keydir/ +RSA_HASH0_KEY := rsa_hash0.pem +BL_PRIV_KEY := bl_priv.pem ifndef BOARD $(error $(red)BOARD is not set$(reset)) endif +ifdef SIGN_FIP +RSA_HASH0_PATH := $(KEYDIR)$(RSA_HASH0_KEY) +BL_PRIV_PATH := $(KEYDIR)$(BL_PRIV_KEY) +#Check that the key directory exists +ifeq ("$(wildcard $(KEYDIR))","") +$(error $(red)Key directory '$(KEYDIR)' not found $(reset)) +endif +#Check for rsa_hash0.pem +ifeq ("$(wildcard $(RSA_HASH0_PATH))","") +$(error $(red)Missing RSA private key: '$(RSA_HASH0_PATH)' $(reset)) +endif +#Check for bl_priv.pem +ifeq ("$(wildcard $(BL_PRIV_PATH))","") +$(error $(red)Missing BL private key: '$(BL_PRIV_PATH)' $(reset)) +endif +endif + include /configs/settings.mk ifneq ("$(wildcard /configs/$(BOARD)/settings.mk)","") @@ -31,6 +51,11 @@ $(info $(blue)Board: $(BOARD)$(reset)) $(info $(blue)Storage: $(STORAGE_TYPE)$(reset)) $(info $(blue)Image Addons: $(IMAGE_ADDITIONS)$(reset)) $(info $(blue)Packages: $(_PACKAGES)$(reset)) +ifdef SIGN_FIP +$(info $(blue)Secure-boot ENABLED $(reset)) +else +$(info $(blue)Secure-boot DISABLED $(reset)) +endif NPROCS := $(shell nproc) @@ -38,8 +63,8 @@ NPROCS := $(shell nproc) $(BUILDDIR)/linux-prepare-checkout-stamp: @echo "$(COLOUR_GREEN)Checking out Kernel for $(BOARD)$(END_COLOUR)" @mkdir -p $(BUILDDIR) - @git clone -b sg200x-dev --depth 7 https://github.com/sophgo/linux_5.10.git /build/kernel - @cd $(BUILDDIR)/kernel && git checkout 8b8fbf8 + @git clone -b sg200x-dev --depth 15 https://github.com/sophgo/linux_5.10.git /build/kernel + @cd $(BUILDDIR)/kernel && git checkout e6ead53 @touch $@ $(BUILDDIR)/linux-prepare-patch-stamp: $(BUILDDIR)/linux-prepare-checkout-stamp @@ -79,7 +104,7 @@ linux-clean: $(BUILDDIR)/uboot-prepare-checkout-stamp: @echo "$(COLOUR_GREEN)Checking out U-Boot for $(BOARD)$(END_COLOUR)" @mkdir -p $(BUILDDIR) - @git clone --depth 1 https://github.com/sophgo/u-boot-2021.10.git $(BUILDDIR)/u-boot + @git clone --depth 15 https://github.com/sophgo/u-boot-2021.10.git $(BUILDDIR)/u-boot @cd $(BUILDDIR)/u-boot && git checkout 4a21b6b @touch $@ @@ -100,13 +125,13 @@ $(BUILDDIR)/uboot-prepare-patch-stamp: $(BUILDDIR)/uboot-prepare-checkout-stamp $(BUILDDIR)/uboot-prepare-configure-stamp: $(BUILDDIR)/uboot-prepare-patch-stamp @echo "$(COLOUR_GREEN)Configuring U-Boot for $(BOARD)$(END_COLOUR)" - @cd $(BUILDDIR)/u-boot/ && $(MAKE) -j$(NPROCS) BOARD=cv181x CONFIG_USE_DEFAULT_ENV=y STORAGE_TYPE=$(STORAGE_TYPE) CHIP=$(UBOOT_CHIP) CVIBOARD=$(UBOOT_BOARD) CROSS_COMPILE="/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-" $(BOARD)_defconfig + cd $(BUILDDIR)/u-boot/ && $(MAKE) -j$(NPROCS) BOARD=cv181x CONFIG_USE_DEFAULT_ENV=y STORAGE_TYPE=$(STORAGE_TYPE) CHIP=$(UBOOT_CHIP) CVIBOARD=$(UBOOT_BOARD) CROSS_COMPILE="/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-" $(BOARD)_defconfig @touch $@ $(BUILDDIR)/uboot-compile-stamp: $(BUILDDIR)/uboot-prepare-configure-stamp @echo "$(COLOUR_GREEN)Building U-Boot for $(BOARD)$(END_COLOUR)" - @cd $(BUILDDIR)/u-boot/ && $(MAKE) -j$(NPROCS) BOARD=cv181x CONFIG_USE_DEFAULT_ENV=y STORAGE_TYPE=$(STORAGE_TYPE) CHIP=$(UBOOT_CHIP) CVIBOARD=$(UBOOT_BOARD) CROSS_COMPILE="/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-" - @cd $(BUILDDIR)/u-boot/ && $(MAKE) -j$(NPROCS) BOARD=cv181x CONFIG_USE_DEFAULT_ENV=y STORAGE_TYPE=$(STORAGE_TYPE) CHIP=$(UBOOT_CHIP) CVIBOARD=$(UBOOT_BOARD) CROSS_COMPILE="/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-" u-boot-initial-env + cd $(BUILDDIR)/u-boot/ && $(MAKE) -j$(NPROCS) BOARD=cv181x CONFIG_USE_DEFAULT_ENV=y STORAGE_TYPE=$(STORAGE_TYPE) CHIP=$(UBOOT_CHIP) CVIBOARD=$(UBOOT_BOARD) CROSS_COMPILE="/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-" + cd $(BUILDDIR)/u-boot/ && $(MAKE) -j$(NPROCS) BOARD=cv181x CONFIG_USE_DEFAULT_ENV=y STORAGE_TYPE=$(STORAGE_TYPE) CHIP=$(UBOOT_CHIP) CVIBOARD=$(UBOOT_BOARD) CROSS_COMPILE="/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-" u-boot-initial-env @cp $(BUILDDIR)/u-boot/u-boot.bin $(BUILDDIR) @cp $(BUILDDIR)/u-boot/u-boot.dtb $(BUILDDIR) @cp $(BUILDDIR)/u-boot/u-boot-initial-env $(BUILDDIR) @@ -122,7 +147,7 @@ uboot-clean: $(BUILDDIR)/opensbi-prepare-checkout-stamp: @echo "$(COLOUR_GREEN)Checking out OpenSBI for $(BOARD)$(END_COLOUR)" @mkdir -p $(BUILDDIR) - @git clone -b sg200x-dev --depth 4 https://github.com/sophgo/opensbi.git $(BUILDDIR)/opensbi + @git clone -b sg200x-dev --depth 15 https://github.com/sophgo/opensbi.git $(BUILDDIR)/opensbi @cd $(BUILDDIR)/opensbi && git checkout 216793f # git clone https://github.com/riscv-software-src/opensbi.git $(BUILDDIR)/opensbi # @cd $(BUILDDIR)/opensbi && git checkout a2b255b @@ -151,14 +176,14 @@ opensbi-clean: $(BUILDDIR)/fsbl-prepare-checkout-stamp: @echo "$(COLOUR_GREEN)Checking out FSBL for $(BOARD)$(END_COLOUR)" @mkdir -p $(BUILDDIR) - @git clone -b sg200x-dev --depth 1 https://github.com/sophgo/fsbl.git $(BUILDDIR)/fsbl - @cd $(BUILDDIR)/fsbl && git checkout 15a84c5 + @git clone -b sg200x-dev --depth 15 https://github.com/sophgo/fsbl.git $(BUILDDIR)/fsbl + @cd $(BUILDDIR)/fsbl && git checkout 7ed3e3e @touch $@ $(BUILDDIR)/fsbl-prepare-patch-stamp: $(BUILDDIR)/fsbl-prepare-checkout-stamp @echo "$(COLOUR_GREEN)Patching FSBL for $(BOARD)$(END_COLOUR)" - @$(foreach file, $(wildcard /configs/common/patches/fsbl/*.patch), cd $(BUILDDIR)/fsbl && git apply --ignore-whitespace $(file);) - @$(foreach file, $(wildcard /configs/$(BOARD)/patches/fsbl/*.patch), cd $(BUILDDIR)/fsbl && git apply --ignore-whitespace $(file);) + $(foreach file, $(wildcard /configs/common/patches/fsbl/*.patch), cd $(BUILDDIR)/fsbl && git apply --ignore-whitespace $(file);) + $(foreach file, $(wildcard /configs/$(BOARD)/patches/fsbl/*.patch), cd $(BUILDDIR)/fsbl && git apply --ignore-whitespace $(file);) @python3 /builder/python/mmap_conv.py --type h /configs/$(BOARD)/memmap.py $(BUILDDIR)/fsbl/plat/$(CHIP)/include/cvi_board_memmap.h @printf '\163\000\120\020\157\360\337\377' > $(BUILDDIR)/fsbl/blank.bin @touch $@ @@ -170,6 +195,29 @@ $(BUILDDIR)/fsbl-compile-stamp: $(BUILDDIR)/fsbl-prepare-patch-stamp $(BUILDDIR) @cp $(BUILDDIR)/fsbl/build/$(CHIP)/fip.bin $(BUILDDIR) @touch $@ +$(BUILDDIR)/fsbl-compile-stamp: $(BUILDDIR)/fsbl-prepare-patch-stamp $(BUILDDIR)/opensbi-compile-stamp $(BUILDDIR)/uboot-compile-stamp + @echo "$(COLOUR_GREEN)Building FSBL for $(BOARD)$(END_COLOUR)" + @cd $(BUILDDIR)/fsbl && OD_CLK_SEL=y $(MAKE) -j$(NPROCS) ARCH=$(ARCH) CHIP_ARCH=$(CHIP) BOOT_CPU=$(BOOT_CPU) DDR_CFG=$(DDR_CFG) RTOS_ENABLE_FREERTOS=y BLCP_2ND_PATH=$(BUILDDIR)/fsbl/blank.bin LOADER_2ND_PATH=$(BUILDDIR)/u-boot.bin \ + CROSS_COMPILE=/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl- + + @if [ -n "$(SIGN_FIP)" ]; then \ + echo "$(blue)SIGN_FIP set; signing fip.bin...$(reset)"; \ + python3 $(BUILDDIR)/fsbl/plat/cv181x/fipsign.py sign \ + --root-priv=$(KEYDIR)/$(RSA_HASH0_KEY) \ + --bl-priv=$(KEYDIR)/$(BL_PRIV_KEY) \ + $(BUILDDIR)/fsbl/build/$(CHIP)/fip.bin \ + $(BUILDDIR)/fsbl/build/$(CHIP)/fip_signed.bin 2>&1 | \ + grep 'KPUB_HASH:' | \ + sed -n 's/.*\(KPUB_HASH:[0-9a-f]\+\).*/\1/p' \ + > $(KEYDIR)/KPUB_HASH.txt; \ + mv $(BUILDDIR)/fsbl/build/$(CHIP)/fip_signed.bin \ + $(BUILDDIR)/fsbl/build/$(CHIP)/fip.bin; \ + fi + + @cp $(BUILDDIR)/fsbl/build/$(CHIP)/fip.bin $(BUILDDIR) + @touch $@ + + $(BUILDDIR)/fsbl-package-stamp: $(BUILDDIR)/fsbl-compile-stamp @echo "$(COLOUR_GREEN)Packaging FSBL for $(BOARD)$(END_COLOUR)" @mkdir -p $(BUILDDIR)/package/cvitek-fsbl-$(BOARD)-$(FSBLVERSION) @@ -197,9 +245,8 @@ $(BUILDDIR)/image-prepare-stamp: @rm -rf /rootfs/ @-rm $(addon-targets) @mkdir -p /rootfs/ - @curl -v -L https://sophgo.my-ho.st:8443/public-key.asc -o $(BUILDDIR)/public-key.asc - @apt-key add $(BUILDDIR)/public-key.asc - @mmdebstrap -v --architectures=riscv64 --include="$(_PACKAGES)" sid "/rootfs/" "deb http://deb.debian.org/debian/ sid main" "deb https://sophgo.my-ho.st:8443/ debian sophgo" + @curl -v -L https://sophgo.my-ho.st/public-key.asc -o $(BUILDDIR)/public-key.asc + @mmdebstrap -v --architectures=riscv64 --include="$(_PACKAGES)" sid "/rootfs/" "deb http://deb.debian.org/debian/ sid main" "deb [signed-by=$(BUILDDIR)/public-key.asc] https://sophgo.my-ho.st:8443/ debian sophgo" @touch $@ $(BUILDDIR)/image-addons-stamp: $(BUILDDIR)/image-prepare-stamp $(BUILDDIR)/fsbl-package-stamp $(BUILDDIR)/linux-compile-stamp $(addon-targets) @@ -221,6 +268,11 @@ $(BUILDDIR)/image-customize-stamp: $(BUILDDIR)/image-addons-stamp $(BUILDDIR)/li @cp -v /builder/setup_rootfs.sh /rootfs/tmp/install/ @cp -v $(BUILDDIR)/public-key.asc /rootfs/tmp/install/ @chroot /rootfs/ /tmp/install/qemu-riscv64-static /bin/sh /tmp/install/setup_rootfs.sh + @if [ -n "$(RTKBASE)" ]; then \ + echo "$(blue)Install RTKBASE$(reset)"; \ + cp -v /builder/setup_rtkbase.sh /rootfs/tmp/install/; \ + chroot /rootfs/ /tmp/install/qemu-riscv64-static /bin/sh /tmp/install/setup_rtkbase.sh; \ + fi @rm -rf /rootfs/tmp/install/ @umount /rootfs/proc || true @umount /rootfs/sys || true diff --git a/scripts/deb/cvitek-fsbl/DEBIAN/control b/scripts/deb/cvitek-fsbl/DEBIAN/control index a8e6317..ecb5261 100644 --- a/scripts/deb/cvitek-fsbl/DEBIAN/control +++ b/scripts/deb/cvitek-fsbl/DEBIAN/control @@ -2,5 +2,5 @@ Package: cvitek-fsbl Architecture: riscv64 Maintainer: @fishwaldo Priority: optional -Version: 1.0.0 +Version: 1.1.0 Description: First Stage Boot Loader for the CV18xx and SG200X series of RISC-V SoC's diff --git a/scripts/setup_rootfs.sh b/scripts/setup_rootfs.sh index 96ca5bf..14d4d62 100755 --- a/scripts/setup_rootfs.sh +++ b/scripts/setup_rootfs.sh @@ -144,11 +144,14 @@ fi rm -rf /etc/apt/sources.list.d/multistrap-debian.list -apt-key add /tmp/install/public-key.asc +#apt-key add /tmp/install/public-key.asc +#cp /tmp/install/public-key.asc /etc/apt/trusted.gpg.d/sophgo-myho-st.gpg +gpg --dearmor /tmp/install/public-key.asc +cp /tmp/install/public-key.asc.gpg /etc/apt/trusted.gpg.d/sophgo-myho-st.gpg cat > /etc/apt/sources.list < /etc/fw_env.config