diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 8ce5e5d9244c89c3ff7bcec0c4e9f8ebf71dd8ad..aa1f5496a1c97558dae0d0c8886bbad7b3515ff9 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -1,3 +1,23 @@ +# Phytium Standalone SDK 2024-01-15 ChangeLog + +Change Log since 2024-01-12 + +## example + +- update sdkconfig default platform + +# Phytium Standalone SDK 2024-01-12 ChangeLog + +Change Log since 2024-01-11 + +## tools + +- modify install.py to support windows native build + +## doc + +- add reference doc to support windows native environment + # Phytium Standalone SDK 2024-01-11 ChangeLog Change Log since 2024-01-09 diff --git a/docs/fig/windows_build_image.png b/docs/fig/windows_build_image.png new file mode 100644 index 0000000000000000000000000000000000000000..3e9af9a7f2d8fa1143587c4abd165d61866d4df7 Binary files /dev/null and b/docs/fig/windows_build_image.png differ diff --git a/docs/fig/windows_env.png b/docs/fig/windows_env.png new file mode 100644 index 0000000000000000000000000000000000000000..4a7afe00529b9c65d916f5d6674160e575d3bb72 Binary files /dev/null and b/docs/fig/windows_env.png differ diff --git a/docs/fig/windows_load_kconfig.png b/docs/fig/windows_load_kconfig.png new file mode 100644 index 0000000000000000000000000000000000000000..0ec9cb4e9a6876ec33e6dc34f7d2d56d8be5d544 Binary files /dev/null and b/docs/fig/windows_load_kconfig.png differ diff --git a/docs/reference/usr/install_windows.md b/docs/reference/usr/install_windows.md index d18ee5c418f29ee670e1e1c9e757dd0d7d7a0ff7..7a4fe69ed57ecef176c102c604ffc389c0ad7cd6 100644 --- a/docs/reference/usr/install_windows.md +++ b/docs/reference/usr/install_windows.md @@ -1,143 +1,35 @@ -# 1. Windows10 SDK安装方法 +# Windows 环境下的 FreeRTOS SDK 开发方法 -Windows 10 SDK开发环境集成了, -- `msys64`,Msys2 portable环境, 主要提供Windows上的shell命令行开发环境,包括了Cygwin (POSIX 兼容性层) 和 MinGW-w64(从"MinGW-生成") -- `setup_dev.py`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装 -- `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz`和`gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, mingw64交叉编译链, SDK安装过程中会被解压到DEV目录的`cross_tool`目录下 -- `tftp`, tftp工具, 提供tftp服务,用于开发板下载二进制镜像文件,主要的功能包括安装tftp32服务和配置tftp目录 -- `run_msys2.cmd`,用于打开和配置msys2 shell的脚本,需要设置`PHYTIUM_DEV_PATH`后才能使用 -- `run_tftd.cmd`,用于打开tftpd工具的脚本,需要设置`PHYTIUM_DEV_PATH`后才能使用 -- `tftp/reinstall.cmd`, 用于安装和配置tftpd服务的脚本 -- `tftp/uninstall.cmd`, 用于卸载tftpd服务的脚本 +- 参考 Phytium Standalone SDK [安装 Winodws 下的开发环境](https://gitee.com/phytium_embedded/phytium-standalone-sdk/blob/master/doc/reference/usr/install_windows.md),支持 Windows 10/11 64 位环境 -## 1.1 获取SDK的开发环境 -- [Windows10](https://pan.baidu.com/s/1V96isNcPq4F7nKi3_8GoGg) ->提取码:WX64 - -- Windows环境下可以用通用的unzip工具解压,如7zip和winrar - -## 1.2 安装SDK开发环境 - -- (1). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),例如,指向文件夹`E:\phytium-dev-windows-nt`(可以自定义) - -![配置环境变量](https://images.gitee.com/uploads/images/2021/1019/105259_18e64169_8736513.png "配置环境变量.png") - -- (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`./setup_dev.py`,注册开发环境 - -![安装开发环境](./pic/setup_dev.png "setup_dev.png") - --(3). DEV目录注册完成后,通过git拉取Phytium FreeRTOS SDK的代码,如 +- (1) 通过git拉取Phytium FreeRTOS SDK的代码,如 ``` git clone https://gitee.com/phytium_embedded/phytium-free-rtos-sdk.git ./phytium-free-rtos-sdk - -``` - -- (4). 进入Phytium FreeRTOS SDK代码目录,运行`./install.py` - -``` -cd ./phytium-free-rtos-sdk -./install.py -``` - -![开发环境安装完成](./pic/install.png "install.png") - -- (5). 安装完成后重启系统 - -### Q: 如果当前环境无法连接互联网 - -- 在执行第(2)步前,需要手动下载Phytium FreeRTOS SDK,放置在DEV目录下 -- https://gitee.com/phytium_embedded/phytium-free-rtos-sdk -- 需要手动下载Phytium Standalone SDK,放置在DEV的standalone目录下 -- https://gitee.com/phytium_embedded/phytium-standalone-sdk - -![手动下载SDK](./pic/download.png "download.png") - -## 1.3 检查安装是否成功 - -- 打印下列环境变量,观察各变量是否存在,指向的目录是否正确 -> `PHYTIUM_DEV_PATH`指向DEV目录 - -> `AARCH32_CROSS_PATH`指向32位交叉编译链目录 - -> `AARCH64_CROSS_PATH`指向64位交叉编译链目录 - -``` -echo $PHYTIUM_DEV_PATH $AARCH32_CROSS_PATH $AARCH64_CROSS_PATH -``` - -- 环境变量打印正确无误,表示**安装成功** -## 1.4 Windows 10安装Msys2(可选) - -- (1). 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) - -> 提取码:MGW6 - -- msys2, `msys2-x86_64-20210725.exe` -- mingw64-arm交叉编译链, `gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz` -- tftp工具,`tftp.zip` - -- (2). 创建Windows集成开发环境(DEV目录),如`D:/phytium-dev`, 将DEV目录添加在Windows环境变量中,变量名为`PHYTIUM_DEV_PATH`,如下图所示,保存环境变量, - -> 对于Windows 10,在桌面左下角系统搜索框中输入“环境变量”即可进入环境变量编辑界面 - -> DEV目录中不要留空格 - -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/192453_4e609b79_8736513.png "配置环境变量.png") - -- (3). 保存DEV环境变量后,打开一个控制台,输入`echo %PHYTIUM_DEV_PATH%`,检查环境变量是否设置成功, - -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164646_3fbc5df8_8736513.png "检查环境变量.png") - -- (4). 双击`msys2-x86_64-20210725.exe`,设置`Msys2`的安装路径在DEV路径下,其余设置按默认安装,注意安装完成后不要马上启动,最后一步取消勾选“马上启动Msys2” - -![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164805_4169d4d2_8736513.png "安装Msys2.png") - -![Msys2安装过程](https://images.gitee.com/uploads/images/2021/1013/135101_c8fc0454_8736513.png "Msys2安装过程.png") - -- (5). `Msys2`安装完成后,需要添加国内软件源,否则下载速度会很慢,进入`D:\phytium-dev\msys64\etc\pacman.d`目录下,找到以下三个文件,在文件末尾分别添加对应的软件源 - -- mirrorlist.mingw32 -``` -Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686 +cd phytium-free-rtos-sdk +python .\install.py ``` -- mirrorlist.mingw64 -``` -Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64 -``` - -- mirrorlist.msys -``` -Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch -``` - -- (6). 进入`D:\phytium-dev\msys64`目录,双击`msys2_shell.cmd`启动运行`Msys2`,输入以下命令,更新`Msys2`软件,安装必要组件 - -> 如果执行失败,可以多次尝试,直到没有报错 - -> 安装过程全部选用默认方式`default`或选择`y`,注意如果没有`default = all`,需要输入`y` - -``` -$ pacman -Syu -$ pacman -S mingw-w64-x86_64-toolchain -$ pacman -S base-devel git python3 python3-pip -``` +![Alt text](../../fig/windows_env.png) -![更新Msys2软件源](https://images.gitee.com/uploads/images/2021/1013/140545_6cda8ecc_8736513.png "更新Msys2软件源.png") +- (2) 进入Phytium FreeRTOS SDK代码目录,选择一个 example 进行编译开发,例如使用 template 例程,目标平台为 E2000D Demo 板,首先加载默认配置 -- (7). 运行以下命令,检查组件是否安装完全 ``` -$ pacman -Q make git wget python3 python3-pip +cd .\example\template +make list_kconfig +make load_kconfig LOAD_CONFIG_NAME=e2000d_aarch64_demo_eg +make menuconfig +make clean +make all ``` -## 1.5 卸载开发环境 +![Alt text](../../fig/windows_load_kconfig.png) -- 在DEV目录下双击`run_msys2.cmd`, 启动`Msys2`控制台,在控制台输入`./uninstall.py`完成SDK卸载 +- (3) 编译成功后会输出一系列镜像文件 -- 在`Msys2`控制台运行`rm /etc/profile.d/phytium_dev.sh`,删除SDK配置文件 +![Alt text](../../fig/windows_build_image.png) -- 在DEV目录`D:\phytium-dev\tftp`下以**管理员权限**打开Windows命令行中断,运行`uninstall.cmd`完成Tftd卸载 +- (4) 参考 Phytium Standalone SDK [通过 TFTP 工具 上传镜像到开发板](https://gitee.com/phytium_embedded/phytium-standalone-sdk/blob/master/doc/reference/usr/install_windows.md) -- 重启系统完成卸载 \ No newline at end of file +- (5) 参考 Phytium Standalone SDK [使用 JTAG 适配器进行调试](https://gitee.com/phytium_embedded/phytium-standalone-sdk/blob/master/doc/reference/usr/install_windows.md) diff --git a/install.py b/install.py index 437cfe75a3317750f3fb19d43d7aaa44bfc51eb7..6f559b6635e3c4d49e0c8d423b6f46a50b2beb9d 100755 --- a/install.py +++ b/install.py @@ -1,70 +1,26 @@ #!/usr/bin/env python3 -import sys import os -import pwd -import stat import platform -import getpass -import tarfile import re -import shutil ### platform constant -platform_tags = ["Linux_X86_64" "Linux_AARCH64" "Msys2"] +platform_tags = ["Linux_X86_64" "Linux_AARCH64" "Windows_x64"] linux_x86 = 0 linux_aarch64 = 1 -windows_msys2 = 2 - -### environment constant -sdk_profile_path = "/etc/profile.d/phytium_dev.sh" -sdk_version = "v0.7.1" - -def rm_line(str, file_path): - with open(file_path,'r+') as f: - lines = [line for line in f.readlines() if str not in line] - f.seek(0) - f.truncate(0) - f.writelines(lines) - -def ap_line(str, file_path): - with open(file_path, 'a') as f: - f.write(str + '\n') +windows_x64 = 2 # STEP 1: Check environment -# check install environment if (platform.system() == 'Linux' ) and (platform.processor() == 'x86_64'): install_platform = linux_x86 elif (platform.system() == 'Linux' ) and (platform.processor() == 'aarch64'): # Arm64 computer install_platform = linux_aarch64 -elif (re.search('MSYS_NT', platform.system()).span() == (0, len('MSYS_NT'))): - install_platform = windows_msys2 +elif (platform.system() == 'Windows') and (platform.machine() == 'AMD64'): + install_platform = windows_x64 else: - print("[1]: Platform not support !!! ") - exit() - - -# create '/etc/profile.d/phytium_standalone_sdk.sh' need sudo right, ask user to create it first -if not os.path.exists(sdk_profile_path): - if (install_platform == linux_x86) or (install_platform == linux_aarch64): - print("[1]: Please create sdk profile with 'sudo touch {}' first".format(sdk_profile_path)) - print("then 'sudo chmod 666 {}'".format(sdk_profile_path)) - else: # for Windows msys2 - print("[1]: Please create sdk profile with 'touch {}' first".format(sdk_profile_path)) - print("then 'chmod 666 {}'".format(sdk_profile_path)) - + print("Platform not support !!! ") exit() -# get current user to install, profile depends on user -usr = getpass.getuser() -if (install_platform == windows_msys2): - # arch is not able to get for msys2 - print("[1]: Usr: {}, OS: {}, Type: {}".format(usr, platform.system(), install_platform)) -else: - print("[1]: Usr: {}, OS: {}, Arch: {}, Type: {}".format(usr, platform.system(), platform.processor(), install_platform)) - -print("[1]: Enviroment variables will set at {}".format(sdk_profile_path)) - # get absoulte path current pwd to install sdk install_path, install_script = os.path.split(os.path.abspath(__file__)) curr_path = os.getcwd() @@ -72,22 +28,19 @@ freertos_sdk_path = '' # in case user call this script not from current path if (curr_path != install_path): - print("[1]: Please cd to install script path first !!!") + print("Please cd to install script path first !!!") exit() # get absolute path of sdk install dir freertos_sdk_path = install_path -print("[1]: Standalone SDK at {}".format(freertos_sdk_path)) - -# make sure sdk scripts are executable -os.system("chmod +x ./*.sh --silent ") -os.system("chmod +x ./scripts/*.sh --silent ") -os.system("chmod +x ./make/*.mk --silent ") -os.system("chmod +x ./lib/Kconfiglib/*.py --silent ") +print("Standalone SDK at {}".format(freertos_sdk_path)) # Add standalone sdk -standalone_sdk_v="e279fe5984778e7e7ac8cfa746d3d66ec9385b38" -standalone_path=freertos_sdk_path + '/standalone' +standalone_sdk_v="822fc36aff031d54e7c80f254fb64206ab187981" +if (install_platform == windows_x64): + standalone_path=freertos_sdk_path + '\\standalone' +else: + standalone_path=freertos_sdk_path + '/standalone' standalone_branche="master" standalone_remote="https://gitee.com/phytium_embedded/phytium-standalone-sdk.git" @@ -98,61 +51,26 @@ if not os.path.exists(standalone_path): os.chdir(standalone_path)# 切换工作路径至standalone 路径 os.system("git config core.sparsecheckout true") os.system("git config advice.detachedHead false") - os.system("echo \"arch/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"board/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"common/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"drivers/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"standalone.mk\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"lib/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"doc/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"third-party/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"tools/*\" >> {}".format(r'.git/info/sparse-checkout')) - os.system("echo \"soc/*\" >> {}".format(r'.git/info/sparse-checkout')) + os.system("git sparse-checkout init") + + # 适配 windows 环境,路径不兼容 + os.system("git sparse-checkout add arch") + os.system("git sparse-checkout add board") + os.system("git sparse-checkout add common") + os.system("git sparse-checkout add drivers") + os.system("git sparse-checkout add standalone.mk") + os.system("git sparse-checkout add lib") + os.system("git sparse-checkout add doc") + os.system("git sparse-checkout add third-party") + os.system("git sparse-checkout add !third-party/lwip-2.1.2/ports/arch") + os.system("git sparse-checkout add tools") + os.system("git sparse-checkout add soc") os.system("git checkout {}".format(standalone_sdk_v)) - print('[1]: Standalone sdk download is succeed') - os.chdir(current_path) # 切换回当前路径 - lwip_port_arch_path=standalone_path + '/third-party/lwip-2.1.2/ports/arch' - shutil.rmtree(lwip_port_arch_path) + print('Standalone sdk download is succeed') else: - print('[1]: Standalone sdk is exist') + print('Standalone sdk is exist') pass -## STEP 2: reset environment -# remove environment variables - -try: - sdk_profile = open(sdk_profile_path, "r+") - sdk_profile.close() - -except Exception as ex: - print(ex) - print("[2]: Create SDK profile {} failed !!!!".format(sdk_profile_path)) - exit() - -rm_line("### PHYTIUM FREERTOS SDK SETTING START",sdk_profile_path) -rm_line("export FREERTOS_SDK_ROOT=",sdk_profile_path) -rm_line("export FREERTOS_STANDALONE=",sdk_profile_path) -rm_line("### PHYTIUM FREERTOS SDK SETTING END",sdk_profile_path) - -print("[2]: Reset environment") - -## STEP 3: get cross-platform compiler -######################################### -if not os.path.exists(os.environ.get('AARCH32_CROSS_PATH')): - print("[3]: Failed, AARCH32 CC package {} non found !!!".format('AARCH32_CROSS_PATH')) - exit() - -if not os.path.exists(os.environ.get('AARCH64_CROSS_PATH')): - print("[3]: Failed, AARCH64 CC package {} non found !!!".format('AARCH64_CROSS_PATH')) - exit() - -print("[3]: GNU CC version: 10.3.1-2021.07") - -## STEP 4: display success message and enable environment -print("[4]: Success!!! Standalone SDK is Install at {}".format(freertos_sdk_path)) -print("[4]: SDK Environment Variables is in {}".format(sdk_profile_path)) -print("[4]: Phytium FREERTOS SDK Setup Done for {}!!!".format(usr)) -print("[4]: FREERTOS SDK version is {}".format(sdk_version)) -print("[4]: Input 'source {}' or Reboot System to Active SDK".format(sdk_profile_path)) - +## STEP 2: display success message and enable environment +print("Success!!! Phytium FreeRTOS SDK is Install at {}".format(freertos_sdk_path)) \ No newline at end of file diff --git a/third-party/cherryusb/core/usbh_core.h b/third-party/cherryusb/core/usbh_core.h index cda0c3bdc5442c843ee8fb4670c11eea01072a69..fd8ac72891f4b8b457a6b209509e63733aa1eaef 100644 --- a/third-party/cherryusb/core/usbh_core.h +++ b/third-party/cherryusb/core/usbh_core.h @@ -173,7 +173,7 @@ struct usbh_hub { struct usbh_hubport *parent; usb_slist_t hub_event_list; struct usbh_bus *usb; - uint ports; /* num of ports */ + uint32_t ports; /* num of ports */ USB_MEM_ALIGNX uint8_t g_hub_buf[32]; USB_MEM_ALIGNX uint8_t g_hub_intbuf[CONFIG_USBHOST_MAX_EXTHUBS + 1][1]; };