This commit is contained in:
刘可亮
2024-10-30 16:50:31 +08:00
parent 0ef85b55da
commit 661e71562d
458 changed files with 46555 additions and 12133 deletions

View File

@@ -8,18 +8,25 @@ config AIC_BOOTLOADER
select AIC_USING_UMM_HEAP
menu "Memory"
config AIC_BOOTLOADER_MEM_AUTO
bool "Bootloader memory auto config"
default y
config AIC_BOOTLOADER_TEXT_BASE
hex "BootLoader link address"
default 0
depends on !AIC_BOOTLOADER_MEM_AUTO
config AIC_BOOTLOADER_TEXT_SIZE
hex "BootLoader code memory size"
default 0
default 0x3FF00
config AIC_BOOTLOADER_HEAP_BASE
hex "BootLoader heap address"
default 0
depends on !AIC_BOOTLOADER_MEM_AUTO
config AIC_BOOTLOADER_HEAP_SIZE
hex "BootLoader heap size"
default 0
default 0xC0000
endmenu
menu "Console"

View File

@@ -544,7 +544,9 @@ err:
static void do_brom_upg(void)
{
#ifdef AIC_WRI_DRV
aic_set_reboot_reason(REBOOT_REASON_UPGRADE);
#endif
reboot_device();
}

View File

@@ -190,11 +190,12 @@ static bool force_upg_check(void)
int upg_type_check(enum boot_device bd)
{
enum aic_reboot_reason r;
upg_type = UPG_TYPE_NONE;
upg_mode = UPG_MODE_NORMAL;
#ifdef AIC_WRI_DRV
enum aic_reboot_reason r;
r = aic_get_reboot_reason();
/*
* if REBOOT_REASON_UPGRADE is not clear in BROM or PBP, should be clear
@@ -218,6 +219,7 @@ int upg_type_check(enum boot_device bd)
aic_clr_reboot_reason();
return 0;
}
#endif
if (bd == BD_USB) {
if (usbd_connect_pc_check()) {

View File

@@ -26,7 +26,7 @@
#define WIDTH_SPLIT_NUMERATOR 5
#define WIDTH_SPLIT_DENOMINATOR 6
#define BAR_HEIGHT 35
#define BAR_HEIGHT 32
#define SPLIT_WIDTH(w) \
((w) * WIDTH_SPLIT_NUMERATOR / WIDTH_SPLIT_DENOMINATOR)
@@ -139,13 +139,11 @@ void aicfb_draw_rect(struct aicfb_screeninfo *info,
u8 red, u8 green, u8 blue)
{
#ifndef AIC_BOOTLOADER_CMD_ONLY_FB_CONSOLE
unsigned long dcache_size, fb_dcache_start;
int pbytes = info->bits_per_pixel / 8;
unsigned char *fb;
int i, j;
fb = (unsigned char *)(info->framebuffer + y * info->stride + x * pbytes);
fb_dcache_start = ALIGN_DOWM((unsigned long)fb, ARCH_DMA_MINALIGN);
switch (info->format) {
case MPP_FMT_ARGB_8888:
@@ -183,9 +181,7 @@ void aicfb_draw_rect(struct aicfb_screeninfo *info,
return;
};
dcache_size = ALIGN_UP((unsigned long)fb - fb_dcache_start,
ARCH_DMA_MINALIGN);
aicos_dcache_clean_range((unsigned long *)fb_dcache_start, dcache_size);
aicos_dcache_clean_range((unsigned long *)info->framebuffer, info->smem_len);
#endif
}
@@ -293,7 +289,7 @@ void aicfb_draw_bar(unsigned int value)
#if (AIC_BOOTLOADER_CMD_PROGRESS_BAR_ROTATE == 90)
width = BAR_HEIGHT;
height = SPLIT_WIDTH(info.height);
bar_x = (info.width - width) / 2;
bar_x = 0;
bar_y = (info.height - height) / 2 + height;
console_x = bar_x + BAR_HEIGHT + 5;
console_y = info.height / 2;
@@ -301,7 +297,7 @@ void aicfb_draw_bar(unsigned int value)
width = SPLIT_WIDTH(info.width);
height = BAR_HEIGHT;
bar_x = (info.width - width) / 2;
bar_y = (info.height - height) / 2;
bar_y = 0;
console_x = info.width / 2;
console_y = bar_y + BAR_HEIGHT + 5;
#endif

View File

@@ -137,6 +137,9 @@ int aicupg_fat_direct_write(char *dst_type, u32 intf_id, char *fpath,
typedef void (*progress_cb)(u32 percent);
void aicupg_fat_set_process_cb(progress_cb cb);
void *aicupg_malloc_align(u32 size, size_t align);
void aicupg_free_align(void *ptr);
#ifdef __cplusplus
}
#endif

View File

@@ -605,7 +605,7 @@ static s32 get_mem_buf_cmd_read_output_data(struct upg_cmd *cmd, u8 *buf,
if (cmd->state == CMD_STATE_RESP) {
memlen = (u32)(long)cmd->priv;
mem = aicos_malloc_align(0, memlen, ARCH_DMA_MINALIGN);
mem = aicupg_malloc_align(memlen, ARCH_DMA_MINALIGN);
/*
* Enter read RESP state, to make it simple, HOST should read
* RESP in one read operation.
@@ -669,7 +669,7 @@ static s32 free_mem_buf_cmd_write_input_data(struct upg_cmd *cmd, u8 *buf,
memcpy(&addr, buf, 4);
clen += 4;
aicos_free_align(0, (void *)(long)addr);
aicupg_free_align((void *)(long)addr);
cmd_state_set_next(cmd, CMD_STATE_RESP);
}

View File

@@ -138,7 +138,7 @@ s32 mmc_fwc_sparse_fill(struct aicupg_mmc_priv *priv, struct aic_partition *part
u32 *fill_buf, fill_buf_num_blks, fill_blks = 0;
int i, j;
fill_buf = (u32 *)aicos_malloc_align(0, ROUNDUP(SPARSE_FILLBUF_SIZE, CACHE_LINE_SIZE), CACHE_LINE_SIZE);
fill_buf = (u32 *)aicupg_malloc_align(ROUNDUP(SPARSE_FILLBUF_SIZE, CACHE_LINE_SIZE), CACHE_LINE_SIZE);
if (!fill_buf) {
pr_err("Malloc failed for: CHUNK_TYPE_FILL\n");
return 0;
@@ -193,7 +193,7 @@ s32 mmc_fwc_sparse_fill(struct aicupg_mmc_priv *priv, struct aic_partition *part
}
out:
aicos_free_align(0, fill_buf);
aicupg_free_align(fill_buf);
return fill_blks;
}
@@ -404,7 +404,7 @@ s32 mmc_fwc_raw_write(struct fwc_info *fwc, u8 *buf, s32 len)
long n;
u32 clen = 0, calc_len = 0;
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
if (!rdbuf) {
pr_err("Error: malloc buffer failed.\n");
return 0;
@@ -468,7 +468,7 @@ s32 mmc_fwc_raw_write(struct fwc_info *fwc, u8 *buf, s32 len)
out:
if (rdbuf)
aicos_free_align(0, rdbuf);
aicupg_free_align(rdbuf);
return clen;
}

View File

@@ -205,7 +205,7 @@ s32 nand_fwc_uffs_write(struct fwc_info *fwc, u8 *buf, s32 len)
int total_len = 0, remain_offset = 0;
u8 *wbuf = NULL, *pbuf = NULL;
wbuf = aicos_malloc_align(0, ROUNDUP(len, fwc->block_size), CACHE_LINE_SIZE);
wbuf = aicupg_malloc_align(ROUNDUP(len, fwc->block_size), CACHE_LINE_SIZE);
if (!wbuf) {
pr_err("malloc failed.\n");
return 0;
@@ -293,13 +293,13 @@ s32 nand_fwc_uffs_write(struct fwc_info *fwc, u8 *buf, s32 len)
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
fwc->calc_partition_crc = fwc->meta.crc;
aicos_free_align(0, wbuf);
aicupg_free_align(wbuf);
return len;
out:
if (wbuf)
aicos_free_align(0, wbuf);
aicupg_free_align(wbuf);
return ret;
}
@@ -350,7 +350,7 @@ s32 nand_fwc_mtd_write(struct fwc_info *fwc, u8 *buf, s32 len)
int i, ret = 0, calc_len = 0;
u8 *rdbuf, *buf_to_write, *buf_to_read;
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
if (!rdbuf) {
pr_err("Error: malloc buffer failed.\n");
return 0;
@@ -431,11 +431,11 @@ s32 nand_fwc_mtd_write(struct fwc_info *fwc, u8 *buf, s32 len)
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
aicos_free_align(0, rdbuf);
aicupg_free_align(rdbuf);
return len;
out:
if (rdbuf)
aicos_free_align(0, rdbuf);
aicupg_free_align(rdbuf);
return 0;
}
@@ -449,7 +449,7 @@ s32 nand_fwc_nftl_write(struct fwc_info *fwc, u8 *buf, s32 len)
int i, calc_len = 0, ret = 0;
u8 *rdbuf;
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
if (!rdbuf) {
pr_err("Error: malloc buffer failed.\n");
return 0;
@@ -514,11 +514,11 @@ s32 nand_fwc_nftl_write(struct fwc_info *fwc, u8 *buf, s32 len)
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
(void)ret;
aicos_free_align(0, rdbuf);
aicupg_free_align(rdbuf);
return len;
out:
if (rdbuf)
aicos_free_align(0, rdbuf);
aicupg_free_align(rdbuf);
return 0;
}
#endif
@@ -567,6 +567,9 @@ void nand_fwc_data_end(struct fwc_info *fwc)
if (!priv)
return;
if (priv->spl_flag)
nand_fwc_spl_end(priv);
#ifdef AIC_NFTL_SUPPORT
struct nftl_api_handler_t *nftl_handler;
for (int i = 0; i < MAX_DUPLICATED_PART; i++) {

View File

@@ -683,6 +683,17 @@ s32 nand_fwc_spl_write(struct fwc_info *fwc, u8 *buf, s32 len)
return len;
}
s32 nand_fwc_spl_end(struct aicupg_nand_priv *priv)
{
struct aicupg_nand_spl *spl;
spl = &g_nand_spl;
if (spl->image_buf)
free(spl->image_buf);
return 0;
}
int nand_spl_get_candidate_blocks(u32 *blks, u32 size)
{
if (!blks || size < SPL_CANDIDATE_BLOCK_NUM) {

View File

@@ -87,6 +87,7 @@ s32 nand_fwc_spl_reserve_blocks(struct aicupg_nand_priv *priv);
s32 nand_fwc_spl_prepare(struct aicupg_nand_priv *priv, u32 datasiz,
u32 blksiz);
s32 nand_fwc_spl_write(struct fwc_info *fwc, u8 *buf, s32 len);
s32 nand_fwc_spl_end(struct aicupg_nand_priv *priv);
int nand_spl_get_candidate_blocks(u32 *blks, u32 size);
#ifdef __cplusplus

View File

@@ -137,7 +137,7 @@ s32 nor_fwc_data_write(struct fwc_info *fwc, u8 *buf, s32 len)
int i, calc_len = 0, ret = 0;
u8 *rdbuf;
rdbuf = aicos_malloc_align(0, len, CACHE_LINE_SIZE);
rdbuf = aicupg_malloc_align(len, CACHE_LINE_SIZE);
if (!rdbuf) {
pr_err("Error: malloc buffer failed.\n");
return 0;
@@ -201,12 +201,12 @@ s32 nor_fwc_data_write(struct fwc_info *fwc, u8 *buf, s32 len)
fwc->trans_size += len;
pr_debug("%s, data len %d, trans len %d\n", __func__, len, fwc->trans_size);
aicos_free_align(0, rdbuf);
aicupg_free_align(rdbuf);
return len;
out:
if (rdbuf)
aicos_free_align(0, rdbuf);
aicupg_free_align(rdbuf);
return ret;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Artinchip Technology Co., Ltd
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -59,10 +59,10 @@ s32 trans_layer_rw_proc(struct phy_data_rw *rw, u8 *buffer, u32 len)
if (!trans_pkt_buf) {
trans_pkt_siz = TRANS_DATA_BUFF_MAX_SIZE;
trans_pkt_buf = aicos_malloc_align(0, trans_pkt_siz, CACHE_LINE_SIZE);
trans_pkt_buf = aicupg_malloc_align(trans_pkt_siz, CACHE_LINE_SIZE);
if (!trans_pkt_buf) {
trans_pkt_siz = TRANS_DATA_BUFF_MIN_SIZE;
trans_pkt_buf = aicos_malloc_align(0, trans_pkt_siz, CACHE_LINE_SIZE);
trans_pkt_buf = aicupg_malloc_align(trans_pkt_siz, CACHE_LINE_SIZE);
if (!trans_pkt_buf) {
pr_err("malloc trans pkt buf(%u) failed.\n", trans_pkt_siz);
return -1;

View File

@@ -33,21 +33,21 @@ static void *upg_fat_malloc_align(struct fwc_info *fwc, u32 *size, size_t align)
switch (*size) {
case DATA_WRITE_ONCE_MAX_SIZE:
*size = ALIGN_DOWN(DATA_WRITE_ONCE_MAX_SIZE, fwc->block_size);
ptr = aicos_malloc_align(0, *size, align);
ptr = aicupg_malloc_align(*size, align);
if (ptr)
break;
case DATA_WRITE_ONCE_MID_SIZE:
*size = ALIGN_DOWN(DATA_WRITE_ONCE_MID_SIZE, fwc->block_size);
ptr = aicos_malloc_align(0, *size, align);
ptr = aicupg_malloc_align(*size, align);
if (ptr)
break;
case DATA_WRITE_ONCE_MIN_SIZE:
*size = ALIGN_DOWN(DATA_WRITE_ONCE_MIN_SIZE, fwc->block_size);
ptr = aicos_malloc_align(0, *size, align);
ptr = aicupg_malloc_align(*size, align);
if (ptr)
break;
default:
ptr = aicos_malloc_align(0, *size, align);
ptr = aicupg_malloc_align(*size, align);
if (ptr)
break;
}
@@ -57,7 +57,7 @@ static void *upg_fat_malloc_align(struct fwc_info *fwc, u32 *size, size_t align)
static void upg_fat_free_align(void *mem)
{
aicos_free_align(0, mem);
aicupg_free_align(mem);
}
#define FRAME_LIST_SIZE 4096
@@ -73,7 +73,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta)
fwc = NULL;
buf = NULL;
fwc = aicos_malloc_align(0, sizeof(struct fwc_info), FRAME_LIST_SIZE);
fwc = aicupg_malloc_align(sizeof(struct fwc_info), FRAME_LIST_SIZE);
if (!fwc) {
pr_err("Error: malloc fwc failed.\n");
ret = -1;
@@ -91,7 +91,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta)
media_data_write_start(fwc);
/*config write size once*/
if (config_ram_size <= 0x100000)
if (config_ram_size <= 0x400000)
write_once_size = DATA_WRITE_ONCE_MIN_SIZE;
else
write_once_size = DATA_WRITE_ONCE_MAX_SIZE;
@@ -151,7 +151,7 @@ static s32 media_device_write(char *image_name, struct fwc_meta *pmeta)
(total_len * 1000000 / start_us) / 1024 % 1024);
upg_fat_free_align(buf);
aicos_free_align(0, fwc);
aicupg_free_align(fwc);
return total_len;
err:
@@ -159,7 +159,7 @@ err:
if (buf)
upg_fat_free_align(buf);
if (fwc)
aicos_free_align(0, fwc);
aicupg_free_align(fwc);
return 0;
}
@@ -175,7 +175,7 @@ s32 aicupg_fat_write(char *image_name, char *protection,
u64 total_len = 0;
pmeta = NULL;
pmeta = (struct fwc_meta *)aicos_malloc_align(0, header->meta_size, FRAME_LIST_SIZE);
pmeta = (struct fwc_meta *)aicupg_malloc_align(header->meta_size, FRAME_LIST_SIZE);
if (!pmeta) {
pr_err("Error: malloc for meta failed.\n");
ret = -1;
@@ -231,10 +231,10 @@ s32 aicupg_fat_write(char *image_name, char *protection,
(ulong)((total_len * 1000000 / start_us) / 1024 / 1024),
(ulong)((total_len * 1000000 / start_us) / 1024 % 1024));
aicos_free_align(0, pmeta);
aicupg_free_align(pmeta);
return write_len;
err:
if (pmeta)
aicos_free_align(0, pmeta);
aicupg_free_align(pmeta);
return 0;
}

View File

@@ -28,7 +28,7 @@ static int fat_direct_mmc_write_raw(struct aic_sdmc *host, char *fpath,
printf("Programming %s to 0x%x\n", fpath, doffset);
printf("\t");
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
soffset = 0;
writecnt = 0;
@@ -62,7 +62,7 @@ static int fat_direct_mmc_write_raw(struct aic_sdmc *host, char *fpath,
}
if (buf)
aicos_free_align(0, buf);
aicupg_free_align(buf);
printf("\n");
return ret;
}
@@ -79,7 +79,7 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath,
printf("Programming %s to 0x%x\n", fpath, doffset);
printf("\t");
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
soffset = 0;
dolen = MAX_WRITE_SIZE;
@@ -149,8 +149,8 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath,
/* Read raw chunk data */
if (chunk_data_sz > MAX_WRITE_SIZE) {
aicos_free_align(0, buf);
buf = aicos_malloc_align(0, chunk_data_sz, FRAME_LIST_SIZE);
aicupg_free_align(buf);
buf = aicupg_malloc_align(chunk_data_sz, FRAME_LIST_SIZE);
p = buf;
}
@@ -225,7 +225,7 @@ static int fat_direct_mmc_write_sparse(struct aic_sdmc *host, char *fpath,
out:
if (buf)
aicos_free_align(0, buf);
aicupg_free_align(buf);
printf("\n");
return ret;
}

View File

@@ -65,7 +65,7 @@ static int fat_direct_spinand_write_boot(char *fpath, struct mtd_dev *mtd)
return -1;
}
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
soffset = 0;
while (1) {
actread = 0;
@@ -91,7 +91,7 @@ static int fat_direct_spinand_write_boot(char *fpath, struct mtd_dev *mtd)
}
if (buf)
aicos_free_align(0, buf);
aicupg_free_align(buf);
return 0;
}
@@ -103,7 +103,7 @@ static int fat_direct_spinand_write_data(char *fpath, struct mtd_dev *mtd,
u32 soffset;
ulong dolen, actread, writecnt;
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
soffset = 0;
writecnt = 0;
@@ -155,7 +155,7 @@ static int fat_direct_spinand_write_data(char *fpath, struct mtd_dev *mtd,
}
if (buf)
aicos_free_align(0, buf);
aicupg_free_align(buf);
return ret;
}
@@ -216,7 +216,7 @@ static int fat_direct_spinand_write_nftl(char *fpath, u32 doffset)
goto out;
}
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
if (!buf) {
pr_err("Failed to malloc buffer.\n");
ret = -1;
@@ -255,7 +255,7 @@ static int fat_direct_spinand_write_nftl(char *fpath, u32 doffset)
out:
if (buf)
aicos_free_align(0, buf);
aicupg_free_align(buf);
if (nftl && nftl->nandt)
aicos_free(MEM_CMA, nftl->nandt);
if (nftl)

View File

@@ -58,7 +58,7 @@ int fat_direct_write_spinor(u32 spi_id, char *fpath, u32 doffset)
printf("Programming %s to 0x%x\n", fpath, doffset);
printf("\t");
buf = aicos_malloc_align(0, MAX_WRITE_SIZE, FRAME_LIST_SIZE);
buf = aicupg_malloc_align(MAX_WRITE_SIZE, FRAME_LIST_SIZE);
soffset = 0;
writecnt = 0;
@@ -103,7 +103,7 @@ int fat_direct_write_spinor(u32 spi_id, char *fpath, u32 doffset)
}
if (buf)
aicos_free_align(0, buf);
aicupg_free_align(buf);
printf("\n");
return ret;
}

View File

@@ -451,3 +451,13 @@ void media_data_write_end(struct fwc_info *fwc)
break;
}
}
void *aicupg_malloc_align(u32 size, size_t align)
{
return aicos_malloc_align(MEM_RESERVED, size, align);
}
void aicupg_free_align(void *ptr)
{
aicos_free_align(MEM_RESERVED, ptr);
}

View File

@@ -1,9 +1,9 @@
/*
* Copyright (c) 2023, Artinchip Technology Co., Ltd
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Wu Dehuang <dehuang.wu@artinchip.com>
* Authors: Wu Dehuang <dehuang.wu@artinchip.com>
*/
#include <stdio.h>
@@ -487,8 +487,8 @@ static s32 exfat_search_file(struct fat_volume *vol, struct fat_file *file,
/* Bingo */
file->start_clus = first_cluster;
file->size = data_len;
pr_err("Start cluster: 0x%X\n", file->start_clus);
pr_err("bootcfg file size: 0x%X\n", file->size);
pr_debug("Start cluster: 0x%X\n", file->start_clus);
pr_debug("bootcfg file size: 0x%X\n", file->size);
return 0;
}
}

View File

@@ -63,7 +63,7 @@ struct hal_axicfg_table axi_cfg_table[HAL_AXICFG_PORT_MAX] = {
static void aic_board_heap_init(enum boot_device bd)
{
size_t heap_size, heap_start, real_ram_size = 0;
size_t real_ram_size = 0;
#if AIC_PSRAM_SIZE
config_ram_size = AIC_PSRAM_SIZE;
@@ -79,15 +79,7 @@ static void aic_board_heap_init(enum boot_device bd)
if (config_ram_size != real_ram_size)
pr_warn("config ram size(0x%x) is not equal real ram size(0x%x)\n", (u32)config_ram_size, (u32)real_ram_size);
heap_size = ((size_t)&__heap_end) - ((size_t)&__heap_start);
/* Limit bootloader's heap to 2MB */
if (bd != BD_UDISK && bd != BD_SDFAT32 && bd != BD_USB && heap_size > 0x200000)
heap_size = 0x200000;
heap_start = (size_t)&__heap_end - heap_size;
heap_init((void *)heap_start, heap_size);
heap_init();
}
static int board_init(enum boot_device bd)