1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: Common Boot for Standard Application Core 15 * 16 * Create: 2021-03-09 17 */ 18 19 #ifndef _BOOT_INIT_H_ 20 #define _BOOT_INIT_H_ 21 22 #include <stddef.h> 23 24 #define FLASH_HEAD_ADDR 0x200000 25 #define FLASH_MEM_SIZE 0x00400000 26 27 #define FLASH_START 0x200000 28 #define FLASH_LEN 0x800000 /* 8M */ 29 30 #define KERNEL_START_ADDR 0x90110000 31 32 #define BOOT_HEAD_ADDR 0x200000 33 #define LOAD_BOOT_ADDR 0xA20000 34 35 #define BOOT_PORTING_RESET_REG 0x40002110 36 #define BOOT_PORTING_RESET_VALUE 0x4 37 38 #define RESET_COUNT_REG 0x40000008 39 #define STATUS_DEBUG_REG_ADDR 0x44000014 // gp reg0 40 41 #define HIBURN_CODELOADER_UART UART_BUS_0 42 #define HIBURN_UART_TX CHIP_FIXED_TX_PIN // 当前驱动没有用到,只有检查 43 #define HIBURN_UART_RX CHIP_FIXED_RX_PIN // 当前驱动没有用到,只有检查 44 #define UART_ROMBOOT_INT_TIMEOUT_DEFAULT 32 45 46 #define FLASHBOOT_MAX_SIZE 0x10000 47 #define SRAM_START_ADDR 0x00100000 /* SRAM 起始地址 */ 48 #define LOADY_MAX_ADDR 0x1000000 /* loady 命令可存储的最大地址(不包括该地址) */ 49 50 #define RAM_MIN_ADDR BOOT_RAM_MIN /* SRAM 可设置的最小起始地址 */ 51 #define RAM_MAX_ADDR BOOT_RAM_MAX 52 53 #define LOAD_MAX_RAM_ADDR (RAM_MAX_ADDR - 0x40) 54 #define LOAD_MIN_SIZE 0x0 /* 0x40(sha256 header len) + 0x20(hash len) + 0x10(tail len) */ 55 #define LOAD_MAX_SIZE 0x1000000 /* 16M */ 56 57 #define RESET_DELAY_MS 100 58 59 #define REPET_TIMES_2 2 60 #define REPET_TIMES_3 3 61 #define REBOOT_MAX_CNT 15 62 #define BOOT_STEP 13 63 64 typedef union { 65 struct { 66 uint32_t fota_fix_app_cnt : 4; /* fota修复app计数使用 */ 67 uint32_t reset_cnt : 4; /* boot阶段软复位次数记录 */ 68 uint32_t resv : 24; 69 } bits; 70 71 uint32_t u32; 72 } gp_reg1_union; 73 74 void start_fastboot(void); 75 void irq_handler(void); 76 77 #endif 78