support full 100 threads test from TIan_chunyu

it is OK
This commit is contained in:
xuedongliang 2022-09-24 22:43:16 +08:00
commit fd69c3d400
18 changed files with 620 additions and 39 deletions

View File

@ -2,6 +2,7 @@
# APP_Framework/Applications/Make.defs
############################################################################
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)

View File

@ -29,5 +29,9 @@ menu "test app"
default "/dev/dac_dev"
endif
endif
config USER_TEST_SEMC
bool "Config test semc sdram"
default n
endif
endmenu

View File

@ -0,0 +1,7 @@
############################################################################
# APP_Framework/Applications/app_test/Make.defs
############################################################################
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/app_test/*/Make.defs)

View File

@ -1,4 +1,4 @@
SRC_FILES :=
SRC_FILES :=
ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y)
SRC_FILES += test_spi_flash.c
@ -12,4 +12,18 @@ ifeq ($(CONFIG_USER_TEST_DAC),y)
SRC_FILES += test_dac.c
endif
ifeq ($(CONFIG_USER_TEST_SEMC),y)
SRC_FILES += test_extsram.c
endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
include $(KERNEL_ROOT)/compiler.mk
endif
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += test_extsram.c
include $(APPDIR)/Application.mk
endif

View File

@ -0,0 +1,97 @@
#ifdef ADD_XIZI_FETURES
#include <xizi.h>
#endif
#include <stdio.h>
#include <stdint.h>
#include "transform.h"
/* parameters for sram peripheral */
// /* stm32f4 Bank3:0X68000000 */
// #define SRAM_BANK_ADDR ((uint32_t)0X68000000)
/* OK-1052 semc:0X80000000 */
#define SRAM_BANK_ADDR ((uint32_t)0X80000000)
/* data width: 8, 16, 32 */
#define SRAM_DATA_WIDTH 16
/* sram size */
#define SRAM_SIZE ((uint32_t)0x2000000)
#define TICK_PER_SECOND 100
int extsram_test(void)
{
int i = 0;
uint32_t start_time = 0, time_cast = 0;
#if SRAM_DATA_WIDTH == 8
char data_width = 1;
uint8_t data = 0;
#elif SRAM_DATA_WIDTH == 16
char data_width = 2;
uint16_t data = 0;
#else
char data_width = 4;
uint32_t data = 0;
#endif
/* write data */
printf("Writing the %ld bytes data, waiting....", SRAM_SIZE);
start_time = PrivGetTickTime();
for (i = 0; i < SRAM_SIZE / data_width; i++)
{
#if SRAM_DATA_WIDTH == 8
*(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width) = (uint8_t)0x55;
#elif SRAM_DATA_WIDTH == 16
*(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width) = (uint16_t)0x5555;
#else
*(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width) = (uint32_t)0x55555555;
#endif
}
time_cast = PrivGetTickTime() - start_time;
printf("Write data success, total time: %ld.%03ldS.\n", time_cast / TICK_PER_SECOND,
time_cast % TICK_PER_SECOND / ((TICK_PER_SECOND * 1 + 999) / 1000));
/* read data */
printf("start Reading and verifying data, waiting....\n");
for (i = 0; i < SRAM_SIZE / data_width; i++)
{
#if SRAM_DATA_WIDTH == 8
data = *(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width);
if (data != 0x55)
{
printf("SRAM test failed!");
break;
}
#elif SRAM_DATA_WIDTH == 16
data = *(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width);
if (data != 0x5555)
{
printf("SRAM test failed! data = 0x%x\n",data);
break;
}
#else
data = *(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width);
if (data != 0x55555555)
{
printf("SRAM test failed!");
break;
}
#endif
}
if (i >= SRAM_SIZE / data_width)
{
printf("SRAM test success!\n");
}
return 0;
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),
sram_test, sram_test, sram_test);
#endif

View File

@ -3,5 +3,11 @@ menu "connection app"
menuconfig APPLICATION_CONNECTION
bool "Using connection apps"
default n
if APPLICATION_CONNECTION
menuconfig SOCKET_DEMO
bool "Config test socket demo"
default n
endif
endmenu

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Application/connection_app/Make.defs
############################################################################
ifneq ($(CONFIG_APPLICATION_CONNECTION),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo
endif

View File

@ -1,7 +1,20 @@
SRC_DIR :=
ifeq ($(CONFIG_RESOURCES_LWIP),y)
SRC_DIR += socket_demo
ifeq ($(CONFIG_SOCKET_DEMO),y)
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
include $(APPDIR)/Application.mk
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_RESOURCES_LWIP),y)
SRC_DIR += socket_demo
endif
include $(KERNEL_ROOT)/compiler.mk
endif
endif

View File

@ -0,0 +1,7 @@
############################################################################
# APP_Framework/Application/connection_app/socket_demo/Make.defs
############################################################################
ifneq ($(CONFIG_SOCKET_DEMO),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo/*/Make.defs
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/connection_app/socket_demo/*/Make.defs)
endif

View File

@ -1,3 +1,14 @@
SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
include $(KERNEL_ROOT)/compiler.mk
endif
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += lwip_tcp_socket_demo.c lwip_udp_socket_demo.c
include $(APPDIR)/Application.mk
endif

View File

@ -19,14 +19,41 @@
*/
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#include "sys_arch.h"
#include <lwip/sockets.h>
#include "lwip/sys.h"
#endif
#ifdef ADD_NUTTX_FETURES
#include <sys/socket.h>
#include <netinet/in.h>
#include "stdio.h"
#endif
#define TCP_DEMO_BUF_SIZE 65535
char tcp_socket_ip[] = {192, 168, 250, 252};
u16_t tcp_socket_port = LWIP_TARGET_PORT;
#ifdef ADD_NUTTX_FETURES
#define lw_print printf
#define lw_notice printf
#define lw_error printf
#define LWIP_DEMO_TIMES 3
/** Create u32_t value from bytes */
#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
((uint32_t)((b) & 0xff) << 16) | \
((uint32_t)((c) & 0xff) << 8) | \
(uint32_t)((d) & 0xff))
#define PP_HTONL(x) ((uint32_t)(x))
#define LWIP_TARGET_PORT 6000
#endif
uint16_t tcp_socket_port = LWIP_TARGET_PORT;
/******************************************************************************/
@ -63,7 +90,7 @@ static void TCPSocketRecvTask(void *arg)
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1)
{
lw_error("Unable to bind\n");
closesocket(fd);
close(fd);
free(recv_buf);
continue;
}
@ -75,7 +102,7 @@ static void TCPSocketRecvTask(void *arg)
if (listen(fd, 5) != 0 )
{
lw_error("Unable to listen\n");
closesocket(fd);
close(fd);
free(recv_buf);
continue;
}
@ -97,10 +124,11 @@ static void TCPSocketRecvTask(void *arg)
}
}
closesocket(fd);
close(fd);
free(recv_buf);
}
#ifdef ADD_XIZI_FETURES
void TCPSocketRecvTest(int argc, char *argv[])
{
int result = 0;
@ -120,6 +148,8 @@ void TCPSocketRecvTest(int argc, char *argv[])
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
TCPSocketRecv, TCPSocketRecvTest, TCP recv echo);
#endif
static void TCPSocketSendTask(void *arg)
{
@ -146,7 +176,7 @@ static void TCPSocketSendTask(void *arg)
if (connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr)))
{
lw_print("Unable to connect\n");
closesocket(fd);
close(fd);
return;
}
@ -158,14 +188,15 @@ static void TCPSocketSendTask(void *arg)
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
sendto(fd, send_msg, strlen(send_msg), 0, (struct sockaddr*)&tcp_sock, sizeof(struct sockaddr));
lw_notice("Send tcp msg: %s ", send_msg);
MdelayKTask(1000);
PrivTaskDelay(1000);
}
closesocket(fd);
close(fd);
return;
}
#ifdef ADD_XIZI_FETURES
void TCPSocketSendTest(int argc, char *argv[])
{
if(argc >= 2)
@ -183,4 +214,18 @@ void TCPSocketSendTest(int argc, char *argv[])
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
TCPSocketSend, TCPSocketSendTest, TCP send demo);
#endif
#ifdef ADD_NUTTX_FETURES
void tcp_recv_demo(void)
{
TCPSocketRecvTask(NULL);
}
void tcp_send_demo(void)
{
TCPSocketSendTask(NULL);
}
#endif

View File

@ -18,13 +18,39 @@
* @date 2022-03-21
*/
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#include "sys_arch.h"
#include "lwip/sockets.h"
#endif
#ifdef ADD_NUTTX_FETURES
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#define LWIP_DEMO_TIMES 3
#define LWIP_LOCAL_PORT 6000
#define lw_error printf
#define lw_notice printf
#define lw_print printf
/** Create u32_t value from bytes */
#define LWIP_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
((uint32_t)((b) & 0xff) << 16) | \
((uint32_t)((c) & 0xff) << 8) | \
(uint32_t)((d) & 0xff))
#define PP_HTONL(x) ((uint32_t)(x))
#endif
#define UDP_BUF_SIZE 65536
char udp_socket_ip[] = {192, 168, 250, 252};
u16_t udp_socket_port = LWIP_LOCAL_PORT;
uint16_t udp_socket_port = LWIP_LOCAL_PORT;
/*****************************************************************************/
@ -61,7 +87,7 @@ static void UdpSocketRecvTask(void *arg)
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1)
{
lw_error("Unable to bind\n");
closesocket(fd);
close(fd);
free(recv_buf);
continue;
}
@ -81,11 +107,12 @@ static void UdpSocketRecvTask(void *arg)
sendto(fd, recv_buf, recv_len, 0, (struct sockaddr*)&server_addr, addr_len);
}
closesocket(fd);
close(fd);
free(recv_buf);
}
}
#ifdef ADD_XIZI_FETURES
void UdpSocketRecvTest(int argc, char *argv[])
{
if(argc >= 2)
@ -103,6 +130,7 @@ void UdpSocketRecvTest(int argc, char *argv[])
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
UDPSocketRecv, UdpSocketRecvTest, UDP Receive DEMO);
#endif
static void UdpSocketSendTask(void *arg)
{
@ -128,7 +156,7 @@ static void UdpSocketSendTask(void *arg)
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)))
{
lw_error("Unable to connect\n");
closesocket(fd);
close(fd);
return;
}
@ -140,13 +168,14 @@ static void UdpSocketSendTask(void *arg)
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
sendto(fd, send_str, strlen(send_str), 0, (struct sockaddr*)&udp_sock, sizeof(struct sockaddr));
lw_notice("Send UDP msg: %s ", send_str);
MdelayKTask(1000);
PrivTaskDelay(1000);
}
closesocket(fd);
close(fd);
return;
}
#ifdef ADD_XIZI_FETURES
void UdpSocketSendTest(int argc, char *argv[])
{
if(argc >= 2)
@ -164,4 +193,16 @@ void UdpSocketSendTest(int argc, char *argv[])
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
UDPSocketSend, UdpSocketSendTest, UDP send echo);
#endif
#ifdef ADD_NUTTX_FETURES
void udp_recv_demo(void)
{
UdpSocketRecvTask(NULL);
}
void udp_send_demo(void)
{
UdpSocketSendTask(NULL);
}
#endif

View File

@ -0,0 +1,70 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ADD_NUTTX_FETURES=y
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="xidatong-arm32"
CONFIG_ARCH_BOARD_XIDATONG_ARM32=y
CONFIG_ARCH_CHIP="imxrt"
CONFIG_ARCH_CHIP_IMXRT=y
CONFIG_ARCH_CHIP_MIMXRT1052CVL5B=y
CONFIG_ARCH_INTERRUPTSTACK=10240
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_ARMV7M_USEBASEPRI=y
CONFIG_BOARD_LOOPSPERMSEC=104926
CONFIG_BUILTIN=y
CONFIG_CLOCK_MONOTONIC=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_IMXRT_GPIO_IRQ=y
CONFIG_IMXRT_GPIO3_0_15_IRQ=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_IMXRT_LPUART1=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LPUART1_SERIAL_CONSOLE=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_IFUPDOWN=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_RAM_SIZE=524288
CONFIG_RAM_START=0x20200000
CONFIG_RAW_BINARY=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=14
CONFIG_START_MONTH=3
CONFIG_SYSTEM_NSH=y
CONFIG_DEV_GPIO=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_READLINE_CMD_HISTORY_LEN=100
CONFIG_READLINE_CMD_HISTORY_LINELEN=120
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_FS_ROMFS=y
CONFIG_NSH_ROMFSETC=y
CONFIG_NSH_ARCHROMFS=y
CONFIG_BOARDCTL_RESET=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_IMXRT_SEMC=y
CONFIG_ARM_MPU=y
CONFIG_ARM_MPU_NREGIONS=16
CONFIG_IMXRT_SEMC_SDRAM=y
CONFIG_IMXRT_SDRAM_START=0x80000000
CONFIG_IMXRT_SDRAM_SIZE=31457280
CONFIG_IMXRT_SDRAM_HEAP=y
CONFIG_IMXRT_SDRAM_HEAPOFFSET=0x0
CONFIG_ARCH_USE_MPU=y
CONFIG_MM_REGIONS=2
CONFIG_TESTING_MM=y
CONFIG_TESTING_MM_PROGNAME="mm"
CONFIG_TESTING_MM_PRIORITY=100
CONFIG_TESTING_MM_STACKSIZE=2048
CONFIG_USER_TEST=y
CONFIG_USER_TEST_SEMC=y

View File

@ -1458,6 +1458,10 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif
#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC)
int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif

View File

@ -64,6 +64,19 @@ int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
}
#endif
/****************************************************************************
* Name: cmd_Extsram
****************************************************************************/
#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC)
extern int extsram_test(void);
int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
nsh_output(vtbl, "Hello, extra sdram!\n");
extsram_test();
return OK;
}
#endif
/****************************************************************************
* Name: cmd_Hcho1os
****************************************************************************/

View File

@ -604,6 +604,10 @@ static const struct cmdmap_s g_cmdmap[] =
{ "lcd", cmd_Lcd, 1, 1, "[LCD demo cmd.]" },
#endif
#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC)
{ "sram", cmd_Extsram, 1, 1, "[Extra sdram demo cmd.]" },
#endif
#if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS)
{ "hcho1os", cmd_Hcho1os, 1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" },
#endif

View File

@ -0,0 +1,227 @@
/****************************************************************************
* arch/arm/src/imxrt/imxrt_mpuinit.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <nuttx/userspace.h>
#include "mpu.h"
#include "barriers.h"
#include "hardware/imxrt_memorymap.h"
#include "imxrt_mpuinit.h"
#ifdef CONFIG_ARM_MPU
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef MAX
# define MAX(a,b) a > b ? a : b
#endif
#ifndef MIN
# define MIN(a,b) a < b ? a : b
#endif
#ifndef CONFIG_ARMV7M_DCACHE
/* With Dcache off:
* Cacheable (MPU_RASR_C) and Bufferable (MPU_RASR_B) needs to be off
*/
# undef MPU_RASR_B
# define MPU_RASR_B 0
# define RASR_B_VALUE 0
# define RASR_C_VALUE 0
#else
# ifndef CONFIG_ARMV7M_DCACHE_WRITETHROUGH
/* With Dcache on:
* Cacheable (MPU_RASR_C) and Bufferable (MPU_RASR_B) needs to be on
*/
# define RASR_B_VALUE MPU_RASR_B
# define RASR_C_VALUE MPU_RASR_C
# else
/* With Dcache in WRITETHROUGH Bufferable (MPU_RASR_B)
* needs to be off, except for FLASH for alignment leniency
*/
# define RASR_B_VALUE 0
# define RASR_C_VALUE MPU_RASR_C
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: imxrt_mpu_initialize
*
* Description:
* Configure the MPU to permit user-space access to only restricted i.MXRT
* resources.
*
****************************************************************************/
void imxrt_mpu_initialize(void)
{
#ifdef CONFIG_BUILD_PROTECTED
uintptr_t datastart;
uintptr_t dataend;
#endif
/* Show MPU information */
mpu_showtype();
#ifdef CONFIG_ARMV7M_DCACHE
/* Memory barrier */
ARM_DMB();
#ifdef CONFIG_IMXFT_QSPI
/* Make QSPI memory region strongly ordered */
mpu_priv_stronglyordered(IMXRT_QSPIMEM_BASE, IMXRT_QSPIMEM_SIZE);
#endif
#endif
#ifdef CONFIG_BUILD_PROTECTED
/* Configure user flash and SRAM space */
DEBUGASSERT(USERSPACE->us_textend >= USERSPACE->us_textstart);
mpu_user_flash(USERSPACE->us_textstart,
USERSPACE->us_textend - USERSPACE->us_textstart);
datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart);
dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend);
DEBUGASSERT(dataend >= datastart);
mpu_user_intsram(datastart, dataend - datastart);
#else
mpu_configure_region(0xc0000000, 512 * 1024 * 1024,
MPU_RASR_TEX_DEV | /* Device
* Not Cacheable
* Not Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
mpu_configure_region(IMXRT_EXTMEM_BASE, 1024 * 1024 * 1024,
MPU_RASR_TEX_DEV | /* Device
* Not Cacheable
* Not Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
mpu_configure_region(IMXRT_FLEXCIPHER_BASE, 8 * 1024 * 1024,
MPU_RASR_TEX_NOR | /* Normal */
RASR_C_VALUE | /* Cacheable */
MPU_RASR_B | /* Bufferable
* Not Shareable */
MPU_RASR_AP_RORO); /* P:RO U:RO
* Instruction access */
mpu_configure_region(IMXRT_ITCM_BASE, 128 * 1024,
MPU_RASR_TEX_NOR | /* Normal */
RASR_C_VALUE | /* Cacheable */
RASR_B_VALUE | /* Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
mpu_configure_region(IMXRT_DTCM_BASE, 128 * 1024,
MPU_RASR_TEX_NOR | /* Normal */
RASR_C_VALUE | /* Cacheable */
RASR_B_VALUE | /* Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
#if 0
mpu_configure_region(IMXRT_OCRAM2_BASE, 512 * 1024,
MPU_RASR_TEX_NOR | /* Normal */
RASR_C_VALUE | /* Cacheable */
RASR_B_VALUE | /* Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
#endif
mpu_configure_region(IMXRT_OCRAM_BASE, 512 * 1024,
MPU_RASR_TEX_NOR | /* Normal */
RASR_C_VALUE | /* Cacheable */
RASR_B_VALUE | /* Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
mpu_configure_region(IMXRT_EXTMEM_BASE, 32 * 1024 * 1024,
MPU_RASR_TEX_SO | /* Ordered */
RASR_C_VALUE | /* Cacheable */
RASR_B_VALUE | /* Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
mpu_configure_region(0x81e00000, 2 * 1024 * 1024,
MPU_RASR_TEX_NOR | /* Normal
* Not Cacheable
* Not Bufferable
* Not Shareable */
MPU_RASR_AP_RWRW); /* P:RW U:RW
* Instruction access */
mpu_control(true, true, true);
return;
#endif
/* Then enable the MPU */
mpu_control(true, false, true);
}
/****************************************************************************
* Name: imxrt_mpu_uheap
*
* Description:
* Map the user-heap region.
*
* This logic may need an extension to handle external SDRAM).
*
****************************************************************************/
#ifdef CONFIG_BUILD_PROTECTED
void imxrt_mpu_uheap(uintptr_t start, size_t size)
{
mpu_user_intsram(start, size);
}
#endif
#endif /* CONFIG_ARM_MPU */

View File

@ -13,7 +13,7 @@
/**
* @file test_threadsched.c
* @brief support to test thread sched function
* @version 1.0
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
@ -25,11 +25,14 @@
extern long ShowTask(void);
extern unsigned int msleep(uint64_t msec);
#define BATCH_TEST_TASK_SIZE 100
static int32 tid1 = NONE;
static int32 tid2 = NONE;
static int32 tid3 = NONE;
static int32 tid4 = NONE;
static int32 tid5 = NONE;
static int32 tids[BATCH_TEST_TASK_SIZE];
#define DYNAMIC_TASK_STACK_SIZE 3072
#define PRIORITY 15
@ -56,12 +59,12 @@ static void Task1Entry(void *parameter)
ShowTask();
#endif
KPrintf("\n");
DOUBLE_LINKLIST_FOR_EACH(node, head) {
tmp = SYS_DOUBLE_LINKLIST_ENTRY(node, struct TaskDyncSchedMember, sched_link);
obj =CONTAINER_OF(tmp,struct TaskDescriptor, task_dync_sched_member);
KPrintf("task ready table node name = %s node remaining_tick= %d node advance_cnt =%d\n",obj->task_base_info.name,
obj->task_dync_sched_member.rest_timeslice, obj->task_dync_sched_member.advance_cnt);
KPrintf("task ready table node name = %s node remaining_tick= %d node advance_cnt =%d\n",obj->task_base_info.name,
obj->task_dync_sched_member.rest_timeslice, obj->task_dync_sched_member.advance_cnt);
}
#ifdef ARCH_SMP
#ifdef SCHED_POLICY_FIFO
@ -120,15 +123,8 @@ void DynamicTaskSchedTest(char* parm)
if (0 == strncmp("-b", parm, strlen("-b")) || 0 == strncmp("-bind", parm, strlen("-bind"))){
strncpy(t_parm,"-b", 4);
}
#endif
tid1 = KTaskCreate("d_tid1",
Task1Entry,
t_parm,
DYNAMIC_TASK_STACK_SIZE,
16);
if (tid1 >= 0)
StartupKTask(tid1);
#endif
tid2 = KTaskCreate("d_tid2",
Task2Entry,
"d_tid2",
@ -141,7 +137,7 @@ void DynamicTaskSchedTest(char* parm)
#endif
if (tid2 >= 0)
StartupKTask(tid2);
tid3 = KTaskCreate("d_tid3",
Task3Entry,
"d_tid3",
@ -154,7 +150,7 @@ void DynamicTaskSchedTest(char* parm)
#endif
if (tid3 >= 0)
StartupKTask(tid3);
tid4 = KTaskCreate("d_tid4",
Task4Entry,
"d_tid4",
@ -167,7 +163,7 @@ void DynamicTaskSchedTest(char* parm)
#endif
if (tid4 >= 0)
StartupKTask(tid4);
tid5 = KTaskCreate("d_tid5",
Task5Entry,
"d_tid5",
@ -183,8 +179,24 @@ void DynamicTaskSchedTest(char* parm)
StartupKTask(tid5);
}
static void BatchTaskSchedTest(char* parm)
{
memset(tids, 0, sizeof(int32) * BATCH_TEST_TASK_SIZE);
char task_name[20] = "batch_tid_";
for(int i = 0; i < BATCH_TEST_TASK_SIZE;i++){
task_name[9] = (char)(i / 100 + '0');
task_name[10] = (char)((i / 10) % 10 + '0');
task_name[11] = (char)(i % 10 + '0');
task_name[12] = 0;
tids[i] = KTaskCreate(task_name, Task2Entry, task_name, 128, 15);
if(tids[i] >= 0){
StartupKTask(tids[i]);
}
}
}
/********************************************************************/
static void UsageHelp(void)
static void UsageHelp(void)
{
KPrintf("test_task_ready_usage.\n");
}
@ -192,8 +204,7 @@ static void UsageHelp(void)
int TestTaskReadyAndSched(int argc, char * argv[])
{
DynamicTaskSchedTest(argv[0]);
BatchTaskSchedTest(argv[0]);
return 0;
}