From 0c0c371bc6d5649bacb1f42b0744a482bfc2110a Mon Sep 17 00:00:00 2001 From: thread-liu Date: Tue, 6 Apr 2021 10:39:22 +0800 Subject: [PATCH 1/5] [update] format ci, add ignore config file. --- .github/workflows/file_check.yml | 2 +- ignore_format.yml | 22 +++++++++++++++++ tools/file_check.py | 42 +++++++++++++++++++++++++------- 3 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 ignore_format.yml diff --git a/.github/workflows/file_check.yml b/.github/workflows/file_check.yml index 90576c4eda..f1f1994af8 100644 --- a/.github/workflows/file_check.yml +++ b/.github/workflows/file_check.yml @@ -16,5 +16,5 @@ jobs: - name: Check Format and License shell: bash run: | - pip install click chardet + pip install click chardet PyYaml python tools/file_check.py check 'https://github.com/RT-Thread/rt-thread' 'master' diff --git a/ignore_format.yml b/ignore_format.yml new file mode 100644 index 0000000000..17614c0b8e --- /dev/null +++ b/ignore_format.yml @@ -0,0 +1,22 @@ +# files format check exclude path, please follow the instructions below to modify; +# If you need to exclude an entire folder, add the folder path in dir_path; +# If you need to exclude a file, add the path to the file in file_path. + +file_path: +- bsp/stm32/stm32f072-st-nucleo/board/CubeMX_Config/Src/main.c + +dir_path: +- bsp/stm32/libraries/STM32F0xx_HAL +- bsp/stm32/libraries/STM32F1xx_HAL +- bsp/stm32/libraries/STM32F2xx_HAL +- bsp/stm32/libraries/STM32F4xx_HAL +- bsp/stm32/libraries/STM32F7xx_HAL +- bsp/stm32/libraries/STM32G0xx_HAL +- bsp/stm32/libraries/STM32G4xx_HAL +- bsp/stm32/libraries/STM32H7xx_HAL +- bsp/stm32/libraries/STM32L0xx_HAL +- bsp/stm32/libraries/STM32L1xx_HAL +- bsp/stm32/libraries/STM32L4xx_HAL +- bsp/stm32/libraries/STM32MPxx_HAL +- bsp/stm32/libraries/STM32WBxx_HAL +- bsp/stm32/libraries/STM32WLxx_HAL diff --git a/tools/file_check.py b/tools/file_check.py index 10d9060a37..f53edb53e6 100644 --- a/tools/file_check.py +++ b/tools/file_check.py @@ -12,6 +12,7 @@ import os import re import sys import click +import yaml import chardet import logging import datetime @@ -25,18 +26,39 @@ def init_logger(): datefmt=date_format, ) + class CheckOut: def __init__(self, rtt_repo, rtt_branch): self.root = os.getcwd() self.rtt_repo = rtt_repo self.rtt_branch = rtt_branch + def __exclude_file(self, file_path): + ignore_file_path = os.path.join(self.root, 'ignore_format.yml') + try: + with open(ignore_file_path) as f: + ignore_config = yaml.safe_load(f.read()) + file_ignore = ignore_config.get("file_path", []) + dir_ignore = ignore_config.get("dir_path", []) + except Exception as e: + logging.error(e) + return 1 + + if file_path in file_ignore: + return 0 + + file_dir_path = os.path.dirname(file_path) + if file_dir_path in dir_ignore: + return 0 + + return 1 + def get_new_file(self): file_list = list() try: - os.system('git remote add rtt_repo {}'.format(self.rtt_repo)) - os.system('git fetch rtt_repo') - os.system('git reset rtt_repo/{} --soft'.format(self.rtt_branch)) + os.system('git remote add rtt_repo {} 1>/dev/null'.format(self.rtt_repo)) + os.system('git fetch rtt_repo 1>/dev/null') + os.system('git reset rtt_repo/{} --soft 1>/dev/null'.format(self.rtt_branch)) os.system('git status > git.txt') except Exception as e: logging.error(e) @@ -60,7 +82,9 @@ class CheckOut: else: continue - file_list.append(file_path) + result = self.__exclude_file(file_path) + if result != 0: + file_list.append(file_path) return file_list @@ -96,13 +120,11 @@ class FormatCheck: encoding_check_result = True format_check_result = True for file_path in self.file_list: - file_lines = '' code = '' if file_path.endswith(".c") or file_path.endswith(".h"): try: - with open(file_path, 'r') as f: + with open(file_path, 'rb') as f: file = f.read() - file_lines = f.readlines() # get file encoding code = chardet.detect(file)['encoding'] except Exception as e: @@ -116,6 +138,8 @@ class FormatCheck: else: logging.info('[{0}]: encoding check success.'.format(file_path)) + with open(file_path, 'r') as f: + file_lines = f.readlines() format_check_result = self.__check_file(file_lines) if not encoding_check_result or not format_check_result: @@ -155,8 +179,8 @@ class LicenseCheck: true_year = '2006-{}'.format(current_year) if license_year != true_year: logging.warning("[{0}]: license year: {} is not true: {}, please update.".format(file_path, - license_year, - true_year)) + license_year, + true_year)) else: logging.info("[{0}]: license check success.".format(file_path)) From 791ecc093f41aa782afc2bc7ce71d621c78f7320 Mon Sep 17 00:00:00 2001 From: StackRyan Date: Wed, 7 Apr 2021 16:54:36 +0800 Subject: [PATCH 2/5] [fix] fix measurement unit of "percentage" to "permillage" for accuracy. --- components/drivers/include/drivers/sensor.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/drivers/include/drivers/sensor.h b/components/drivers/include/drivers/sensor.h index e05006f9f6..ede8d11c99 100644 --- a/components/drivers/include/drivers/sensor.h +++ b/components/drivers/include/drivers/sensor.h @@ -90,8 +90,6 @@ extern "C" { #define RT_SENSOR_UNIT_PPB (15) /* Concentration unit: ppb */ #define RT_SENSOR_UNIT_DMS (16) /* Coordinates unit: DMS */ #define RT_SENSOR_UNIT_DD (17) /* Coordinates unit: DD */ -#define RT_SENSOR_UNIT_PERCENT (18) /* Percentage unit: % */ - /* Sensor communication interface types */ #define RT_SENSOR_INTF_I2C (1 << 0) @@ -219,7 +217,7 @@ struct rt_sensor_data rt_int32_t force; /* Force sensor. unit: mN */ rt_uint32_t dust; /* Dust sensor. unit: ug/m3 */ rt_uint32_t eco2; /* eCO2 sensor. unit: ppm */ - rt_uint32_t spo2; /* SpO2 sensor. unit: % */ + rt_uint32_t spo2; /* SpO2 sensor. unit: permillage */ } data; }; From 903869718389be7a80da9a1ea5d6835a68cda655 Mon Sep 17 00:00:00 2001 From: thread-liu Date: Wed, 7 Apr 2021 11:50:47 +0800 Subject: [PATCH 3/5] [update] support bsp .ignore_format.yml. --- .ignore_format.yml | 9 +++++++ ignore_format.yml | 22 ---------------- tools/file_check.py | 62 +++++++++++++++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 41 deletions(-) create mode 100644 .ignore_format.yml delete mode 100644 ignore_format.yml diff --git a/.ignore_format.yml b/.ignore_format.yml new file mode 100644 index 0000000000..4a0e8bbec7 --- /dev/null +++ b/.ignore_format.yml @@ -0,0 +1,9 @@ +# files format check exclude path, please follow the instructions below to modify; +# If you need to exclude an entire folder, add the folder path in dir_path; +# If you need to exclude a file, add the path to the file in file_path. + +file_path: +- bsp/allwinner_tina/libcpu/cpu.c + +dir_path: +- tools \ No newline at end of file diff --git a/ignore_format.yml b/ignore_format.yml deleted file mode 100644 index 17614c0b8e..0000000000 --- a/ignore_format.yml +++ /dev/null @@ -1,22 +0,0 @@ -# files format check exclude path, please follow the instructions below to modify; -# If you need to exclude an entire folder, add the folder path in dir_path; -# If you need to exclude a file, add the path to the file in file_path. - -file_path: -- bsp/stm32/stm32f072-st-nucleo/board/CubeMX_Config/Src/main.c - -dir_path: -- bsp/stm32/libraries/STM32F0xx_HAL -- bsp/stm32/libraries/STM32F1xx_HAL -- bsp/stm32/libraries/STM32F2xx_HAL -- bsp/stm32/libraries/STM32F4xx_HAL -- bsp/stm32/libraries/STM32F7xx_HAL -- bsp/stm32/libraries/STM32G0xx_HAL -- bsp/stm32/libraries/STM32G4xx_HAL -- bsp/stm32/libraries/STM32H7xx_HAL -- bsp/stm32/libraries/STM32L0xx_HAL -- bsp/stm32/libraries/STM32L1xx_HAL -- bsp/stm32/libraries/STM32L4xx_HAL -- bsp/stm32/libraries/STM32MPxx_HAL -- bsp/stm32/libraries/STM32WBxx_HAL -- bsp/stm32/libraries/STM32WLxx_HAL diff --git a/tools/file_check.py b/tools/file_check.py index f53edb53e6..d4095f55e4 100644 --- a/tools/file_check.py +++ b/tools/file_check.py @@ -34,22 +34,46 @@ class CheckOut: self.rtt_branch = rtt_branch def __exclude_file(self, file_path): - ignore_file_path = os.path.join(self.root, 'ignore_format.yml') - try: - with open(ignore_file_path) as f: - ignore_config = yaml.safe_load(f.read()) - file_ignore = ignore_config.get("file_path", []) - dir_ignore = ignore_config.get("dir_path", []) - except Exception as e: - logging.error(e) - return 1 + dir_number = file_path.split('/') + ignore_path = file_path - if file_path in file_ignore: - return 0 - - file_dir_path = os.path.dirname(file_path) - if file_dir_path in dir_ignore: - return 0 + # gets the file path depth. + for i in dir_number: + # current directory. + dir_name = os.path.dirname(ignore_path) + ignore_path = dir_name + # judge the ignore file exists in the current directory. + ignore_file_path = os.path.join(dir_name, ".ignore_format.yml") + if not os.path.exists(ignore_file_path): + continue + try: + with open(ignore_file_path) as f: + ignore_config = yaml.safe_load(f.read()) + file_ignore = ignore_config.get("file_path", []) + dir_ignore = ignore_config.get("dir_path", []) + except Exception as e: + logging.error(e) + continue + + try: + # judge file_path in the ignore file. + for file in file_ignore: + if file is not None: + file_real_path = os.path.join(dir_name, file) + if file_real_path == file_path: + logging.info("ignore file path: {}".format(file_real_path)) + return 0 + + file_dir_path = os.path.dirname(file_path) + for _dir in dir_ignore: + if _dir is not None: + dir_real_path = os.path.join(dir_name, _dir) + if dir_real_path == file_dir_path: + logging.info("ignore dir path: {}".format(dir_real_path)) + return 0 + except Exception as e: + logging.error(e) + continue return 1 @@ -93,7 +117,7 @@ class FormatCheck: def __init__(self, file_list): self.file_list = file_list - def __check_file(self, file_lines): + def __check_file(self, file_lines, file_path): line_num = 1 check_result = False for line in file_lines: @@ -101,12 +125,12 @@ class FormatCheck: line_start = line.replace(' ', '') # find tab if line_start.startswith('\t'): - logging.error("line[{}]: please use space replace tab at the start of this line.".format(line_num)) + logging.error("{} line[{}]: please use space replace tab at the start of this line.".format(file_path, line_num)) check_result = False # check line end lin_end = line.split('\n')[0] if lin_end.endswith(' ') or lin_end.endswith('\t'): - logging.error("line[{}]: please delete extra space at the end of this line.".format(line_num)) + logging.error("{} line[{}]: please delete extra space at the end of this line.".format(file_path, line_num)) check_result = False line_num += 1 @@ -140,7 +164,7 @@ class FormatCheck: with open(file_path, 'r') as f: file_lines = f.readlines() - format_check_result = self.__check_file(file_lines) + format_check_result = self.__check_file(file_lines, file_path) if not encoding_check_result or not format_check_result: logging.error("files format check fail.") From e939ffe35502b2c0ccfa709673b21a42d2253109 Mon Sep 17 00:00:00 2001 From: zhouji <956133287@qq.com> Date: Tue, 6 Apr 2021 19:15:02 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=BC=82=E5=B8=B8=E6=97=B6=E8=87=AA=E5=8A=A8=E5=BC=80?= =?UTF-8?q?=E5=90=AFFPU=E7=9A=84=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=BD=93FPU=E6=9C=AB=E5=BC=80=E5=90=AF=E6=97=B6?= =?UTF-8?q?=E5=B0=86=E8=87=AA=E5=8A=A8=E5=BC=80=E5=90=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libcpu/arm/cortex-a/trap.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/libcpu/arm/cortex-a/trap.c b/libcpu/arm/cortex-a/trap.c index a213e776c7..3faa136677 100644 --- a/libcpu/arm/cortex-a/trap.c +++ b/libcpu/arm/cortex-a/trap.c @@ -47,30 +47,24 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { #ifdef RT_USING_FPU { - uint32_t ins; + uint32_t val; uint32_t addr; if (regs->cpsr & (1 << 5)) { /* thumb mode */ addr = regs->pc - 2; - ins = (uint32_t)*(uint16_t*)addr; - if ((ins & (3 << 11)) != 0) - { - /* 32 bit ins */ - ins <<= 16; - ins += *(uint16_t*)(addr + 2); - } } else { addr = regs->pc - 4; - ins = *(uint32_t*)addr; } - if ((ins & 0xe00) == 0xa00) + asm volatile ("vmrs %0, fpexc" : "=r"(val)::"memory"); + + if (!(val & 0x40000000)) { /* float ins */ - uint32_t val = (1U << 30); + val = (1U << 30); asm volatile ("vmsr fpexc, %0"::"r"(val):"memory"); regs->pc = addr; From 219012d75e4f7cb8ff8c2ff216c1e172e2d25bcb Mon Sep 17 00:00:00 2001 From: thread-liu Date: Thu, 8 Apr 2021 15:17:11 +0800 Subject: [PATCH 5/5] [update] stm32mp1 wifi sdio. --- bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_sdio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_sdio.c b/bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_sdio.c index df1ca92691..458a62097a 100644 --- a/bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_sdio.c +++ b/bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_sdio.c @@ -54,7 +54,7 @@ struct rthw_sdio }; /* SYSRAM SDMMC1/2 accesses */ -#define SDCARD_ADDR 0x2FFC0000 +#define SDCARD_ADDR 0x2FFFF000 #if defined(__CC_ARM) || defined(__CLANG_ARM) __attribute__((at(SDCARD_ADDR))) static rt_uint8_t cache_buf[SDIO_BUFF_SIZE]; #elif defined ( __GNUC__ ) @@ -579,7 +579,11 @@ int rt_hw_sdio_init(void) #endif #ifdef BSP_USING_SDIO2 - MX_RTC_Init(); + + if (IS_ENGINEERING_BOOT_MODE()) + { + MX_RTC_Init(); + } LBEE5KL1DX_init(); struct stm32_sdio_des sdio_des2;