说明

默认情况下,PetaLinux在编译完成后会删除源代码,以节省硬盘空间。

project-spec/meta-user/conf/petalinuxbsp.conf里,添加如下内容,可以保留Linux和UBoot源代码。

RM_WORK_EXCLUDE += "linux-xlnx"
RM_WORK_EXCLUDE += "u-boot-xlnx"

可以使用下面的方法创建petalinux工程:

##
# Copyright By Schips, All Rights Reserved
# https://gitee.com/schips/
#
# File Name: copy_petalinux_project_with_hw.sh
# Created : 2020-07-25 11:28:24
#
##
#!/bin/sh
help () {
echo "Error : need \$projectname \$hw_bsp"
echo " eg :"
echo " $0 ax_project ~/hw-vivado-bsp-for-petalinux/some_packakge"
exit 1
} if [ -z "$1" ]; then
help
fi
if [ -z "$2" ]; then
help
fi ## 删除源目录
rm $1 -rf ## 创建项目
petalinux-create --type project --template zynq --name $1 ## 导入硬件信息
cd $1
petalinux-config --get-hw-description $2 ## 使PetaLinux不删除源码
echo 'RM_WORK_EXCLUDE += "linux-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf echo 'RM_WORK_EXCLUDE += "u-boot-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf echo ''>> project-spec/meta-user/conf/petalinuxbsp.conf

此后,只要PetaLinux通过编译就可以获取源码。

system-top.dts、system-conf.dtsi 等这些设备树文件是petalinux-build在之后生成的

Linux、uboot的源码没有变化,关键在于配置以及设备树的变化

这里以:2018.03的ZYNQ-7000平台为例。

提取以后,还有一篇文章简单地介绍了如何打包BOOT.bin以及image.ub

https://www.cnblogs.com/schips/p/using-petalinux-package-boot_bin_and_image_ub.html

文件系统

文件系统位于image/linux,可以使用下面命令解压。

mkdir /tmp/rootfs_petalinx -p
sudo tar -zxf image/linux/rootfs.tar.gz -C /tmp/rootfs_petalinx

获取Linux有关内容

Linux源码

PetaLinux工程在编译后,在build/tmp/work-shared/目录下,根据对应芯片的$DIR下的kernel-source,含有所有Linux源代码。

使用以下命令进行到达所在目录:

#find . -type d -name "$1" 2> /dev/null | grep $1
cd build/tmp/work-shared/
cd `find . -type d -name "kernel-source" 2> /dev/null`

可以复制这个目录里的Linux源代码,用来使用open source流程编译。

以ZYNQ-7000为例,目录为:build/tmp/work-shared/plnx-zynq7/kernel-source

build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/这个目录下的源码有点不太一样,不要使用这个目录下面的。

Linux内核配置

PetaLinux工程在编译后,在build/tmp/work-shared/目录下,根据对应芯片的$DIR下的kernel-build-artifacts,保存了Linux的配置文件.config

通过以下命令查找它的所在目录:

#find . -type d -name "$1" 2> /dev/null | grep $1
cd build/tmp/work-shared/
find . -type d -name "kernel-build-artifacts" 2> /dev/null

以ZYNQ-7000为例,目录为:build/tmp/work-shared/plnx-zynq7/kernel-build-artifacts

为了方便使用,可以把文件.config复制到Linux源代码的子目录arch/arm/configs/下,重命名为xilinx_peta_defconfig。这样使用make xilinx_peta_defconfig,可以创建PetaLinux使用的Linux配置。

DIR=plnx-zynq7 # ZYNQ-7000
cp \
build/tmp/work-shared/$DIR/kernel-build-artifacts/.config \
build/tmp/work-shared/$DIR/kernel-source/arch/arm/configs/xilinx_peta_defconfig

获取设备树 .dts 文件

说明:

  • zynq-7000.dtsi :文件中的内容是 zynq-7000 系列处理器相同的硬件外设配置信息(PS 端的)
  • pl.dtsi :内容是我们在vivado 当中添加的 pl 端外设对应的配置信息
  • pcw.dtsi :表示我们在 vivado 当中已经使能的 PS 外设。

获取设备树源码一共有下列的方式:

工具 输入 输出 备注
SDK hdf dts 需要对SDK工程进行配置,但是使用方便
PetaLinux-build hdf dtb、dts 构建后才生成结果,过程不透明
PetaLinux-hsi hdf dts 需要使用交互式命令构建,生成的dts与build出来的有点不一样
dtc dts或dtb dtb或dts 传统方法;由dtb反编译再构建的dtb不一定可靠
kernel-make dts dtb 放在内核树中进行编译得到的设备树,需要修改Makefile

原理:除了dtc常规编译设备树以外,其他的方式都是由tcl脚本生成的。

dtc处理设备树

使用petalinux根据bsp建立工程以后,会在build/tmp/deploy/images目录中根据对应芯片的$DIR下的产生system.dtb,用dtc反汇编可获取dts文件。

#!/bin/bash

DTC=${A_DCT_FULL_PATH}  # 一般是在 Linux内核源码中的 scripts/dtc/dtc

find . -type f -name "system.dtb" 2> /dev/null

# 以 ZYNQ 7000 为例
##./build/tmp/deploy/images/plnx-zynq7/plnx-zynq7-system.dtb
##./images/linux/system.dtb # 反编译 dtb获取 dts
$DTC -I dtb -O dts -o system-top.dts system-top.dtb # 将dts 编译为 dtb
$DTC -I dts -O dtb -o system-top.dtb system-top.dts

完整编译工程以后,在image/linux中也会有一个system.dtb

hsi生成设备树

下载PetaLinux依赖的 设备树仓库路径:

wget https://github.com/Xilinx/device-tree-xlnx/archive/xilinx-v2018.3.tar.gz
tar -xf xilinx-v2018.3.tar.gz -C /opt/env

生成:

##
# Copyright By Schips, All Rights Reserved
# https://gitee.com/schips/
#
# File Name: hdf2dts.sh
# Created : 2020-08-06 20:14:03
#
##
#!/bin/sh
HDF=$1
DEVICE_TREE_DIR=/opt/env/device-tree-xlnx-xilinx-v2018.3
OUTDIR=$2
help () {
echo "ERROR : Need arguments"
echo " eg:"
echo " $0 xx.hdf outputDirForDTS"
exit
} if [ -z "$1" ]; then
help
fi if [ -z "$2" ]; then
help
fi
#export PATH=$PATH:${DEVICE_TREE_DIR}/
command -v hsi >/dev/null 2>&1 || { echo >&2 "Aborted : Require \"hsi\" but not found."; exit 1; }
echo "Creating DTS from [$$HDF]"
hsi <<EOF
open_hw_design $HDF
set_repo_path $DEVICE_TREE_DIR
create_sw_design deviec-tree -os device_tree -proc ps7_cortexa9_0
generate_target -dir $OUTDIR
EOF sed 's/\#include/\/include\//g' $OUTDIR/system-top.dts -i
echo "/include/ \"system-user.dtsi\"" >> $OUTDIR/system-top.dts
find ${OUTDIR} -type f -name "*.dts*" -exec sed -E -i -e "s/@0x([0-9a-fA-F\.]+)\s?\{/@\L\1 \{/g" -e "s/@0+([0-9a-fA-F\.]+)\s?\{/@\L\1 \{/g" {} +
echo "Created DTS from [$HDF]"
echo "You may need [system-conf.dtsi], [system-user.dtsi] from Petalinux Project" exit 0
# 进入交互命令
hsi
## 打开硬件描述文件
open_hw_design
## 设置仓库路径
set_repo_path
## 创建软件设计(CortexA9用的设备树)
create_sw_design deviec-tree -os device_tree -proc ps7_cortexa9_0
## 生成目标到目录
generate_target -dir

从PetaLinux工程中提取设备树

路径:

cp project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi  	${DTS_OUT}/common
cp components/plnx_workspace/device-tree/device-tree/system-conf.dtsi ${DTS_OUT}/common
cp components/plnx_workspace/device-tree/device-tree/system-top.dts ${DTS_OUT}/common
cp components/plnx_workspace/device-tree/device-tree/pl.dtsi ${DTS_OUT}/common
cp components/plnx_workspace/device-tree/device-tree/pcw.dtsi ${DTS_OUT}/common # 注意,kernel和uboot用的设备树中,还有一些地方不太一样:
cp -v ${petaProject}/`find . -type f -name "zynq-7000.dtsi" 2> /dev/null | grep "kernel-source"` ${DTS_OUT}/kernel
cp -v ${petaProject}/`find . -type f -name "zynq-7000.dtsi" 2> /dev/null | grep "u-boot"` ${DTS_OUT}/uboot

注意,kernel和uboot中的zynq-7000.dtsi不太一样,一般用kernel的就可以了。

SDK构建设备树

略。SDK需要安装一个类似dts的插件,此后也是根据hdf来创建一个设备树工程。

但是我认为这种方法还是比较臃肿。

获取 .its文件

image.ub哪里来?image.ub是U-Boot fitImage

搜索资料,得知这个文件把image, rootfs,dtb打包到一个文件里面

生成image.ub,需要一个后缀名为its的配置文件,来指定使用的设备树文件、根文件系统文件、内核文件。

参考蜗窝科技 u-boot FIT image介绍

image source file(.its)和device tree source file(.dts)类似,负责描述要生成的image

file的信息。mkimage和dtc工具,可以将.its文件以及对应的image data

file,打包成一个image file。

再将这个文件下载到么memory中,使用bootm命令就可以执行。

PetaLinux工程在编译后,在build/tmp/work/目录下中有fit-image-petalinux-user-image.its,可以用于生成image.ub。

目录比较深,我们不对它的路径规则进行分析,直接使用脚本进行查找:

cd build/tmp/work/
find . -name "fit-image-petalinux-user-image.its" 2> /dev/null

在PetaLinux 2018.2/2018.3里,images/linux/下有文件rootfs.its,用diff工具比较,两者的内容是一样的。

在PetaLinux 2019.1里,images/linux/已经没有这个文件。

为了方便,可以修改为使用images/linux下的文件。PetaLinux工程的目录"images/linux/"里,含有创建image.ub的devicetree、rootfs文件等。

取得UBoot有关内容

UBoot源码

如果使用了外部UBoot源代码编译,则没有这个源代码。可以复制前面提到的UBoot源代码,用来使用open source流程编译。

PetaLinux工程在编译后,在build/tmp/work/目录下,根据对应芯片的$DIR下的u-boot-xlnx中的git目录含有所有UBoot源代码。

通过以下命令查找它的所在目录:

#find . -type d -name "$1" 2> /dev/null | grep $1
cd build/tmp/work/
find . -type d -name "git" 2> /dev/null | grep "u-boot-xlnx"| grep "git"

以ZYNQ-7000为例,目录为:build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/u-boot-xlnx/

对于PetaLinux 2019.1的ZCU106 BSP工程,UBoot源代码在目录 ./build/tmp/work/zcu106_zynqmp-xilinx-linux/u-boot-xlnx/v2019.01-xilinx-v2019.1+gitAUTOINC+d895ac5e94-r0/git/。

UBoot配置

PetaLinux工程在编译后,在build/tmp/work/目录下,根据对应芯片的$DIR下的u-boot-xlnxbuild目录下保存了UBoot的配置文件.config

例如:

build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/u-boot-xlnx/v2018.01-xilinx-v2018.3+gitAUTOINC+d8fc4b3b70-r0/build/.config

使用以下命令定位所在目录:

#find . -type d -name "$1" 2> /dev/null | grep $1
cd build/tmp/work/
find . -type d -name "build" 2> /dev/null | grep "u-boot-xlnx"| grep "build"

为了方便使用,可以把文件.config复制到UBoot源代码的configs目录下,重命名为xilinx_peta_defconfig

这样一来,使用make xilinx_peta_defconfig,就可以创建PetaLinux使用的UBoot配置。

注意事项:

从PetaLinux工程里得到的UBoot源代码中自动生成的文件include/configs/platform-auto.h里的宏定义里的连接符后有空格,可能导致编译时编译器会产生大量警告。

使用以下命令去除:

sed 's/ $//' include/configs/platform-auto.h -i

uboot自动生成的配置

uboot头文件:project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h,实际上会变成platform-auto.h

修改bif文件

需要创建BOOT.BIN,需要bootgen.bif(boot image format)。

PetaLinux工程生成boot.bin时,会在build目录下生成文件bootgen.bif

BIF 文件的所有语法都在 Zynq UltraScale+ MPSoC 软件开发指南 (UG1137) 中,见附录 A。

默认的bif文件的内容如下,没有包括aes安全信息等:

the_ROM_image:
{
[bootloader] /tmp/tmp.0MmcVIZQVR/zynq_fsbl.elf
/tmp/tmp.0MmcVIZQVR/system.bit
/tmp/tmp.0MmcVIZQVR/u-boot.elf
}

bootgen.bif里用的是临时目录,最好改成PetaLinux工程的目录images/linux/,我们这里可以使用一个脚本,生成一个更规范的bif文件,在 顶级目录下 执行以下脚本:

#!/bin/sh

TOP=`pwd`
DESTDIR="${TOP}/images/linux"
BIF=new.bif echo "the_ROM_image:" > $BIF
echo "{" >> $BIF
echo " [bootloader] ${DESTDIR}/zynq_fsbl.elf" >> $BIF
echo " ${DESTDIR}/system.bit" >> $BIF
echo " ${DESTDIR}/u-boot.elf" >> $BIF
echo "}" >> $BIF

一键拷贝

原文:https://www.cnblogs.com/schips/p/get-source-code-and-config-from-petalinux-project-built.html

一键拷贝内核、uboot等源码(实际上不需要,因为构建时用的源码没有被修改)

关键在于设备树、以及配置

##
# Copyright By Schips, All Rights Reserved
# https://gitee.com/schips/
#
# File Name: cp_src_from_petalinux.sh
# Created : 2020-07-25 08:08:47
#
##
#!/bin/sh help () {
echo "ERROR : Need arguments"
echo " eg:"
echo " $0 petaProject outputDir"
exit
} if [ -z "$1" ]; then
help
fi if [ -z "$2" ]; then
help
fi petaProject=`cd $1 && pwd`
mkdir $2 -p
outputDir=`cd $2 && pwd` cd $petaProject || exit 1 CONFIG=xilinx_zynq7000_peta_defconfig KERNEL_DIR=${petaProject}/`find . -type d -name "kernel-source" 2> /dev/null`
UBOOT_DIR=${petaProject}/`find . -type d -name "git" 2> /dev/null | grep "u-boot-xlnx"| grep "git"` KERNEL_OUT=${outputDir}/linux
UBOOT_OUT=${outputDir}/uboot DTB=${petaProject}/images/linux/system.dtb
DTS_OUT=${outputDir}/dts
mkdir $DTS_OUT
#DTC=$KERNEL_DIR/scripts/dtc/dtc ## 拷贝配置
cp_config () {
KERNEL_CFG=${petaProject}/`find . -type d -name "kernel-build-artifacts" 2> /dev/null`/.config
UBOOT_CFG=${petaProject}/`find . -type d -name "build" 2> /dev/null | grep "u-boot-xlnx"| grep "build"`/.config
cp ${KERNEL_CFG} ${KERNEL_OUT}/arch/arm/configs/${CONFIG} -v
cp ${UBOOT_CFG} ${UBOOT_OUT}/configs/${CONFIG} -v
cp ./project-spec/meta-plnx-generated/recipes-bsp/u-boot/configs/platform-auto.h ${UBOOT_OUT}/include/configs/platform-auto.h -v
## 处理掉空格
sed 's/ $//' ${UBOOT_OUT}/include/configs/platform-auto.h -i
} cp_dt() {
echo "Warring : 经过对比分析,提取的设备树与PetaLinux构建的设备树很多地方不一致,不建议使用提取的设备树。"
cp $DTB ${DTS_OUT} -v
mkdir -p ${DTS_OUT}/uboot
mkdir -p ${DTS_OUT}/kernel
cp ${petaProject}/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi ${DTS_OUT}/uboot -v
cp ${petaProject}/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi ${DTS_OUT}/kernel -v cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/system-conf.dtsi ${DTS_OUT}/uboot -v
cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/system-conf.dtsi ${DTS_OUT}/kernel -v cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/system-top.dts ${DTS_OUT}/uboot -v
cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/system-top.dts ${DTS_OUT}/kernel -v cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/pl.dtsi ${DTS_OUT}/uboot -v
cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/pl.dtsi ${DTS_OUT}/kernel -v cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/pcw.dtsi ${DTS_OUT}/uboot -v
cp ${petaProject}/components/plnx_workspace/device-tree/device-tree/pcw.dtsi ${DTS_OUT}/kernel -v cp -v ${petaProject}/`find . -type f -name "zynq-7000.dtsi" 2> /dev/null | grep "kernel-source"` ${DTS_OUT}/kernel
cp -v ${petaProject}/`find . -type f -name "zynq-7000.dtsi" 2> /dev/null | grep "u-boot"` ${DTS_OUT}/uboot
## 更正设备树语法格式
sed -i 's/\#include/\/include\//g' ${DTS_OUT}/kernel/system-top.dts
sed -i 's/\#include/\/include\//g' ${DTS_OUT}/uboot/system-top.dts
find ${DTS_OUT} -type f -name "*.dts*" -exec sed -E -i -e "s/@0x([0-9a-fA-F\.]+)\s?\{/@\L\1 \{/g" -e "s/@0+([0-9a-fA-F\.]+)\s?\{/@\L\1 \{/g" {} +
} cp_rootfs () {
cp ${petaProject}/image/linux/rootfs.tar.gz ${outputDir} -v
} cp_src () {
## 拷贝源码 到 指定的 目录
cp ${KERNEL_DIR} ${KERNEL_OUT} -r
cp ${UBOOT_DIR} ${UBOOT_OUT} -r
cp ${petaProject}/images/linux/rootfs.tar.gz ${outputDir} -v
} cp_src
cp_dt
cp_config
cp_rootfs

清理、恢复 PetaLinux 工程

使用脚本清理

#
# Copyright By Schips, All Rights Reserved
# https://gitee.com/schips/
#
# File Name: clean_petalinux_project.sh
# Created : 2020-07-29 11:28:24
#
#
#!/bin/sh
BASE=`pwd`
SOURCEDIR=`cd $1 && pwd`
LOG=${SOURCEDIR}/cleanlog help () {
echo "ERROR : Need arguments"
echo " eg:"
echo " $0 petaProject"
exit
} if [ -z "$1" ]; then
help
fi rm ${LOG} backup_kernel_config () {
cd ${BASE}
cd ${SOURCEDIR}
KERNEL_CFG=${SOURCEDIR}/`find . -type d -name "kernel-build-artifacts" 2> /dev/null`/.config
mkdir -p ${SOURCEDIR}/our_config
cp ${KERNEL_CFG} -v ${SOURCEDIR}/our_config/kernel_config >> $LOG
} backup_uboot_config () {
cd ${BASE}
cd ${SOURCEDIR}
UBOOT_CFG=${SOURCEDIR}/`find . -type d -name "build" 2> /dev/null | grep "u-boot-xlnx"| grep "build"`/.config
mkdir -p ${SOURCEDIR}/our_config
cp ${UBOOT_CFG} -v ${SOURCEDIR}/our_config/uboot_config >> $LOG
}
backup_uboot_config
backup_kernel_config cd ${BASE}
rm -rf ${SOURCEDIR}/components ${SOURCEDIR}/build ${SOURCEDIR}/images echo "See log : [$LOG]"

之后,内核、uboot的配置会被保存到our_config中。

PetaLinux本身的配置不会改变:使用petalinux-config会看到之前的配置。

恢复被删除的工程的配置

Linux的配置,因为完整的构造目录被删除了,因此,需要LOAD回来,要么使用这样的命令

petalinux-config -c kernel

Uboot也是一样的,如果配置过了uboot,那么需要额外的LOAD操作。

petalinux-config -c u-boot

此后,直接petalinux-build即可。

提取以后,还有一篇文章简单地介绍了如何打包BOOT.bin以及image.ub

https://www.cnblogs.com/schips/p/xilinx-petalinux-package-boot_bin_and_image_ub.html

ZYNQ:提取PetaLinux中Linux和UBoot配置、源码的更多相关文章

  1. Linux内核分析(一)---linux体系简介|内核源码简介|内核配置编译安装

    原文:Linux内核分析(一)---linux体系简介|内核源码简介|内核配置编译安装 Linux内核分析(一) 从本篇博文开始我将对linux内核进行学习和分析,整个过程必将十分艰辛,但我会坚持到底 ...

  2. Linux系统的命令源码的获取方法

    我们知道,Linux是开源的,它自带的功能强大的命令也是开源的,也就是说.我们能够获得这些命令的源码并研究它.那到底怎样获得系统的命令的源码呢? 命令的源码是一个软件包为单元的,放在一个软件包的源码中 ...

  3. Fabric2.2中的Raft共识模块源码分析

    引言 Hyperledger Fabric是当前比较流行的一种联盟链系统,它隶属于Linux基金会在2015年创建的超级账本项目且是这个项目最重要的一个子项目.目前,与Hyperledger的另外几个 ...

  4. Linux 系统下用源码包安装软件

    Linux系统下用源码包安装软件 by:授客 QQ:1033553122 下载源码安装包,解压或者直接双击打开(如果有安装zip或rar等压缩/解压缩软件的话),查找相关的安装说明文件,一般是READ ...

  5. 转载~Linux 平台下阅读源码的工具

    Linux 平台下阅读源码的工具 前言 看源代码是一个程序员必须经历的事情,也是可以提升能力的一个捷径.个人认为: 要完全掌握一个软件的方法只有阅读源码在Windows下有sourceinsight这 ...

  6. Linux 内核调度器源码分析 - 初始化

    导语 上篇系列文 混部之殇-论云原生资源隔离技术之CPU隔离(一) 介绍了云原生混部场景中CPU资源隔离核心技术:内核调度器,本系列文章<Linux内核调度器源码分析>将从源码的角度剖析内 ...

  7. SpringBoot自动配置源码调试

    之前对SpringBoot的自动配置原理进行了较为详细的介绍(https://www.cnblogs.com/stm32stm32/p/10560933.html),接下来就对自动配置进行源码调试,探 ...

  8. RocketMQ中Broker的HA策略源码分析

    Broker的HA策略分为两部分①同步元数据②同步消息数据 同步元数据 在Slave启动时,会启动一个定时任务用来从master同步元数据 if (role == BrokerRole.SLAVE) ...

  9. SpringBoot Profile使用详解及配置源码解析

    在实践的过程中我们经常会遇到不同的环境需要不同配置文件的情况,如果每换一个环境重新修改配置文件或重新打包一次会比较麻烦,Spring Boot为此提供了Profile配置来解决此问题. Profile ...

  10. linux线程池thrmgr源码解析

    linux线程池thrmgr源码解析 1         thrmgr线程池的作用 thrmgr线程池的作用是提高程序的并发处理能力,在多CPU的服务器上运行程序,可以并发执行多个任务. 2      ...

随机推荐

  1. 设置Mysql数据库允许远程连接

    Mysql数据库用户权限设置 1.进入容器 docker exec -it mysql_test /bin/bash 注意:由于我是通过docker安装的数据库,所以在操作之前需要进入容器,直接安装在 ...

  2. 9.3K+ Star!一个面向中小型企业设计的开源运维平台!

    大家好,我是Java陈序员. 我们在日常开发中,会有很多的应用环境,开发环境.测试环境.回归环境.生产环境等等. 这些环境,需要部署在一台台的服务器上,有的可能是物理机,有的可能是云服务器. 那么,这 ...

  3. 从零开始:Django项目的创建与配置指南

    title: 从零开始:Django项目的创建与配置指南 date: 2024/5/2 18:29:33 updated: 2024/5/2 18:29:33 categories: 后端开发 tag ...

  4. 2024-05-04:用go语言,给定一个起始索引为0的字符串s和一个整数k。 要进行分割操作,直到字符串s为空: 选择s的最长前缀,该前缀最多包含k个不同字符; 删除该前缀,递增分割计数。如果有剩余

    2024-05-04:用go语言,给定一个起始索引为0的字符串s和一个整数k. 要进行分割操作,直到字符串s为空: 选择s的最长前缀,该前缀最多包含k个不同字符: 删除该前缀,递增分割计数.如果有剩余 ...

  5. flask入门 快速入门后台写接口【API】【Python3】【无前端】【json格式】

    目录 新建项目 虚拟环境 安装flask插件包 新建hello_world.py debug调适 四.flask应用 flask路由 变量规则 唯一的 URL / 重定向行为 flask重定向 JSO ...

  6. 如何在 Ubuntu 服务器上安装桌面环境 (GUI)

    先以VNC方式远程登录服务器 执行命令 sudo apt update && sudo apt upgrade # 选择1---使用tasksel安装 sudo apt install ...

  7. 用Python画一个冰墩墩!

    北京2022年冬奥会的召开,吉祥物冰墩墩着实火了,真的是一墩难求,为了实现冰墩墩的自由,经过资料搜集及参考冰墩墩网上的开源代码(https://github.com/HelloCoder-HaC/bi ...

  8. Flutter 多线程实现

    异步Isolate实现多线程   最近在看Flutter开发相关知识点,对照着Android原生,探究了下多线程实现方式.在Flutter中有 Isolate,隔离,它的实现原理并不是内存共享的,它更 ...

  9. C# 实现Ping远程主机功能

    C#实现Ping远程主机功能. 1.引用nuget包 Wesky.Net.OpenTools OpenTools是一个用于提高开发效率的开源工具库.该项目为个人开源项目,采用MIT开源协议,永不更改协 ...

  10. C 语言编程 — 高级数据类型 — 数组

    目录 文章目录 目录 前文列表 数组 声明数组 初始化数据 访问数组元素 二维数组 指向数组的指针 将数组指针作为实参传入函数 从函数返回一个数组指针 指针数组 数组名和取数组首地址的区别 前文列表 ...