mirror of
https://github.com/sipeed/LicheeRV-Nano-Build.git
synced 2026-11-09 18:04:55 -06:00
Update the vendored FSBL from Sophgo sg200x-dev commit 426d1e7eccce84b34169e5f21de7d6e7da1804a1 to 5a80c127cf614dea7f534d5b5352886a1c720d37, incorporating 24 upstream commits. Keep the local plat/sg200x symlink to cv181x. Import the upstream DDR, clock, storage and boot-image changes together with their platform support, prebuilt firmware and licensing files. All 935 upstream files match the target revision. Validation on LicheeRV Nano (SG2002/C906, SD, DDR3-1866 x16): - Cross-build BL2 with the existing Xuantie GCC 10.2.0 toolchain. - Repack FIP while preserving the installed OpenSBI and U-Boot byte for byte; verify headers, payload checksums, entry addresses and LZMA. - Software reboot and power-cycle boot succeed; memtester 16M 1 passes all 18 checks. Validation covers the FSBL update with existing later boot stages. Full firmware builds, A53 and video/HID acceptance are not covered.
101 lines
2.7 KiB
C
101 lines
2.7 KiB
C
#include <debug.h>
|
|
#include <console.h>
|
|
#include <platform.h>
|
|
#include <bl2.h>
|
|
#include <string.h>
|
|
#include <delay_timer.h>
|
|
#include <rom_api.h>
|
|
#include <cpu.h>
|
|
enum CHIP_CLK_MODE chip_clk_mode = CLK_ND;
|
|
#ifdef RTOS_ENABLE_FREERTOS
|
|
int init_comm_info(int ret)
|
|
{
|
|
struct transfer_config_t *transfer_config = (struct transfer_config_t *)MAILBOX_FIELD;
|
|
struct transfer_config_t transfer_config_s;
|
|
unsigned char *ptr = (unsigned char *)&transfer_config_s;
|
|
unsigned short checksum = 0;
|
|
/* mailbox field is 4 byte write access, and can not access byte by byte.
|
|
* so init parameters and copy all to mailbox field together.
|
|
*/
|
|
transfer_config_s.conf_magic = RTOS_MAGIC_HEADER;
|
|
transfer_config_s.conf_size = ((uint64_t)&transfer_config_s.checksum - (uint64_t)&transfer_config_s.conf_magic);
|
|
transfer_config_s.isp_buffer_addr = CVIMMAP_ISP_MEM_BASE_ADDR;
|
|
transfer_config_s.isp_buffer_size = CVIMMAP_ISP_MEM_BASE_SIZE;
|
|
transfer_config_s.encode_img_addr = CVIMMAP_H26X_BITSTREAM_ADDR;
|
|
transfer_config_s.encode_img_size = CVIMMAP_H26X_BITSTREAM_SIZE;
|
|
transfer_config_s.encode_buf_addr = CVIMMAP_H26X_ENC_BUFF_ADDR;
|
|
transfer_config_s.encode_buf_size = CVIMMAP_H26X_ENC_BUFF_SIZE;
|
|
transfer_config_s.dump_print_enable = RTOS_DUMP_PRINT_ENABLE;
|
|
transfer_config_s.dump_print_size_idx = RTOS_DUMP_PRINT_SZ_IDX;
|
|
transfer_config_s.image_type = RTOS_FAST_IMAGE_TYPE;
|
|
transfer_config_s.mcu_status = MCU_STATUS_NONOS_DONE;
|
|
for (int i = 0; i < transfer_config_s.conf_size; i++) {
|
|
checksum += ptr[i];
|
|
}
|
|
|
|
transfer_config_s.checksum = checksum;
|
|
memcpy(transfer_config, &transfer_config_s, sizeof(struct transfer_config_t));
|
|
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#if !FSBL_SECURE_BOOT_SUPPORT
|
|
int dec_verify_image(const void *image, size_t size, size_t dec_skip, struct fip_param1 *fip_param1)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
void bl2_main(void)
|
|
{
|
|
uint32_t v = p_rom_api_get_boot_src();
|
|
|
|
if (v == BOOT_SRC_UART) {
|
|
console_init(0, PLAT_UART_CLK_IN_HZ, UART_DL_BAUDRATE);
|
|
}
|
|
|
|
ATF_STATE = ATF_STATE_BL2_MAIN;
|
|
time_records->fsbl_start = read_time_ms();
|
|
|
|
NOTICE("\nFSBL %s:%s\n", version_string, build_message);
|
|
|
|
INFO("sw_info=0x%x\n", get_sw_info()->value);
|
|
INFO("fip_param1: param_cksum=0x%x param2_loadaddr=0x%x\n", fip_param1->param_cksum,
|
|
fip_param1->param2_loadaddr);
|
|
|
|
INFO("CP_STATE_REG=0x%x\n", mmio_read_32(0x0E000018));
|
|
|
|
// print_sram_log();
|
|
lock_efuse_chipsn();
|
|
|
|
setup_dl_flag();
|
|
|
|
#ifdef SWITCH_32K_XTAL
|
|
switch_rtc_mode_1st_stage();
|
|
#endif
|
|
|
|
set_rtc_en_registers();
|
|
|
|
#ifdef OD_CLK_SEL
|
|
chip_clk_mode = CLK_OD;
|
|
#else
|
|
#ifdef VC_CLK_OVERDRIVE
|
|
chip_clk_mode = CLK_VC_OD;
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef CONFIG_SUSPEND
|
|
#ifndef NO_DDR_CFG //for fpga
|
|
jump_to_warmboot_entry();
|
|
#endif
|
|
#endif
|
|
load_ddr();
|
|
|
|
load_rest();
|
|
NOTICE("BL2 end.\n");
|
|
|
|
while (1)
|
|
;
|
|
}
|