User Configuration
Introduction
This chapter mainly introduces various configuration files that require special attention and modification during the development process.
ameba_bootcfg
This section introduces the boot-related configurations including SoC clock switch and boot log.
github source code
The KM4 boots at 200MHz at the BootRom Stage, and switches to a higher frequency during the bootloader Stage.
There are some limitations when changing the SoC clock:
Clock |
Frequency |
Core voltage |
|---|---|---|
PLL |
300MHz ~ 688.128MHz |
|
KM0 |
≤105MHz |
0.9V |
KM0 |
≤115MHz |
1.0V |
KM4 |
≤262MHz |
0.9V |
KM4 |
≤345MHz |
1.0V |
Note
By default, the SDK assumes the Flash is powered at 3.3V. And during initialization, it will automatically switch the Flash to the highest speed rate that does not exceed the 104MHz limit.
For wide voltage range ICs, the maximum operating frequency of the Flash should comply with the speed limitations in the 1.65V to 2.3V power supply range. You can refer to ameba_flashcfg to reduce the speed or contact Realtek for assistance.
SoC & PSRAM Clock Set Flow
Check the value of
Boot_SocClk_Info_IdxandSocClk_Info[]inameba_bootcfg.c.1// for km4, max 345MHz under 1.0v, max 262MHz under 0.9v 2// for km0, max 115MHz under 1.0v, max 105MHz under 0.9v 3// PLL can be 300MHz~688.128MHz 4// KM4_CKD range is [1, 8], KM0_CKD range is [1, 16] or USEXTAL 5const SocClk_Info_TypeDef SocClk_Info[] = { 6 /* PLL_CLK, Vol_Type, KM4_CKD, KM0_CKD, PSRAMC_CKD*/ 7 /* This group is to reduce the impact of PSRAM on RF, the frequency is specially selected */ 8 {PLL_524M, CORE_VOL_0P9, CLKDIV(2), CLKDIV(5), CLKDIV(2)}, // For SiP Psram 9 {PLL_392M, CORE_VOL_0P9, CLKDIV(2), CLKDIV(4), CLKDIV(1)}, // For SiP Psram 10 {PLL_334M, CORE_VOL_1P0, CLKDIV(1), CLKDIV(3), CLKDIV(1)}, // For SiP Psram 11 /* This group is to reduce the impact of Flash on RF, the frequency is specially selected. 12 Single die use the same settings. */ 13 {PLL_512M, CORE_VOL_0P9, CLKDIV(2), CLKDIV(5), CLKDIV(2)}, // For SiP Flash or single die (No Psram) 14 {PLL_400M, CORE_VOL_0P9, CLKDIV(2), CLKDIV(4), CLKDIV(1)}, // For SiP Flash or single die (No Psram) 15 {PLL_334M, CORE_VOL_1P0, CLKDIV(1), CLKDIV(3), CLKDIV(1)}, // For SiP Flash or single die (No Psram) 16 /* The following frequency settings are not adjustable */ 17 {PLL_480M, CORE_VOL_0P9, CLKDIV(2), CLKDIV(5), CLKDIV(2)}, // 48M for usb, both For SiP Psram / SiP Flash / single die 18 {PLL_677P376M, CORE_VOL_1P0, CLKDIV(2), CLKDIV(6), CLKDIV(2)}, // Audio 19 {PLL_688P128M, CORE_VOL_1P0, CLKDIV(2), CLKDIV(6), CLKDIV(2)}, // Audio 20}; 21 22/** 23* @brif SocClk_Info select. One of Valid_Boot_Idx_for_SiP_Psram or Valid_Boot_Idx_for_No_Psram depend on different chip types 24* Boot_SocClk_Info_Idx is [0, sizeof(SocClk_Info)), Soc will set socclk by SocClk_Info[Boot_SocClk_Info_Idx] 25*/ 26#ifdef CONFIG_USB_DEVICE_EN 27u8 Boot_SocClk_Info_Idx = 6; /* Make sure the PLL_CLK for USB is an integer multiple of 48MHz */ 28#else 29u8 Boot_SocClk_Info_Idx = 6; /* 480M has an acceptable impact on the RF performance of SiP Psram and SiP Flash */ 30#endif
Due to certain frequencies of PSRAM or Flash interfering with RF, the
BOOT_ChipInfo_ClkInfoIdx()function in thebootloaderbootloader_km4.cfile only allows indices represented byBoot_SocClk_Info_Idxwithin theSocClk_Infoarray.”Note
It is not recommended to modify
SocClk_Info. If frequency combinations outside ofSocClk_Infoare needed, it is necessary to confirm whether such configurations would affect RF performance.u32 BOOT_ChipInfo_ClkInfoIdx(void) { /* PSRAM die is wb955 which can run up to 200MHz */ ... return Boot_SocClk_Info_Idx; }
The Bootloader will configure the SoC voltage and clock according to the definition of
SocClk_Info[Boot_SocClk_Info_Idx]. The PSRAMC (twice the PSRAM clock) rate will also be adjusted synchronously with the SoC clock. The clock speeds for other modules will be automatically set to reasonable values by the software based on their maximum operating speeds. The cases where the value ofBoot_SocClk_Info_Idxis 0 and 4 serve as examples:PSRAM type
PSRAM speed
SocClk_Info[x]
Clock Info
No PSRAM
SocClk_Info[4]
PLL: 400MHz
KM4: PLL/2
KM0: PLL/4
With PSRAM
≤200MHz
SocClk_Info[0]
PLL: 524MHz
KM4: PLL/2
KM0: PLL/5
PSRAMC: PLL/2
Refer to one of the following methods to change the SoC clock if needed.
Modify
Boot_SocClk_Info_Idxto a value within the range of[0, sizeof(SocClk_Info)], then customize the clock configuration information inSocClk_Info [Boot_SocClk_Info_Idx].
Note
Consider the limitations of the hardware and do not set the clock info illogically.
Rebuild the project and download the new image again.
Boot_Agg_En
The Boot_Agg_En is used with Trace Tool to sort out boot logs from different cores. It can be enabled through Boot_Agg_En.
/**
* @brif Loguart AGG enable or disable
* FALSE: disable
* TRUE: enable
*/
u8 Boot_Agg_En = FALSE;
Note
Refer to Chapter Trace Tool for more information.
github source code
The KM4 boots at 150MHz at the BootROM Stage, and switches to a higher frequency during the bootloader Stage.
There are some limitations when changing the SoC clock:
Clock |
Frequency |
Core voltage |
|---|---|---|
PLLM |
330MHz ~ 660MHz |
|
PLLD |
330MHz ~ 660MHz |
|
KM4/KR4 |
≤300MHz |
0.9V |
KM4/KR4 |
≤400MHz |
1.0V |
SoC & PSRAM Clock Set Flow
(Optional) Find out the speed limit of embedded PSRAM device, if not sure.
Refer to the
BOOT_ChipInfo_PSRAMType()function in thebootloaderbootloader_km4.cfile, and print the value ofPSRAM_CLK_LIMIT_GET(ChipInfo_PSRAMType()). This can be used to read the speed limit of the built-in PSRAM from the OTP.Refer to the chip’s specification document to understand the speed limits of the built-in PSRAM.
Check the value of Boot_SocClk_Info_Idx and the clock info in
ameba_bootcfg.c.1// for kr4/km4, max 400MHz under 1.0v, max 200MHz under 0.9v 2// for dsp, max 500MHz under 1.0v, max 400MHz under 0.9v 3// CPUPLL(PLLM)/DSPPLL(PLLD) can be 330MHz~660MHz 4// All CLKDIV range is [1, 16] 5SocClk_Info_TypeDef SocClk_Info[] = { 6 /* PLLM_CLK, PLLD_CLK, Vol_Type, CPU_CKD, PSRAMC_CKD */ 7 {PLL_600M, PLL_500M, CORE_VOL_0P9, CLKDIV(3) | ISPLLM, CLKDIV(2) | ISPLLM}, /* 0.9V, PSRAM-166M */ 8 {PLL_600M, PLL_500M, CORE_VOL_1P0, CLKDIV(3) | ISPLLM, CLKDIV(2) | ISPLLM}, /* 1.0V, PSRAM-166M */ 9 {PLL_400M, PLL_500M, CORE_VOL_1P0, CLKDIV(2) | ISPLLM, CLKDIV(1) | ISPLLM}, /* 1.0V, PSRAM-200M */ 10 {PLL_480M, PLL_500M, CORE_VOL_1P0, CLKDIV(2) | ISPLLM, CLKDIV(1) | ISPLLD}, /* 1.0V, PSRAM-250M */ 11}; 12 13/** 14* @brif SocClk_Info select 15* Boot_SocClk_Info_Idx valid value is [0, 3] and 0xFF 16* when Boot_SocClk_Info_Idx is 0xFF, set socclk by chipinfo Automatically 17* when Boot_SocClk_Info_Idx is [0, 3], set socclk by SocClk_Info[Boot_SocClk_Info_Idx] 18*/ 19u8 Boot_SocClk_Info_Idx = 0xFF;
If Boot_SocClk_Info_Idx is 0xFF (default), the bootloader will set the SoC clock automatically according to the embedded PSRAM type.
If Boot_SocClk_Info_Idx is not 0xFF, the bootloader will set the SoC clock defined by
SocClk_Info[Boot_SocClk_Info_Idx].
For example, if Boot_SocClk_Info_Idx is
0, and the maximum operating frequency of PSRAM is 166MHz, the bootloader will useSocClk_Info[0]for configuration. This means the clock frequency of KM4/KR4 will be set to 1/3 of the PLLM frequency, and the PSRAMC (twice the PSRAM clock) rate will be set to 1/2 of the PLLM frequency. The clock rates for the remaining modules will be automatically set by the software to reasonable values based on their maximum operating speeds.PSRAM type
PSRAM speed
SocClk_Info[x]
Clock Info
No PSRAM
SocClk_Info[0]
PLLM: 600MHz
PLLD: 500MHz
KM4/KR4: PLLM/3
With PSRAM
≤166MHz
SocClk_Info[1]
PLLM: 600MHz
PLLD: 500MHz
KM4/KR4: PLLM/3
PSRAMC: PLLM/2
≤200MHz
SocClk_Info[2]
PLLM: 400MHz
PLLD: 500MHz
KM4/KR4: PLLM/2
PSRAMC: PLLM
Refer to one of the following methods to change the SoC clock if needed.
Keep the
Boot_SocClk_Info_Idx0xFF, and only change the clock info ofSocClk_Info[x]to set the clocks of PLLM/PLLD and CPUs.Modify the
Boot_SocClk_Info_Idxto[0, sizeof(SocClk_Info)], and then customize the clock configuration information inSocClk_Info[Boot_SocClk_Info_Idx].
Note
Consider the limitations of the hardware and do not set the clock info illogically.
The PLLD can be disabled if you do not need it work.
Re-build the project and download the new image again.
Boot_Agg_En
The Boot_Agg_En is used with Trace Tool to sort out boot logs from different cores. It can be enabled through Boot_Agg_En.
/**
* @brif Loguart AGG enable or disable
* FALSE: disable
* TRUE: enable
*/
u8 Boot_Agg_En = FALSE;
Note
Refer to Chapter Trace Tool for more information.
github source code
The KM4 boots at 150MHz at the BootROM Stage, and switches to a higher frequency during the bootloader Stage.
There are some limitations when changing the SoC clock:
Clock |
Frequency |
Core voltage |
Note |
|---|---|---|---|
PLLM |
330MHz ~ 660MHz |
||
PLLD |
330MHz ~ 660MHz |
Can not exceed the maximum frequency of DSP clock |
|
KM4/KR4 |
≤300MHz |
0.9V |
|
KM4/KR4 |
≤400MHz |
1.0V |
|
DSP |
≤400MHz |
0.9V |
The same as PLLD |
DSP |
≤500MHz |
1.0V |
The same as PLLD |
SoC & PSRAM Clock Set Flow
(Optional) Find out the speed limit of embedded PSRAM device, if not sure.
Refer to the
BOOT_ChipInfo_PSRAMType()function in thebootloaderbootloader_km4.cfile, and print the value ofPSRAM_CLK_LIMIT_GET(ChipInfo_PSRAMType()). This can be used to read the speed limit of the built-in PSRAM from the OTP.Refer to the chip’s specification document to understand the speed limits of the built-in PSRAM.
Check the value of Boot_SocClk_Info_Idx and the clock info in
ameba_bootcfg.c.1// for kr4/km4, max 400MHz under 1.0v, max 200MHz under 0.9v 2// for dsp, max 500MHz under 1.0v, max 400MHz under 0.9v 3// CPUPLL(PLLM)/DSPPLL(PLLD) can be 330MHz~660MHz 4// All CLKDIV range is [1, 16] 5SocClk_Info_TypeDef SocClk_Info[] = { 6 /* PLLM_CLK, PLLD_CLK, Vol_Type, CPU_CKD, PSRAMC_CKD */ 7 {PLL_600M, PLL_500M, CORE_VOL_0P9, CLKDIV(3) | ISPLLM, CLKDIV(2) | ISPLLM}, /* 0.9V, PSRAM-166M */ 8 {PLL_600M, PLL_500M, CORE_VOL_1P0, CLKDIV(3) | ISPLLM, CLKDIV(2) | ISPLLM}, /* 1.0V, PSRAM-166M */ 9 {PLL_400M, PLL_500M, CORE_VOL_1P0, CLKDIV(2) | ISPLLM, CLKDIV(1) | ISPLLM}, /* 1.0V, PSRAM-200M */ 10 {PLL_480M, PLL_500M, CORE_VOL_1P0, CLKDIV(2) | ISPLLM, CLKDIV(1) | ISPLLD}, /* 1.0V, PSRAM-250M */ 11}; 12 13/** 14* @brif SocClk_Info select 15* Boot_SocClk_Info_Idx valid value is [0, 3] and 0xFF 16* when Boot_SocClk_Info_Idx is 0xFF, set socclk by chipinfo Automatically 17* when Boot_SocClk_Info_Idx is [0, 3], set socclk by SocClk_Info[Boot_SocClk_Info_Idx] 18*/ 19u8 Boot_SocClk_Info_Idx = 0xFF;
If Boot_SocClk_Info_Idx is 0xFF (default), the bootloader will set the SoC clock automatically according to the embedded PSRAM type.
If Boot_SocClk_Info_Idx is not 0xFF, the bootloader will set the SoC clock defined by
SocClk_Info[Boot_SocClk_Info_Idx].
For example, if Boot_SocClk_Info_Idx is
0, and the maximum operating frequency of PSRAM is 166MHz, the bootloader will useSocClk_Info[0]for configuration. This means the clock frequency of KM4/KR4 will be set to 1/3 of the PLLM frequency, and the PSRAMC (twice the PSRAM clock) rate will be set to 1/2 of the PLLM frequency. The clock rates for the remaining modules will be automatically set by the software to reasonable values based on their maximum operating speeds.PSRAM type
PSRAM speed
SocClk_Info[x]
Clock Info
With PSRAM
≤250MHz
SocClk_Info[3]
PLLM: 480MHz
PLLD: 500MHz
KM4/KR4: PLLM/2
PSRAMC: PLLD
DSP: PLLD
Refer to one of the following methods to change the SoC clock if needed.
Keep the
Boot_SocClk_Info_Idx0xFF, and only change the clock info ofSocClk_Info[x]to set the clocks of PLLM/PLLD and CPUs.Modify the
Boot_SocClk_Info_Idxto[0, sizeof(SocClk_Info)], and then customize the clock configuration information inSocClk_Info[Boot_SocClk_Info_Idx].
Note
Consider the limitations of the hardware and do not set the clock info illogically.
Re-build the project and download the new image again.
Boot_Agg_En
The Boot_Agg_En is used with Trace Tool to sort out boot logs from different cores. It can be enabled through Boot_Agg_En.
/**
* @brif Loguart AGG enable or disable
* FALSE: disable
* TRUE: enable
*/
u8 Boot_Agg_En = FALSE;
Note
Refer to Chapter Trace Tool for more information.
github source code
The KM4 boots at 150MHz at the BootROM Stage, and switches to a higher frequency during the bootloader Stage.
There are some limitations when changing the SoC clock:
Clock |
Frequency |
Core voltage |
Note |
|---|---|---|---|
PLLM |
330MHz ~ 660MHz |
||
PLLD |
330MHz ~ 660MHz |
Can not exceed the maximum frequency of DSP clock |
|
KM4/KR4 |
≤300MHz |
0.9V |
|
KM4/KR4 |
≤400MHz |
1.0V |
|
DSP |
≤400MHz |
0.9V |
The same as PLLD |
DSP |
≤500MHz |
1.0V |
The same as PLLD |
SoC & PSRAM Clock Set Flow
(Optional) Find out the speed limit of embedded PSRAM device, if not sure.
Refer to the
BOOT_ChipInfo_PSRAMType()function in thebootloaderbootloader_km4.cfile, and print the value ofPSRAM_CLK_LIMIT_GET(ChipInfo_PSRAMType()). This can be used to read the speed limit of the built-in PSRAM from the OTP.Refer to the chip’s specification document to understand the speed limits of the built-in PSRAM.
Check the value of Boot_SocClk_Info_Idx and the clock info in
ameba_bootcfg.c.1// for kr4/km4, max 400MHz under 1.0v, max 200MHz under 0.9v 2// for dsp, max 500MHz under 1.0v, max 400MHz under 0.9v 3// CPUPLL(PLLM)/DSPPLL(PLLD) can be 330MHz~660MHz 4// All CLKDIV range is [1, 16] 5SocClk_Info_TypeDef SocClk_Info[] = { 6 /* PLLM_CLK, PLLD_CLK, Vol_Type, CPU_CKD, PSRAMC_CKD */ 7 {PLL_600M, PLL_500M, CORE_VOL_0P9, CLKDIV(3) | ISPLLM, CLKDIV(2) | ISPLLM}, /* 0.9V, PSRAM-166M */ 8 {PLL_600M, PLL_500M, CORE_VOL_1P0, CLKDIV(3) | ISPLLM, CLKDIV(2) | ISPLLM}, /* 1.0V, PSRAM-166M */ 9 {PLL_400M, PLL_500M, CORE_VOL_1P0, CLKDIV(2) | ISPLLM, CLKDIV(1) | ISPLLM}, /* 1.0V, PSRAM-200M */ 10 {PLL_480M, PLL_500M, CORE_VOL_1P0, CLKDIV(2) | ISPLLM, CLKDIV(1) | ISPLLD}, /* 1.0V, PSRAM-250M */ 11}; 12 13/** 14* @brif SocClk_Info select 15* Boot_SocClk_Info_Idx valid value is [0, 3] and 0xFF 16* when Boot_SocClk_Info_Idx is 0xFF, set socclk by chipinfo Automatically 17* when Boot_SocClk_Info_Idx is [0, 3], set socclk by SocClk_Info[Boot_SocClk_Info_Idx] 18*/ 19u8 Boot_SocClk_Info_Idx = 0xFF;
If Boot_SocClk_Info_Idx is 0xFF (default), the bootloader will set the SoC clock automatically according to the embedded PSRAM type.
If Boot_SocClk_Info_Idx is not 0xFF, the bootloader will set the SoC clock defined by
SocClk_Info[Boot_SocClk_Info_Idx].
For example, if Boot_SocClk_Info_Idx is
0, and the maximum operating frequency of PSRAM is 166MHz, the bootloader will useSocClk_Info[0]for configuration. This means the clock frequency of KM4/KR4 will be set to 1/3 of the PLLM frequency, and the PSRAMC (twice the PSRAM clock) rate will be set to 1/2 of the PLLM frequency. The clock rates for the remaining modules will be automatically set by the software to reasonable values based on their maximum operating speeds.PSRAM type
PSRAM speed
SocClk_Info[x]
Clock Info
With PSRAM
≤250MHz
SocClk_Info[3]
PLLM: 480MHz
PLLD: 500MHz
KM4/KR4: PLLM/2
PSRAMC: PLLD
DSP: PLLD
Refer to one of the following methods to change the SoC clock if needed.
Keep the
Boot_SocClk_Info_Idx0xFF, and only change the clock info ofSocClk_Info[x]to set the clocks of PLLM/PLLD and CPUs.Modify the
Boot_SocClk_Info_Idxto[0, sizeof(SocClk_Info)], and then customize the clock configuration information inSocClk_Info[Boot_SocClk_Info_Idx].
Note
Consider the limitations of the hardware and do not set the clock info illogically.
Re-build the project and download the new image again.
Boot_Agg_En
The Boot_Agg_En is used with Trace Tool to sort out boot logs from different cores. It can be enabled through Boot_Agg_En.
/**
* @brif Loguart AGG enable or disable
* FALSE: disable
* TRUE: enable
*/
u8 Boot_Agg_En = FALSE;
Note
Refer to Chapter Trace Tool for more information.
github source code
The KM4 boots at 200MHz at the BootRom Stage, and switches to a higher frequency during the bootloader Stage.
There are some limitations when changing the SoC clock:
Clock |
Frequency |
Core voltage |
Note |
|---|---|---|---|
NPPLL |
800MHz ~ 1.0GHz |
||
APPLL |
1.0GHz ~ 1.6GHz |
Can not exceed the maximum frequency of CA32 clock |
|
KM4 |
≤250MHz |
0.9V |
|
KM4 |
≤333MHz |
1.0V |
|
CA32 |
≤920MHz |
0.9V |
|
CA32 |
≤1200MHz |
1.0V |
When the Memory Type is DDR, the limit is 1320MHz. |
SoC & PSRAM 时钟设置流程
Check the value of
SocClk_Info[]inameba_bootcfg.c.1// for km4, max 333MHz under 1.0v, max 250MHz under 0.9v 2// for AP, max 1200MHz under 1.0v, max 920MHz under 0.9v 3// NP PLL can be 800MHz~1000MHz 4SocClk_Info_TypeDef SocClk_Info[1] = { 5 /* NPPLL_CLK, APPLL_Clk, Vol_Type, KM4_CPU_CKD, AP_CPU_CKD */ 6 {NPPLL_1000M, APPLL_1200M, VOL_10, CLKDIV(3), CLKDIV(1) | ISAPPLL}, //best porformance 7 // {NPPLL_920M, APPLL_NULL, VOL_09, CLKDIV(4), CLKDIV(1) | ISNPPLL}, 8};
The Bootloader will configure the SoC voltage and clock according to the definition in
SocClk_Info[0]. The clock settings for the remaining modules will be automatically set to reasonable values by the software based on their maximum operating speeds.KM4 Clock: NPPLL / SocClk_Info[0].KM4_CPU_CKD
CA32 Clock: If SocClk_Info[0].AP_CPU_CKD is ISAPPLL, then CA32 Clock = APPLL / SocClk_Info[0].AP_CPU_CKD, otherwise CA32 Clock = NPPLL / SocClk_Info[0].AP_CPU_CKD
If necessary, customize the clock configuration information in
SocClk_Info.Note
Please consider the hardware limitations carefully to avoid setting illegal clock configuration parameters.
Recompile the project and download the new firmware.
Boot_Agg_En
The Boot_Agg_En is used with Trace Tool to sort out boot logs from different cores. It can be enabled through Boot_Agg_En.
/**
* @brif Loguart AGG enable or disable
* FALSE: disable
* TRUE: enable
*/
u8 Boot_Agg_En = FALSE;
Note
Refer to Chapter Trace Tool for more information.
ameba_flashcfg
This section introduces the Flash-related configurations including speed, read mode, layout and protect mode.
github source code
Flash_Speed
The frequency of the SPIC controller is set to XTAL (40MHz) during the BootRom stage, and switches to a higher frequency during the Bootloader stage.
The Flash runs at half the speed of the SPIC controller. By default, the SPIC controller’s speed is derived from the PLL divider, but it must remain below SPIC_CLK_LIMIT (208MHz).
If the Flash needs to run slower, modify the value of Flash_Speed (for SPIC0) or Data_Flash_Speed (for SPIC1), which is the PLL division factor.
const u16 Flash_Speed = CLKDIV(2);
const u16 Data_Flash_Speed = CLKDIV(2);
Note
Refer to ameba_bootcfg for details about the Frequency of PLL.
The maximum clock of Flash is
SPIC_CLK_LIMIT/2. The initial flow will automatically check whether the configured speed is higher than the maximun one or not.Flash has already been set to optimal performance during initialization, so it is not recommended to modify
Flash_SpeedandFlash_ReadMode, orData_Flash_SpeedandData_Flash_ReadMode.
Flash_ReadMode
During the BootRom stage, the SPIC operates in 1IO mode, and switches to the mode specified by Flash_ReadMode (default is 4IO) during the Bootloader stage.
If the currently configured read mode is not supported, the system will automatically try other modes until a compatible mode is found.
Flash_Layout
The default Flash layout in the SDK are illustrated in Chapter Flash Layout . If you want to modify the Flash layout, refer to Section Flash Layout Modification Guide.
Flash Protect Enable
For more information about this function, refer to Section Flash Protection Mechanism .
github source code
Flash_Speed
The frequency of the SPIC controller is set to XTAL (40MHz) during the BootRom stage, and switches to a higher frequency during the Bootloader stage.
The Flash runs at half the speed of the SPIC controller. By default, the SPIC controller’s speed is derived from the PLLM divider, but it must remain below SPIC_CLK_LIMIT (208MHz).
If the Flash needs to run slower, change the value of Flash_Speed, which is the PLLM division factor.
const u16 Flash_Speed = 0xFF;
Note
Refer to ameba_bootcfg for details about the Frequency of PLLM.
The maximum clock of Flash is
SPIC_CLK_LIMIT/2. The initial flow will automatically check whether the configured speed is higher than the maximun one or not.
Flash_ReadMode
During the BootRom stage, the SPIC operates in 1IO mode, and switches to the mode specified by Flash_ReadMode (default is 4IO) during the Bootloader stage.
If the currently configured read mode is not supported, the system will automatically try other modes until a compatible mode is found.
Flash_Layout
The default Flash layout in the SDK are illustrated in Chapter Flash Layout . If you want to modify the Flash layout, refer to Section Flash Layout Modification Guide.
Flash Protect Enable
For more information about this function, refer to Section Flash Protection Mechanism .
github source code
Flash_Speed
The frequency of the SPIC controller is set to XTAL (40MHz) during the BootRom stage, and switches to a higher frequency during the Bootloader stage.
The Flash runs at half the speed of the SPIC controller. By default, the SPIC controller’s speed is derived from the PLLM divider, but it must remain below SPIC_CLK_LIMIT (208MHz).
If the Flash needs to run slower, change the value of Flash_Speed, which is the PLLM division factor.
const u16 Flash_Speed = 0xFF;
Note
Refer to ameba_bootcfg for details about the Frequency of PLLM.
The maximum clock of Flash is
SPIC_CLK_LIMIT/2. The initial flow will automatically check whether the configured speed is higher than the maximun one or not.
Flash_ReadMode
During the BootRom stage, the SPIC operates in 1IO mode, and switches to the mode specified by Flash_ReadMode (default is 4IO) during the Bootloader stage.
If the currently configured read mode is not supported, the system will automatically try other modes until a compatible mode is found.
Flash_Layout
The default Flash layout in the SDK are illustrated in Chapter Flash Layout . If you want to modify the Flash layout, refer to Section Flash Layout Modification Guide.
Flash Protect Enable
For more information about this function, refer to Section Flash Protection Mechanism .
github source code
Flash_Speed
The frequency of the SPIC controller is set to XTAL (40MHz) during the BootRom stage, and switches to a higher frequency during the Bootloader stage.
The Flash runs at half the speed of the SPIC controller. By default, the SPIC controller’s speed is derived from the PLLM divider, but it must remain below SPIC_CLK_LIMIT (208MHz).
If the Flash needs to run slower, change the value of Flash_Speed, which is the PLLM division factor.
const u16 Flash_Speed = 0xFF;
Note
Refer to ameba_bootcfg for details about the Frequency of PLLM.
The maximum clock of Flash is
SPIC_CLK_LIMIT/2. The initial flow will automatically check whether the configured speed is higher than the maximun one or not.
Flash_ReadMode
During the BootRom stage, the SPIC operates in 1IO mode, and switches to the mode specified by Flash_ReadMode (default is 4IO) during the Bootloader stage.
If the currently configured read mode is not supported, the system will automatically try other modes until a compatible mode is found.
Flash_Layout
The default Flash layout in the SDK are illustrated in Chapter Flash Layout . If you want to modify the Flash layout, refer to Section Flash Layout Modification Guide.
Flash Protect Enable
For more information about this function, refer to Section Flash Protection Mechanism .
github source code
Flash_Speed
The frequency of the SPIC controller is set to XTAL (40MHz) during the BootRom stage, and switches to a higher frequency during the Bootloader stage.
The Flash runs at half the speed of the SPIC controller. By default, the SPIC controller’s speed is derived from the NPPLL divider, but it must remain below SPIC_CLK_LIMIT (208MHz).
If the Flash needs to run slower, change the value of Flash_Speed, which is the NPPLL division factor.
const u16 Flash_Speed = 0x7FF;
Note
Refer to ameba_bootcfg for details about the Frequency of NPPLL.
The maximum clock of Flash is
SPIC_CLK_LIMIT/2. The initial flow will automatically check whether the configured speed is higher than the maximun one or not.
Flash_ReadMode
During the BootRom stage, the SPIC operates in 1IO mode, and switches to the mode specified by Flash_ReadMode (default is 4IO) during the Bootloader stage.
If the currently configured read mode is not supported, the system will automatically try other modes until a compatible mode is found.
Flash_Layout
The default Flash layout in the SDK are illustrated in Chapter Flash Layout . If you want to modify the Flash layout, refer to Section Flash Layout Modification Guide.
Flash Protect Enable
For more information about this function, refer to Section Flash Protection Mechanism .
ameba_boot_trustzonecfg
This section introduces TrustZone-related configurations, focusing primarily on the configuration of the MPC and SAU in chips that support Secure features. If the chip does not support the Secure feature, this configuration profile will be ignored.
github source code
sau_config
Users can configure the security attributes of KM4 by modifying the values in sau_config. Within the specified interval [Start, End], users can set NSC to 0 or 1 to designate whether the area is non-secure.
If
NSCis set to 1, the area will be treated as secure code, i.e., Non-secure Callable (NSC);If
NSCis set to 0, the area will be treated as non-secure code, and Non-secure KM4 will be able to access this area.Areas that are not set will be treated as secure code, accessible by Secure KM4.
mpc1_config
Users can configure the security attributes of certain SRAM intervals by modifying the values in mpc1_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc2_config
Users can configure the security attributes of certain PSRAM intervals by modifying the values in mpc2_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
Note
If the chip supports the TrustZone Secure Image Protection(RDP) feature, this file will be compiled and linked into the Bootloader; Otherwise, this file will be ignored.
You can refer to TrustZone Layout to modify
ameba_boot_trustzonecfg.c.
github source code
sau_config
Users can configure the security attributes of KM4 by modifying the values in sau_config. Within the specified interval [Start, End], users can set NSC to 0 or 1 to designate whether the area is non-secure.
If
NSCis set to 1, the area will be treated as secure code, i.e., Non-secure Callable (NSC);If
NSCis set to 0, the area will be treated as non-secure code, and Non-secure KM4 will be able to access this area.Areas that are not set will be treated as secure code, accessible by Secure KM4.
mpc1_config
Users can configure the security attributes of certain hs_sram0(0x20000000~0x20040000) intervals by modifying the values in mpc1_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc2_config
Users can configure the security attributes of certain hs_sram1(0x20040000~0x20080000) intervals by modifying the values in mpc2_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc3_config
Users can configure the security attributes of certain PSRAM intervals by modifying the values in mpc3_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
Note
If the chip supports the TrustZone Secure Image Protection(RDP) feature, this file will be compiled and linked into the Bootloader; Otherwise, this file will be ignored.
You can refer to TrustZone Layout to modify
ameba_boot_trustzonecfg.c.
github source code
sau_config
Users can configure the security attributes of KM4 by modifying the values in sau_config. Within the specified interval [Start, End], users can set NSC to 0 or 1 to designate whether the area is non-secure.
If
NSCis set to 1, the area will be treated as secure code, i.e., Non-secure Callable (NSC);If
NSCis set to 0, the area will be treated as non-secure code, and Non-secure KM4 will be able to access this area.Areas that are not set will be treated as secure code, accessible by Secure KM4.
mpc1_config
Users can configure the security attributes of certain hs_sram0(0x20000000~0x20040000) intervals by modifying the values in mpc1_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc2_config
Users can configure the security attributes of certain hs_sram1(0x20040000~0x20080000) intervals by modifying the values in mpc2_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc3_config
Users can configure the security attributes of certain PSRAM intervals by modifying the values in mpc3_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
Note
If the chip supports the TrustZone Secure Image Protection(RDP) feature, this file will be compiled and linked into the Bootloader; Otherwise, this file will be ignored.
You can refer to TrustZone Layout to modify
ameba_boot_trustzonecfg.c.
github source code
sau_config
Users can configure the security attributes of KM4 by modifying the values in sau_config. Within the specified interval [Start, End], users can set NSC to 0 or 1 to designate whether the area is non-secure.
If
NSCis set to 1, the area will be treated as secure code, i.e., Non-secure Callable (NSC);If
NSCis set to 0, the area will be treated as non-secure code, and Non-secure KM4 will be able to access this area.Areas that are not set will be treated as secure code, accessible by Secure KM4.
mpc1_config
Users can configure the security attributes of certain hs_sram0(0x20000000~0x20040000) intervals by modifying the values in mpc1_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc2_config
Users can configure the security attributes of certain hs_sram1(0x20040000~0x20080000) intervals by modifying the values in mpc2_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc3_config
Users can configure the security attributes of certain PSRAM intervals by modifying the values in mpc3_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
Note
If the chip supports the TrustZone Secure Image Protection(RDP) feature, this file will be compiled and linked into the Bootloader; Otherwise, this file will be ignored.
You can refer to TrustZone Layout to modify
ameba_boot_trustzonecfg.c.
github source code
sau_config
Users can configure the security attributes of KM4 by modifying the values in sau_config. Within the specified interval [Start, End], users can set NSC to 0 or 1 to designate whether the area is non-secure.
If
NSCis set to 1, the area will be treated as secure code, i.e., Non-secure Callable (NSC);If
NSCis set to 0, the area will be treated as non-secure code, and Non-secure KM4 will be able to access this area.Areas that are not set will be treated as secure code, accessible by Secure KM4.
mpc1_config
Users can configure the security attributes of certain HS_SRAM intervals by modifying the values in mpc1_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
mpc2_config
Users can configure the security attributes of certain PSRAM/DRAM intervals by modifying the values in mpc2_config:
Within the specified interval [Start, End], Non-secure Master can access this area;
Areas that are not set can only be accessed by Secure Master.
Note
If the chip supports the TrustZone Secure Image Protection(RDP) feature, this file will be compiled and linked into the Bootloader; Otherwise, this file will be ignored.
You can refer to TrustZone Layout to modify
ameba_boot_trustzonecfg.c.
ameba_intfcfg
This section introduces peripheral pin assignment, which refers to mapping the physical pins of the chip to various peripheral functions.
github source code
sdio_config
Users can select different pin group of the SDIO device by modifying SDIO_Pin_Grp.
/* sdio pinmux group: 0x0-0x4 */
/* Please refer to SDIO_PAD for more details. */
u8 SDIO_Pin_Grp = 0x2;
SDIO_PAD array is provided by Realtek, which contains multiple pin groups supporting high-speed communication.
/* Please do not modify this table!!! */
const u8 SDIO_PAD[5][6] = {
/* CLK CMD D3 D2 D1 D0 */
{_PA_16, _PA_15, _PA_14, _PA_13, _PA_18, _PA_17}, // Group0: PA13-PA18
{_PA_29, _PA_28, _PA_27, _PA_26, _PA_31, _PA_30}, // Group1: PA26-PA31
{_PB_9, _PB_8, _PB_7, _PB_6, _PB_14, _PB_13}, // Group2: PB6-PB9, PB13-PB14, default
{_PB_19, _PB_18, _PB_17, _PA_12, _PB_21, _PB_20}, // Group3: PA12, PB17-PB21
{_PB_26, _PB_25, _PB_24, _PB_23, _PB_28, _PB_27} // Group4: PB23-PB28
};
Note
To ensure the high-speed transmission performance of SDIO, please do not modify the SDIO_PAD array.
github source code
TBD
github source code
TBD
github source code
TBD
github source code
sdioh_config
Users can configure different parameters of the SD host, including transfer speed, bus width, and function pins, by modifying members in the sdioh_config structure.
SDIOHCFG_TypeDef sdioh_config = {
.sdioh_bus_speed = SD_SPEED_HS, //SD_SPEED_DS or SD_SPEED_HS
.sdioh_bus_width = SDIOH_BUS_WIDTH_4BIT, //SDIOH_BUS_WIDTH_1BIT or SDIOH_BUS_WIDTH_4BIT
.sdioh_cd_pin = _PC_0, // _PC_0 or _PNC
.sdioh_wp_pin = _PNC, //_PB_31 or _PNC
};
ameba_pinmapcfg
This section introduces the pull-up and pull-down status of each pin configged by pinmap_init() during the initialization phase.
github source code
pmap_func
The pmap_func array is mainly used to configure the pull-up and pull-down status of each pin:
The
Func PU/PDcontrols the default pull-up and pull-down states of pins when the SOC is Active. Inmain()or subsequent tasks, the pull-up and pull-down states of pins need to be set according to the specific IP requirements when the SOC is Active.The
Slp PU/PDcontrols the pull-up and pull-down states when the SOC is in Sleep mode. If not set correctly, leakage current may occur on that pin during sleep, Please modify according to the hardware status.
const PMAP_TypeDef pmap_func[] = {
// Pin Name Func PU/PD Slp PU/PD
{_PA_0, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_1, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_2, GPIO_PuPd_KEEP, GPIO_PuPd_UP},
...
};
github source code
pmap_func
The pmap_func array is mainly used to configure the pull-up and pull-down status of each pin:
The
Func PU/PDcontrols the default pull-up and pull-down states of pins when the SOC is Active. Inmain()or subsequent tasks, the pull-up and pull-down states of pins need to be set according to the specific IP requirements when the SOC is Active.The
Slp PU/PDcontrols the pull-up and pull-down states when the SOC is in Sleep mode. If not set correctly, leakage current may occur on that pin during sleep, Please modify according to the hardware status.
const PMAP_TypeDef pmap_func[] = {
// Pin Name Func PU/PD Slp PU/PD
{_PA_0, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_1, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_2, GPIO_PuPd_KEEP, GPIO_PuPd_UP},
...
};
github source code
pmap_func
The pmap_func array is mainly used to configure the pull-up and pull-down status of each pin:
The
Func PU/PDcontrols the default pull-up and pull-down states of pins when the SOC is Active. Inmain()or subsequent tasks, the pull-up and pull-down states of pins need to be set according to the specific IP requirements when the SOC is Active.The
Slp PU/PDcontrols the pull-up and pull-down states when the SOC is in Sleep mode. If not set correctly, leakage current may occur on that pin during sleep, Please modify according to the hardware status.
const PMAP_TypeDef pmap_func[] = {
// Pin Name Func PU/PD Slp PU/PD
{_PA_0, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_1, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_2, GPIO_PuPd_KEEP, GPIO_PuPd_UP},
...
};
github source code
pmap_func
The pmap_func array is mainly used to configure the pull-up and pull-down status of each pin:
The
Func PU/PDcontrols the default pull-up and pull-down states of pins when the SOC is Active. Inmain()or subsequent tasks, the pull-up and pull-down states of pins need to be set according to the specific IP requirements when the SOC is Active.The
Slp PU/PDcontrols the pull-up and pull-down states when the SOC is in Sleep mode. If not set correctly, leakage current may occur on that pin during sleep, Please modify according to the hardware status.
const PMAP_TypeDef pmap_func[] = {
// Pin Name Func PU/PD Slp PU/PD
{_PA_0, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_1, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_2, GPIO_PuPd_KEEP, GPIO_PuPd_UP},
...
};
github source code
pmap_func
The pmap_func array is mainly used to configure the pull-up and pull-down status of each pin:
The
Func PU/PDcontrols the default pull-up and pull-down states of pins when the SOC is Active. Inmain()or subsequent tasks, the pull-up and pull-down states of pins need to be set according to the specific IP requirements when the SOC is Active.The
Slp PU/PDcontrols the pull-up and pull-down states when the SOC is in Sleep mode. If not set correctly, leakage current may occur on that pin during sleep, Please modify according to the hardware status.
const PMAP_TypeDef pmap_func[] = {
// Pin Name Func PU/PD Slp PU/PD
{_PA_0, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_1, GPIO_PuPd_UP, GPIO_PuPd_UP},
{_PA_2, GPIO_PuPd_KEEP, GPIO_PuPd_UP},
...
};
ameba_sleepcfg
Please reference Power-Saving User Config chapter for detail information.
ameba_wificfg
Please reference Wi-Fi User Configuration chapter for detailed Wi-Fi configuration information.