Skip to content

Commit 0182e4c

Browse files
authored
Merge pull request #59 from YuzukiHD/dev
Avaota A1 support bootlogo, avaota-a1 add lcd error info
2 parents dd2b935 + 6fd8b27 commit 0182e4c

File tree

8 files changed

+526
-101
lines changed

8 files changed

+526
-101
lines changed

board/avaota-a1/extlinux_boot/main.c

+57-48
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#include <sstdlib.h>
1717
#include <string.h>
1818

19-
#include <cli.h>
20-
#include <cli_shell.h>
21-
#include <cli_termesc.h>
22-
2319
#include <sys-clk.h>
2420
#include <sys-dram.h>
2521
#include <sys-i2c.h>
@@ -36,6 +32,11 @@
3632
#include <sys-sdhci.h>
3733
#include <uart.h>
3834

35+
#include "spi_lcd.c"
36+
37+
#define CONFIG_SPLASH_LOAD_ADDR (0x40080000)
38+
#define CONFIG_SPLASH_FILENAME "splash.bin"
39+
3940
#define CONFIG_BL31_FILENAME "bl31.bin"
4041
#define CONFIG_BL31_LOAD_ADDR (0x48000000)
4142

@@ -53,8 +54,6 @@
5354

5455
#define CONFIG_SDMMC_SPEED_TEST_SIZE 1024// (unit: 512B sectors)
5556

56-
#define CONFIG_DEFAULT_BOOTDELAY 3
57-
5857
#define CONFIG_HEAP_BASE (0x50800000)
5958
#define CONFIG_HEAP_SIZE (16 * 1024 * 1024)
6059

@@ -99,6 +98,9 @@ typedef struct {
9998
uint8_t *scp_dest;
10099
char scp_filename[FILENAME_MAX_LEN];
101100

101+
uint8_t *splash_dest;
102+
char splash_filename[FILENAME_MAX_LEN];
103+
102104
uint8_t *kernel_dest;
103105
uint8_t *ramdisk_dest;
104106
uint8_t *of_dest;
@@ -199,6 +201,11 @@ static int load_sdcard(image_info_t *image) {
199201
if (ret)
200202
return ret;
201203

204+
printk(LOG_LEVEL_INFO, "FATFS: read %s addr=%x\n", image->splash_filename, (uint32_t) image->splash_dest);
205+
ret = fatfs_loadimage(image->splash_filename, image->splash_dest);
206+
if (ret)
207+
printk(LOG_LEVEL_INFO, "FATFS: Splash load fail, Leave Black Screen.\n");
208+
202209
/* umount fs */
203210
fret = f_mount(0, "", 0);
204211
if (fret != FR_OK) {
@@ -536,36 +543,6 @@ static int load_extlinux(image_info_t *image, uint64_t dram_size) {
536543
return err;
537544
}
538545

539-
msh_declare_command(boot);
540-
msh_define_help(boot, "boot to linux", "Usage: boot\n");
541-
int cmd_boot(int argc, const char **argv) {
542-
atf_head_t *atf_head = (atf_head_t *) image.bl31_dest;
543-
544-
atf_head->dtb_base = (uint32_t) image.of_dest;
545-
atf_head->nos_base = (uint32_t) image.kernel_dest;
546-
547-
/* Fill platform magic */
548-
memcpy(atf_head->platform, CONFIG_PLATFORM_MAGIC, 8);
549-
550-
printk(LOG_LEVEL_INFO, "ATF: Kernel addr: 0x%08x\n", atf_head->nos_base);
551-
printk(LOG_LEVEL_INFO, "ATF: Kernel DTB addr: 0x%08x\n", atf_head->dtb_base);
552-
553-
clean_syterkit_data();
554-
555-
jmp_to_arm64(CONFIG_BL31_LOAD_ADDR);
556-
557-
printk(LOG_LEVEL_INFO, "Back to SyterKit\n");
558-
559-
// if kernel boot not success, jump to fel.
560-
jmp_to_fel();
561-
return 0;
562-
}
563-
564-
const msh_command_entry commands[] = {
565-
msh_define_command(boot),
566-
msh_command_end,
567-
};
568-
569546
static int abortboot_single_key(int bootdelay) {
570547
int abort = 0;
571548
unsigned long ts;
@@ -640,6 +617,8 @@ int main(void) {
640617
/* Initialize the small memory allocator. */
641618
smalloc_init(CONFIG_HEAP_BASE, CONFIG_HEAP_SIZE);
642619

620+
LCD_Init();
621+
643622
sunxi_nsi_init();
644623

645624
/* Clear the image_info_t struct. */
@@ -651,15 +630,18 @@ int main(void) {
651630
image.of_dest = (uint8_t *) CONFIG_DTB_LOAD_ADDR;
652631
image.ramdisk_dest = (uint8_t *) CONFIG_INITRD_LOAD_ADDR;
653632
image.kernel_dest = (uint8_t *) CONFIG_KERNEL_LOAD_ADDR;
633+
image.splash_dest = (uint8_t *) CONFIG_SPLASH_LOAD_ADDR;
654634

655635
strcpy(image.bl31_filename, CONFIG_BL31_FILENAME);
656636
strcpy(image.scp_filename, CONFIG_SCP_FILENAME);
657637
strcpy(image.extlinux_filename, CONFIG_EXTLINUX_FILENAME);
638+
strcpy(image.splash_filename, CONFIG_SPLASH_FILENAME);
658639

659640
/* Initialize the SD host controller. */
660641
if (sunxi_sdhci_init(&sdhci0) != 0) {
661642
printk(LOG_LEVEL_ERROR, "SMHC: %s controller init failed\n", sdhci0.name);
662-
goto _shell;
643+
LCD_ShowString(0, 80, "SMHC: controller init failed", SPI_LCD_COLOR_GREEN, SPI_LCD_COLOR_BLACK, 12);
644+
goto _fail;
663645
} else {
664646
printk(LOG_LEVEL_INFO, "SMHC: %s controller initialized\n", sdhci0.name);
665647
}
@@ -670,34 +652,61 @@ int main(void) {
670652
mdelay(30);
671653
if (sdmmc_init(&card0, &sdhci0) != 0) {
672654
printk(LOG_LEVEL_WARNING, "SMHC: init failed\n");
673-
goto _shell;
655+
LCD_ShowString(0, 80, "SMHC: init failed", SPI_LCD_COLOR_GREEN, SPI_LCD_COLOR_BLACK, 12);
656+
goto _fail;
674657
}
675658
}
676659

677660
/* Load the DTB, kernel image, and configuration data from the SD card. */
678661
if (load_sdcard(&image) != 0) {
679662
printk(LOG_LEVEL_WARNING, "SMHC: loading failed\n");
680-
goto _shell;
663+
LCD_ShowString(0, 80, "SMHC: loading failed", SPI_LCD_COLOR_GREEN, SPI_LCD_COLOR_BLACK, 12);
664+
goto _fail;
681665
}
682666

667+
LCD_Show_Splash(image.splash_dest);
668+
669+
LCD_Open_BLK();
670+
683671
if (load_extlinux(&image, dram_size) != 0) {
684672
printk(LOG_LEVEL_ERROR, "EXTLINUX: load extlinux failed\n");
685-
goto _shell;
673+
LCD_ShowString(0, 80, "EXTLINUX: load extlinux failed", SPI_LCD_COLOR_GREEN, SPI_LCD_COLOR_BLACK, 12);
674+
goto _fail;
686675
}
687676

688677
printk(LOG_LEVEL_INFO, "EXTLINUX: load extlinux done, now booting...\n");
689678

690-
int bootdelay = CONFIG_DEFAULT_BOOTDELAY;
679+
atf_head_t *atf_head = (atf_head_t *) image.bl31_dest;
691680

692-
/* Showing boot delays */
693-
if (abortboot_single_key(bootdelay)) {
694-
goto _shell;
695-
}
681+
atf_head->dtb_base = (uint32_t) image.of_dest;
682+
atf_head->nos_base = (uint32_t) image.kernel_dest;
683+
684+
/* Fill platform magic */
685+
memcpy(atf_head->platform, CONFIG_PLATFORM_MAGIC, 8);
686+
687+
printk(LOG_LEVEL_INFO, "ATF: Kernel addr: 0x%08x\n", atf_head->nos_base);
688+
printk(LOG_LEVEL_INFO, "ATF: Kernel DTB addr: 0x%08x\n", atf_head->dtb_base);
689+
690+
LCD_ShowString(0, 0, "SyterKit Now Booting", SPI_LCD_COLOR_GREEN, SPI_LCD_COLOR_BLACK, 12);
691+
LCD_ShowString(0, 12, "Kernel addr: 0x40800000", SPI_LCD_COLOR_GREEN, SPI_LCD_COLOR_BLACK, 12);
692+
LCD_ShowString(0, 24, "DTB addr: 0x40400000", SPI_LCD_COLOR_GREEN, SPI_LCD_COLOR_BLACK, 12);
693+
694+
clean_syterkit_data();
695+
696+
jmp_to_arm64(CONFIG_BL31_LOAD_ADDR);
697+
698+
printk(LOG_LEVEL_INFO, "Back to SyterKit\n");
699+
700+
// if kernel boot not success, jump to fel.
701+
jmp_to_fel();
696702

697-
cmd_boot(0, NULL);
703+
_fail:
704+
LCD_ShowString(0, 0, "SyterKit Boot Failed", SPI_LCD_COLOR_RED, SPI_LCD_COLOR_BLACK, 12);
705+
LCD_ShowString(0, 12, "Please Connect UART for Debug info", SPI_LCD_COLOR_RED, SPI_LCD_COLOR_BLACK, 12);
706+
LCD_ShowString(0, 24, "Error Info:", SPI_LCD_COLOR_RED, SPI_LCD_COLOR_BLACK, 12);
707+
LCD_Open_BLK();
698708

699-
_shell:
700-
syterkit_shell_attach(commands);
709+
abort();
701710

702711
return 0;
703712
}

0 commit comments

Comments
 (0)