Browse Source

!44 v0.1.17

pull/45/MERGE v0.1.17
wangxiaodong 3 years ago
parent
commit
17ad4668da
  1. 1
      Kconfig
  2. 45
      README.md
  3. 12
      arch/Kconfig
  4. 25
      arch/armv8/aarch32/aarch32.h
  5. 52
      arch/armv8/aarch32/cache.c
  6. 3
      arch/armv8/aarch32/cache.h
  7. 19
      arch/armv8/aarch32/cp15.h
  8. 27
      arch/armv8/aarch32/exception.c
  9. 27
      arch/armv8/aarch32/exception.h
  10. 21
      arch/armv8/aarch32/gcc/exception_debug.c
  11. 23
      arch/armv8/aarch32/generic_timer.c
  12. 22
      arch/armv8/aarch32/generic_timer.h
  13. 65
      arch/armv8/aarch32/mmu.c
  14. 99
      arch/armv8/aarch32/mmu.h
  15. 2
      arch/armv8/aarch32/psci.c
  16. 23
      arch/armv8/aarch64/aarch64.c
  17. 4
      arch/armv8/aarch64/aarch64.h
  18. 22
      arch/armv8/aarch64/arm-smccc.h
  19. 80
      arch/armv8/aarch64/cache.c
  20. 27
      arch/armv8/aarch64/cache.h
  21. 29
      arch/armv8/aarch64/exception.c
  22. 27
      arch/armv8/aarch64/exception.h
  23. 23
      arch/armv8/aarch64/gcc/gcc_debug.c
  24. 8
      arch/armv8/aarch64/gcc/tlb.S
  25. 29
      arch/armv8/aarch64/gcc/vectors_g.c
  26. 22
      arch/armv8/aarch64/generic_timer.c
  27. 23
      arch/armv8/aarch64/generic_timer.h
  28. 41
      arch/armv8/aarch64/l3cache.h
  29. 261
      arch/armv8/aarch64/mmu.c
  30. 81
      arch/armv8/aarch64/mmu.h
  31. 2
      arch/armv8/aarch64/psci.c
  32. 31
      arch/armv8/aarch64/psw.c
  33. 30
      arch/armv8/aarch64/psw.h
  34. 5
      arch/common/kernel.h
  35. 27
      arch/common/l3cache.c
  36. 52
      arch/common/l3cache.h
  37. 22
      arch/common/linkage.h
  38. 22
      arch/common/macro.h
  39. 23
      arch/common/swap.h
  40. 38
      baremetal/example/get-start/hello_letter_shell/README.md
  41. 29
      baremetal/example/get-start/hello_letter_shell/main.c
  42. 22
      baremetal/example/get-start/hello_world/main.c
  43. 23
      baremetal/example/network/fgmac_lwip_echo/inc/fgmac_lwip_echo_example.h
  44. 22
      baremetal/example/network/fgmac_lwip_echo/main.c
  45. 22
      baremetal/example/network/fgmac_lwip_echo/src/cmd_lwip.c
  46. 24
      baremetal/example/network/fgmac_lwip_echo/src/fgmac_lwip_echo_example.c
  47. 22
      baremetal/example/network/fgmac_lwip_tftp/inc/fgmac_fatfs.h
  48. 22
      baremetal/example/network/fgmac_lwip_tftp/inc/fgmac_lwip.h
  49. 22
      baremetal/example/network/fgmac_lwip_tftp/inc/fgmac_lwip_tftp_client.h
  50. 22
      baremetal/example/network/fgmac_lwip_tftp/main.c
  51. 22
      baremetal/example/network/fgmac_lwip_tftp/src/cmd_tftp.c
  52. 28
      baremetal/example/network/fgmac_lwip_tftp/src/fgmac_fatfs.c
  53. 24
      baremetal/example/network/fgmac_lwip_tftp/src/fgmac_lwip.c
  54. 24
      baremetal/example/network/fgmac_lwip_tftp/src/fgmac_lwip_tftp_client.c
  55. 65
      baremetal/example/peripheral/can/can_test/configs/d2000_aarch32_eg_configs
  56. 66
      baremetal/example/peripheral/can/can_test/configs/d2000_aarch64_eg_configs
  57. 65
      baremetal/example/peripheral/can/can_test/configs/ft2004_aarch32_eg_configs
  58. 66
      baremetal/example/peripheral/can/can_test/configs/ft2004_aarch64_eg_configs
  59. 37
      baremetal/example/peripheral/can/can_test/fcan_test.c
  60. 22
      baremetal/example/peripheral/can/can_test/main.c
  61. 4
      baremetal/example/peripheral/can/can_test/makefile
  62. 66
      baremetal/example/peripheral/can/can_test/sdkconfig
  63. 53
      baremetal/example/peripheral/can/can_test/sdkconfig.h
  64. 27
      baremetal/example/peripheral/dma/gdma_test/gdma_test.c
  65. 22
      baremetal/example/peripheral/dma/gdma_test/main.c
  66. 22
      baremetal/example/peripheral/eth/fgmac_link/inc/fgamc_recv_example.h
  67. 22
      baremetal/example/peripheral/eth/fgmac_link/main.c
  68. 22
      baremetal/example/peripheral/eth/fgmac_link/src/cmd_eth_recv.c
  69. 32
      baremetal/example/peripheral/eth/fgmac_link/src/fgmac_recv_example.c
  70. 51
      baremetal/example/peripheral/eth/xmac_test/main.c
  71. 4
      baremetal/example/peripheral/i2c/fi2c_eeprom/README.md
  72. 47
      baremetal/example/peripheral/i2c/fi2c_eeprom/cmd_fi2c_eeprom.c
  73. 43
      baremetal/example/peripheral/i2c/fi2c_eeprom/configs/d2000_aarch32_eg_configs
  74. 44
      baremetal/example/peripheral/i2c/fi2c_eeprom/configs/d2000_aarch64_eg_configs
  75. 42
      baremetal/example/peripheral/i2c/fi2c_eeprom/configs/ft2004_aarch32_eg_configs
  76. 42
      baremetal/example/peripheral/i2c/fi2c_eeprom/configs/ft2004_aarch64_eg_configs
  77. 151
      baremetal/example/peripheral/i2c/fi2c_eeprom/fi2c_eeprom_example.c
  78. 30
      baremetal/example/peripheral/i2c/fi2c_eeprom/fi2c_eeprom_example.h
  79. BIN
      baremetal/example/peripheral/i2c/fi2c_eeprom/fig/fast_speed.png
  80. 22
      baremetal/example/peripheral/i2c/fi2c_eeprom/main.c
  81. 2
      baremetal/example/peripheral/i2c/fi2c_eeprom/makefile
  82. 44
      baremetal/example/peripheral/i2c/fi2c_eeprom/sdkconfig
  83. 35
      baremetal/example/peripheral/i2c/fi2c_eeprom/sdkconfig.h
  84. 22
      baremetal/example/peripheral/i2c/fi2c_slave/cmd_fi2c_slave.c
  85. 43
      baremetal/example/peripheral/i2c/fi2c_slave/configs/d2000_aarch32_eg_configs
  86. 44
      baremetal/example/peripheral/i2c/fi2c_slave/configs/d2000_aarch64_eg_configs
  87. 41
      baremetal/example/peripheral/i2c/fi2c_slave/configs/ft2004_aarch32_eg_configs
  88. 44
      baremetal/example/peripheral/i2c/fi2c_slave/configs/ft2004_aarch64_eg_configs
  89. 90
      baremetal/example/peripheral/i2c/fi2c_slave/fi2c_slave_example.c
  90. 22
      baremetal/example/peripheral/i2c/fi2c_slave/fi2c_slave_example.h
  91. 22
      baremetal/example/peripheral/i2c/fi2c_slave/main.c
  92. 2
      baremetal/example/peripheral/i2c/fi2c_slave/makefile
  93. 44
      baremetal/example/peripheral/i2c/fi2c_slave/sdkconfig
  94. 35
      baremetal/example/peripheral/i2c/fi2c_slave/sdkconfig.h
  95. 23
      baremetal/example/peripheral/mmc/fsdio_probe/inc/fsdio_sdcard.h
  96. 22
      baremetal/example/peripheral/mmc/fsdio_probe/inc/fsdio_trans_example.h
  97. 22
      baremetal/example/peripheral/mmc/fsdio_probe/main.c
  98. 3
      baremetal/example/peripheral/mmc/fsdio_probe/makefile
  99. 22
      baremetal/example/peripheral/mmc/fsdio_probe/src/cmd_sdio.c
  100. 22
      baremetal/example/peripheral/mmc/fsdio_probe/src/fsdio_sdcard.c

1
Kconfig

@ -12,6 +12,7 @@ endmenu
menu "Building Option"
source "$(STANDALONE_DIR)/common/Kconfig"
source "$(STANDALONE_DIR)/make/ld/Kconfig"
source "$(STANDALONE_DIR)/make/Kconfig"
endmenu
menu "Library Configuration"

45
README.md

@ -1,6 +1,6 @@
# Phytium-Standalone-SDK
**v0.1.16** [ReleaseNote](./doc/ChangeLog.md)
**v0.1.17** [ReleaseNote](./doc/ChangeLog.md)
## 1. 项目概要
@ -71,8 +71,7 @@
├── scripts
├── standalone.mk
├── third-party
│   ├── letter-shell-3.1
│   └── yaffs2 --> 第三方库
│   └── letter-shell-3.1 --> 第三方库
├── tools
└── uninstall.py --> 卸载脚本
```
@ -137,9 +136,8 @@ D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个
| UART (PrimeCell PL011) | FT2000/4<br>E2000<br>D2000 | | usart/pl011_uart |
| 10/100/1000MB-ETHERNET | FT2000/4<br>D2000 | E2000 | eth/f_gmac |
| CAN | FT2000/4 | E2000 | can/ft_can |
| GPIO | FT2000/4<br>E2000<br>D2000 | | gpio/f_gpio |
| GPIO | FT2000/4<br>E2000<br>D2000 | | gpio/fgpio |
| I2C | FT2000/4<br>D2000 | E2000 | i2c/fi2c |
| IOMUX | FT2000/4<br>D2000 | | iomux/f_iomux |
| QSPI (Nor Flash) | FT2000/4<br>D2000 | E2000 | qspi/fqspi |
| SPI | FT2000/4<br>D2000 | E2000 | spi/fspim |
| TIMER & TACHO | E2000 | | timer/hw_timer_tacho |
@ -163,31 +161,46 @@ D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个
| Tlsf | FT2000/4<br>D2000 | | tlsf-3.1.0 |
| Fatfs (RAM/Sd) | FT2000/4<br>D2000 | | fatfs-0.1.3 |
| Ymodem | FT2000/4<br>D2000 | | |
| OpenAMP | FT2000/4<br>D2000 | | openAmp-2021.10.0 |
---
## 4. API指南
### 4.1 [FI2C](./doc/reference/driver/fi2c.md)
### 4.1 DRIVERS
#### 4.1.1 [FI2C](./doc/reference/driver/fi2c.md)
#### 4.1.2 [FPL011](./doc/reference/driver/fpl011.md)
#### 4.1.3 [FRTC](./doc/reference/driver/frtc.md)
#### 4.1.4 [FWDT](./doc/reference/driver/fwdt.md)
#### 4.1.5 [FSPIM](./doc/reference/driver/fspim.md)
#### 4.1.6 [FQSPI](./doc/reference/driver/fqspi.md)
#### 4.1.7 [FSDMMC](./doc/reference/driver/fsdmmc.md)
### 4.2 [FPL011](./doc/reference/driver/fpl011.md)
#### 4.1.8 [FSATA](./doc/reference/driver/fsata.md)
### 4.3 [FRTC](./doc/reference/driver/frtc.md)
#### 4.1.9 [FPCIE](./doc/reference/driver/fpcie.md)
### 4.4 [FWDT](./doc/reference/driver/fwdt.md)
#### 4.1.10 [FUSB](./doc/reference/driver/fusb.md)
### 4.5 [FSPIM](./doc/reference/driver/fspim.md)
#### 4.1.11 [FGPIO](./doc/reference/driver/fgpio.md)
### 4.6 [FQSPI](./doc/reference/driver/fqspi.md)
### 4.7 [FSDMMC](./doc/reference/driver/fsdmmc.md)
### 4.2 MEMORY
#### 4.2.1 [FMEMORY_POOL](./doc/reference/sdk/fmemory_pool.md)
### 4.8 [FMEMORY_POOL](./doc/reference/sdk/fmemory_pool.md)
### 4.3 CPU
### 4.9 [FSATA](./doc/reference/driver/fsata.md)
#### 4.3.1 [MMU](./doc/reference/processor/mmu.md)
### 4.10 [FPCIE](./doc/reference/driver/fpcie.md)
#### 4.3.2 [FPINCTRL](./doc/reference/sdk/fpinctrl.md)
### 4.11 [FUSB](./doc/reference/driver/fusb.md)
---
## 5. 贡献方法

12
arch/Kconfig

@ -52,5 +52,17 @@ config USE_AARCH64_L1_TO_AARCH32
help
Use the Aarch64 to Aarch32 mode function
endif
if TARGET_ARMV8_AARCH64
config MMU_DEBUG_PRINTS
bool
prompt "MMU debug"
default n
help
Enable MMU debug printing
endif
endmenu

25
arch/armv8/aarch32/aarch32.h

@ -1,17 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-06-23 15:01:04
* @LastEditTime: 2021-08-04 16:12:25
* @Description:  This files is for
* FilePath: aarch32.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:28:37
* Description:  This files is for
*
* @Modify History:
* Ver   Who        Date         Changes
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
* 1.0 Huanghe 2021/7/3 init
* 1.1 wxd 2021/9/24 modify sys_icc_bpr_set and sys_icc_bpr_get
* 1.1 Wangxiaodong 2021/9/24 modify sys_icc_bpr_set and sys_icc_bpr_get
*/
#ifndef BSP_AARCH32_ASM_H

52
arch/armv8/aarch32/cache.c

@ -53,20 +53,13 @@ static inline u32 FCacheDcacheLineSize(void)
void FCacheDCacheEnable(void)
{
u32 ctrl_reg;
ctrl_reg = MFCP(FREG_CP15_SYS_CONTROL);
/* enable caches only if they are disabled */
if ((ctrl_reg & FREG_CONTROL_DCACHE_BIT) == 0x00000000U)
{
/* invalidate the Data cache */
FCacheDCacheInvalidate();
ctrl_reg |= FREG_CONTROL_DCACHE_BIT;
/* enable the Data cache */
MTCP(FREG_CP15_SYS_CONTROL, ctrl_reg);
}
}
@ -74,32 +67,34 @@ void FCacheDCacheEnable(void)
void FCacheDCacheDisable(void)
{
u32 ctrl_reg;
/* clean and invalidate the Data cache */
FCacheDCacheFlush();
ctrl_reg = MFCP(FREG_CP15_SYS_CONTROL);
ctrl_reg &= ~(FREG_CONTROL_DCACHE_BIT);
/* disable the Data cache */
MTCP(FREG_CP15_SYS_CONTROL, ctrl_reg);
}
void FCacheDCacheFlushLine(u32 adr)
void FCacheDCacheFlushLine(intptr adr)
{
u32 currmask;
currmask = MFCPSR();
MTCPSR(currmask | IRQ_FIQ_MASK);
/* Select cache level 0 and D cache in CSSR */
MTCP(FREG_CP15_CACHE_SIZE_SEL, 0x0);
ISB();
MTCP(FREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC, (adr & (~0x3F)));
MTCP(FREG_CP15_CLEAN_DC_LINE_MVA_POC, (adr & (~0x3F))); /* Clean data or unified cache line by virtual address to PoC. */
/* Wait for invalidate to complete */
DSB();
/* Select cache level 1 and D cache in CSSR */
MTCP(FREG_CP15_CACHE_SIZE_SEL, 0x2);
ISB();
MTCP(FREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC, (adr & (~0x3F)));
MTCPSR(currmask);
}
void FCacheDCacheInvalidateLine(intptr adr)
{
u32 currmask;
currmask = MFCPSR();
MTCPSR(currmask | IRQ_FIQ_MASK);
MTCP(FREG_CP15_INVAL_DC_LINE_MVA_POC, (adr & (~0x3F))); /* Invalidate data or unified cache line by virtual address to PoC. */
/* Wait for invalidate to complete */
DSB();
MTCPSR(currmask);
@ -200,13 +195,13 @@ void FCacheDCacheInvalidateRange(intptr adr, intptr len)
if ((tempadr & (cacheline - 1U)) != 0U)
{
tempadr &= (~(cacheline - 1U));
FCacheDCacheFlushLine(tempadr);
FCacheDCacheInvalidateLine(tempadr);
tempadr += cacheline;
}
if ((tempend & (cacheline - 1U)) != 0U)
{
tempend &= (~(cacheline - 1U));
FCacheDCacheFlushLine(tempend);
FCacheDCacheInvalidateLine(tempend);
}
while (tempadr < tempend)
@ -324,17 +319,8 @@ void FCacheDCacheFlushRange(intptr adr, intptr len)
while (tempadr < tempend)
{
/* Select cache level 0 and D cache in CSSR */
MTCP(FREG_CP15_CACHE_SIZE_SEL, 0x0);
/* Invalidate Data cache line */
MTCP(FREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC,
(tempadr & (~0x3F)));
/* Wait for invalidate to complete */
DSB();
/* Select cache level 0 and D cache in CSSR */
MTCP(FREG_CP15_CACHE_SIZE_SEL, 0x2);
/* Invalidate Data cache line */
MTCP(FREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC,
/* Clean Data cache line */
MTCP(FREG_CP15_CLEAN_DC_LINE_MVA_POC,
(tempadr & (~0x3F)));
/* Wait for invalidate to complete */
DSB();
@ -380,7 +366,8 @@ void FCacheICacheInvalidate(void)
currmask = MFCPSR();
MTCPSR(currmask | IRQ_FIQ_MASK);
MTCP(FREG_CP15_CACHE_SIZE_SEL, 0x1);
MTCP(FREG_CP15_CACHE_SIZE_SEL, 0x1); /* select Instruction cache. */
ISB();
DSB();
/* invalidate the instruction cache */
MTCP(FREG_CP15_INVAL_IC_POU, 0x0);
@ -423,6 +410,7 @@ void FCacheICacheInvalidateRange(intptr adr, u32 len)
/* Select cache Level 0 I-cache in CSSR */
MTCP(FREG_CP15_CACHE_SIZE_SEL, 0x1);
ISB();
while (tempadr < tempend)
{
/*Invalidate I Cache line*/

3
arch/armv8/aarch32/cache.h

@ -30,10 +30,11 @@
/* Dcache */
void FCacheDCacheEnable(void);
void FCacheDCacheDisable(void);
void FCacheDCacheFlushLine(u32 adr);
void FCacheDCacheInvalidate(void);
void FCacheDCacheInvalidateLine(intptr adr);
void FCacheDCacheInvalidateRange(intptr adr, intptr len);
void FCacheDCacheFlush(void);
void FCacheDCacheFlushLine(intptr adr);
void FCacheDCacheFlushRange(intptr adr, intptr len);
/* Icache */

19
arch/armv8/aarch32/cp15.h

@ -104,17 +104,18 @@
#define FREG_CP15_NOP2 "p15, 0, %0, c7, c13, 1"
#define FREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c14, 1"
#define FREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c14, 1" /* DCCIMVAC */
#define FREG_CP15_CLEAN_INVAL_DC_LINE_SW "p15, 0, %0, c7, c14, 2"
/* The CP15 register access below has been deprecated in favor of the new
* isb instruction in Cortex A53.
*/
#define FREG_CP15_INST_SYNC_BARRIER "p15, 0, %0, c7, c5, 4"
#define FREG_CP15_INVAL_BRANCH_ARRAY "p15, 0, %0, c7, c5, 6"
#define FREG_CP15_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c6, 1"
#define FREG_CP15_INVAL_DC_LINE_SW "p15, 0, %0, c7, c6, 2"
#define FREG_CP15_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c6, 1" /* DCIMVAC --- DC IVAC. Invalidate data or unified cache line by virtual address to PoC*/
#define FREG_CP15_INVAL_DC_LINE_SW "p15, 0, %0, c7, c6, 2" /* DCISW */
#define FREG_CP15_VA_TO_PA_CURRENT_0 "p15, 0, %0, c7, c8, 0"
#define FREG_CP15_VA_TO_PA_CURRENT_1 "p15, 0, %0, c7, c8, 1"
@ -126,7 +127,7 @@
#define FREG_CP15_VA_TO_PA_OTHER_2 "p15, 0, %0, c7, c8, 6"
#define FREG_CP15_VA_TO_PA_OTHER_3 "p15, 0, %0, c7, c8, 7"
#define FREG_CP15_CLEAN_DC_LINE_MVA_POC "p15, 0, %0, c7, c10, 1"
#define FREG_CP15_CLEAN_DC_LINE_MVA_POC "p15, 0, %0, c7, c10, 1" /* DCCMVAC --- DC CVAC. Clean data or unified cache line by virtual address to PoC */
#define FREG_CP15_CLEAN_DC_LINE_SW "p15, 0, %0, c7, c10, 2"
/* C0 Register defines */
@ -154,7 +155,8 @@
#define FREG_CP15_CACHE_LEVEL_ID "p15, 1, %0, c0, c0, 1"
#define FREG_CP15_AUXILARY_ID "p15, 1, %0, c0, c0, 7"
#define FREG_CP15_CACHE_SIZE_SEL "p15, 2, %0, c0, c0, 0"
#define FREG_CP15_CACHE_SIZE_SEL "p15, 2, %0, c0, c0, 0" /* CSSELR Selects the current Cache Size ID Register, CCSIDR, by specifying the required cache level and the
cache type (either instruction or data cache). */
/* C1 Register Defines */
#define FREG_CP15_SYS_CONTROL "p15, 0, %0, c1, c0, 0"
@ -167,20 +169,23 @@
#define FREG_CP15_VIRTUAL_CONTROL "p15, 0, %0, c1, c1, 3"
/* C7 Register Defines */
#define XREG_CP15_NOP "p15, 0, %0, c7, c0, 4"
#define FREG_CP15_BPIALL "p15, 0, %0, c7, c5, 6"
#define FREG_CP15_INVAL_IC_POU_IS "p15, 0, %0, c7, c1, 0"
#define FREG_CP15_INVAL_BRANCH_ARRAY_IS "p15, 0, %0, c7, c1, 6"
#define FREG_CP15_PHYS_ADDR "p15, 0, %0, c7, c4, 0"
#define FREG_CP15_INVAL_IC_POU "p15, 0, %0, c7, c5, 0"
#define FREG_CP15_INVAL_IC_LINE_MVA_POU "p15, 0, %0, c7, c5, 1"
#define FREG_CP15_INVAL_IC_LINE_MVA_POU "p15, 0, %0, c7, c5, 1" /* ICIMVAU --- IC IVAU. --- Invalidate instruction cache line by virtual address to PoU */
#define FREG_CONTROL_DCACHE_BIT (0x00000001U << 2U)
#define FREG_CONTROL_ICACHE_BIT (0x00000001U << 12U)
/* C8 Register Defines */
#define FREG_CP15_TLBIALL "p15, 0, %0, c8, c7, 0"
/* DBGDSCR Register Definitions */
#define DBGDSCR_MOE_Pos (2U)

27
arch/armv8/aarch32/exception.c

@ -1,16 +1,27 @@
/*
* @[H]: Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-23 10:11:22
* @LastEditTime: 2021-11-29 09:05:13
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* FilePath: exception.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:29:43
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "sdkconfig.h"
#include "exception.h"
#include "f_printk.h"

27
arch/armv8/aarch32/exception.h

@ -1,24 +1,31 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-06-25 14:42:54
* @LastEditTime: 2021-11-23 17:00:20
* @Description:  This files is for
* FilePath: exception.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:29:56
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef BSP_ARCH_ARMV8_AARCH32_EXCEPTION_H
#define BSP_ARCH_ARMV8_AARCH32_EXCEPTION_H
#include "ft_types.h"
#include "ft_types.h"
typedef struct _ExceptionFrame
{

21
arch/armv8/aarch32/gcc/exception_debug.c

@ -1,13 +1,22 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-06 08:08:20
* @LastEditTime: 2021-11-23 19:13:33
* @Description:  This files is for
* FilePath: exception_debug.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:27:11
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/

23
arch/armv8/aarch32/generic_timer.c

@ -1,17 +1,27 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-06-21 14:11:09
* @LastEditTime: 2021-10-14 18:42:37
* @Description:  This files is for
* FilePath: generic_timer.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:30:07
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "parameters.h"
#include "generic_timer.h"
#include "aarch32.h"
@ -24,7 +34,6 @@
#ifdef CONFIG_USE_SYS_TICK
#include "ft_assert.h"
#include "interrupt.h"
//#include "gicv3.h"
static volatile u32 genericTick;
#endif

22
arch/armv8/aarch32/generic_timer.h

@ -1,17 +1,27 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-06-21 14:10:59
* @LastEditTime: 2021-08-24 18:43:39
* @Description:  This files is for
* FilePath: generic_timer.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:30:13
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef BSP_ARCH_ARMV8_AARCH32_GENERIC_TIMER_H
#define BSP_ARCH_ARMV8_AARCH32_GENERIC_TIMER_H

65
arch/armv8/aarch32/mmu.c

@ -1,13 +1,22 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-06-29 09:20:24
* @LastEditTime: 2021-11-29 16:01:15
* @Description:  This files is for
* FilePath: mmu.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:30:19
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
@ -16,8 +25,12 @@
#include "f_printk.h"
#include "ft_types.h"
#include "mmu.h"
#include "cache.h"
#include "cp15.h"
#include "sdkconfig.h"
#include "l3cache.h"
#define DESC_SEC (0x2) /* Section table select */
/* dump 2nd level page table */
void Dump2ndPageTable(u32 *ptb)
@ -140,7 +153,7 @@ void SetMMUTable(u32 vaddrStart,
nSec = (vaddrEnd >> 20) - (vaddrStart >> 20);
for (i = 0; i <= nSec; i++)
{
*pTT = attr | (((paddrStart >> 20) + i) << 20);
*pTT = DESC_SEC | attr | (((paddrStart >> 20) + i) << 20);
pTT++;
}
}
@ -205,9 +218,45 @@ void InitCache(void)
{
CpuDcacheCleanFlush();
CpuIcacheFlush();
FCacheL3CacheInvalidate();
CpuDcacheDisable();
CpuIcacheDisable();
FCacheL3CacheDisable();
InitMMU();
CpuIcacheEnable();
CpuDcacheEnable();
}
}
/**
* @name: FSetTlbAttributes
* @msg: This function sets the memory attributes for a section
* @param {uintptr} addr is 32-bit address for which the attributes need to be set.
* @param {fsize_t} size of the mapped memory region in bytes
* @param {u32} attrib or the specified memory region.
* @return {*}
*/
void FSetTlbAttributes(uintptr addr,fsize_t size,u32 attrib)
{
volatile u32 *ptt;
volatile int i, nsec;
ptt = (u32 *)MMUTable + (addr >> 20);
nsec = size>>20;
for (i = 0; i <= nsec; i++)
{
*ptt = DESC_SEC | attrib | (((addr >> 20) + i) << 20) ;
ptt++;
}
FCacheDCacheFlush();
/* Invalidate all cached copies of translation table entries from TLBs that are from any level of the translation table walk. */
MTCP(FREG_CP15_TLBIALL,0U) ;
/* Invalidate all entries from branch predictors. */
MTCP(FREG_CP15_BPIALL,0U) ;
DSB();
ISB();
}

99
arch/armv8/aarch32/mmu.h

@ -1,46 +1,96 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-06-29 09:20:31
* @LastEditTime: 2021-07-01 17:25:19
* @Description:  This files is for
* FilePath: mmu.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:30:29
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef BSP_ARCH_AARCH32_MMU_H
#define BSP_ARCH_AARCH32_MMU_H
#include "ft_types.h"
#define DESC_SEC (0x2)
#define MEMWBWA ((1 << 12) | (3 << 2)) /* write back, write allocate */
#define MEMWB (3 << 2) /* write back, no write allocate */
#define MEMWT (2 << 2) /* write through, no write allocate */
#define SHAREDEVICE (1 << 2) /* shared device */
#define STRONGORDER (0 << 2) /* strong ordered */
#define XN (1 << 4) /* eXecute Never */
#define AP_RW (3 << 10) /* supervisor=RW, user=RW */
#define AP_RO (2 << 10) /* supervisor=RW, user=RO */
#define SHARED (1 << 16) /* shareable */
#define DOMAIN_FAULT (0x0)
#define DOMAIN_CHK (0x1)
/* mmu Short-descriptor translation table section(TTB) */
#define TTB_SETC_SIZE (1024*1024)
#define TTB_SETC_SIZE_MASK (~(TTB_SETC_SIZE - 1UL))
#define MT_XN (1 << 4) /* eXecute Never */
#define MT_NS (1 << 19)
#define MT_NG (1 << 17)
#define AP_0_1_00 (0<<10)
#define AP_0_1_01 (1<<10)
#define AP_0_1_10 (2<<10)
#define AP_0_1_11 (3<<10)
#define AP_2_0 (0<<15)
#define AP_2_1 (1<<15)
/* only SCTRL.AFE == 0 */
#define MT_P_NA_U_NA (AP_0_1_00 | AP_2_0) /* PL1 access=NA, user=NA */
#define MT_P_RW_U_NA (AP_0_1_01 | AP_2_0) /* PL1 access=RW, user=NA */
#define MT_P_RW_U_RO (AP_0_1_10 | AP_2_0) /* PL1 access=RW, user=RO */
#define MT_P_RW_U_RW (AP_0_1_11 | AP_2_0) /* PL1 access=RW, user=RW */
#define MT_P_RO_U_NA (AP_0_1_01 | AP_2_1) /* PL1 access=RO, user=NA */
#define MT_P_RO_U_RO (AP_0_1_11 | AP_2_1) /* PL1 access=RO, user=RO */
#define MT_SHAREABLE (1 << 16) /* shareable */
/* only SCTRL.TRE == 0 ,Close TEX */
#define TREN_TEX2_0_000 (0<<12)
#define TREN_TEX2_0_001 (1<<12)
#define TREN_TEX2_0_010 (2<<12)
#define TREN_TEX2_0_011 (3<<12)
#define TREN_TEX2_0_111 (7<<12)
#define TREN_TEX2_0_110 (6<<12)
#define TREN_TEX2_0_101 (5<<12)
#define TREN_TEX2_0_100 (4<<12)
#define CACHEABLE (1<<3)
#define BUFFERABLE (1<<2)
#define MT_DEVICE_NGNRNE (TREN_TEX2_0_000) /* Device-nGnRnE , Outer Shareable */
#define MT_DEVICE_NGNRE (TREN_TEX2_0_000|BUFFERABLE) /* Device-nGnRE , Outer Shareable */
#define MT_DEVICE_NGNRE_2 (TREN_TEX2_0_010) /* Device-nGnRE , Outer Shareable */
#define MT_NORMAL_WT (TREN_TEX2_0_000|CACHEABLE|MT_SHAREABLE) /* Outer and Inner Write-Through, Read-Allocate No Write-Allocate , Outer Shareable */
#define MT_NORMAL_WB_WCN (TREN_TEX2_0_000|CACHEABLE|BUFFERABLE|MT_SHAREABLE) /* Outer and Inner Write-Back, Read-Allocate No Write-Allocate , Outer Shareable */
#define MT_NORMAL_NC (TREN_TEX2_0_001|MT_SHAREABLE) /* Outer and Inner Non-cacheable , Outer Shareable , For compatibility with ARMv7 software should set SHAREABLE to 1 , Outer Shareable */
#define MT_NORMAL (TREN_TEX2_0_001|BUFFERABLE|CACHEABLE|MT_SHAREABLE) /* Outer and Inner Write-Back, Read-Allocate Write-Allocate , Outer Shareable , Outer Shareable */
#define DOMAIN_FAULT (0x0)
#define DOMAIN_CHK (0x1)
#define DOMAIN_NOTCHK (0x3)
#define DOMAIN0 (0x0 << 5)
#define DOMAIN1 (0x1 << 5)
#define DOMAIN0 (0x0 << 5)
#define DOMAIN1 (0x1 << 5)
#define DOMAIN0_ATTR (DOMAIN_CHK << 0)
#define DOMAIN1_ATTR (DOMAIN_FAULT << 2)
/* device mapping type */
#define DEVICE_MEM (SHARED | AP_RW | DOMAIN0 | SHAREDEVICE | DESC_SEC | XN)
#define DEVICE_MEM (MT_DEVICE_NGNRNE | MT_P_RW_U_RW | MT_XN)
/* normal memory mapping type */
#define NORMAL_MEM (SHARED | AP_RW | DOMAIN0 | MEMWBWA | DESC_SEC)
#define NORMAL_MEM (MT_NORMAL_WB_WCN|MT_P_RW_U_RW)
struct mem_desc
{
@ -50,4 +100,7 @@ struct mem_desc
u32 attr;
};
void FSetTlbAttributes(uintptr addr, fsize_t size, u32 attrib);
#endif

2
arch/armv8/aarch32/psci.c

@ -24,7 +24,7 @@
#include "psci.h"
#include "smc.h"
#include "_cpu.h"
#include "cpu_info.h"
#include "ft_error_code.h"
#include "parameters.h"
#include "ft_types.h"

23
arch/armv8/aarch64/aarch64.c

@ -1,3 +1,26 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: aarch64.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:32:00
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
/*
* Reference: ARM® Architecture Reference Manual ARMv8, for ARMv8-A architecture profile
*/

4
arch/armv8/aarch64/aarch64.h

@ -48,6 +48,10 @@
#define CNTV_CTL_IMASK (1 << 1) /* Timer interrupt mask bit */
#define CNTV_CTL_ISTATUS (1 << 2) /* The status of the timer interrupt. This bit is read-only */
/* AArch64 Memory Model Feature Register 0 */
#define ID_AA64MMFR0_EL1_4K_NO_SURPOORT (0xFULL << 28)
/*
* AArch64 SPSR
*/

22
arch/armv8/aarch64/arm-smccc.h

@ -1,3 +1,25 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: arm-smccc.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:32:15
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef __LINUX_ARM_SMCCC_H
#define __LINUX_ARM_SMCCC_H

80
arch/armv8/aarch64/cache.c

@ -1,14 +1,24 @@
/*
* @[H]: Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0.
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: cache.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:32:24
* Description:  This files is for
*
* @Date: 2021-11-17 14:49:01
* @LastEditTime: 2021-11-18 09:40:11
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "cache.h"
@ -169,12 +179,6 @@ void FCacheDCacheDisable(void)
* @name: FCacheDCacheInvalidate
* @msg: Invalidate the Data cache. The contents present in the cache are
* cleaned and invalidated.
* @note: Such operations are a problem for an environment
* that supports virtualisation. It would allow one OS to invalidate
* a line belonging to another OS. This could lead to the other OS
* crashing because of the loss of essential data. Hence, such
* operations are promoted to clean and invalidate which avoids such
* corruption.
*/
void FCacheDCacheInvalidate(void)
{
@ -280,13 +284,6 @@ void FCacheDCacheInvalidateLine(intptr adr)
currmask = MFCPSR();
MTCPSR(currmask | IRQ_FIQ_MASK);
/* Select cache level 1 and D cache in CSSR */
AARCH64_WRITE_SYSREG(CSSELR_EL1, 0x0);
MTCPDC(CIVAC, (adr & (~CACHE_LINE_ADDR_MASK))); /* Clean and Invalidate data cache by address to Point of Coherency */
/* Wait for invalidate to complete */
DSB();
/* Select cache level 2 and D cache in CSSR */
AARCH64_WRITE_SYSREG(CSSELR_EL1, 0x2);
MTCPDC(IVAC, (adr & (~CACHE_LINE_ADDR_MASK))); /* Invalidate data cache by address to Point of Coherency */
/* Wait for invalidate to complete */
DSB();
@ -320,15 +317,7 @@ void FCacheDCacheInvalidateRange(intptr adr, intptr len)
MTCPSR(currmask);
}
/**
* @name:
* @msg:
* @in param:
* @inout param:
* @out param:
* @return {*}
* @note:
*/
void FCacheDCacheFlush(void)
{
register u32 csid_reg, c7reg;
@ -340,7 +329,6 @@ void FCacheDCacheFlush(void)
MTCPSR(currmask | IRQ_FIQ_MASK);
/* Number of level of cache*/
cache_level = 0U;
/* Select cache level 1 and D cache in CSSR */
AARCH64_WRITE_SYSREG(CSSELR_EL1, cache_level);
@ -428,23 +416,16 @@ void FCacheDCacheFlush(void)
* invalidated. If the cacheline is modified (dirty), the entire
* contents of the cacheline are written to system memory before the
* line is invalidated.
* @param {intptr} adr
* @param {intptr} adr 64bit start address of the range to be flush.
* @return {*}
* @note:
*/
void FCacheDCacheFlushLine(intptr adr)
{
u32 currmask;
currmask = MFCPSR();
MTCPSR(currmask | IRQ_FIQ_MASK);
/* Select cache level 1 and D cache in CSSR */
AARCH64_WRITE_SYSREG(CSSELR_EL1, 0x0);
MTCPDC(CIVAC, (adr & (~CACHE_LINE_ADDR_MASK))); /* Clean and Invalidate data cache by address to Point of Coherency */
/* Wait for flush to complete */
DSB();
/* Select cache level 2 and D cache in CSSR */
AARCH64_WRITE_SYSREG(CSSELR_EL1, 0x2);
MTCPDC(CIVAC, (adr & (~CACHE_LINE_ADDR_MASK)));
MTCPDC(CVAC, (adr & (~CACHE_LINE_ADDR_MASK))); /* Clean data cache by address to Point of Coherency. */
/* Wait for flush to complete */
DSB();
MTCPSR(currmask);
@ -452,7 +433,22 @@ void FCacheDCacheFlushLine(intptr adr)
void FCacheDCacheFlushRange(intptr adr, intptr len){
FCacheDCacheInvalidateRange(adr,len) ;
const intptr cacheline = CACHE_LINE;
intptr end = adr + len;
adr = adr & (~CACHE_LINE_ADDR_MASK);
u32 currmask = MFCPSR();
MTCPSR(currmask | IRQ_FIQ_MASK);
if (len != 0U)
{
while (adr < end)
{
MTCPDC(CVAC, adr); /* Clean data cache by address to Point of Coherency */
adr += cacheline;
}
}
/* Wait for Clean to complete */
DSB();
MTCPSR(currmask);
}
/* Icache */

27
arch/armv8/aarch64/cache.h

@ -1,16 +1,27 @@
/*
* @[H]: Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-16 16:34:20
* @LastEditTime: 2021-11-17 09:55:38
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* FilePath: cache.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:32:40
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef ARM_ARMV8_AARCH64_CACHE_H
#define ARM_ARMV8_AARCH64_CACHE_H

29
arch/armv8/aarch64/exception.c

@ -1,16 +1,27 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-14 19:30:09
* @LastEditTime: 2021-11-05 15:26:22
* @Description:  This files is for
* FilePath: exception.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:32:48
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "exception.h"
#include "ft_types.h"
#include "ft_assert.h"
@ -25,7 +36,7 @@
_WEAK void SerrHandle(ExceptionFrame *exc)
{
FT_ASSERTVOID(0);
FASSERT(0);
(void)exc;
while (1)
{
@ -34,7 +45,7 @@ _WEAK void SerrHandle(ExceptionFrame *exc)
_WEAK void IrqHandleException(void *value)
{
FT_ASSERTVOID(0);
FASSERT(0);
(void)value;
while (1)
{
@ -43,7 +54,7 @@ _WEAK void IrqHandleException(void *value)
_WEAK void FIQInterrupt(void *value)
{
FT_ASSERTVOID(0);
FASSERT(0);
(void)value;
while (1)
{

27
arch/armv8/aarch64/exception.h

@ -1,16 +1,27 @@
/*
* @: Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-29 09:13:14
* @LastEditTime: 2021-11-29 16:02:14
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* FilePath: exception.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:32:53
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef ARM_ARMV8_AARCH64_EXCEPTION_H
#define ARM_ARMV8_AARCH64_EXCEPTION_H

23
arch/armv8/aarch64/gcc/gcc_debug.c

@ -1,3 +1,26 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: gcc_debug.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:31:16
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdio.h>
#include "f_printk.h"
#include "sdkconfig.h"

8
arch/armv8/aarch64/gcc/tlb.S

@ -25,12 +25,12 @@
#include <macro.h>
/*
* void __asm_invalidate_tlb_all(void)
* void AsmInvalidateTlbAll(void)
*
* invalidate all tlb entries.
*/
.pushsection .text.__asm_invalidate_tlb_all, "ax"
ENTRY(__asm_invalidate_tlb_all)
.pushsection .text.AsmInvalidateTlbAll, "ax"
ENTRY(AsmInvalidateTlbAll)
switch_el x9, 3f, 2f, 1f
3: tlbi alle3
dsb sy
@ -45,5 +45,5 @@ ENTRY(__asm_invalidate_tlb_all)
isb
0:
ret
ENDPROC(__asm_invalidate_tlb_all)
ENDPROC(AsmInvalidateTlbAll)
.popsection

29
arch/armv8/aarch64/gcc/vectors_g.c

@ -1,13 +1,28 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: vectors_g.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:31:39
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "ft_types.h"
volatile u8 fpu_context[528] ;
volatile u8 *fpu_context_base ;
volatile u8 fpu_status ;

22
arch/armv8/aarch64/generic_timer.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-08-23 16:20:51
* @LastEditTime: 2021-11-18 09:40:39
* @Description:  This files is for
* FilePath: generic_timer.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:32:59
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "parameters.h"
#include "generic_timer.h"
#include "aarch64.h"

23
arch/armv8/aarch64/generic_timer.h

@ -1,16 +1,27 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-08-23 16:20:51
* @LastEditTime: 2021-08-25 14:48:14
* @Description:  This files is for
* FilePath: generic_timer.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:33:07
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef BSP_ARCH_ARMV8_AARCH64_GENERIC_TIMER_H
#define BSP_ARCH_ARMV8_AARCH64_GENERIC_TIMER_H

41
arch/armv8/aarch64/l3cache.h

@ -1,41 +0,0 @@
/*
* @[H]: Copyright (c) 2021 Phytium Information Technology, Inc.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-17 10:52:39
* @LastEditTime: 2021-11-17 11:06:13
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
*/
#ifndef ARM_ARMV8_AARCH64_L3CACHE_H
#define ARM_ARMV8_AARCH64_L3CACHE_H
/***************************** Include Files *********************************/
#include "parameters.h"
#include "ft_io.h"
/************************** Constant Definitions *****************************/
/**************************** Type Definitions *******************************/
/************************** Variable Definitions *****************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
void FCacheL3CacheEnable(void);
void FCacheL3CacheDisable(void);
void FCacheL3CacheInvalidate(void);
void FCacheL3CacheFlush(void);
#endif

261
arch/armv8/aarch64/mmu.c

@ -1,15 +1,27 @@
/*
* @: Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-29 09:13:18
* @LastEditTime: 2021-11-29 16:00:23
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* FilePath: mmu.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:33:35
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "aarch64.h"
#include "cache.h"
#include <sys/errno.h>
@ -17,6 +29,7 @@
#include "ft_assert.h"
#include "mmu.h"
#include "kernel.h"
#include "l3cache.h"
/**************************** Type Definitions *******************************/
@ -52,23 +65,23 @@
#define L3_XLAT_VA_SIZE_SHIFT PAGE_SIZE_SHIFT
/* Number of VA bits to assign to each table (9 bits) */
#define Ln_XLAT_VA_SIZE_SHIFT (PAGE_SIZE_SHIFT - 3)
#define LN_XLAT_VA_SIZE_SHIFT (PAGE_SIZE_SHIFT - 3)
/* Starting bit in the VA address for each level */
#define L2_XLAT_VA_SIZE_SHIFT (L3_XLAT_VA_SIZE_SHIFT + Ln_XLAT_VA_SIZE_SHIFT)
#define L1_XLAT_VA_SIZE_SHIFT (L2_XLAT_VA_SIZE_SHIFT + Ln_XLAT_VA_SIZE_SHIFT)
#define L0_XLAT_VA_SIZE_SHIFT (L1_XLAT_VA_SIZE_SHIFT + Ln_XLAT_VA_SIZE_SHIFT)
#define L2_XLAT_VA_SIZE_SHIFT (L3_XLAT_VA_SIZE_SHIFT + LN_XLAT_VA_SIZE_SHIFT) /* 21 */
#define L1_XLAT_VA_SIZE_SHIFT (L2_XLAT_VA_SIZE_SHIFT + LN_XLAT_VA_SIZE_SHIFT) /* 30 */
#define L0_XLAT_VA_SIZE_SHIFT (L1_XLAT_VA_SIZE_SHIFT + LN_XLAT_VA_SIZE_SHIFT) /* 39 */
#define LEVEL_TO_VA_SIZE_SHIFT(level) \
(PAGE_SIZE_SHIFT + (Ln_XLAT_VA_SIZE_SHIFT * \
(XLAT_LAST_LEVEL - (level)))) // 12 + (9*(3-level))
(PAGE_SIZE_SHIFT + (LN_XLAT_VA_SIZE_SHIFT * \
(XLAT_LAST_LEVEL - (level)))) /* 12 + (9*(3-level)) */
/* Number of entries for each table (512) */
#define Ln_XLAT_NUM_ENTRIES ((1U << PAGE_SIZE_SHIFT) / 8U)
#define LN_XLAT_NUM_ENTRIES ((1U << PAGE_SIZE_SHIFT) / 8U)
/* Virtual Address Index within a given translation table level */
#define XLAT_TABLE_VA_IDX(va_addr, level) \
((va_addr >> LEVEL_TO_VA_SIZE_SHIFT(level)) & (Ln_XLAT_NUM_ENTRIES - 1))
((va_addr >> LEVEL_TO_VA_SIZE_SHIFT(level)) & (LN_XLAT_NUM_ENTRIES - 1))
/*
* Calculate the initial translation table level from CONFIG_ARM64_VA_BITS
@ -182,11 +195,11 @@
/************************** Variable Definitions *****************************/
static u64 xlat_tables[CONFIG_MAX_XLAT_TABLES * Ln_XLAT_NUM_ENTRIES] __aligned(Ln_XLAT_NUM_ENTRIES * sizeof(u64));
static u64 xlat_tables[CONFIG_MAX_XLAT_TABLES * LN_XLAT_NUM_ENTRIES] __aligned(LN_XLAT_NUM_ENTRIES * sizeof(u64));
static u16 xlat_use_count[CONFIG_MAX_XLAT_TABLES];
/************************** Function Prototypes ******************************/
extern void __asm_invalidate_tlb_all();
extern void AsmInvalidateTlbAll();
/* Returns a reference to a free table */
static u64 *NewTable(void)
{
@ -198,7 +211,7 @@ static u64 *NewTable(void)
if (xlat_use_count[i] == 0U)
{
xlat_use_count[i] = 1U;
return &xlat_tables[i * Ln_XLAT_NUM_ENTRIES];
return &xlat_tables[i * LN_XLAT_NUM_ENTRIES];
}
}
@ -208,9 +221,9 @@ static u64 *NewTable(void)
static inline unsigned int TableIndex(u64 *pte)
{
unsigned int i = (pte - xlat_tables) / Ln_XLAT_NUM_ENTRIES;
unsigned int i = (pte - xlat_tables) / LN_XLAT_NUM_ENTRIES;
FT_ASSERT(i < CONFIG_MAX_XLAT_TABLES, "table %x out of range", pte);
FASSERT_MSG(i < CONFIG_MAX_XLAT_TABLES, "table %x out of range", pte);
return i;
}
@ -220,7 +233,7 @@ static void FreeTable(u64 *table)
unsigned int i = TableIndex(table);
MMU_DEBUG("freeing table [%d]%x\r\n", i, table);
FT_ASSERT(xlat_use_count[i] == 1U, "table still in use");
FASSERT_MSG(xlat_use_count[i] == 1U, "table still in use");
xlat_use_count[i] = 0U;
}
@ -230,7 +243,7 @@ static int TableUsage(u64 *table, int adjustment)
unsigned int i = TableIndex(table);
xlat_use_count[i] += adjustment;
FT_ASSERT(xlat_use_count[i] > 0, "usage count underflow");
FASSERT_MSG(xlat_use_count[i] > 0, "usage count underflow");
return xlat_use_count[i];
}
@ -270,9 +283,10 @@ static inline int IsDescSuperset(u64 desc1, u64 desc2,
return (desc1 & mask) == (desc2 & mask);
}
#if DUMP_PTE
static void DebugShowPte(u64 *pte, unsigned int level)
{
#if DUMP_PTE
MMU_DEBUG("%d ", level);
MMU_DEBUG("%.*s", level * 2U, ". . . ");
MMU_DEBUG("[%d]%x: ", TableIndex(pte), pte);
@ -309,12 +323,9 @@ static void DebugShowPte(u64 *pte, unsigned int level)
MMU_DEBUG((*pte & PTE_BLOCK_DESC_PXN) ? "-PXN" : "-PX");
MMU_DEBUG((*pte & PTE_BLOCK_DESC_UXN) ? "-UXN" : "-UX");
MMU_DEBUG("\r\n");
}
#else
static inline void DebugShowPte(u64 *pte, unsigned int level)
{
}
#endif
return;
}
static void SetPteTableDesc(u64 *pte, u64 *table, unsigned int level)
{
@ -337,7 +348,7 @@ static u64 *ExpandToTable(u64 *pte, unsigned int level)
{
u64 *table;
FT_ASSERT(level < XLAT_LAST_LEVEL, "can't expand last level");
FASSERT_MSG(level < XLAT_LAST_LEVEL, "can't expand last level");
table = NewTable();
if (!table)
@ -356,7 +367,7 @@ static u64 *ExpandToTable(u64 *pte, unsigned int level)
MMU_DEBUG("expanding PTE 0x%016llx into table [%d]%x\r\n",
desc, TableIndex(table), table);
FT_ASSERT(IsBlockDesc(desc), "");
FASSERT_MSG(IsBlockDesc(desc), "");
if (level + 1 == XLAT_LAST_LEVEL)
{
@ -364,11 +375,11 @@ static u64 *ExpandToTable(u64 *pte, unsigned int level)
}
stride_shift = LEVEL_TO_VA_SIZE_SHIFT(level + 1);
for (i = 0U; i < Ln_XLAT_NUM_ENTRIES; i++)
for (i = 0U; i < LN_XLAT_NUM_ENTRIES; i++)
{
table[i] = desc | (i << stride_shift);
}
TableUsage(table, Ln_XLAT_NUM_ENTRIES);
TableUsage(table, LN_XLAT_NUM_ENTRIES);
}
else
{
@ -386,8 +397,9 @@ static u64 *ExpandToTable(u64 *pte, unsigned int level)
return table;
}
static int SetMapping(struct ArmMmuPtables *ptables,
uintptr_t virt, size_t size,
uintptr virt, fsize_t size,
u64 desc, int may_overwrite)
{
u64 *pte, *ptes[XLAT_LAST_LEVEL + 1];
@ -398,7 +410,7 @@ static int SetMapping(struct ArmMmuPtables *ptables,
while (size)
{
FT_ASSERT(level <= XLAT_LAST_LEVEL,
FASSERT_MSG(level <= XLAT_LAST_LEVEL,
"max translation table level exceeded\r\n");
/* Locate PTE for given virtual address and page table level */
@ -435,7 +447,7 @@ static int SetMapping(struct ArmMmuPtables *ptables,
}
goto move_on;
}
if ((size < level_size) || (virt & (level_size - 1)))
{
/* Range doesn't fit, create subtable */
@ -485,7 +497,7 @@ static int SetMapping(struct ArmMmuPtables *ptables,
return ret;
}
static u64 GetRegionDesc(uint32_t attrs)
static u64 GetRegionDesc(u32 attrs)
{
unsigned int mem_type;
u64 desc = 0U;
@ -519,8 +531,8 @@ static u64 GetRegionDesc(uint32_t attrs)
switch (mem_type)
{
case MT_DEVICE_nGnRnE:
case MT_DEVICE_nGnRE:
case MT_DEVICE_NGNRNE:
case MT_DEVICE_NGNRE:
case MT_DEVICE_GRE:
/* Access to Device memory and non-cacheable memory are coherent
* for all observers in the system and are treated as
@ -543,7 +555,7 @@ static u64 GetRegionDesc(uint32_t attrs)
desc |= PTE_BLOCK_DESC_UXN;
if (mem_type == MT_NORMAL)
desc |= PTE_BLOCK_DESC_INNER_SHARE;
desc |= PTE_BLOCK_DESC_OUTER_SHARE;
else
desc |= PTE_BLOCK_DESC_OUTER_SHARE;
}
@ -551,36 +563,29 @@ static u64 GetRegionDesc(uint32_t attrs)
return desc;
}
static int __AddMap(struct ArmMmuPtables *ptables, const char *name,
uintptr_t phys, uintptr_t virt, size_t size, uint32_t attrs)
static int AddMap(struct ArmMmuPtables *ptables, const char *name,
uintptr phys, uintptr virt, fsize_t size, u32 attrs)
{
u64 desc = GetRegionDesc(attrs);
int may_overwrite = !(attrs & MT_NO_OVERWRITE);
MMU_DEBUG("mmap [%s]: virt %p phys %p size %p attr %p\r\n",
name, virt, phys, size, desc);
FT_ASSERT(((virt | phys | size) & (CONFIG_MMU_PAGE_SIZE - 1)) == 0,
FASSERT_MSG(((virt | phys | size) & (CONFIG_MMU_PAGE_SIZE - 1)) == 0,
"address/size are not page aligned\r\n");
desc |= phys;
return SetMapping(ptables, virt, size, desc, may_overwrite);
}
// static int AddMap(struct ArmMmuPtables *ptables, const char *name,
// uintptr_t phys, uintptr_t virt, size_t size, uint32_t attrs)
// {
// int ret;
// ret = __AddMap(ptables, name, phys, virt, size, attrs);
// return ret;
// }
static int RemoveMap(struct ArmMmuPtables *ptables, const char *name,
uintptr_t virt, size_t size)
uintptr virt, fsize_t size)
{
int ret;
MMU_DEBUG("unmmap [%s]: virt %p size %p\r\n", name, virt, size);
FT_ASSERT(((virt | size) & (CONFIG_MMU_PAGE_SIZE - 1)) == 0,
FASSERT_MSG(((virt | size) & (CONFIG_MMU_PAGE_SIZE - 1)) == 0,
"address/size are not page aligned\r\n");
ret = SetMapping(ptables, virt, size, 0, 1);
@ -589,12 +594,12 @@ static int RemoveMap(struct ArmMmuPtables *ptables, const char *name,
static inline void AddArmMmuRegion(struct ArmMmuPtables *ptables,
const struct ArmMmuRegion *region,
uint32_t extra_flags)
u32 extra_flags)
{
if (region->size || region->attrs)
{
/* MMU not yet active: must use unlocked version */
__AddMap(ptables, region->name, region->base_pa, region->base_va,
AddMap(ptables, region->name, region->base_pa, region->base_va,
region->size, region->attrs | extra_flags);
}
}
@ -603,12 +608,13 @@ static void SetupPageTables(struct ArmMmuPtables *ptables)
{
unsigned int index;
const struct ArmMmuRegion *region;
uintptr_t max_va = 0, max_pa = 0;
uintptr max_va = 0, max_pa = 0;
MMU_DEBUG("xlat tables:\r\n");
for (index = 0U; index < CONFIG_MAX_XLAT_TABLES; index++)
MMU_DEBUG("%d: %x\r\n", index, xlat_tables + index * Ln_XLAT_NUM_ENTRIES);
MMU_DEBUG("%d: %x\r\n", index, xlat_tables + index * LN_XLAT_NUM_ENTRIES);
/* 从不同的board 中获取,内存映射表中地址范围 */
for (index = 0U; index < mmu_config.num_regions; index++)
{
region = &mmu_config.mmu_regions[index];
@ -616,19 +622,19 @@ static void SetupPageTables(struct ArmMmuPtables *ptables)
max_pa = max(max_pa, region->base_pa + region->size);
}
FT_ASSERT(max_va <= (1ULL << CONFIG_ARM64_VA_BITS),
FASSERT_MSG(max_va <= (1ULL << CONFIG_ARM64_VA_BITS),
"Maximum VA not supported\r\n");
FT_ASSERT(max_pa <= (1ULL << CONFIG_ARM64_PA_BITS),
FASSERT_MSG(max_pa <= (1ULL << CONFIG_ARM64_PA_BITS),
"Maximum PA not supported\r\n");
/* setup translation table for zephyr execution regions */
/* setup translation table for execution regions */
for (index = 0U; index < mmu_config.num_regions; index++)
{
region = &mmu_config.mmu_regions[index];
AddArmMmuRegion(ptables, region, 0);
}
__asm_invalidate_tlb_all();
AsmInvalidateTlbAll();
}
/* Translation table control register settings */
@ -696,120 +702,109 @@ static void EnableMmuEl1(struct ArmMmuPtables *ptables, unsigned int flags)
static struct ArmMmuPtables kernel_ptables;
/*
* @brief MMU default configuration
*
* This function provides the default configuration mechanism for the Memory
* Management Unit (MMU).
/**
* @name: MmuInit
* @msg: This function provides the default configuration mechanism for the Memory
* Management Unit (MMU)
* @return {*}
*/
void MmuInit(void)
{
unsigned int flags = 0U;
u32 val = 0U;
FT_ASSERT(CONFIG_MMU_PAGE_SIZE == KB(4),
u64 val = 0U;
FCacheL3CacheFlush();
/* 增加粒度判断 */
val = AARCH64_READ_SYSREG(ID_AA64MMFR0_EL1);
FASSERT_MSG((CONFIG_MMU_PAGE_SIZE == KB(4)) && (!(val & ID_AA64MMFR0_EL1_4K_NO_SURPOORT)) ,
"Only 4K page size is supported\r\n");
/* Current MMU code supports only EL1 */
__asm__ volatile("mrs %0, CurrentEL"
: "=r"(val));
val = AARCH64_READ_SYSREG(CurrentEL);
FT_ASSERT(GET_EL(val) == MODE_EL1, "Exception level not EL1, MMU not enabled!\n");
FASSERT_MSG(GET_EL(val) == MODE_EL1, "Exception level not EL1, MMU not enabled!\n");
/* Ensure that MMU is already not enabled */
__asm__ volatile("mrs %0, sctlr_el1"
: "=r"(val));
FT_ASSERT((val & SCTLR_ELx_M) == 0, "MMU is already enabled\n");
val = AARCH64_READ_SYSREG(sctlr_el1);
FASSERT_MSG((val & SCTLR_ELx_M) == 0, "MMU is already enabled\n");
/*
* Only booting core setup up the page tables.
*/
kernel_ptables.base_xlat_table = NewTable();
SetupPageTables(&kernel_ptables);
FCacheL3CacheDisable();
/* currently only EL1 is supported */
EnableMmuEl1(&kernel_ptables, flags);
}
static int __ArchMemMap(void *virt, uintptr_t phys, size_t size, uint32_t flags)
{
struct ArmMmuPtables *ptables;
uint32_t entry_flags = MT_SECURE | MT_P_RX_U_NA;
/* Always map in the kernel page tables */
ptables = &kernel_ptables;
/* Translate flags argument into HW-recognized entry flags. */
switch (flags & K_MEM_CACHE_MASK)
static void ArchMemMap(uintptr virt, uintptr phys, fsize_t size, u32 flags)
{
int ret = AddMap(&kernel_ptables, "dynamic", phys, virt, size, flags);
if (ret)
{
/*
* K_MEM_CACHE_NONE => MT_DEVICE_nGnRnE
* (Device memory nGnRnE)
* K_MEM_CACHE_WB => MT_NORMAL
* (Normal memory Outer WB + Inner WB)
* K_MEM_CACHE_WT => MT_NORMAL_WT
* (Normal memory Outer WT + Inner WT)
*/
case K_MEM_CACHE_NONE:
entry_flags |= MT_DEVICE_nGnRnE;
break;
case K_MEM_CACHE_WT:
entry_flags |= MT_NORMAL_WT;
break;
case K_MEM_CACHE_WB:
entry_flags |= MT_NORMAL;
break;
default:
return -ENOTSUP;
MMU_WRNING("warning AddMap() returned %d", ret);
}
if ((flags & K_MEM_PERM_RW) != 0U)
else
{
entry_flags |= MT_RW;
AsmInvalidateTlbAll();
}
}
if ((flags & K_MEM_PERM_EXEC) == 0U)
{
entry_flags |= MT_P_EXECUTE_NEVER;
}
static fsize_t MemRegionAlign(uintptr *aligned_addr,fsize_t *aligned_size,
uintptr addr,fsize_t size,fsize_t align)
{
fsize_t addr_offset;
if ((flags & K_MEM_PERM_USER) != 0U)
{
return -ENOTSUP;
}
*aligned_addr = rounddown(addr,align) ;
addr_offset = addr - *aligned_addr ;
*aligned_size = roundup(size + ,align);
return __AddMap(ptables, "generic", phys, (uintptr_t)virt, size, entry_flags);
return addr_offset;
}
void ArchMemMap(void *virt, uintptr_t phys, size_t size, uint32_t flags)
/**
* @name: FSetTlbAttributes
* @msg: This function sets the memory attributes for a section
* @param {uintptr} addr is 32-bit address for which the attributes need to be set.
* @param {fsize_t} size of the mapped memory region in bytes
* @param {u32} attrib or the specified memory region. mmu.h contains commonly used memory attributes definitions which can be
* utilized for this function.
* @return {*}
*/
void FSetTlbAttributes(uintptr addr,fsize_t size,u32 attrib)
{
int ret = __ArchMemMap(virt, phys, size, flags);
uintptr_t aligned_phys, addr_offset;
size_t aligned_size;
MemRegionAlign(&aligned_phys,&aligned_size,
addr,size,CONFIG_MMU_PAGE_SIZE);
if (ret)
{
MMU_DEBUG("__ArchMemMap() returned %d", ret);
}
else
{
__asm_invalidate_tlb_all();
}
FASSERT_MSG(aligned_size != 0U, "0-length mapping at 0x%lx", aligned_phys);
FASSERT_MSG(aligned_phys < (aligned_phys + (aligned_size - 1)),
"wraparound for physical address 0x%lx (size %zu)",
aligned_phys, aligned_size);
MMU_DEBUG("addr %p,size %d,aligned_phys %p,aligned_size %d \r\n",addr,size,aligned_phys,aligned_size);
ArchMemMap(aligned_phys, aligned_phys, aligned_size, attrib);
}
void ArchMemUnmap(void *addr, size_t size)
void ArchMemUnmap(uintptr addr, fsize_t size)
{
int ret = RemoveMap(&kernel_ptables, "generic", (uintptr_t)addr, size);
int ret = RemoveMap(&kernel_ptables, "dynamic", (uintptr)addr, size);
if (ret)
{
MMU_DEBUG("RemoveMap() returned %d", ret);
MMU_WRNING("RemoveMap() returned %d", ret);
}
else
{
__asm_invalidate_tlb_all();
AsmInvalidateTlbAll();
}
}
int ArchPagePhysGet(void *virt, uintptr_t *phys)
int ArchPagePhysGet(uintptr virt, uintptr *phys)
{
u64 par;
int key;

81
arch/armv8/aarch64/mmu.h

@ -1,10 +1,27 @@
/*
* Copyright 2019 Broadcom
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: mmu.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:33:43
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef ARMV8_MMU_H
#define ARMV8_MMU_H
@ -16,6 +33,7 @@ extern "C"
#include "f_printk.h"
#include "ft_types.h"
#include "sdkconfig.h"
/************************** Constant Definitions *****************************/
@ -32,15 +50,15 @@ extern "C"
*/
#define MT_TYPE_MASK 0x7U
#define MT_TYPE(attr) (attr & MT_TYPE_MASK)
#define MT_DEVICE_nGnRnE 0U
#define MT_DEVICE_nGnRE 1U
#define MT_DEVICE_GRE 2U
#define MT_NORMAL_NC 3U
#define MT_NORMAL 4U
#define MT_NORMAL_WT 5U
#define MEMORY_ATTRIBUTES ((0x00 << (MT_DEVICE_nGnRnE * 8)) | \
(0x04 << (MT_DEVICE_nGnRE * 8)) | \
#define MT_DEVICE_NGNRNE 0U
#define MT_DEVICE_NGNRE 1U
#define MT_DEVICE_GRE 2U
#define MT_NORMAL_NC 3U
#define MT_NORMAL 4U
#define MT_NORMAL_WT 5U
#define MEMORY_ATTRIBUTES ((0x00 << (MT_DEVICE_NGNRNE * 8)) | \
(0x04 << (MT_DEVICE_NGNRE * 8)) | \
(0x0c << (MT_DEVICE_GRE * 8)) | \
(0x44 << (MT_NORMAL_NC * 8)) | \
(0xffUL << (MT_NORMAL * 8)) | \
@ -59,24 +77,24 @@ extern "C"
* attrs[8] : Overwrite existing mapping if any
*
*/
#define MT_PERM_SHIFT 3U
#define MT_SEC_SHIFT 4U
#define MT_P_EXECUTE_SHIFT 5U
#define MT_U_EXECUTE_SHIFT 6U
#define MT_RW_AP_SHIFT 7U
#define MT_PERM_SHIFT 3U /* Selects between read-only and read/write access */
#define MT_SEC_SHIFT 4U /* Non-secure bit. For memory accesses from Secure state, specifies whether the output address is in the Secure or Non-secure address map */
#define MT_P_EXECUTE_SHIFT 5U /* The Privileged execute-never bit. Determines whether the region is executable at EL1 */
#define MT_U_EXECUTE_SHIFT 6U /* */
#define MT_RW_AP_SHIFT 7U /* Selects between Application level (EL0) control and the higher Exception level control. */
#define MT_NO_OVERWRITE_SHIFT 8U
#define MT_RO (0U << MT_PERM_SHIFT)
#define MT_RW (1U << MT_PERM_SHIFT)
#define MT_RO (0U << MT_PERM_SHIFT) /* Selects read-only access */
#define MT_RW (1U << MT_PERM_SHIFT) /* Selects read/write access */
#define MT_RW_AP_ELX (1U << MT_RW_AP_SHIFT)
#define MT_RW_AP_EL_HIGHER (0U << MT_RW_AP_SHIFT)
#define MT_RW_AP_EL_HIGHER (0U << MT_RW_AP_SHIFT) /* EL0 can't access */
#define MT_RW_AP_ELX (1U << MT_RW_AP_SHIFT) /* EL0 can access */
#define MT_SECURE (0U << MT_SEC_SHIFT)
#define MT_NS (1U << MT_SEC_SHIFT)
#define MT_SECURE (0U << MT_SEC_SHIFT) /* Access the Secure PA space. */
#define MT_NS (1U << MT_SEC_SHIFT) /* Access the Non-secure PA space. */
#define MT_P_EXECUTE (0U << MT_P_EXECUTE_SHIFT)
#define MT_P_EXECUTE_NEVER (1U << MT_P_EXECUTE_SHIFT)
#define MT_P_EXECUTE (0U << MT_P_EXECUTE_SHIFT)
#define MT_P_EXECUTE_NEVER (1U << MT_P_EXECUTE_SHIFT)
#define MT_U_EXECUTE (0U << MT_U_EXECUTE_SHIFT)
#define MT_U_EXECUTE_NEVER (1U << MT_U_EXECUTE_SHIFT)
@ -137,12 +155,10 @@ extern "C"
MMU_REGION_ENTRY(name, adr, adr, sz, attrs)
/* 模块内配置 */
#define CONFIG_MMU_PAGE_SIZE 0x1000
#define CONFIG_MMU_PAGE_SIZE 0x1000 /* log2 resualt is 12 */
/* Set below flag to get debug prints */
#define MMU_DEBUG_PRINTS 0
#if MMU_DEBUG_PRINTS
#ifdef CONFIG_MMU_DEBUG_PRINTS
/* To dump page table entries while filling them, set DUMP_PTE macro */
#define DUMP_PTE 1
#define MMU_DEBUG(fmt, ...) f_printk(fmt, ##__VA_ARGS__)
@ -150,8 +166,12 @@ extern "C"
#define MMU_DEBUG(...)
#endif
#define MMU_WRNING(fmt, ...) f_printk(fmt, ##__VA_ARGS__)
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) \
((long)((sizeof(array) / sizeof((array)[0]))))
#endif
/* KB, MB, GB */
#define KB(x) ((x) << 10)
@ -199,4 +219,5 @@ extern "C"
void MmuInit(void);
void FSetTlbAttributes(uintptr addr,fsize_t size,u32 attrib);
#endif

2
arch/armv8/aarch64/psci.c

@ -24,7 +24,7 @@
#include "psci.h"
#include "arm-smccc.h"
#include "ft_types.h"
#include "_cpu.h"
#include "cpu_info.h"
#include "ft_error_code.h"
FError PsciCpuOn(s32 cpu_id_mask, uintptr bootaddr)

31
arch/armv8/aarch64/psw.c

@ -1,11 +1,26 @@
/* -*- mode: c; coding:utf-8 -*- */
/**********************************************************************/
/* OS kernel sample */
/* Copyright 2014 Takeharu KATO */
/* */
/* Processor Status Word */
/* */
/**********************************************************************/
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: psw.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:34:20
* Description:  This files is for Processor Status Word
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdint.h>
#include "aarch64.h"
#include "psw.h"

30
arch/armv8/aarch64/psw.h

@ -1,10 +1,26 @@
/**********************************************************************/
/* OS kernel sample */
/* Copyright 2014 Takeharu KATO */
/* */
/* Processor Status Word */
/* */
/**********************************************************************/
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: psw.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:34:39
* Description:  This files is for Processor Status Word
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#if !defined(_PSW_H)
#define _PSW_H

5
arch/common/kernel.h

@ -100,7 +100,7 @@
#define roundup(x, y) ( \
{ \
const typeof(y) __y = y; \
(((x) + (__y - 1)) / __y) * __y; \
((x + (__y - 1)) / __y) * __y; \
})
#define rounddown(x, y) ( \
{ \
@ -216,4 +216,7 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif
/* set 32-bit register [a:b] as x, where a is high bit, b is low bit, x is setting/getting value */
#define GET_REG32_BITS(x, a, b) (u32)((((u32)(x)) & GENMASK(a, b)) >> b)
#define SET_REG32_BITS(x, a, b) (u32)((((u32)(x)) << b) & GENMASK(a, b))
#endif

27
arch/armv8/aarch64/l3cache.c → arch/common/l3cache.c

@ -1,16 +1,27 @@
/*
* @[H]: Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-17 10:52:26
* @LastEditTime: 2021-11-17 11:07:56
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* FilePath: l3cache.c
* Date: 2022-03-08 21:56:42
* LastEditTime: 2022-03-15 11:10:40
* Description:  This file is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "l3cache.h"
#include "sdkconfig.h"

52
arch/common/l3cache.h

@ -0,0 +1,52 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: l3cache.h
* Date: 2022-03-08 21:56:42
* LastEditTime: 2022-03-15 11:14:45
* Description:  This file is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef ARM_ARMV8_AARCH64_L3CACHE_H
#define ARM_ARMV8_AARCH64_L3CACHE_H
/***************************** Include Files *********************************/
#include "parameters.h"
#include "ft_io.h"
/************************** Constant Definitions *****************************/
/**************************** Type Definitions *******************************/
/************************** Variable Definitions *****************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
void FCacheL3CacheEnable(void);
void FCacheL3CacheDisable(void);
void FCacheL3CacheInvalidate(void);
void FCacheL3CacheFlush(void);
#endif

22
arch/common/linkage.h

@ -1,3 +1,25 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: linkage.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:35:12
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef _LINUX_LINKAGE_H

22
arch/common/macro.h

@ -1,3 +1,25 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: macro.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:35:17
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef __ASM_ARM_MACRO_H__

23
arch/common/swap.h

@ -1,3 +1,26 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: swap.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:35:24
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef _SWAP_H_
#define _SWAP_H_

38
baremetal/example/get-start/hello_letter_shell/README.md

@ -1,38 +0,0 @@
# XXX
## 1. 例程介绍
><font size="1">介绍例程的用途,使用场景,相关基本概念,描述用户可以使用例程完成哪些工作</font><br />
## 2. 如何使用例程
><font size="1">描述开发平台准备,使用例程配置,构建和下载镜像的过程</font><br />
### 2.1 硬件配置方法
><font size="1">哪些硬件平台是支持的,需要哪些外设,例程与开发板哪些IO口相关等(建议附录开发板照片,展示哪些IO口被引出)</font><br />
### 2.2 SDK配置方法
><font size="1">依赖哪些驱动、库和第三方组件,如何完成配置(列出需要使能的关键配置项)</font><br />
### 2.3 构建和下载
><font size="1">描述构建、烧录下载镜像的过程,列出相关的命令</font><br />
### 2.4 输出与实验现象
><font size="1">描述输入输出情况,列出存在哪些输出,对应的输出是什么(建议附录相关现象图片)</font><br />
## 3. 如何解决问题
><font size="1">主要记录使用例程中可能会遇到的问题,给出相应的解决方案</font><br />
## 4. 修改历史记录
><font size="1">记录例程的重大修改记录,标明修改发生的版本号 </font><br />

29
baremetal/example/get-start/hello_letter_shell/main.c

@ -1,29 +0,0 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-25 15:45:58
* @Description:  This files is for phytium baremetal hello world
*
* @Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "sdkconfig.h"
#ifndef SDK_CONFIG_H__
#warning "Please include sdkconfig.h"
#endif
#ifndef CONFIG_USE_LETTER_SHELL
#error "Please include letter shell first!!!"
#endif
#include "shell_port.h"
int main()
{
LSUserShellLoop();
return 0;
}

22
baremetal/example/get-start/hello_world/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-08-30 16:43:14
* @Description:  This files is for phytium baremetal hello world
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:36:17
* Description:  This files is for phytium baremetal hello world
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdio.h>
int main()

23
baremetal/example/network/fgmac_lwip_echo/inc/fgmac_lwip_echo_example.h

@ -1,16 +1,27 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-11 08:33:06
* @LastEditTime: 2021-11-12 11:41:17
* @Description:  This files is for
* FilePath: fgmac_lwip_echo_example.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:36:39
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_FGMAC_LWIP_ECHO_EXAMPLE_H
#define EXAMPLE_FGMAC_LWIP_ECHO_EXAMPLE_H

22
baremetal/example/network/fgmac_lwip_echo/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-25 15:45:58
* @Description:  This files is for phytium baremetal hello world
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:38:03
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "sdkconfig.h"

22
baremetal/example/network/fgmac_lwip_echo/src/cmd_lwip.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 09:45:25
* @LastEditTime: 2021-12-10 14:13:30
* @Description:  This files is for
* FilePath: cmd_lwip.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:36:47
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "strto.h"

24
baremetal/example/network/fgmac_lwip_echo/src/fgmac_lwip_echo_example.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 09:42:33
* @LastEditTime: 2021-12-10 14:12:38
* @Description:  This files is for
* FilePath: fgmac_lwip_echo_example.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:37:51
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "ft_debug.h"
@ -52,7 +62,7 @@ static ip4_addr_t gateway_addr;
static boolean setup_done = FALSE;
int FGmacLwipSetup(const char *ip, const char *netmask, const char *gateway, int exit_time)
{
FT_ASSERTZERONUM(ip && netmask && gateway);
FASSERT(ip && netmask && gateway);
memset(&ip_addr, 0 ,sizeof(ip_addr));
memset(&netmask_addr, 0 ,sizeof(netmask_addr));

22
baremetal/example/network/fgmac_lwip_tftp/inc/fgmac_fatfs.h

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 15:18:07
* @LastEditTime: 2021-11-12 16:09:51
* @Description:  This files is for
* FilePath: fgmac_fatfs.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:38:16
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_FGMAC_FATFS_H
#define EXAMPLE_FGMAC_FATFS_H

22
baremetal/example/network/fgmac_lwip_tftp/inc/fgmac_lwip.h

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 15:05:05
* @LastEditTime: 2021-11-12 16:38:47
* @Description:  This files is for
* FilePath: fgmac_lwip.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:38:30
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_FGMAC_LWIP_H
#define EXAMPLE_FGMAC_LWIP_H

22
baremetal/example/network/fgmac_lwip_tftp/inc/fgmac_lwip_tftp_client.h

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 15:03:16
* @LastEditTime: 2021-11-12 15:58:41
* @Description:  This files is for
* FilePath: fgmac_lwip_tftp_client.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:38:22
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_FGMAC_LWIP_TFTP_CLIENT_H
#define EXAMPLE_FGMAC_LWIP_TFTP_CLIENT_H

22
baremetal/example/network/fgmac_lwip_tftp/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-25 15:45:58
* @Description:  This files is for phytium baremetal hello world
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:39:10
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "sdkconfig.h"

22
baremetal/example/network/fgmac_lwip_tftp/src/cmd_tftp.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 14:53:25
* @LastEditTime: 2021-11-12 17:28:43
* @Description:  This files is for
* FilePath: cmd_tftp.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:38:47
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "strto.h"

28
baremetal/example/network/fgmac_lwip_tftp/src/fgmac_fatfs.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 15:18:20
* @LastEditTime: 2021-11-12 17:02:29
* @Description:  This files is for
* FilePath: fgmac_fatfs.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:38:53
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include "ft_assert.h"
@ -33,7 +43,7 @@ static BYTE buff[FGMAC_FATFS_FILE_SIZE];
static boolean fatfs_ok = FALSE;
int FGmacFatfsSetup(const char *mount_point)
{
FT_ASSERTZERONUM(mount_point);
FASSERT(mount_point);
FRESULT res;
UINT fnum;
FIL file_handler;
@ -74,7 +84,7 @@ int FGmacFatfsSetup(const char *mount_point)
int FGmacFatfsCreateFile(const char *file_name)
{
FT_ASSERTZERONUM(file_name);
FASSERT(file_name);
FRESULT res;
UINT fnum;
FIL file_handler;
@ -145,7 +155,7 @@ err_handle:
int FGmacFatfsReadFile(const char *file_name, size_t len)
{
FT_ASSERTZERONUM(file_name);
FASSERT(file_name);
FRESULT res;
UINT fnum;
FIL file_handler;

24
baremetal/example/network/fgmac_lwip_tftp/src/fgmac_lwip.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 15:05:16
* @LastEditTime: 2021-11-12 16:40:32
* @Description:  This files is for
* FilePath: fgmac_lwip.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:39:04
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "ft_debug.h"
@ -47,7 +57,7 @@ static ip4_addr_t gateway_addr;
static boolean setup_done = FALSE;
int FGmacLwipSetup(const char *ip, const char *netmask, const char *gateway, int exit_time)
{
FT_ASSERTZERONUM(ip && netmask && gateway);
FASSERT(ip && netmask && gateway);
memset(&ip_addr, 0 ,sizeof(ip_addr));
memset(&netmask_addr, 0 ,sizeof(netmask_addr));

24
baremetal/example/network/fgmac_lwip_tftp/src/fgmac_lwip_tftp_client.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-12 15:03:16
* @LastEditTime: 2021-11-15 13:54:01
* @Description:  This files is for
* FilePath: fgmac_lwip_tftp_client.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:38:58
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdio.h>
#include <string.h>
@ -209,7 +219,7 @@ int FGmacTftpClientSetup(const char *ip, const char *srv_ip, const char *netmask
int FGmacTftpClientGet(const char *file_name)
{
FT_ASSERTZERONUM(file_name);
FASSERT(file_name);
void *f;
err_t err;

65
baremetal/example/peripheral/can/can_test/configs/d2000_aarch32_eg_configs

@ -6,7 +6,7 @@
#
# Baremetal Configuration
#
CONFIG_TARGET_NAME="baremetal"
CONFIG_TARGET_NAME="d2000_baremetal_a32"
# end of Baremetal Configuration
# end of Project Configuration
@ -31,8 +31,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -42,10 +44,15 @@ CONFIG_TARGET_D2000=y
# CONFIG_USE_QSPI is not set
CONFIG_USE_GIC=y
CONFIG_ENABLE_GICV3=y
# CONFIG_USE_SERIAL is not set
CONFIG_USE_SERIAL=y
#
# Usart Configuration
#
CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
CONFIG_USE_CAN=y
@ -63,26 +70,20 @@ CONFIG_ENABLE_F_CAN=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
CONFIG_LOG_VERBOS=y
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
# CONFIG_LOG_ERROR is not set
CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
@ -105,6 +106,20 @@ CONFIG_ABORT_STACK_SIZE=0x1000
CONFIG_FIQ_STACK_SIZE=0x1000
CONFIG_UNDEF_STACK_SIZE=0x1000
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -116,18 +131,21 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
# CONFIG_USE_LETTER_SHELL is not set
CONFIG_USE_LETTER_SHELL=y
#
# Letter Shell Configuration
#
CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -153,8 +171,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

66
baremetal/example/peripheral/can/can_test/configs/d2000_aarch64_eg_configs

@ -6,7 +6,7 @@
#
# Baremetal Configuration
#
CONFIG_TARGET_NAME="baremetal"
CONFIG_TARGET_NAME="d2000_baremetal_a64"
# end of Baremetal Configuration
# end of Project Configuration
@ -24,14 +24,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -41,10 +44,15 @@ CONFIG_TARGET_D2000=y
# CONFIG_USE_QSPI is not set
CONFIG_USE_GIC=y
CONFIG_ENABLE_GICV3=y
# CONFIG_USE_SERIAL is not set
CONFIG_USE_SERIAL=y
#
# Usart Configuration
#
CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
CONFIG_USE_CAN=y
@ -62,26 +70,20 @@ CONFIG_ENABLE_F_CAN=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
CONFIG_LOG_VERBOS=y
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
# CONFIG_LOG_ERROR is not set
CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
@ -99,6 +101,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -110,18 +126,21 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
# CONFIG_USE_LETTER_SHELL is not set
CONFIG_USE_LETTER_SHELL=y
#
# Letter Shell Configuration
#
CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -147,8 +166,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

65
baremetal/example/peripheral/can/can_test/configs/ft2004_aarch32_eg_configs

@ -6,7 +6,7 @@
#
# Baremetal Configuration
#
CONFIG_TARGET_NAME="baremetal"
CONFIG_TARGET_NAME="ft2004_baremetal_a32"
# end of Baremetal Configuration
# end of Project Configuration
@ -31,8 +31,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# Board Configuration
#
CONFIG_TARGET_F2000_4=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_D2000 is not set
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -42,10 +44,15 @@ CONFIG_TARGET_F2000_4=y
# CONFIG_USE_QSPI is not set
CONFIG_USE_GIC=y
CONFIG_ENABLE_GICV3=y
# CONFIG_USE_SERIAL is not set
CONFIG_USE_SERIAL=y
#
# Usart Configuration
#
CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
CONFIG_USE_CAN=y
@ -63,26 +70,20 @@ CONFIG_ENABLE_F_CAN=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
CONFIG_LOG_VERBOS=y
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
# CONFIG_LOG_ERROR is not set
CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
@ -105,6 +106,20 @@ CONFIG_ABORT_STACK_SIZE=0x1000
CONFIG_FIQ_STACK_SIZE=0x1000
CONFIG_UNDEF_STACK_SIZE=0x1000
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -116,18 +131,21 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
# CONFIG_USE_LETTER_SHELL is not set
CONFIG_USE_LETTER_SHELL=y
#
# Letter Shell Configuration
#
CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -153,8 +171,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

66
baremetal/example/peripheral/can/can_test/configs/ft2004_aarch64_eg_configs

@ -6,7 +6,7 @@
#
# Baremetal Configuration
#
CONFIG_TARGET_NAME="baremetal"
CONFIG_TARGET_NAME="ft2004_baremetal_a64"
# end of Baremetal Configuration
# end of Project Configuration
@ -24,14 +24,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
CONFIG_TARGET_F2000_4=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_D2000 is not set
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -41,10 +44,15 @@ CONFIG_TARGET_F2000_4=y
# CONFIG_USE_QSPI is not set
CONFIG_USE_GIC=y
CONFIG_ENABLE_GICV3=y
# CONFIG_USE_SERIAL is not set
CONFIG_USE_SERIAL=y
#
# Usart Configuration
#
CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
CONFIG_USE_CAN=y
@ -62,26 +70,20 @@ CONFIG_ENABLE_F_CAN=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
CONFIG_LOG_VERBOS=y
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
# CONFIG_LOG_ERROR is not set
CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
@ -99,6 +101,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -110,18 +126,21 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
# CONFIG_USE_LETTER_SHELL is not set
CONFIG_USE_LETTER_SHELL=y
#
# Letter Shell Configuration
#
CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -147,8 +166,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

37
baremetal/example/peripheral/can/can_test/fcan_test.c

@ -1,18 +1,29 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
*  SPDX-License-Identifier: Apache-2.0.
* FilePath: fcan_test.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:39:27
* Description:  This files is for
*
* @Date: 2021-07-15 10:14:37
* @LastEditTime: 2021-12-10 14:14:44
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "ft_can.h"
#include "f_iomux.h"
#include "fpinctrl.h"
#include "ft_can_hw.h"
#include "interrupt.h"
#include "parameters.h"
@ -50,10 +61,10 @@ static int FCanHwInit(void)
struct FCanBittiming data_bittiming;
u32 frame_type;
FIomuxSetFun(FCAN_IOMUX_CAN0_TX_OFFSET, FUN1);
FIomuxSetFun(FCAN_IOMUX_CAN0_RX_OFFSET, FUN1);
FIomuxSetFun(FCAN_IOMUX_CAN1_TX_OFFSET, FUN1);
FIomuxSetFun(FCAN_IOMUX_CAN1_RX_OFFSET, FUN1);
FPinSetFunc(FIOCTRL_TJTAG_TDI_PAD, FPIN_FUNC1); /* can0-tx: func 1 */
FPinSetFunc(FIOCTRL_SWDITMS_SWJ_PAD, FPIN_FUNC1); /* can0-rx: func 1 */
FPinSetFunc(FIOCTRL_NTRST_SWJ_PAD, FPIN_FUNC1); /* can1-tx: func 1 */
FPinSetFunc(FIOCTRL_SWDO_SWJ_PAD, FPIN_FUNC1); /* can1-rx: func 1 */
status = FCanCfgInitialize(&can0, FCanLookupConfig(0));
if (status != FCAN_SUCCESS)

22
baremetal/example/peripheral/can/can_test/main.c

@ -1,17 +1,27 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-27 14:46:26
* @Description:  This files is for
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:39:32
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdio.h>
#include "sdkconfig.h"

4
baremetal/example/peripheral/can/can_test/makefile

@ -21,8 +21,8 @@ include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
# 配置例程所需的配置
USR_CONFIGS := USE_LETTER_SHELL=y \
USE_RTC=y \
ENABLE_FRTC=y
USE_CAN=y \
ENABLE_F_CAN=y
# 编译所有支持的平台
.PHONY: rebuild boot

66
baremetal/example/peripheral/can/can_test/sdkconfig

@ -6,7 +6,7 @@
#
# Baremetal Configuration
#
CONFIG_TARGET_NAME="baremetal"
CONFIG_TARGET_NAME="d2000_baremetal_a64"
# end of Baremetal Configuration
# end of Project Configuration
@ -24,14 +24,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -41,10 +44,15 @@ CONFIG_TARGET_D2000=y
# CONFIG_USE_QSPI is not set
CONFIG_USE_GIC=y
CONFIG_ENABLE_GICV3=y
# CONFIG_USE_SERIAL is not set
CONFIG_USE_SERIAL=y
#
# Usart Configuration
#
CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
CONFIG_USE_CAN=y
@ -62,26 +70,20 @@ CONFIG_ENABLE_F_CAN=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
CONFIG_LOG_VERBOS=y
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
# CONFIG_LOG_ERROR is not set
CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
@ -99,6 +101,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -110,18 +126,21 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
# CONFIG_USE_LETTER_SHELL is not set
CONFIG_USE_LETTER_SHELL=y
#
# Letter Shell Configuration
#
CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -147,8 +166,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

53
baremetal/example/peripheral/can/can_test/sdkconfig.h

@ -5,7 +5,7 @@
/* Baremetal Configuration */
#define CONFIG_TARGET_NAME "baremetal"
#define CONFIG_TARGET_NAME "d2000_baremetal_a64"
/* end of Baremetal Configuration */
/* end of Project Configuration */
@ -20,13 +20,16 @@
/* CONFIG_USE_L3CACHE is not set */
#define CONFIG_USE_MMU
/* CONFIG_USE_SYS_TICK is not set */
/* CONFIG_MMU_DEBUG_PRINTS is not set */
/* end of Arch Configuration */
/* Board Configuration */
/* CONFIG_TARGET_F2000_4 is not set */
/* CONFIG_TARGET_E2000Q is not set */
#define CONFIG_TARGET_D2000
/* CONFIG_TARGET_E2000Q is not set */
/* CONFIG_TARGET_E2000D is not set */
/* CONFIG_TARGET_E2000S is not set */
/* end of Board Configuration */
/* Components Configuration */
@ -35,10 +38,13 @@
/* CONFIG_USE_QSPI is not set */
#define CONFIG_USE_GIC
#define CONFIG_ENABLE_GICV3
/* CONFIG_USE_SERIAL is not set */
#define CONFIG_USE_SERIAL
/* Usart Configuration */
#define CONFIG_ENABLE_Pl011_UART
/* end of Usart Configuration */
/* CONFIG_USE_GPIO is not set */
#define CONFIG_USE_IOMUX
#define CONFIG_ENABLE_FIOMUX
/* CONFIG_USE_ETH is not set */
#define CONFIG_USE_CAN
@ -54,22 +60,19 @@
/* CONFIG_USE_DMA is not set */
/* CONFIG_USE_NAND is not set */
/* CONFIG_USE_RTC is not set */
/* CONFIG_USE_SATA is not set */
/* CONFIG_USE_USB is not set */
#define CONFIG_USE_IOCTRL
/* end of Components Configuration */
/* end of Platform Setting */
/* Building Option */
/* Cross-Compiler Setting */
#define CONFIG_COMPILER_NO_STD_STARUP
#define CONFIG_GCC_OPTIMIZE_LEVEL 0
/* CONFIG_USE_EXT_COMPILER is not set */
/* end of Cross-Compiler Setting */
#define CONFIG_LOG_VERBOS
/* CONFIG_LOG_VERBOS is not set */
/* CONFIG_LOG_DEBUG is not set */
/* CONFIG_LOG_INFO is not set */
/* CONFIG_LOG_WARN is not set */
/* CONFIG_LOG_ERROR is not set */
#define CONFIG_LOG_ERROR
/* CONFIG_LOG_NONE is not set */
/* Linker Options */
@ -86,6 +89,15 @@
#define CONFIG_HEAP_SIZE 2
#define CONFIG_STACK_SIZE 0x400
/* end of Linker Options */
/* Compiler Options */
/* Cross-Compiler Setting */
#define CONFIG_GCC_OPTIMIZE_LEVEL 0
/* CONFIG_USE_EXT_COMPILER is not set */
/* end of Cross-Compiler Setting */
/* end of Compiler Options */
/* end of Building Option */
/* Library Configuration */
@ -95,18 +107,19 @@
/* Third-Party Configuration */
/* CONFIG_USE_COREMARK is not set */
/* CONFIG_USE_LWIP is not set */
/* CONFIG_USE_LETTER_SHELL is not set */
#define CONFIG_USE_LETTER_SHELL
/* Letter Shell Configuration */
#define CONFIG_LS_PL011_UART
/* end of Letter Shell Configuration */
/* CONFIG_USE_AMP is not set */
/* CONFIG_USE_YAFFS2 is not set */
/* CONFIG_USE_SDMMC_CMD is not set */
/* CONFIG_USE_YMODEM is not set */
/* CONFIG_USE_SFUD is not set */
#define CONFIG_USE_BACKTRACE
/* CONFIG_USE_FATFS is not set */
/* CONFIG_USE_LLCBENCH is not set */
/* CONFIG_USE_MEMPREF is not set */
#define CONFIG_USE_TLSF
/* end of Third-Party Configuration */
@ -131,8 +144,4 @@
/* end of TFTP flash config */
/* end of PC Console Configuration */
/* Tests Configuration */
/* end of Tests Configuration */
#endif

27
baremetal/example/peripheral/dma/gdma_test/gdma_test.c

@ -1,16 +1,27 @@
/*
* @[H]: Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
*  SPDX-License-Identifier: Apache-2.0.
* FilePath: gdma_test.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:39:42
* Description:  This files is for
*
* @Date: 2021-08-18 16:07:09
* @LastEditTime: 2021-09-06 14:54:56
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include "fgdma.h"
#include "ft_types.h"
// #include "gicv3.h"

22
baremetal/example/peripheral/dma/gdma_test/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-14 15:29:58
* @Description:  This files is for
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:39:47
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "ft_types.h"

22
baremetal/example/peripheral/eth/fgmac_link/inc/fgamc_recv_example.h

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-11 08:33:06
* @LastEditTime: 2021-11-15 10:01:06
* @Description:  This files is for
* FilePath: fgamc_recv_example.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:00
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_FGMAC_RECV_EXAMPLE_H
#define EXAMPLE_FGMAC_RECV_EXAMPLE_H

22
baremetal/example/peripheral/eth/fgmac_link/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-25 15:45:58
* @Description:  This files is for phytium baremetal hello world
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:20
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "sdkconfig.h"

22
baremetal/example/peripheral/eth/fgmac_link/src/cmd_eth_recv.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-11 14:36:45
* @LastEditTime: 2021-11-15 10:01:15
* @Description:  This files is for
* FilePath: cmd_eth_recv.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:09
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "strto.h"

32
baremetal/example/peripheral/eth/fgmac_link/src/fgmac_recv_example.c

@ -1,17 +1,27 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-11 08:32:34
* @LastEditTime: 2021-11-15 14:27:40
* @Description:  This files is for
* FilePath: fgmac_recv_example.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:14
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include "parameters.h"
#include "ft_debug.h"
@ -48,7 +58,7 @@ void EthLinkInternalProbe(uintptr base_addr);
static void EthLinkPhyStatusChecker(void *param)
{
FT_ASSERTVOID(param != NULL);
FASSERT(param != NULL);
FGmac *instance_p = (FGmac *)param;
uintptr base_addr = instance_p->config.base_addr;
@ -68,7 +78,7 @@ static void EthLinkPhyStatusChecker(void *param)
static void EthLinkDmaErrChecker(void *param)
{
FT_ASSERTVOID(param != NULL);
FASSERT(param != NULL);
FGmac *instance_p = (FGmac *)param;
uintptr base_addr = instance_p->config.base_addr;
@ -130,7 +140,7 @@ static void EthLinkDmaErrChecker(void *param)
void EthLinkStatusChecker(void *param)
{
FT_ASSERTVOID(param);
FASSERT(param);
FGmac *instance_p = (FGmac *)param;
uintptr base_addr = instance_p->config.base_addr;
u32 status = FGMAC_READ_REG32(base_addr, FGMAC_MAC_PHY_STATUS);
@ -169,7 +179,7 @@ void EthLinkStatusChecker(void *param)
static void EthLinkRecvDoneCallback(void *param)
{
FT_ASSERTVOID(param);
FASSERT(param);
FGmac *instance_p = (FGmac *)param;
if (TRUE == rx_data_flag)
@ -184,7 +194,7 @@ static void EthLinkRecvDoneCallback(void *param)
static void EthLinkTransDoneCallback(void *param)
{
FT_ASSERTVOID(param);
FASSERT(param);
FGmac *instance_p = (FGmac *)param;
FGmacResumeDmaSend(instance_p->config.base_addr);

51
baremetal/example/peripheral/eth/xmac_test/main.c

@ -1,40 +1,27 @@
/*
* @[H]: Copyright (C) 2014-2021 Phytium Technology.  All rights reserved.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:30
* Description:  This files is for
*
*  The above copyright notice and this permission notice shall be included in
*  all copies or substantial portions of the Software.
*
*  Use of the Software is limited solely to applications:
*  (a) running on a Phytium device, or
*  (b) that interact with a Phytium device through a bus or interconnect.
*
*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
*  PHYTIUM  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
*  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
*  OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*  SOFTWARE.
*
*  Except as contained in this notice, the name of the Phytium shall not be used
*  in advertising or otherwise to promote the sale, use or other dealings in
*  this Software without prior written authorization from Phytium. 
*
* @Date: 2021-07-12 10:27:46
* @LastEditTime: 2021-07-12 10:27:46
* @Description:  Description of file
* @Modify History:
* * * Ver   Who        Date         Changes
* * ----- ------     --------    --------------------------------------
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdio.h>
#include "sdkconfig.h"

4
baremetal/example/peripheral/i2c/fi2c_eeprom/README.md

@ -97,6 +97,10 @@ bootelf -p 0x90100000
![read](./fig/read.png)
- 使用快速模式读写eeprom,
![fast speed](./fig/fast_speed.png)
## 3. 如何解决问题
><font size="1">主要记录使用例程中可能会遇到的问题,给出相应的解决方案</font><br />

47
baremetal/example/peripheral/i2c/fi2c_eeprom/cmd_fi2c_eeprom.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-22 14:32:44
* @LastEditTime: 2021-10-29 15:12:48
* @Description:  This files is for
* FilePath: cmd_fi2c_eeprom.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:42
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "strto.h"
@ -27,11 +37,11 @@ static u8 read_buf[IO_BUF_LEN] __attribute__((aligned(4)));
static void I2cEepromCmdUsage(void)
{
printf("usage:\r\n");
printf(" fi2ceeprom probe\r\n");
printf(" -- init i2c ctrl\r\n");
printf(" fi2ceeprom probe <speed>\r\n");
printf(" -- init i2c ctrl in standard-rate or fast-rate\r\n");
printf(" fi2ceeprom write [offset] [string]\r\n");
printf(" -- init i2c ctrl\r\n");
printf(" fi2ceeprom read [offset] [len] \r\n");
printf(" fi2ceeprom read [offset] [len]\r\n");
printf(" -- init i2c ctrl\r\n");
printf(" fi2ceeprom info\r\n");
printf(" -- print i2c driver info\r\n");
@ -52,7 +62,24 @@ static int I2cEepromCmdEntry(int argc, char *argv[])
if (!strcmp(argv[1], "probe"))
{
ret = FI2cEepromInit(I2C_INSTANCE_0);
int speed_rate = FI2C_SPEED_STANDARD_RATE;
if (argc >= 3)
{
if (!strcmp(argv[2], "standard")) /* standard speed rate */
{
speed_rate = FI2C_SPEED_STANDARD_RATE;
}
else if (!strcmp(argv[2], "fast")) /* fast speed rate */
{
speed_rate = FI2C_SPEED_FAST_RATE;
}
}
ret = FI2cEepromInit(I2C_INSTANCE_0, speed_rate);
}
else if (!strcmp(argv[1], "deinit"))
{
ret = FI2cEepromDeinit();
}
else if (!strcmp(argv[1], "write"))
{

43
baremetal/example/peripheral/i2c/fi2c_eeprom/configs/d2000_aarch32_eg_configs

@ -2,7 +2,7 @@
#
# Project Configuration
#
CONFIG_TARGET_NAME="ft2004_baremetal_a32"
CONFIG_TARGET_NAME="d2000_baremetal_a32"
# end of Project Configuration
#
@ -26,8 +26,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -46,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -59,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -101,6 +95,20 @@ CONFIG_ABORT_STACK_SIZE=0x1000
CONFIG_FIQ_STACK_SIZE=0x1000
CONFIG_UNDEF_STACK_SIZE=0x1000
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -112,7 +120,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -123,14 +130,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -156,8 +160,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

44
baremetal/example/peripheral/i2c/fi2c_eeprom/configs/d2000_aarch64_eg_configs

@ -2,7 +2,7 @@
#
# Project Configuration
#
CONFIG_TARGET_NAME="ft2004_baremetal_a64"
CONFIG_TARGET_NAME="d2000_baremetal_a64"
# end of Project Configuration
#
@ -19,14 +19,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -45,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -58,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -95,6 +90,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -106,7 +115,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -117,14 +125,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -150,8 +155,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

42
baremetal/example/peripheral/i2c/fi2c_eeprom/configs/ft2004_aarch32_eg_configs

@ -26,8 +26,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# Board Configuration
#
CONFIG_TARGET_F2000_4=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_D2000 is not set
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -46,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -59,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -101,6 +95,20 @@ CONFIG_ABORT_STACK_SIZE=0x1000
CONFIG_FIQ_STACK_SIZE=0x1000
CONFIG_UNDEF_STACK_SIZE=0x1000
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -112,7 +120,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -123,15 +130,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_UNITY is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -157,8 +160,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

42
baremetal/example/peripheral/i2c/fi2c_eeprom/configs/ft2004_aarch64_eg_configs

@ -19,14 +19,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
CONFIG_TARGET_F2000_4=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_D2000 is not set
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -45,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -58,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -95,6 +90,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -106,7 +115,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -117,14 +125,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -150,8 +155,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

151
baremetal/example/peripheral/i2c/fi2c_eeprom/fi2c_eeprom_example.c

@ -1,32 +1,47 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-22 10:31:26
* @LastEditTime: 2021-10-28 10:56:09
* @Description:  This files is for
* FilePath: fi2c_eeprom_example.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:48
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "parameters.h"
#include "kernel.h"
#include "ft_types.h"
#include "ft_debug.h"
#include "fpinctrl.h"
#include "fsleep.h"
#include "fi2c_eeprom_example.h"
#include "fi2c.h"
#include "f_iomux.h"
static FI2c device;
#define IO_BUF_LEN 64
static u8 write_buf[IO_BUF_LEN] __attribute__((aligned(4)));
static u8 read_buf[IO_BUF_LEN] __attribute__((aligned(4)));
#define FI2C_DEBUG_TAG "EEPROM"
#define FI2C_ERROR(format, ...) FT_DEBUG_PRINT_E(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
#define FI2C_INFO(format, ...) FT_DEBUG_PRINT_I(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
#define FI2C_DEBUG(format, ...) FT_DEBUG_PRINT_D(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
static FError FI2cEepromWritePoll(FI2c *instance_p, u8 inchip_addr, const u8 *buf_p, size_t buf_len)
{
FError status = FI2C_SUCCESS;
@ -43,15 +58,15 @@ static FError FI2cEepromWritePoll(FI2c *instance_p, u8 inchip_addr, const u8 *bu
trans_size);
if (FI2C_SUCCESS != status)
{
printf("failed in loop %d buf %p ret 0x%x\r\n",
loop,
buf_p + loop * trans_size,
status);
FI2C_ERROR("failed in loop %d buf %p ret 0x%x",
loop,
buf_p + loop * trans_size,
status);
break;
}
else
{
printf("write loop %d buf %p\r\n", loop, buf_p + loop * trans_size);
FI2C_INFO("write loop %d buf %p", loop, buf_p + loop * trans_size);
}
}
@ -67,13 +82,13 @@ static FError FI2cEepromWritePoll(FI2c *instance_p, u8 inchip_addr, const u8 *bu
if (FI2C_SUCCESS != status)
{
printf("failed in last trans buf 0x%x, len %d\r\n",
buf_p + trans_times * trans_size,
last_trans_len);
FI2C_ERROR("failed in last trans buf 0x%x, len %d",
buf_p + trans_times * trans_size,
last_trans_len);
}
else
{
printf("write final loop buf %p\r\n", buf_p + trans_times * trans_size);
FI2C_INFO("write final loop buf %p", buf_p + trans_times * trans_size);
}
}
@ -96,15 +111,15 @@ static FError FI2cEepromReadPoll(FI2c *instance_p, u8 inchip_addr, u8 *buf_p, si
trans_size);
if (FI2C_SUCCESS != status)
{
printf("failed in loop %d buf 0x%x ret 0x%x\r\n",
loop,
buf_p + loop * trans_size,
status);
FI2C_ERROR("failed in loop %d buf 0x%x ret 0x%x",
loop,
buf_p + loop * trans_size,
status);
return status;
}
else
{
printf("read loop %d buf %p\r\n", loop, buf_p + loop * trans_size);
FI2C_INFO("read loop %d buf %p", loop, buf_p + loop * trans_size);
}
}
@ -120,15 +135,15 @@ static FError FI2cEepromReadPoll(FI2c *instance_p, u8 inchip_addr, u8 *buf_p, si
if (FI2C_SUCCESS != status)
{
printf("failed in last trans buf 0x%x, len %d\r\n",
buf_p + trans_times * trans_size,
last_trans_len);
FI2C_ERROR("failed in last trans buf 0x%x, len %d",
buf_p + trans_times * trans_size,
last_trans_len);
return status;
}
else
{
printf("read final loop buf %p\r\n", buf_p + trans_times * trans_size);
FI2C_INFO("read final loop buf %p", buf_p + trans_times * trans_size);
}
}
@ -137,66 +152,45 @@ static FError FI2cEepromReadPoll(FI2c *instance_p, u8 inchip_addr, u8 *buf_p, si
static void FI2cEepromSetIoMux(u32 instance_id)
{
/* i2c io mux */
#define I2C_0_SCL_MUX IOMUX_I2C_0_SCL_PAD
#define I2C_0_SDA_MUX IOMUX_I2C_0_SDA_PAD
#define I2C_0_SCL_FUN FUN0
#define I2C_0_SDA_FUN FUN0
#define I2C_1_SCL_MUX IOMUX_ALL_PLL_LOCK_PAD
#define I2C_1_SDA_MUX IOMUX_ALL_PLL_LOCK_PAD
#define I2C_1_SCL_FUN FUN2
#define I2C_1_SDA_FUN FUN2
#define I2C_2_SCL_MUX IOMUX_SWDO_SWJ_PAD
#define I2C_2_SDA_MUX IOMUX_TDO_SWJ_PAD
#define I2C_2_SCL_FUN FUN2
#define I2C_2_SDA_FUN FUN2
#define I2C_3_SCL_MUX IOMUX_HDT_MB_DONE_STATE_PAD
#define I2C_3_SDA_MUX IOMUX_HDT_MB_FAIL_STATE_PAD
#define I2C_3_SCL_FUN FUN2
#define I2C_3_SDA_FUN FUN2
int sclpad_off, sdapad_off;
PadFun scl_fun, sda_fun;
FPinIndex sclpad_off, sdapad_off;
FPinFunc scl_fun, sda_fun;
switch (instance_id)
{
case I2C_INSTANCE_0:
sclpad_off = I2C_0_SCL_MUX;
sdapad_off = I2C_0_SDA_MUX;
scl_fun = I2C_0_SCL_FUN;
sda_fun = I2C_0_SDA_FUN;
case I2C_INSTANCE_0:
sclpad_off = FIOCTRL_I2C0_SCL_PAD; /* i2c0-scl: func 0 */
sdapad_off = FIOCTRL_I2C0_SDA_PAD; /* i2c0-sda: func 0 */
scl_fun = FPIN_FUNC0;
sda_fun = FPIN_FUNC0;
break;
case I2C_INSTANCE_1:
sclpad_off = I2C_1_SCL_MUX;
sdapad_off = I2C_1_SDA_MUX;
scl_fun = I2C_1_SCL_FUN;
sda_fun = I2C_1_SDA_FUN;
sclpad_off = FIOCTRL_ALL_PLL_LOCK_PAD; /* i2c1-scl: func 2 */
sdapad_off = FIOCTRL_CRU_CLK_OBV_PAD; /* i2c1-sda: func 2 */
scl_fun = FPIN_FUNC2;
sda_fun = FPIN_FUNC2;
break;
case I2C_INSTANCE_2:
sclpad_off = I2C_2_SCL_MUX;
sdapad_off = I2C_2_SDA_MUX;
scl_fun = I2C_2_SCL_FUN;
sda_fun = I2C_2_SDA_FUN;
sclpad_off = FIOCTRL_SWDO_SWJ_PAD; /* i2c2-scl: func 2 */
sdapad_off = FIOCTRL_TDO_SWJ_IN_PAD; /* i2c2-sda: func 2 */
scl_fun = FPIN_FUNC2;
sda_fun = FPIN_FUNC2;
break;
case I2C_INSTANCE_3:
sclpad_off = I2C_3_SCL_MUX;
sdapad_off = I2C_3_SDA_MUX;
scl_fun = I2C_3_SCL_FUN;
sda_fun = I2C_3_SDA_FUN;
sclpad_off = FIOCTRL_HDT_MB_DONE_STATE_PAD; /* i2c3-scl: func 2 */
sdapad_off = FIOCTRL_HDT_MB_FAIL_STATE_PAD; /* i2c3-sda: func 2 */
scl_fun = FPIN_FUNC2;
sda_fun = FPIN_FUNC2;
break;
default:
FT_ASSERTVOID(0);
FASSERT(0);
break;
}
FIomuxSetFun(sclpad_off, scl_fun);
FIomuxSetFun(sdapad_off, sda_fun);
FPinSetFunc(sclpad_off, scl_fun);
FPinSetFunc(sdapad_off, sda_fun);
}
int FI2cEepromInit(u32 instance_id)
int FI2cEepromInit(u32 instance_id, int speed_rate)
{
FI2cConfig input_cfg;
const FI2cConfig *config_p = NULL;
@ -209,7 +203,7 @@ int FI2cEepromInit(u32 instance_id)
config_p = FI2cLookupConfig(instance_id);
if (NULL == config_p)
{
printf("config of i2c instance %d non found\r\n", instance_id);
FI2C_ERROR("config of i2c instance %d non found", instance_id);
return -1;
}
@ -217,7 +211,7 @@ int FI2cEepromInit(u32 instance_id)
input_cfg = *config_p;
input_cfg.slave_addr = AT24C02_ADDR | AT24C02_CHIP_SEL;
input_cfg.slave_addr_len = 1;
input_cfg.speed_rate = FI2C_SPEED_STANDARD_RATE;
input_cfg.speed_rate = speed_rate;
/* Setup iomux */
FI2cEepromSetIoMux(instance_id);
@ -226,7 +220,7 @@ int FI2cEepromInit(u32 instance_id)
status = FI2cCfgInitialize(instance_p, &input_cfg);
if (FI2C_SUCCESS != status)
{
printf("init i2c master failed, ret: 0x%x\r\n", status);
FI2C_ERROR("init i2c master failed, ret: 0x%x", status);
return -2;
}
@ -234,6 +228,15 @@ int FI2cEepromInit(u32 instance_id)
return 0;
}
int FI2cEepromDeinit(void)
{
FI2c *instance_p = &device;
FI2cDeInitialize(instance_p);
return 0;
}
int FI2cEepromWrite(const u8 *buf_p, u32 buf_len, u8 inchip_offset)
{
FI2c *instance_p = &device;
@ -245,7 +248,7 @@ int FI2cEepromWrite(const u8 *buf_p, u32 buf_len, u8 inchip_offset)
status = FI2cEepromWritePoll(instance_p, inchip_offset, buf_p, buf_len);
if (FI2C_SUCCESS != status)
{
printf("write to eeprom failed, ret: 0x%x\r\n", status);
FI2C_ERROR("write to eeprom failed, ret: 0x%x", status);
return -3;
}
@ -264,7 +267,7 @@ int FI2cEepromRead(u8 *buf_p, u32 buf_len, u8 inchip_offset)
status = FI2cEepromReadPoll(instance_p, inchip_offset, buf_p, buf_len);
if (FI2C_SUCCESS != status)
{
printf("read eeprom failed, ret: 0x%x\r\n", status);
FI2C_ERROR("read eeprom failed, ret: 0x%x", status);
return -4;
}

30
baremetal/example/peripheral/i2c/fi2c_eeprom/fi2c_eeprom_example.h

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-22 10:31:36
* @LastEditTime: 2021-10-28 10:25:44
* @Description:  This files is for
* FilePath: fi2c_eeprom_example.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:40:54
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_I2C_EEPROM_H
#define EXAMPLE_I2C_EEPROM_H
@ -19,6 +29,9 @@ extern "C"
{
#endif
#include "ft_types.h"
#include "fi2c.h"
#define AT24C02_ADDR 0x50 /* eeprom slave address */
#define AT24C02_CHIP_SEL 0x07 /* eeprom chip select */
/*
@ -29,10 +42,11 @@ extern "C"
#define AT24C02_BLK_SIZE 8
int FI2cEepromExample(u32 instance_id);
int FI2cEepromInit(u32 instance_id);
int FI2cEepromInit(u32 instance_id, int speed_rate);
int FI2cEepromDeinit(void);
int FI2cEepromWrite(const u8 *buf_p, u32 buf_len, u8 inchip_offset);
int FI2cEepromRead(u8 *buf_p, u32 buf_len, u8 inchip_offset);
int FI2cEepromDriverInfo();
int FI2cEepromDriverInfo(void);
#ifdef __cplusplus
}

BIN
baremetal/example/peripheral/i2c/fi2c_eeprom/fig/fast_speed.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

22
baremetal/example/peripheral/i2c/fi2c_eeprom/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-28 17:11:55
* @Description:  This files is for phytium baremetal hello world
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:02
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "sdkconfig.h"

2
baremetal/example/peripheral/i2c/fi2c_eeprom/makefile

@ -21,8 +21,6 @@ include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
# 配置例程所需的配置
USR_CONFIGS := USE_LETTER_SHELL=y \
USE_IOMUX=y \
ENABLE_FIOMUX=y \
USE_I2C=y \
USE_FI2C=y

44
baremetal/example/peripheral/i2c/fi2c_eeprom/sdkconfig

@ -2,7 +2,7 @@
#
# Project Configuration
#
CONFIG_TARGET_NAME="ft2004_baremetal_a64"
CONFIG_TARGET_NAME="d2000_baremetal_a64"
# end of Project Configuration
#
@ -19,14 +19,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -45,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -58,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -95,6 +90,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -106,7 +115,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -117,14 +125,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -150,8 +155,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

35
baremetal/example/peripheral/i2c/fi2c_eeprom/sdkconfig.h

@ -3,7 +3,7 @@
/* Project Configuration */
#define CONFIG_TARGET_NAME "ft2004_baremetal_a64"
#define CONFIG_TARGET_NAME "d2000_baremetal_a64"
/* end of Project Configuration */
/* Platform Setting */
@ -17,13 +17,16 @@
/* CONFIG_USE_L3CACHE is not set */
#define CONFIG_USE_MMU
/* CONFIG_USE_SYS_TICK is not set */
/* CONFIG_MMU_DEBUG_PRINTS is not set */
/* end of Arch Configuration */
/* Board Configuration */
/* CONFIG_TARGET_F2000_4 is not set */
/* CONFIG_TARGET_E2000Q is not set */
#define CONFIG_TARGET_D2000
/* CONFIG_TARGET_E2000Q is not set */
/* CONFIG_TARGET_E2000D is not set */
/* CONFIG_TARGET_E2000S is not set */
/* end of Board Configuration */
/* Components Configuration */
@ -39,8 +42,6 @@
#define CONFIG_ENABLE_Pl011_UART
/* end of Usart Configuration */
/* CONFIG_USE_GPIO is not set */
#define CONFIG_USE_IOMUX
#define CONFIG_ENABLE_FIOMUX
/* CONFIG_USE_ETH is not set */
/* CONFIG_USE_CAN is not set */
#define CONFIG_USE_I2C
@ -52,17 +53,14 @@
/* CONFIG_USE_DMA is not set */
/* CONFIG_USE_NAND is not set */
/* CONFIG_USE_RTC is not set */
/* CONFIG_USE_SATA is not set */
/* CONFIG_USE_USB is not set */
#define CONFIG_USE_IOCTRL
/* end of Components Configuration */
/* end of Platform Setting */
/* Building Option */
/* Cross-Compiler Setting */
#define CONFIG_COMPILER_NO_STD_STARUP
#define CONFIG_GCC_OPTIMIZE_LEVEL 0
/* CONFIG_USE_EXT_COMPILER is not set */
/* end of Cross-Compiler Setting */
/* CONFIG_LOG_VERBOS is not set */
/* CONFIG_LOG_DEBUG is not set */
/* CONFIG_LOG_INFO is not set */
@ -84,6 +82,15 @@
#define CONFIG_HEAP_SIZE 2
#define CONFIG_STACK_SIZE 0x400
/* end of Linker Options */
/* Compiler Options */
/* Cross-Compiler Setting */
#define CONFIG_GCC_OPTIMIZE_LEVEL 0
/* CONFIG_USE_EXT_COMPILER is not set */
/* end of Cross-Compiler Setting */
/* end of Compiler Options */
/* end of Building Option */
/* Library Configuration */
@ -93,7 +100,6 @@
/* Third-Party Configuration */
/* CONFIG_USE_COREMARK is not set */
/* CONFIG_USE_LWIP is not set */
#define CONFIG_USE_LETTER_SHELL
@ -102,14 +108,11 @@
#define CONFIG_LS_PL011_UART
/* end of Letter Shell Configuration */
/* CONFIG_USE_AMP is not set */
/* CONFIG_USE_YAFFS2 is not set */
/* CONFIG_USE_SDMMC_CMD is not set */
/* CONFIG_USE_YMODEM is not set */
/* CONFIG_USE_SFUD is not set */
#define CONFIG_USE_BACKTRACE
/* CONFIG_USE_FATFS is not set */
/* CONFIG_USE_LLCBENCH is not set */
/* CONFIG_USE_MEMPREF is not set */
#define CONFIG_USE_TLSF
/* end of Third-Party Configuration */
@ -134,8 +137,4 @@
/* end of TFTP flash config */
/* end of PC Console Configuration */
/* Tests Configuration */
/* end of Tests Configuration */
#endif

22
baremetal/example/peripheral/i2c/fi2c_slave/cmd_fi2c_slave.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-26 08:37:22
* @LastEditTime: 2021-10-29 15:12:40
* @Description:  This files is for
* FilePath: cmd_fi2c_slave.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:12
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "strto.h"

43
baremetal/example/peripheral/i2c/fi2c_slave/configs/d2000_aarch32_eg_configs

@ -2,7 +2,7 @@
#
# Project Configuration
#
CONFIG_TARGET_NAME="ft2004_baremetal_a64"
CONFIG_TARGET_NAME="d2000_baremetal_a32"
# end of Project Configuration
#
@ -26,8 +26,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -46,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -59,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -101,6 +95,20 @@ CONFIG_ABORT_STACK_SIZE=0x1000
CONFIG_FIQ_STACK_SIZE=0x1000
CONFIG_UNDEF_STACK_SIZE=0x1000
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -112,7 +120,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -123,14 +130,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -156,8 +160,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

44
baremetal/example/peripheral/i2c/fi2c_slave/configs/d2000_aarch64_eg_configs

@ -2,7 +2,7 @@
#
# Project Configuration
#
CONFIG_TARGET_NAME="ft2004_baremetal_a64"
CONFIG_TARGET_NAME="d2000_baremetal_a64"
# end of Project Configuration
#
@ -19,14 +19,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -45,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -58,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -95,6 +90,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -106,7 +115,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -117,14 +125,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -150,8 +155,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

41
baremetal/example/peripheral/i2c/fi2c_slave/configs/ft2004_aarch32_eg_configs

@ -26,8 +26,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# Board Configuration
#
CONFIG_TARGET_F2000_4=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_D2000 is not set
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -46,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -59,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -101,6 +95,20 @@ CONFIG_ABORT_STACK_SIZE=0x1000
CONFIG_FIQ_STACK_SIZE=0x1000
CONFIG_UNDEF_STACK_SIZE=0x1000
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -112,7 +120,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -123,14 +130,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -156,8 +160,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

44
baremetal/example/peripheral/i2c/fi2c_slave/configs/ft2004_aarch64_eg_configs

@ -2,7 +2,7 @@
#
# Project Configuration
#
CONFIG_TARGET_NAME="ft2004_baremetal_a32"
CONFIG_TARGET_NAME="ft2004_baremetal_a64"
# end of Project Configuration
#
@ -19,14 +19,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
CONFIG_TARGET_F2000_4=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_D2000 is not set
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -45,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -58,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -95,6 +90,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -106,7 +115,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -117,14 +125,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -150,8 +155,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

90
baremetal/example/peripheral/i2c/fi2c_slave/fi2c_slave_example.c

@ -1,28 +1,39 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-25 10:56:28
* @LastEditTime: 2021-10-29 15:12:25
* @Description:  This files is for
* FilePath: fi2c_slave_example.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:20
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "parameters.h"
#include "kernel.h"
#include "ft_types.h"
#include "ft_debug.h"
#include "fpinctrl.h"
#include "fsleep.h"
#include "fi2c.h"
#include "f_iomux.h"
#include "fi2c_slave_example.h"
#define IO_BUF_LEN 64
typedef struct
{
FI2c device;
@ -102,63 +113,42 @@ void FI2cSlaveWriteRequest(void *instance_p, void *para)
static void FI2cSlaveSetIoMux(u32 instance_id)
{
/* i2c io mux */
#define I2C_0_SCL_MUX IOMUX_I2C_0_SCL_PAD
#define I2C_0_SDA_MUX IOMUX_I2C_0_SDA_PAD
#define I2C_0_SCL_FUN FUN0
#define I2C_0_SDA_FUN FUN0
#define I2C_1_SCL_MUX IOMUX_ALL_PLL_LOCK_PAD
#define I2C_1_SDA_MUX IOMUX_ALL_PLL_LOCK_PAD
#define I2C_1_SCL_FUN FUN2
#define I2C_1_SDA_FUN FUN2
#define I2C_2_SCL_MUX IOMUX_SWDO_SWJ_PAD
#define I2C_2_SDA_MUX IOMUX_TDO_SWJ_PAD
#define I2C_2_SCL_FUN FUN2
#define I2C_2_SDA_FUN FUN2
#define I2C_3_SCL_MUX IOMUX_HDT_MB_DONE_STATE_PAD
#define I2C_3_SDA_MUX IOMUX_HDT_MB_FAIL_STATE_PAD
#define I2C_3_SCL_FUN FUN2
#define I2C_3_SDA_FUN FUN2
int sclpad_off, sdapad_off;
PadFun scl_fun, sda_fun;
FPinIndex sclpad_off, sdapad_off;
FPinFunc scl_fun, sda_fun;
switch (instance_id)
{
case I2C_INSTANCE_0:
sclpad_off = I2C_0_SCL_MUX;
sdapad_off = I2C_0_SDA_MUX;
scl_fun = I2C_0_SCL_FUN;
sda_fun = I2C_0_SDA_FUN;
case I2C_INSTANCE_0:
sclpad_off = FIOCTRL_I2C0_SCL_PAD; /* i2c0-scl: func 0 */
sdapad_off = FIOCTRL_I2C0_SDA_PAD; /* i2c0-sda: func 0 */
scl_fun = FPIN_FUNC0;
sda_fun = FPIN_FUNC0;
break;
case I2C_INSTANCE_1:
sclpad_off = I2C_1_SCL_MUX;
sdapad_off = I2C_1_SDA_MUX;
scl_fun = I2C_1_SCL_FUN;
sda_fun = I2C_1_SDA_FUN;
sclpad_off = FIOCTRL_ALL_PLL_LOCK_PAD; /* i2c1-scl: func 2 */
sdapad_off = FIOCTRL_CRU_CLK_OBV_PAD; /* i2c1-sda: func 2 */
scl_fun = FPIN_FUNC2;
sda_fun = FPIN_FUNC2;
break;
case I2C_INSTANCE_2:
sclpad_off = I2C_2_SCL_MUX;
sdapad_off = I2C_2_SDA_MUX;
scl_fun = I2C_2_SCL_FUN;
sda_fun = I2C_2_SDA_FUN;
sclpad_off = FIOCTRL_SWDO_SWJ_PAD; /* i2c2-scl: func 2 */
sdapad_off = FIOCTRL_TDO_SWJ_IN_PAD; /* i2c2-sda: func 2 */
scl_fun = FPIN_FUNC2;
sda_fun = FPIN_FUNC2;
break;
case I2C_INSTANCE_3:
sclpad_off = I2C_3_SCL_MUX;
sdapad_off = I2C_3_SDA_MUX;
scl_fun = I2C_3_SCL_FUN;
sda_fun = I2C_3_SDA_FUN;
sclpad_off = FIOCTRL_HDT_MB_DONE_STATE_PAD; /* i2c3-scl: func 2 */
sdapad_off = FIOCTRL_HDT_MB_FAIL_STATE_PAD; /* i2c3-sda: func 2 */
scl_fun = FPIN_FUNC2;
sda_fun = FPIN_FUNC2;
break;
default:
FT_ASSERTVOID(0);
FASSERT(0);
break;
}
FIomuxSetFun(sclpad_off, scl_fun);
FIomuxSetFun(sdapad_off, sda_fun);
FPinSetFunc(sclpad_off, scl_fun);
FPinSetFunc(sdapad_off, sda_fun);
}
int FI2cSlaveInit(u32 instance_id)

22
baremetal/example/peripheral/i2c/fi2c_slave/fi2c_slave_example.h

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-25 10:56:36
* @LastEditTime: 2021-10-29 15:12:34
* @Description:  This files is for
* FilePath: fi2c_slave_example.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:25
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_I2C_SLAVE_H
#define EXAMPLE_I2C_SLAVE_H

22
baremetal/example/peripheral/i2c/fi2c_slave/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-25 15:45:58
* @Description:  This files is for phytium baremetal hello world
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:34
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "sdkconfig.h"

2
baremetal/example/peripheral/i2c/fi2c_slave/makefile

@ -21,8 +21,6 @@ include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
# 配置例程中需要的配置
USR_CONFIGS := USE_LETTER_SHELL=y \
USE_IOMUX=y \
ENABLE_FIOMUX=y \
USE_I2C=y \
USE_FI2C=y

44
baremetal/example/peripheral/i2c/fi2c_slave/sdkconfig

@ -2,7 +2,7 @@
#
# Project Configuration
#
CONFIG_TARGET_NAME="ft2004_baremetal_a64"
CONFIG_TARGET_NAME="d2000_baremetal_a64"
# end of Project Configuration
#
@ -19,14 +19,17 @@ CONFIG_USE_CACHE=y
# CONFIG_USE_L3CACHE is not set
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
# CONFIG_MMU_DEBUG_PRINTS is not set
# end of Arch Configuration
#
# Board Configuration
#
# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_D2000=y
# CONFIG_TARGET_E2000Q is not set
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# end of Board Configuration
#
@ -45,8 +48,6 @@ CONFIG_ENABLE_Pl011_UART=y
# end of Usart Configuration
# CONFIG_USE_GPIO is not set
CONFIG_USE_IOMUX=y
CONFIG_ENABLE_FIOMUX=y
# CONFIG_USE_ETH is not set
# CONFIG_USE_CAN is not set
CONFIG_USE_I2C=y
@ -58,21 +59,15 @@ CONFIG_USE_FI2C=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# CONFIG_USE_RTC is not set
# CONFIG_USE_SATA is not set
# CONFIG_USE_USB is not set
CONFIG_USE_IOCTRL=y
# end of Components Configuration
# end of Platform Setting
#
# Building Option
#
#
# Cross-Compiler Setting
#
CONFIG_COMPILER_NO_STD_STARUP=y
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
@ -95,6 +90,20 @@ CONFIG_RAM_SIZE_MB=64
CONFIG_HEAP_SIZE=2
CONFIG_STACK_SIZE=0x400
# end of Linker Options
#
# Compiler Options
#
#
# Cross-Compiler Setting
#
CONFIG_GCC_OPTIMIZE_LEVEL=0
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
# end of Compiler Options
# end of Building Option
#
@ -106,7 +115,6 @@ CONFIG_USE_NEW_LIBC=y
#
# Third-Party Configuration
#
# CONFIG_USE_COREMARK is not set
# CONFIG_USE_LWIP is not set
CONFIG_USE_LETTER_SHELL=y
@ -117,14 +125,11 @@ CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
# CONFIG_USE_SDMMC_CMD is not set
# CONFIG_USE_YMODEM is not set
# CONFIG_USE_SFUD is not set
CONFIG_USE_BACKTRACE=y
# CONFIG_USE_FATFS is not set
# CONFIG_USE_LLCBENCH is not set
# CONFIG_USE_MEMPREF is not set
CONFIG_USE_TLSF=y
# end of Third-Party Configuration
@ -150,8 +155,3 @@ CONFIG_UBOOT_GATEWAY_IP="192.168.4.51"
CONFIG_UBOOT_ELF_BOOT_ADDR="0xf0000000"
# end of TFTP flash config
# end of PC Console Configuration
#
# Tests Configuration
#
# end of Tests Configuration

35
baremetal/example/peripheral/i2c/fi2c_slave/sdkconfig.h

@ -3,7 +3,7 @@
/* Project Configuration */
#define CONFIG_TARGET_NAME "ft2004_baremetal_a64"
#define CONFIG_TARGET_NAME "d2000_baremetal_a64"
/* end of Project Configuration */
/* Platform Setting */
@ -17,13 +17,16 @@
/* CONFIG_USE_L3CACHE is not set */
#define CONFIG_USE_MMU
/* CONFIG_USE_SYS_TICK is not set */
/* CONFIG_MMU_DEBUG_PRINTS is not set */
/* end of Arch Configuration */
/* Board Configuration */
/* CONFIG_TARGET_F2000_4 is not set */
/* CONFIG_TARGET_E2000Q is not set */
#define CONFIG_TARGET_D2000
/* CONFIG_TARGET_E2000Q is not set */
/* CONFIG_TARGET_E2000D is not set */
/* CONFIG_TARGET_E2000S is not set */
/* end of Board Configuration */
/* Components Configuration */
@ -39,8 +42,6 @@
#define CONFIG_ENABLE_Pl011_UART
/* end of Usart Configuration */
/* CONFIG_USE_GPIO is not set */
#define CONFIG_USE_IOMUX
#define CONFIG_ENABLE_FIOMUX
/* CONFIG_USE_ETH is not set */
/* CONFIG_USE_CAN is not set */
#define CONFIG_USE_I2C
@ -52,17 +53,14 @@
/* CONFIG_USE_DMA is not set */
/* CONFIG_USE_NAND is not set */
/* CONFIG_USE_RTC is not set */
/* CONFIG_USE_SATA is not set */
/* CONFIG_USE_USB is not set */
#define CONFIG_USE_IOCTRL
/* end of Components Configuration */
/* end of Platform Setting */
/* Building Option */
/* Cross-Compiler Setting */
#define CONFIG_COMPILER_NO_STD_STARUP
#define CONFIG_GCC_OPTIMIZE_LEVEL 0
/* CONFIG_USE_EXT_COMPILER is not set */
/* end of Cross-Compiler Setting */
/* CONFIG_LOG_VERBOS is not set */
/* CONFIG_LOG_DEBUG is not set */
/* CONFIG_LOG_INFO is not set */
@ -84,6 +82,15 @@
#define CONFIG_HEAP_SIZE 2
#define CONFIG_STACK_SIZE 0x400
/* end of Linker Options */
/* Compiler Options */
/* Cross-Compiler Setting */
#define CONFIG_GCC_OPTIMIZE_LEVEL 0
/* CONFIG_USE_EXT_COMPILER is not set */
/* end of Cross-Compiler Setting */
/* end of Compiler Options */
/* end of Building Option */
/* Library Configuration */
@ -93,7 +100,6 @@
/* Third-Party Configuration */
/* CONFIG_USE_COREMARK is not set */
/* CONFIG_USE_LWIP is not set */
#define CONFIG_USE_LETTER_SHELL
@ -102,14 +108,11 @@
#define CONFIG_LS_PL011_UART
/* end of Letter Shell Configuration */
/* CONFIG_USE_AMP is not set */
/* CONFIG_USE_YAFFS2 is not set */
/* CONFIG_USE_SDMMC_CMD is not set */
/* CONFIG_USE_YMODEM is not set */
/* CONFIG_USE_SFUD is not set */
#define CONFIG_USE_BACKTRACE
/* CONFIG_USE_FATFS is not set */
/* CONFIG_USE_LLCBENCH is not set */
/* CONFIG_USE_MEMPREF is not set */
#define CONFIG_USE_TLSF
/* end of Third-Party Configuration */
@ -134,8 +137,4 @@
/* end of TFTP flash config */
/* end of PC Console Configuration */
/* Tests Configuration */
/* end of Tests Configuration */
#endif

23
baremetal/example/peripheral/mmc/fsdio_probe/inc/fsdio_sdcard.h

@ -1,3 +1,26 @@
/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: fsdio_sdcard.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:46
* Description:  This files is for
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef __FSDIO_SDCARD_H_
#define __FSDIO_SDCARD_H_

22
baremetal/example/peripheral/mmc/fsdio_probe/inc/fsdio_trans_example.h

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-23 10:12:31
* @LastEditTime: 2021-11-23 17:53:35
* @Description:  This files is for
* FilePath: fsdio_trans_example.h
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:52
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef EXAMPLE_MMC_FSDIO_TRANS_EX_H
#define EXAMPLE_MMC_FSDIO_TRANS_EX_H

22
baremetal/example/peripheral/mmc/fsdio_probe/main.c

@ -1,16 +1,26 @@
/*
* Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
* @LastEditTime: 2021-10-25 15:45:58
* @Description:  This files is for phytium baremetal hello world
* FilePath: main.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:42:15
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "sdkconfig.h"

3
baremetal/example/peripheral/mmc/fsdio_probe/makefile

@ -38,5 +38,4 @@ rebuild:
make
build_all:
make build_e2000_aarch32
make build_e2000_aarch64

22
baremetal/example/peripheral/mmc/fsdio_probe/src/cmd_sdio.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-23 17:49:50
* @LastEditTime: 2021-11-23 17:58:31
* @Description:  This files is for
* FilePath: cmd_sdio.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:41:58
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include "strto.h"

22
baremetal/example/peripheral/mmc/fsdio_probe/src/fsdio_sdcard.c

@ -1,16 +1,26 @@
/*
* @ : Copyright (c) 2021 Phytium Information Technology, Inc.
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-11-23 16:54:45
* @LastEditTime: 2021-11-23 18:08:44
* @Description:  This files is for
* FilePath: fsdio_sdcard.c
* Date: 2022-02-10 14:53:41
* LastEditTime: 2022-02-17 17:42:03
* Description:  This files is for
*
* @Modify History:
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save