ameba micropython sdk first commit

This commit is contained in:
xidameng 2020-07-31 22:16:12 +08:00
commit 8508ee6139
5619 changed files with 1874619 additions and 0 deletions

View file

@ -0,0 +1,23 @@
;; Memory information ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Used to define address zones within the ARM address space (Memory).
;;
;; Name may be almost anything
;; AdrSpace must be Memory
;; StartAdr start of memory block
;; EndAdr end of memory block
;; AccType type of access, read-only (R), read-write (RW) or SFR (W)
[Memory]
;; Name AdrSpace StartAdr EndAdr AccType Width
Memory = SRAM Memory 0x10000000 0x1007FFFF RW
Memory = ERAM Memory 0x100E0000 0x100FFFFF RW
Memory = ROM Memory 0x10100000 0x101D7FFF R
Memory = SFR Memory 0x40000000 0x57FFFFFF RW
Memory = PSRAM Memory 0x02000000 0x07FFFFFF RW
Memory = FLASH Memory 0x08000000 0x0FFFFFFF R
TrustedRanges = true
UseSfrFilter = true
[SfrInclude]

View file

@ -0,0 +1,22 @@
;; Memory information ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Used to define address zones within the ARM address space (Memory).
;;
;; Name may be almost anything
;; AdrSpace must be Memory
;; StartAdr start of memory block
;; EndAdr end of memory block
;; AccType type of access, read-only (R), read-write (RW) or SFR (W)
[Memory]
;; Name AdrSpace StartAdr EndAdr AccType Width
Memory = ROM Memory 0x00000000 0x00027FFF R
Memory = SRAM Memory 0x00080000 0x0008FFFF RW
Memory = RRAM Memory 0x000C0000 0x000C3FFF RW
Memory = SFR Memory 0x48000000 0x4FFFFFFF RW
Memory = FLASH Memory 0x08000000 0x0FFFFFFF R
TrustedRanges = true
UseSfrFilter = true
[SfrInclude]

View file

@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008-2015 IAR Systems
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision: 38952 $
//
//------------------------------------------------------------------------------
// You should create a copy of this file in your flash loader project
// and configure it as described below
// when this macro is non-zero, your FlashInit function should accept
// extra 'argc' and 'argv' arguments as specified by the function
// prototype in 'flash_loader.h'
#define USE_ARGC_ARGV 1
// You can customize the memory reserved for passing arguments to FlashInit
// through argc and argv.
#if USE_ARGC_ARGV
// This specifies the maximum allowed number of arguments in argv
#define MAX_ARGS 5
// This specifies the maximum combined size of the arguments, including
// a trailing null for each argument
#define MAX_ARG_SIZE 64
#endif
// If this is true (non-zero), the parameter designating the code destination
// in flash operations will be a 'void *', otherwise it will be a uint32_t.
// Targets where void * is smaller than a code pointer should set this to 0.
#define CODE_ADDR_AS_VOID_PTR 1

View file

@ -0,0 +1,96 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008-2015 IAR Systems
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision: 38952 $
//
//------------------------------------------------------------------------------
#include "flash_config.h"
#include <stdint.h>
#define RESULT_OK 0
#define RESULT_ERROR 1
#define RESULT_OVERRIDE_DEVICE 2
#define RESULT_ERASE_DONE 3
#define RESULT_CUSTOM_FIRST 100
#define RESULT_CUSTOM_LAST 200
#define FLAG_ERASE_ONLY 0x1
#ifndef CODE_ADDR_AS_VOID_PTR
#define CODE_ADDR_AS_VOID_PTR 1
#endif
// These are functions you MUST implement -------------------------------
#if CODE_ADDR_AS_VOID_PTR
#if USE_ARGC_ARGV
uint32_t FlashInit(void *base_of_flash, uint32_t image_size,
uint32_t link_address, uint32_t flags,
int argc, char const *argv[]);
#else
uint32_t FlashInit(void *base_of_flash, uint32_t image_size,
uint32_t link_address, uint32_t flags);
#endif
uint32_t FlashWrite(void *block_start,
uint32_t offset_into_block,
uint32_t count,
char const *buffer);
uint32_t FlashErase(void *block_start,
uint32_t block_size);
#else // !CODE_ADDR_AS_VOID_PTR
#if USE_ARGC_ARGV
uint32_t FlashInit(uint32_t base_of_flash, uint32_t image_size,
uint32_t link_address, uint32_t flags,
int argc, char const *argv[]);
#else
uint32_t FlashInit(uint32_t base_of_flash, uint32_t image_size,
uint32_t link_address, uint32_t flags);
#endif
uint32_t FlashWrite(uint32_t block_start,
uint32_t offset_into_block,
uint32_t count,
char const *buffer);
uint32_t FlashErase(uint32_t block_start,
uint32_t block_size);
#endif // CODE_ADDR_AS_VOID_PTR
// These are functions you MAY implement --------------------------------
#if CODE_ADDR_AS_VOID_PTR
uint32_t FlashChecksum(void const *begin, uint32_t count);
#else
uint32_t FlashChecksum(uint32_t begin, uint32_t count);
#endif
uint32_t FlashSignoff(void);
#define OPTIONAL_CHECKSUM _Pragma("required=FlashChecksumEntry") __root
#define OPTIONAL_SIGNOFF _Pragma("required=FlashSignoffEntry") __root
void FlashChecksumEntry();
void FlashSignoffEntry();
// These are functions you may call -------------------------------------
// If your code cannot be accessed using data pointers, you will have to
// write your own Crc16 function.
uint16_t Crc16(uint8_t const *p, uint32_t len);

View file

@ -0,0 +1,45 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008-2015 IAR Systems
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision: 38952 $
//
//------------------------------------------------------------------------------
#define OVERRIDE_LAYOUT 0x010000
#define OVERRIDE_BUFSIZE 0x020000
#define OVERRIDE_PAGESIZE 0x040000
#define LAYOUT_OVERRIDE_BUFFER ((char*)theFlashParams.buffer)
#define SET_BUFSIZE_OVERRIDE(new_size) theFlashParams.block_size = (new_size)
#define SET_PAGESIZE_OVERRIDE(new_size) theFlashParams.offset_into_block = (new_size)
// parameter passing structure
typedef struct {
uint32_t base_ptr;
uint32_t count;
uint32_t offset_into_block;
void *buffer;
uint32_t block_size;
} FlashParamsHolder;
typedef struct {
uint32_t start;
uint32_t length;
} FlashEraseData;
extern FlashParamsHolder theFlashParams;
extern char FlashBufferStart;
extern char FlashBufferEnd;

View file

@ -0,0 +1,42 @@
call security_config.cmd
if exist %target_dir%\km0_km4_image2.bin (
del %target_dir%\km0_km4_image2.bin
)
:: copy km0_image2_all.bin
if not exist %km0_dir%\km0_image2_all.bin (
xcopy %libdir%\image\km0_image2_all.bin %km0_dir%\
)
:: copy km4_image2_all.bin
if not exist %km4_dir%\km4_image2_all.bin (
xcopy %libdir%\image\km4_image2_all.bin %km4_dir%\
)
if %RSIP_ENABLE% equ 1 (
:: encrpyt km0_image2_all.bin => km0_image2_all-en.bin
%tooldir%\EncTool.exe rsip %km0_dir%\km0_image2_all.bin %km0_dir%\km0_image2_all-en.bin 0x0c000000 %RSIP_KEY% %RSIP_IV%
:: encrpyt km4_image2_all.bin => km4_image2_all-en.bin
%tooldir%\EncTool.exe rsip %km4_dir%\km4_image2_all.bin %km4_dir%\km4_image2_all-en.bin 0x0e000000 %RSIP_KEY% %RSIP_IV%
copy /b %km0_dir%\km0_image2_all-en.bin+%km4_dir%\km4_image2_all-en.bin %target_dir%\km0_km4_image2_tmp.bin
) else (
copy /b %km0_dir%\km0_image2_all.bin+%km4_dir%\km4_image2_all.bin %target_dir%\km0_km4_image2_tmp.bin
)
if %RDP_ENABLE% equ 1 (
if exist %km4_dir%\km4_image3_all-en.bin (
copy /b %target_dir%\km0_km4_image2_tmp.bin+%km4_dir%\km4_image3_all-en.bin+%km4_dir%\km4_image3_psram-en.bin %target_dir%\km0_km4_image2.bin
) else (
rename %target_dir%\km0_km4_image2_tmp.bin km0_km4_image2.bin
)
) else (
rename %target_dir%\km0_km4_image2_tmp.bin km0_km4_image2.bin
)
if exist %target_dir%\km0_km4_image2_tmp.bin (
del %target_dir%\km0_km4_image2_tmp.bin
)

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<flash_board>
<pass>
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_hp.flash</loader>
<range>CODE 0x8000000 0x8001FFF</range>
<abs_offset>0x0</abs_offset>
</pass>
<pass>
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_hp.flash</loader>
<range>CODE 0x8004000 0x8005FFF</range>
<abs_offset>0x4000</abs_offset>
</pass>
<pass>
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_hp.flash</loader>
<range>CODE 0x8006000 0xfffffff</range>
<abs_offset>0x6000</abs_offset>
</pass>
</flash_board>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<flash_device>
<exe>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_hp.out</exe>
<flash_base>0x00000000</flash_base>
<page>4</page>
<block>512 0x1000</block>
<macro>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_hp.mac</macro>
<aggregate>1</aggregate>
</flash_device>

View file

@ -0,0 +1,78 @@
setup()
{
__var tmp;
__message "----- setup start -----\n";
//__hwResetWithStrategy(0, 3);
//__hwReset(1);
__message "----- setup end -----\n";
__delay(200);
/*
tmp = __readMemory32(0x40000014,"Memory"); __delay(10);
__message "0x40000014=",tmp:%x;
__writeMemory32(0x21, 0x40000014, "Memory"); __delay(10);
__writeMemory32(0x1FC00002, 0x40000304, "Memory"); __delay(10);
__writeMemory32(0x400, 0x40000250, "Memory"); __delay(10);
__writeMemory32(0x0, 0x40000340, "Memory"); __delay(10);
__writeMemory32(0xc04, 0x40000230, "Memory"); __delay(10);
__writeMemory32(0x1157, 0x40000210, "Memory"); __delay(10);
__writeMemory32(0x110011, 0x400002c0, "Memory"); __delay(10);
__writeMemory32(0xffffffff, 0x40000320, "Memory"); __delay(10);
*/
/*
__writeMemory32(0x1, 0x40005224, "Memory"); __delay(10);
__writeMemory32(0x2c8, 0x40005004, "Memory"); __delay(10);
__writeMemory32(0xffffd000, 0x40005008, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x22, 0x40005020, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x09032001, 0x40005010, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x2611, 0x40005014, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x68413, 0x40005018, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x42, 0x4000501c, "Memory"); __delay(10);
__delay(3);
// Enable
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
__delay(20);
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(10);
__delay(100);
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
__delay(30);
*/
}
execUserPreload()
{
__var tmp;
setup();
// TODO For AmebaD tmp = __readMemory32(0x40000210, "Memory")|(1<<28);
// TODO For AmebaD __writeMemory32(tmp, 0x40000210, "Memory");
}
execUserSetup()
{
//execUserPreload();
//__loadImage("$TARGET_PATH$ ", 0, 0);
//__writeMemory32(0x80000000, 0x40000218, "Memory");
}
execUserFlashInit() // Called by debugger before loading flash loader in RAM.
{
__var tmp;
__message "----- Prepare hardware for Flashloader -----\n";
//tmp = __readMemory32(0x480003f8, "Memory")|(1<<26);
//__writeMemory32(tmp, 0x480003f8, "Memory");
setup();
__message "----- execUserFlashInit done -----\n";
}

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<flash_board>
<pass>
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_lp.flash</loader>
<range>CODE 0x8000000 0x8001FFF</range>
<abs_offset>0x0</abs_offset>
</pass>
<pass>
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_lp.flash</loader>
<range>CODE 0x8004000 0x8005FFF</range>
<abs_offset>0x4000</abs_offset>
</pass>
<pass>
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_lp.flash</loader>
<range>CODE 0x8006000 0xfffffff</range>
<abs_offset>0x6000</abs_offset>
</pass>
</flash_board>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<flash_device>
<exe>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_lp.out</exe>
<flash_base>0x00000000</flash_base>
<page>4</page>
<block>512 0x1000</block>
<macro>$PROJ_DIR$\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\flashloader\FlashRTL8721D_lp.mac</macro>
<aggregate>1</aggregate>
</flash_device>

View file

@ -0,0 +1,78 @@
setup()
{
__var tmp;
__message "----- setup start -----\n";
//__hwResetWithStrategy(0, 3);
//__hwReset(1);
__message "----- setup end -----\n";
__delay(200);
/*
tmp = __readMemory32(0x40000014,"Memory"); __delay(10);
__message "0x40000014=",tmp:%x;
__writeMemory32(0x21, 0x40000014, "Memory"); __delay(10);
__writeMemory32(0x1FC00002, 0x40000304, "Memory"); __delay(10);
__writeMemory32(0x400, 0x40000250, "Memory"); __delay(10);
__writeMemory32(0x0, 0x40000340, "Memory"); __delay(10);
__writeMemory32(0xc04, 0x40000230, "Memory"); __delay(10);
__writeMemory32(0x1157, 0x40000210, "Memory"); __delay(10);
__writeMemory32(0x110011, 0x400002c0, "Memory"); __delay(10);
__writeMemory32(0xffffffff, 0x40000320, "Memory"); __delay(10);
*/
/*
__writeMemory32(0x1, 0x40005224, "Memory"); __delay(10);
__writeMemory32(0x2c8, 0x40005004, "Memory"); __delay(10);
__writeMemory32(0xffffd000, 0x40005008, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x22, 0x40005020, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x09032001, 0x40005010, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x2611, 0x40005014, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x68413, 0x40005018, "Memory"); __delay(10);
__delay(3);
__writeMemory32(0x42, 0x4000501c, "Memory"); __delay(10);
__delay(3);
// Enable
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
__delay(20);
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(10);
__delay(100);
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
__delay(30);
*/
}
execUserPreload()
{
__var tmp;
setup();
// TODO For AmebaD tmp = __readMemory32(0x40000210, "Memory")|(1<<28);
// TODO For AmebaD __writeMemory32(tmp, 0x40000210, "Memory");
}
execUserSetup()
{
//execUserPreload();
//__loadImage("$TARGET_PATH$ ", 0, 0);
//__writeMemory32(0x80000000, 0x40000218, "Memory");
}
execUserFlashInit() // Called by debugger before loading flash loader in RAM.
{
__var tmp;
__message "----- Prepare hardware for Flashloader -----\n";
//tmp = __readMemory32(0x480003f8, "Memory")|(1<<26);
//__writeMemory32(tmp, 0x480003f8, "Memory");
setup();
__message "----- execUserFlashInit done -----\n";
}

View file

@ -0,0 +1,34 @@
__setup_system()
{
__var tmp;
__hwReset(1);
}
execUserPreload()
{
__message "User execUserPreload....";
__setup_system();
}
execUserSetup()
{
//__var tmp;
//__message "User Setup....";
// if use normal reset, please unmark those 2 lines
//execUserPreload();
//__setup_system();
//__message "User __loadImage....";
//__loadImage("$TARGET_PATH$ ", 0, 0);
}
execUserReset()
{
__var tmp;
__message "User Reset....";
tmp = __readMemory32(0x480003F8, "Memory")|((1<<25));
__writeMemory32(tmp, 0x480003F8, "Memory");
}

View file

@ -0,0 +1,21 @@
cd /D %1
set build_dir=%2
:: Generate build_info.h
::echo off
::echo %date:~0,10%-%time:~0,8%
::echo %USERNAME%
for /f "usebackq" %%i in (`hostname`) do set hostname=%%i
::echo %hostname%
echo #define UTS_VERSION "%date:~0,10%-%time:~0,8%" > %build_dir%\build_info.h
echo #define RTL_FW_COMPILE_TIME "%date:~0,10%-%time:~0,8%" >> %build_dir%\build_info.h
echo #define RTL_FW_COMPILE_DATE "%date:~0,10%" >> %build_dir%\build_info.h
echo #define RTL_FW_COMPILE_BY "%USERNAME%" >> %build_dir%\build_info.h
echo #define RTL_FW_COMPILE_HOST "%hostname%" >> %build_dir%\build_info.h
echo #define RTL_FW_COMPILE_DOMAIN >> %build_dir%\build_info.h
echo #define RTL_FW_COMPILER "IAR compiler" >> %build_dir%\build_info.h
:end
exit

View file

@ -0,0 +1,5 @@
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c "+WScript.Arguments.Item(0)+"\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\rtl8721d_prebuild.bat"+" "+WScript.Arguments.Item(0)+" "+WScript.Arguments.Item(1), 0

View file

@ -0,0 +1,122 @@
cd /D %2
set tooldir=%2\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\tools
set libdir=%2\..\..\..\component\soc\realtek\amebad\misc\bsp
set iartooldir=%3
set km4_dir=Debug\Exe\km4_image
del %km4_dir%\km4_bootloader.map %km4_dir%\km4_bootloader.asm %km4_dir%\km4_bootloader.dbg.axf
cmd /c "%tooldir%\nm Debug/Exe/km4_image/km4_bootloader.axf | %tooldir%\sort > Debug/Exe/km4_image/km4_bootloader.map"
cmd /c "%tooldir%\objdump -d Debug/Exe/km4_image/km4_bootloader.axf > Debug/Exe/km4_image/km4_bootloader.asm"
set ram1_start=0
set ram1_end=0
set xip_image1_start=0x08004020
set xip_image1_end=%xip_image1_start%
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/km4_image/km4_bootloader.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram1_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/km4_image/km4_bootloader.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram1_end=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image1 Debug/Exe/km4_image/km4_bootloader.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set xip_image1_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image1 Debug/Exe/km4_image/km4_bootloader.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set xip_image1_end=0x%%i
echo ram1_start: %ram1_start% > tmp.txt
echo ram1_end: %ram1_end% >> tmp.txt
echo xip_image1_start: %xip_image1_start% >> tmp.txt
echo xip_image1_end: %xip_image1_end% >> tmp.txt
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"PLACEMENT" Debug\List\km4_bootloader\km4_bootloader.map') do (
set skipline=%%i
)
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"Kind" Debug\List\km4_bootloader\km4_bootloader.map') do (
set endline=%%i
)
set /a line=endline-skipline
@echo off&setlocal enabledelayedexpansion
set n=0
(for /f "skip=%skipline% delims=" %%a in (Debug\List\km4_bootloader\km4_bootloader.map) do (
set /a n+=1
if !n! leq %line% echo %%a
))>km4_bootloader1.txt
(for /f "delims=" %%a in (km4_bootloader1.txt) do (
set /p="%%a"<nul | find /V "<Block>"
))>km4_bootloader2.txt
@echo off&setlocal enabledelayedexpansion
set strstart={
set strend=}
set /a m=1
(for /f "delims=" %%a in (km4_bootloader2.txt) do (
set /p="%%a"<nul
echo %%a | find "%strstart%" >nul && set /a m-=1
echo %%a | find "%strend%" >nul && set /a m+=1
if !m!==1 (echo.)
))>km4_bootloader3.txt
findstr /r "place" km4_bootloader3.txt > tmp.txt
del km4_bootloader1.txt
del km4_bootloader2.txt
del km4_bootloader3.txt
::findstr /r "place" Debug\List\km4_bootloader\km4_bootloader.map > tmp.txt
setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /r "IMAGE1" tmp.txt') do (
set "var=%%i"
set "sectname_ram1=!var:~1,2!"
)
for /f "delims=:" %%i in ('findstr /r "xip_image1.text" tmp.txt') do (
set "var=%%i"
set "sectname_xip1=!var:~1,2!"
)
setlocal disabledelayedexpansion
::del tmp.txt
echo sectname_ram1: %sectname_ram1% sectname_xip: %sectname_xip1%
%tooldir%\objcopy --rename-section "%sectname_ram1% rw"="%sectname_ram1%" Debug/Exe/km4_image/km4_bootloader.axf Debug/Exe/km4_image/km4_bootloader.axf
%tooldir%\objcopy --rename-section "%sectname_xip1% rw"="%sectname_xip1%" Debug/Exe/km4_image/km4_bootloader.axf Debug/Exe/km4_image/km4_bootloader.axf
:: pick ram_1.bin
%tooldir%\objcopy -j "%sectname_ram1%" -Obinary Debug/Exe/km4_image/km4_bootloader.axf Debug/Exe/km4_image/ram_1.bin
:: add header
%tooldir%\pick %ram1_start% %ram1_end% %km4_dir%\ram_1.bin %km4_dir%\ram_1.p.bin boot
:: pick xip_image1.bin
%tooldir%\objcopy -j "%sectname_xip1%" -Obinary Debug/Exe/km4_image/km4_bootloader.axf Debug/Exe/km4_image/xip_image1.bin
:: add header
%tooldir%\pick %xip_image1_start% %xip_image1_end% %km4_dir%\xip_image1.bin %km4_dir%\xip_image1.p.bin boot
:: aggregate km4_boot_all.bin
copy /b %km4_dir%\xip_image1.p.bin+%km4_dir%\ram_1.p.bin %km4_dir%\km4_boot_all.bin
del %km4_dir%\ram_1.bin
del %km4_dir%\ram_1.p.bin
del %km4_dir%\xip_image1.bin
del %km4_dir%\xip_image1.p.bin
rename %km4_dir%\km4_bootloader.axf km4_bootloader.dbg.axf
call security_config.cmd
if %SBOOT_ENABLE% equ 1 (
:: ECC sign
%tooldir%\EncTool.exe sboot %km4_dir%\km4_boot_all.bin %km4_dir%\km4_boot_all-sb.bin key_pair.txt %SBOOT_SEED%
del %km4_dir%\km4_boot_all.bin
rename %km4_dir%\km4_boot_all-sb.bin km4_boot_all.bin
)
if %RSIP_ENABLE% equ 1 (
:: RSIP encryption km4_boot_all.bin ==> km4_boot_all-en.bin
%tooldir%\EncTool.exe rsip %km4_dir%\km4_boot_all.bin %km4_dir%\km4_boot_all-en.bin 0x08004000 %RSIP_KEY% %RSIP_IV%
del %km4_dir%\km4_boot_all.bin
rename %km4_dir%\km4_boot_all-en.bin km4_boot_all.bin
)
%iartooldir%\bin\ilinkarm.exe %tooldir%\link_dummy_hp.o --image_input %km4_dir%\km4_boot_all.bin,boot_start,hs_boot,32 --cpu Cortex-M33 --fpu=VFPv5 --no_entry --keep boot_start --config rtl8721d_FLASH.icf --no_library_search --define_symbol __vector_table=0x10100000 -o %km4_dir%\km4_bootloader.axf
exit

View file

@ -0,0 +1,6 @@
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c """""+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\rtl8721dhp_postbuild_img1.bat"" """+WScript.Arguments.Item(0)+""" """+WScript.Arguments.Item(1)+""" """+WScript.Arguments.Item(2)+""" """, 1

View file

@ -0,0 +1,134 @@
cd /D %2
set tooldir=%2\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\tools
set libdir=%2\..\..\..\component\soc\realtek\amebad\misc\bsp
set iartooldir=%3
set build_type=%4
set km4_dir=Debug\Exe\km4_image
set km0_dir=Debug\Exe\km0_image
del %km4_dir%\km4_application.map %km4_dir%\km4_application.asm %km4_dir%\km4_application.dbg.axf
cmd /c "%tooldir%\nm Debug/Exe/km4_image/km4_application.axf | %tooldir%\sort > Debug/Exe/km4_image/km4_application.map"
cmd /c "%tooldir%\objdump -d Debug/Exe/km4_image/km4_application.axf > Debug/Exe/km4_image/km4_application.asm"
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 Debug/Exe/km4_image/km4_application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram2_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 Debug/Exe/km4_image/km4_application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram2_end=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image2 Debug/Exe/km4_image/km4_application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set xip_image2_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image2 Debug/Exe/km4_image/km4_application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set xip_image2_end=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMG2_PSRAM Debug/Exe/km4_image/km4_application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set psram2_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMG2_PSRAM Debug/Exe/km4_image/km4_application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set psram2_end=0x%%i
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"PLACEMENT" Debug\List\km4_application\km4_application.map') do (
set skipline=%%i
)
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"Kind" Debug\List\km4_application\km4_application.map') do (
set endline=%%i
)
set /a line=endline-skipline
@echo off&setlocal enabledelayedexpansion
set n=0
(for /f "skip=%skipline% delims=" %%a in (Debug\List\km4_application\km4_application.map) do (
set /a n+=1
if !n! leq %line% echo %%a
))>km4_application1.txt
(for /f "delims=" %%a in (km4_application1.txt) do (
set /p="%%a"<nul | find /V "<Block>"
))>km4_application2.txt
@echo off&setlocal enabledelayedexpansion
set strstart={
set strend=}
set /a m=1
(for /f "delims=" %%a in (km4_application2.txt) do (
set /p="%%a"<nul
echo %%a | find "%strstart%" >nul && set /a m-=1
echo %%a | find "%strend%" >nul && set /a m+=1
if !m!==1 (echo.)
))>km4_application3.txt
findstr /r "place" km4_application3.txt > tmp.txt
del km4_application1.txt
del km4_application2.txt
del km4_application3.txt
setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /r "IMAGE2" tmp.txt') do (
set "var=%%i"
set "sectname_ram2=!var:~1,2!"
)
for /f "delims=:" %%i in ('findstr /r "xip_image2.text" tmp.txt') do (
set "var=%%i"
set "sectname_xip=!var:~1,2!"
)
for /f "delims=:" %%i in ('findstr /r "IMG2_PSRAM" tmp.txt') do (
set "var=%%i"
set "sectname_psram2=!var:~1,2!"
)
setlocal disabledelayedexpansion
del tmp.txt
echo sectname_ram2: %sectname_ram2% sectname_xip: %sectname_xip% sectname_psram2: %sectname_psram2%
%tooldir%\objcopy --rename-section "%sectname_ram2% rw"="%sectname_ram2%" Debug/Exe/km4_image/km4_application.axf Debug/Exe/km4_image/km4_application.axf
%tooldir%\objcopy --rename-section "%sectname_xip% rw"="%sectname_xip%" Debug/Exe/km4_image/km4_application.axf Debug/Exe/km4_image/km4_application.axf
%tooldir%\objcopy --rename-section "%sectname_psram2% rw"="%sectname_psram2%" Debug/Exe/km4_image/km4_application.axf Debug/Exe/km4_image/km4_application.axf
%tooldir%\objcopy -j "%sectname_ram2%" -Obinary Debug/Exe/km4_image/km4_application.axf Debug/Exe/km4_image/ram_2.r.bin
%tooldir%\objcopy -j "%sectname_xip%" -Obinary Debug/Exe/km4_image/km4_application.axf Debug/Exe/km4_image/xip_image2.bin
%tooldir%\objcopy -j "%sectname_psram2%" -Obinary Debug/Exe/km4_image/km4_application.axf Debug/Exe/km4_image/psram_2.r.bin
:: remove bss sections
%tooldir%\pick %ram2_start% %ram2_end% %km4_dir%\ram_2.r.bin %km4_dir%\ram_2.bin raw
del %km4_dir%\ram_2.r.bin
%tooldir%\pick %psram2_start% %psram2_end% %km4_dir%\psram_2.r.bin %km4_dir%\psram_2.bin raw
del %km4_dir%\psram_2.r.bin
:: dword aligned
%tooldir%\pad %km4_dir%\ram_2.bin 4
%tooldir%\pad %km4_dir%\xip_image2.bin 4
%tooldir%\pad %km4_dir%\psram_2.bin 4
set /a ram2_end_align=(((%ram2_end% - 1)/4) + 1)*4
set /a xip_image2_end_align=(((%xip_image2_end% - 1)/4) + 1)*4
set /a psram2_end_align=(((%psram2_end% - 1)/4) + 1)*4
:: add header
%tooldir%\pick %ram2_start% %ram2_end_align% %km4_dir%\ram_2.bin %km4_dir%\ram_2.p.bin
%tooldir%\pick %xip_image2_start% %xip_image2_end_align% %km4_dir%\xip_image2.bin %km4_dir%\xip_image2.p.bin
%tooldir%\pick %psram2_start% %psram2_end_align% %km4_dir%\psram_2.bin %km4_dir%\psram_2.p.bin
:: aggregate image2_all.bin
copy /b %km4_dir%\xip_image2.p.bin+%km4_dir%\ram_2.p.bin+%km4_dir%\psram_2.p.bin %km4_dir%\km4_image2_all.bin
%tooldir%\pad %km4_dir%\km4_image2_all.bin 4096
del %km4_dir%\ram_2.bin
del %km4_dir%\ram_2.p.bin
del %km4_dir%\xip_image2.bin
del %km4_dir%\xip_image2.p.bin
del %km4_dir%\psram_2.bin
del %km4_dir%\psram_2.p.bin
rename %km4_dir%\km4_application.axf km4_application.dbg.axf
if %build_type% equ "mp" (
copy /b %km0_dir%\km0_image2_all.bin+%km4_dir%\km4_image2_all.bin+%km4_dir%\km4_image3_all.bin+%km4_dir%\km4_image3_psram.bin %km4_dir%\km0_km4_image2.bin
) else (
set target_dir=%km4_dir%
call %tooldir%\..\combine_img2.bat
)
%iartooldir%\bin\ilinkarm.exe %tooldir%\link_dummy_hp.o --image_input %km4_dir%\km0_km4_image2.bin,flash_start,firmware,32 --cpu Cortex-M33 --fpu=VFPv5 --no_entry --keep flash_start --config rtl8721d_FLASH.icf --no_library_search --define_symbol __vector_table=0x10100000 -o %km4_dir%\km4_application.axf
if %build_type% equ "mp" (
del %km4_dir%\km0_km4_image2_mp.bin
rename %km4_dir%\km0_km4_image2.bin km0_km4_image2_mp.bin
)
%tooldir%\objcopy -I elf32-little -j "BTTRACE rw" -Obinary %km4_dir%\km4_application.dbg.axf %km4_dir%\APP.trace
exit

View file

@ -0,0 +1,6 @@
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c """""+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\rtl8721dhp_postbuild_img2.bat"" """+WScript.Arguments.Item(0)+""" """+WScript.Arguments.Item(1)+""" """+WScript.Arguments.Item(2)+""" """+WScript.Arguments.Item(3)+""" """, 1

View file

@ -0,0 +1,125 @@
cd /D %2
set tooldir=%2\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\tools
set libdir=%2\..\..\..\component\soc\realtek\amebad\misc\bsp
set build_type=%3
set km4_dir=Debug\Exe\km4_image
del %km4_dir%\km4_secure.map %km4_dir%\km4_secure.asm *.bin
cmd /c "%tooldir%\nm Debug/Exe/km4_image/km4_secure.axf | %tooldir%\sort > Debug/Exe/km4_image/km4_secure.map"
cmd /c "%tooldir%\objdump -d Debug/Exe/km4_image/km4_secure.axf > Debug/Exe/km4_image/km4_secure.asm"
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE3 Debug/Exe/km4_image/km4_secure.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram3_s_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE3 Debug/Exe/km4_image/km4_secure.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram3_s_end=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep CMSE Debug/Exe/km4_image/km4_secure.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram3_nsc_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep CMSE Debug/Exe/km4_image/km4_secure.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram3_nsc_end=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMG3_PSRAM Debug/Exe/km4_image/km4_secure.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set psram3_s_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMG3_PSRAM Debug/Exe/km4_image/km4_secure.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set psram3_s_end=0x%%i
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"PLACEMENT" Debug\List\km4_secure\km4_secure.map') do (
set skipline=%%i
)
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"Kind" Debug\List\km4_secure\km4_secure.map') do (
set endline=%%i
)
set /a line=endline-skipline
@echo off&setlocal enabledelayedexpansion
set n=0
(for /f "skip=%skipline% delims=" %%a in (Debug\List\km4_secure\km4_secure.map) do (
set /a n+=1
if !n! leq %line% echo %%a
))>km4_secure1.txt
(for /f "delims=" %%a in (km4_secure1.txt) do (
set /p="%%a"<nul | find /V "<Block>"
))>km4_secure2.txt
@echo off&setlocal enabledelayedexpansion
set strstart={
set strend=}
set /a m=1
(for /f "delims=" %%a in (km4_secure2.txt) do (
set /p="%%a"<nul
echo %%a | find "%strstart%" >nul && set /a m-=1
echo %%a | find "%strend%" >nul && set /a m+=1
if !m!==1 (echo.)
))>km4_secure3.txt
findstr /r "place" km4_secure3.txt > tmp.txt
del km4_secure1.txt
del km4_secure2.txt
del km4_secure3.txt
setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /r "IMAGE3" tmp.txt') do (
set "var=%%i"
set "sectname_ram3=!var:~1,2!"
)
for /f "delims=:" %%i in ('findstr /r ".nsc.text" tmp.txt') do (
set "var=%%i"
set "sectname_ram3_nsc=!var:~1,2!"
)
for /f "delims=:" %%i in ('findstr /r "IMG3_PSRAM" tmp.txt') do (
set "var=%%i"
set "sectname_psram3=!var:~1,2!"
)
setlocal disabledelayedexpansion
del tmp.txt
echo sectname_ram3: %sectname_ram3% sectname_ram3_nsc: %sectname_ram3_nsc% sectname_psram3: %sectname_psram3%
%tooldir%\objcopy --rename-section "%sectname_ram3% rw"="%sectname_ram3%" Debug/Exe/km4_image/km4_secure.axf Debug/Exe/km4_image/km4_secure.axf
%tooldir%\objcopy --rename-section "%sectname_ram3_nsc% rw"="%sectname_ram3_nsc%" Debug/Exe/km4_image/km4_secure.axf Debug/Exe/km4_image/km4_secure.axf
%tooldir%\objcopy --rename-section "%sectname_psram3% rw"="%sectname_psram3%" Debug/Exe/km4_image/km4_secure.axf Debug/Exe/km4_image/km4_secure.axf
%tooldir%\objcopy -j "%sectname_ram3%" -Obinary Debug/Exe/km4_image/km4_secure.axf Debug/Exe/km4_image/ram3_s.r.bin
%tooldir%\objcopy -j "%sectname_ram3_nsc%" -Obinary Debug/Exe/km4_image/km4_secure.axf Debug/Exe/km4_image/ram3_nsc.bin
%tooldir%\objcopy -j "%sectname_psram3%" -Obinary Debug/Exe/km4_image/km4_secure.axf Debug/Exe/km4_image/psram3_s.r.bin
:: remove bss sections
%tooldir%\pick %ram3_s_start% %ram3_s_end% %km4_dir%\ram3_s.r.bin %km4_dir%\ram3_s.bin raw
%tooldir%\pick %psram3_s_start% %psram3_s_end% %km4_dir%\psram3_s.r.bin %km4_dir%\psram3_s.bin raw
%tooldir%\pad %km4_dir%\ram3_s.bin 16
%tooldir%\pad %km4_dir%\ram3_nsc.bin 16
%tooldir%\pad %km4_dir%\psram3_s.bin 16
set /a ram3_s_end_aligned=(((%ram3_s_end%-1)">>"4)+1)"<<"4
set /a ram3_nsc_end_aligned=(((%ram3_nsc_end%-1)">>"4)+1)"<<"4
set /a psram3_s_end_aligned=(((%psram3_s_end%-1)">>"4)+1)"<<"4
:: add header
%tooldir%\pick %ram3_s_start% %ram3_s_end_aligned% %km4_dir%\ram3_s.bin %km4_dir%\ram3_s.p.bin
%tooldir%\pick %ram3_nsc_start% %ram3_nsc_end_aligned% %km4_dir%\ram3_nsc.bin %km4_dir%\ram3_nsc.p.bin
%tooldir%\pick %psram3_s_start% %psram3_s_end_aligned% %km4_dir%\psram3_s.bin %km4_dir%\km4_image3_psram.bin
copy /b %km4_dir%\ram3_s.p.bin+%km4_dir%\ram3_nsc.p.bin %km4_dir%\km4_image3_all.bin
::copy /b %km4_dir%\km0_km4_image2.bin+%km4_dir%\km4_image3_all.bin %km4_dir%\km4_image_all.bin
call security_config.cmd
:: RDP encryption km4_image3_all.bin ==> km4_image3_all-en.bin
if %RDP_ENABLE% equ 1 (
%tooldir%\EncTool.exe rdp %km4_dir%\km4_image3_all.bin %km4_dir%\km4_image3_all-en.bin %RDP_KEY%
%tooldir%\EncTool.exe rdp %km4_dir%\km4_image3_psram.bin %km4_dir%\km4_image3_psram-en.bin %RDP_KEY%
)
del %km4_dir%\ram3_s.r.bin
del %km4_dir%\ram3_s.bin
del %km4_dir%\ram3_s.p.bin
del %km4_dir%\ram3_nsc.bin
del %km4_dir%\ram3_nsc.p.bin
del %km4_dir%\psram3_s.r.bin
del %km4_dir%\psram3_s.bin
if %build_type% equ mp (
copy %km4_dir%\cmse_implib_mp.a %libdir%\lib\common\IAR\cmse_implib_mp.a
) else (
copy %km4_dir%\cmse_implib.a %libdir%\lib\common\IAR\cmse_implib.a
)
exit

View file

@ -0,0 +1,5 @@
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c "+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\rtl8721dhp_postbuild_img3.bat "+WScript.Arguments.Item(0)+" "+WScript.Arguments.Item(1)+" "+WScript.Arguments.Item(2), 1

View file

@ -0,0 +1,103 @@
cd /D %2
set tooldir=%2\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\tools
set libdir=%2\..\..\..\component\soc\realtek\amebad\misc\bsp
set iartooldir=%3
set km0_dir=Debug\Exe\km0_image
del %km0_dir%\km0_bootloader.map %km0_dir%\km0_bootloader.asm %km0_dir%\km0_bootloader.dbg.axf
cmd /c "%tooldir%\nm Debug/Exe/km0_image/km0_bootloader.axf | %tooldir%\sort > Debug/Exe/km0_image/km0_bootloader.map"
cmd /c "%tooldir%\objdump -d Debug/Exe/km0_image/km0_bootloader.axf > Debug/Exe/km0_image/km0_bootloader.asm"
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/km0_image/km0_bootloader.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram1_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/km0_image/km0_bootloader.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram1_end=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image1 Debug/Exe/km0_image/km0_bootloader.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set xip_image1_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image1 Debug/Exe/km0_image/km0_bootloader.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set xip_image1_end=0x%%i
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"PLACEMENT" Debug\List\km0_bootloader\km0_bootloader.map') do (
set skipline=%%i
)
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"Kind" Debug\List\km0_bootloader\km0_bootloader.map') do (
set endline=%%i
)
set /a line=endline-skipline
@echo off&setlocal enabledelayedexpansion
set n=0
(for /f "skip=%skipline% delims=" %%a in (Debug\List\km0_bootloader\km0_bootloader.map) do (
set /a n+=1
if !n! leq %line% echo %%a
))>km0_bootloader1.txt
(for /f "delims=" %%a in (km0_bootloader1.txt) do (
set /p="%%a"<nul | find /V "<Block>"
))>km0_bootloader2.txt
@echo off&setlocal enabledelayedexpansion
set strstart={
set strend=}
set /a m=1
(for /f "delims=" %%a in (km0_bootloader2.txt) do (
set /p="%%a"<nul
echo %%a | find "%strstart%" >nul && set /a m-=1
echo %%a | find "%strend%" >nul && set /a m+=1
if !m!==1 (echo.)
))>km0_bootloader3.txt
findstr /r "place" km0_bootloader3.txt > tmp.txt
del km0_bootloader1.txt
del km0_bootloader2.txt
del km0_bootloader3.txt
setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /r "IMAGE1" tmp.txt') do (
set "var=%%i"
set "sectname_ram1=!var:~1,2!"
)
for /f "delims=:" %%i in ('findstr /r "xip_image1.text" tmp.txt') do (
set "var=%%i"
set "sectname_xip1=!var:~1,2!"
)
setlocal disabledelayedexpansion
::del tmp.txt
echo sectname_ram1: %sectname_ram1% sectname_xip: %sectname_xip1%
%tooldir%\objcopy --rename-section "%sectname_ram1% rw"="%sectname_ram1%" Debug/Exe/km0_image/km0_bootloader.axf Debug/Exe/km0_image/km0_bootloader.axf
%tooldir%\objcopy --rename-section "%sectname_xip1% rw"="%sectname_xip1%" Debug/Exe/km0_image/km0_bootloader.axf Debug/Exe/km0_image/km0_bootloader.axf
:: pick ram_1.bin
%tooldir%\objcopy -j "%sectname_ram1%" -Obinary Debug/Exe/km0_image/km0_bootloader.axf Debug/Exe/km0_image/ram_1.bin
:: add header
%tooldir%\pick %ram1_start% %ram1_end% %km0_dir%\ram_1.bin %km0_dir%\ram_1.p.bin boot
:: pick xip_image1.bin
%tooldir%\objcopy -j "%sectname_xip1%" -Obinary Debug/Exe/km0_image/km0_bootloader.axf Debug/Exe/km0_image/xip_image1.bin
:: add header
%tooldir%\pick %xip_image1_start% %xip_image1_end% %km0_dir%\xip_image1.bin %km0_dir%\xip_image1.p.bin boot
:: aggregate km0_boot_all.bin
copy /b %km0_dir%\xip_image1.p.bin+%km0_dir%\ram_1.p.bin %km0_dir%\km0_boot_all.bin
del %km0_dir%\ram_1.bin
del %km0_dir%\ram_1.p.bin
del %km0_dir%\xip_image1.bin
del %km0_dir%\xip_image1.p.bin
rename %km0_dir%\km0_bootloader.axf km0_bootloader.dbg.axf
call security_config.cmd
if %RSIP_ENABLE% equ 1 (
:: RSIP encryption km4_boot_all.bin ==> km4_boot_all-en.bin
%tooldir%\EncTool.exe rsip %km0_dir%\km0_boot_all.bin %km0_dir%\km0_boot_all-en.bin 0x08000000 %RSIP_KEY% %RSIP_IV%
del %km0_dir%\km0_boot_all.bin
rename %km0_dir%\km0_boot_all-en.bin km0_boot_all.bin
)
%iartooldir%\bin\ilinkarm.exe %tooldir%\link_dummy_lp.o --image_input %km0_dir%\km0_boot_all.bin,boot_start,ls_boot,32 --cpu Cortex-M23 --no_entry --keep boot_start --config rtl8721d_FLASH.icf --no_library_search --define_symbol __vector_table=0x00 -o %km0_dir%\km0_bootloader.axf
exit

View file

@ -0,0 +1,5 @@
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c """""+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\rtl8721dlp_postbuild_img1.bat"" """+WScript.Arguments.Item(0)+""" """+WScript.Arguments.Item(1)+""" """+WScript.Arguments.Item(2)+""" """, 1

View file

@ -0,0 +1,114 @@
cd /D %2
set tooldir=%2\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\tools
set libdir=%2\..\..\..\component\soc\realtek\amebad\misc\bsp
set iartooldir=%3
set km4_dir=Debug\Exe\km4_image
set km0_dir=Debug\Exe\km0_image
echo input1=%1 >tmp.txt
echo input2=%2 >>tmp.txt
del %km0_dir%\km0_application.map %km0_dir%\km0_application.asm %km0_dir%\km0_application.dbg.axf
cmd /c "%tooldir%\nm Debug/Exe/km0_image/km0_application.axf | %tooldir%\sort > Debug/Exe/km0_image/km0_application.map"
cmd /c "%tooldir%\objdump -d Debug/Exe/km0_image/km0_application.axf > Debug/Exe/km0_image/km0_application.asm"
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 Debug/Exe/km0_image/km0_application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram2_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 Debug/Exe/km0_image/km0_application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram2_end=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image2 Debug/Exe/km0_image/km0_application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set xip_image2_start=0x%%i
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep xip_image2 Debug/Exe/km0_image/km0_application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set xip_image2_end=0x%%i
echo ram2_start: %ram2_start% > tmp.txt
echo ram2_end: %ram2_end% >> tmp.txt
echo xip_image2_start: %xip_image2_start% >> tmp.txt
echo xip_image2_end: %xip_image2_end% >> tmp.txt
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"PLACEMENT" Debug\List\km0_application\km0_application.map') do (
set skipline=%%i
)
@echo off&setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /n /c:"Kind" Debug\List\km0_application\km0_application.map') do (
set endline=%%i
)
set /a line=endline-skipline
@echo off&setlocal enabledelayedexpansion
set n=0
(for /f "skip=%skipline% delims=" %%a in (Debug\List\km0_application\km0_application.map) do (
set /a n+=1
if !n! leq %line% echo %%a
))>km0_application1.txt
(for /f "delims=" %%a in (km0_application1.txt) do (
set /p="%%a"<nul | find /V "<Block>"
))>km0_application2.txt
@echo off&setlocal enabledelayedexpansion
set strstart={
set strend=}
set /a m=1
(for /f "delims=" %%a in (km0_application2.txt) do (
set /p="%%a"<nul
echo %%a | find "%strstart%" >nul && set /a m-=1
echo %%a | find "%strend%" >nul && set /a m+=1
if !m!==1 (echo.)
))>km0_application3.txt
findstr /r "place" km0_application3.txt > tmp.txt
del km0_application1.txt
del km0_application2.txt
del km0_application3.txt
setlocal enabledelayedexpansion
for /f "delims=:" %%i in ('findstr /r "IMAGE2" tmp.txt') do (
set "var=%%i"
set "sectname_ram2=!var:~1,2!"
)
for /f "delims=:" %%i in ('findstr /r "xip_image2.text" tmp.txt') do (
set "var=%%i"
set "sectname_xip=!var:~1,2!"
)
setlocal disabledelayedexpansion
del tmp.txt
::echo sectname_ram2: %sectname_ram2% sectname_xip: %sectname_xip%
%tooldir%\objcopy --rename-section "%sectname_ram2% rw"="%sectname_ram2%" Debug/Exe/km0_image/km0_application.axf Debug/Exe/km0_image/km0_application.axf
%tooldir%\objcopy --rename-section "%sectname_xip% rw"="%sectname_xip%" Debug/Exe/km0_image/km0_application.axf Debug/Exe/km0_image/km0_application.axf
%tooldir%\objcopy -j "%sectname_ram2%" -Obinary Debug/Exe/km0_image/km0_application.axf Debug/Exe/km0_image/ram_2.r.bin
%tooldir%\objcopy -j "%sectname_xip%" -Obinary Debug/Exe/km0_image/km0_application.axf Debug/Exe/km0_image/xip_image2.bin
:: remove bss sections
%tooldir%\pick %ram2_start% %ram2_end% %km0_dir%\ram_2.r.bin %km0_dir%\ram_2.bin raw
del %km0_dir%\ram_2.r.bin
:: dword aligned
%tooldir%\pad %km0_dir%\ram_2.bin 4
%tooldir%\pad %km0_dir%\xip_image2.bin 4
set /a ram2_end_align=(((%ram2_end% - 1)/4) + 1)*4
set /a xip_image2_end_align=(((%xip_image2_end% - 1)/4) + 1)*4
:: add header
%tooldir%\pick %ram2_start% %ram2_end_align% %km0_dir%\ram_2.bin %km0_dir%\ram_2.p.bin
%tooldir%\pick %xip_image2_start% %xip_image2_end_align% %km0_dir%\xip_image2.bin %km0_dir%\xip_image2.p.bin
:: aggregate image2_all.bin
copy /b %km0_dir%\xip_image2.p.bin+%km0_dir%\ram_2.p.bin %km0_dir%\km0_image2_all.bin
%tooldir%\pad %km0_dir%\km0_image2_all.bin 4096
del %km0_dir%\ram_2.bin
del %km0_dir%\ram_2.p.bin
del %km0_dir%\xip_image2.bin
del %km0_dir%\xip_image2.p.bin
rename %km0_dir%\km0_application.axf km0_application.dbg.axf
set target_dir=%km0_dir%
call %tooldir%\..\combine_img2.bat
%iartooldir%\bin\ilinkarm.exe %tooldir%\link_dummy_lp.o --image_input %km0_dir%\km0_km4_image2.bin,flash_start,firmware,32 --cpu Cortex-M23 --no_entry --keep flash_start --config rtl8721d_FLASH.icf --no_library_search --define_symbol __vector_table=0x00 -o %km0_dir%\km0_application.axf
exit

View file

@ -0,0 +1,5 @@
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c """""+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\amebad\misc\iar_utility\common\rtl8721dlp_postbuild_img2.bat"" """+WScript.Arguments.Item(0)+""" """+WScript.Arguments.Item(1)+""" """+WScript.Arguments.Item(2)+""" """, 1

View file

@ -0,0 +1,96 @@
#ifndef _FREERTOS_PMU_8721D_H_
#define _FREERTOS_PMU_8721D_H_
typedef enum {
PMU_OS =0,
PMU_WLAN_DEVICE =1,
PMU_LOGUART_DEVICE =2,
PMU_KM4_RUN =3,
PMU_UART0_DEVICE =4,
PMU_UART1_DEVICE =5,
PMU_I2C0_DEVICE =6,
PMU_TOUCH_DEVICE =7,
PMU_USOC_DEVICE =8,
PMU_DONGLE_DEVICE =9,
PMU_RTC_DEVICE =10,
PMU_CONSOL_DEVICE =11,
PMU_ADC_DEVICE =12,
PMU_WAKWLOCK_TIMEOUT=13,
PMU_KEYSCAN_DEVICE =14,
PMU_PSRAM_DEVICE =15,
PMU_DEV_USER_BASE =16, /*number 16 ~ 31 is reserved for customer use*/
PMU_MAX =31
} PMU_DEVICE;
enum SLEEP_TYPE {
SLEEP_PG = 0,
SLEEP_CG = 1,
};
// default locked by OS and not to sleep until OS release wakelock in somewhere
#if defined (ARM_CORE_CM4)
#define DEFAULT_WAKELOCK (BIT(PMU_OS))
#else
#define DEFAULT_WAKELOCK (BIT(PMU_OS))
#endif
#define DEFAULT_DEEP_WAKELOCK (BIT(PMU_OS))
#define SLEEP_MAX_DELAY (u32) 0xffffffffUL
typedef uint32_t (*PSM_HOOK_FUN)( unsigned int, void* param_ptr );
#define PMU_DEVICE_TIMER_DEFAULT_INTERVAL 2000
#define PMU_DEVICE_TIMER_MAX_INTERVAL (1000*30) /* max 30sec */
typedef struct
{
u32 nDeviceId;
PSM_HOOK_FUN sleep_hook_fun;
void* sleep_param_ptr;
PSM_HOOK_FUN wakeup_hook_fun;
void* wakeup_param_ptr;
}PSM_DD_HOOK_INFO;
/**
* @brief init system active timer for PMU.
* @param none.
* @retval status value:
* - 0: _FAIL
* - 1: _SUCCESS
* @note can just used in late resume or later, can not used in wakeup_hook_fun.
*/
uint32_t pmu_yield_os_check(void);
u32 pmu_exec_sleep_hook_funs(void);
void pmu_exec_wakeup_hook_funs(u32 nDeviceIdMax);
uint32_t pmu_set_sleep_type(uint32_t type);
uint32_t pmu_get_sleep_type(void);
void pmu_set_max_sleep_time(uint32_t timer_ms);
#ifndef CONFIG_BUILD_ROM
void pmu_deepsleep_cmd(u32 NewStatus);
#endif
void pmu_tickless_debug(u32 NewStatus);
void pmu_set_dsleep_active_time(uint32_t TimeOutMs);
void pmu_acquire_deepwakelock(uint32_t nDeviceId);
void pmu_release_deepwakelock(uint32_t nDeviceId);
void pmu_set_dev_wakeup_tick(u32 nDeviceId, u32 Ms);
uint32_t pmu_set_sysactive_time(uint32_t timeout);
void pmu_register_sleep_callback(u32 nDeviceId, PSM_HOOK_FUN sleep_hook_fun, void* sleep_param_ptr, PSM_HOOK_FUN wakeup_hook_fun, void* wakeup_param_ptr);
void pmu_unregister_sleep_callback(u32 nDeviceId);
int freertos_ready_to_sleep(void);
int freertos_ready_to_dsleep(void);
void freertos_pre_sleep_processing(unsigned int *expected_idle_time);
void freertos_post_sleep_processing(unsigned int *expected_idle_time);
void pmu_acquire_wakelock(uint32_t nDeviceId);
void pmu_release_wakelock(uint32_t nDeviceId);
uint32_t pmu_get_wakelock_status(void);
uint32_t pmu_get_deepwakelock_status(void);
extern u32 tickless_debug;
extern u32 tick_last_tcp;
#endif