mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-14 18:38:55 +00:00
v1.0.2: fitimage for demo88 mmc
This commit is contained in:
@@ -19,8 +19,10 @@ if GetDepend('AIC_BOOTLOADER_CMD_NOR_BOOT') and not GetDepend('LPKG_USING_FDTLIB
|
||||
src += Glob('nor_boot_no_fitimage.c')
|
||||
if GetDepend('AIC_BOOTLOADER_CMD_NAND_BOOT'):
|
||||
src += Glob('nand_boot.c')
|
||||
if GetDepend('AIC_BOOTLOADER_CMD_MMC_BOOT'):
|
||||
if GetDepend('AIC_BOOTLOADER_CMD_MMC_BOOT') and GetDepend('LPKG_USING_FDTLIB'):
|
||||
src += Glob('mmc_boot.c')
|
||||
if GetDepend('AIC_BOOTLOADER_CMD_MMC_BOOT') and not GetDepend('LPKG_USING_FDTLIB'):
|
||||
src += Glob('mmc_boot_no_fitimage.c')
|
||||
if GetDepend('AIC_BOOTLOADER_CMD_PSRAM_TEST'):
|
||||
src += Glob('psram_test.c')
|
||||
if GetDepend('AIC_BOOTLOADER_CMD_XIP_BOOT'):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <image.h>
|
||||
#include <boot.h>
|
||||
#include <hexdump.h>
|
||||
#include "fitimage.h"
|
||||
|
||||
#define APPLICATION_PART "os"
|
||||
#define MMC_BOOT_CONTROL_ID 0
|
||||
@@ -24,12 +25,10 @@
|
||||
static int do_mmc_boot(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0, mmc_id = MMC_BOOT_CONTROL_ID;
|
||||
struct image_header *head = NULL;
|
||||
struct aic_sdmc *host = NULL;
|
||||
struct aic_partition *part = NULL, *parts = NULL;
|
||||
void *la;
|
||||
u64 blkstart, blkcnt;
|
||||
u32 start_us;
|
||||
struct spl_load_info info;
|
||||
ulong entry_point;
|
||||
|
||||
ret = mmc_init(mmc_id);
|
||||
if (ret) {
|
||||
@@ -62,39 +61,20 @@ static int do_mmc_boot(int argc, char *argv[])
|
||||
goto out;
|
||||
}
|
||||
|
||||
head = malloc(MMC_BLOCK_SIZE);
|
||||
blkstart = part->start / MMC_BLOCK_SIZE;
|
||||
ret = mmc_bread(host, blkstart, 1, (void *)head);
|
||||
if (ret < 0) {
|
||||
printf("Read image header failed.\n");
|
||||
info.dev = (void *)host;
|
||||
info.priv = (void *)part;
|
||||
info.dev_type = DEVICE_MMC;
|
||||
info.bl_len = MMC_BLOCK_SIZE;
|
||||
|
||||
ret = spl_load_simple_fit(&info, &entry_point);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = image_verify_magic((void *)head, AIC_IMAGE_MAGIC);
|
||||
if (ret) {
|
||||
printf("Application header is unknown.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
la = (void *)(unsigned long)head->load_address;
|
||||
|
||||
start_us = aic_get_time_us();
|
||||
blkcnt = ROUNDUP(head->image_len, MMC_BLOCK_SIZE) / MMC_BLOCK_SIZE;
|
||||
ret = mmc_bread(host, blkstart, blkcnt, la);
|
||||
show_speed("mmc read speed", head->image_len, aic_get_time_us() - start_us);
|
||||
|
||||
if (ret < 0) {
|
||||
printf("Read image failed.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
boot_app(la);
|
||||
boot_app((void *)entry_point);
|
||||
|
||||
out:
|
||||
if (parts)
|
||||
mmc_free_partition(parts);
|
||||
if (head)
|
||||
free(head);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
101
application/baremetal/bootloader/cmd/mmc_boot_no_fitimage.c
Normal file
101
application/baremetal/bootloader/cmd/mmc_boot_no_fitimage.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Wu Dehuang <dehuang.wu@artinchip.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <console.h>
|
||||
#include <aic_common.h>
|
||||
#include <aic_errno.h>
|
||||
#include <mmc.h>
|
||||
#include <image.h>
|
||||
#include <boot.h>
|
||||
#include <hexdump.h>
|
||||
|
||||
#define APPLICATION_PART "os"
|
||||
#define MMC_BOOT_CONTROL_ID 0
|
||||
|
||||
static int do_mmc_boot(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0, mmc_id = MMC_BOOT_CONTROL_ID;
|
||||
struct image_header *head = NULL;
|
||||
struct aic_sdmc *host = NULL;
|
||||
struct aic_partition *part = NULL, *parts = NULL;
|
||||
void *la;
|
||||
u64 blkstart, blkcnt;
|
||||
u32 start_us;
|
||||
|
||||
ret = mmc_init(mmc_id);
|
||||
if (ret) {
|
||||
printf("sdmc %d init failed.\n", mmc_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
host = find_mmc_dev_by_index(mmc_id);
|
||||
if (!host) {
|
||||
pr_err("find mmc dev failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
parts = mmc_create_gpt_part();
|
||||
if (!parts) {
|
||||
pr_err("sdmc %d create gpt part failed.\n", mmc_id);
|
||||
goto out;
|
||||
}
|
||||
|
||||
part = parts;
|
||||
while (part) {
|
||||
if (!strcmp(part->name, APPLICATION_PART))
|
||||
break;
|
||||
|
||||
part = part->next;
|
||||
}
|
||||
|
||||
if (!part) {
|
||||
printf("Failed to get application partition.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
head = malloc(MMC_BLOCK_SIZE);
|
||||
blkstart = part->start / MMC_BLOCK_SIZE;
|
||||
ret = mmc_bread(host, blkstart, 1, (void *)head);
|
||||
if (ret < 0) {
|
||||
printf("Read image header failed.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = image_verify_magic((void *)head, AIC_IMAGE_MAGIC);
|
||||
if (ret) {
|
||||
printf("Application header is unknown.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
la = (void *)(unsigned long)head->load_address;
|
||||
|
||||
start_us = aic_get_time_us();
|
||||
blkcnt = ROUNDUP(head->image_len, MMC_BLOCK_SIZE) / MMC_BLOCK_SIZE;
|
||||
ret = mmc_bread(host, blkstart, blkcnt, la);
|
||||
show_speed("mmc read speed", head->image_len, aic_get_time_us() - start_us);
|
||||
|
||||
if (ret < 0) {
|
||||
printf("Read image failed.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
boot_app(la);
|
||||
|
||||
out:
|
||||
if (parts)
|
||||
mmc_free_partition(parts);
|
||||
if (head)
|
||||
free(head);
|
||||
return ret;
|
||||
}
|
||||
|
||||
CONSOLE_CMD(mmc_boot, do_mmc_boot, "Boot from eMMC/SD.");
|
||||
Reference in New Issue
Block a user