16
16
#include <sstdlib.h>
17
17
#include <string.h>
18
18
19
- #include <cli.h>
20
- #include <cli_shell.h>
21
- #include <cli_termesc.h>
22
-
23
19
#include <sys-clk.h>
24
20
#include <sys-dram.h>
25
21
#include <sys-i2c.h>
36
32
#include <sys-sdhci.h>
37
33
#include <uart.h>
38
34
35
+ #include "spi_lcd.c"
36
+
37
+ #define CONFIG_SPLASH_LOAD_ADDR (0x40080000)
38
+ #define CONFIG_SPLASH_FILENAME "splash.bin"
39
+
39
40
#define CONFIG_BL31_FILENAME "bl31.bin"
40
41
#define CONFIG_BL31_LOAD_ADDR (0x48000000)
41
42
53
54
54
55
#define CONFIG_SDMMC_SPEED_TEST_SIZE 1024// (unit: 512B sectors)
55
56
56
- #define CONFIG_DEFAULT_BOOTDELAY 3
57
-
58
57
#define CONFIG_HEAP_BASE (0x50800000)
59
58
#define CONFIG_HEAP_SIZE (16 * 1024 * 1024)
60
59
@@ -99,6 +98,9 @@ typedef struct {
99
98
uint8_t * scp_dest ;
100
99
char scp_filename [FILENAME_MAX_LEN ];
101
100
101
+ uint8_t * splash_dest ;
102
+ char splash_filename [FILENAME_MAX_LEN ];
103
+
102
104
uint8_t * kernel_dest ;
103
105
uint8_t * ramdisk_dest ;
104
106
uint8_t * of_dest ;
@@ -199,6 +201,11 @@ static int load_sdcard(image_info_t *image) {
199
201
if (ret )
200
202
return ret ;
201
203
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
+
202
209
/* umount fs */
203
210
fret = f_mount (0 , "" , 0 );
204
211
if (fret != FR_OK ) {
@@ -536,36 +543,6 @@ static int load_extlinux(image_info_t *image, uint64_t dram_size) {
536
543
return err ;
537
544
}
538
545
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
-
569
546
static int abortboot_single_key (int bootdelay ) {
570
547
int abort = 0 ;
571
548
unsigned long ts ;
@@ -640,6 +617,8 @@ int main(void) {
640
617
/* Initialize the small memory allocator. */
641
618
smalloc_init (CONFIG_HEAP_BASE , CONFIG_HEAP_SIZE );
642
619
620
+ LCD_Init ();
621
+
643
622
sunxi_nsi_init ();
644
623
645
624
/* Clear the image_info_t struct. */
@@ -651,15 +630,18 @@ int main(void) {
651
630
image .of_dest = (uint8_t * ) CONFIG_DTB_LOAD_ADDR ;
652
631
image .ramdisk_dest = (uint8_t * ) CONFIG_INITRD_LOAD_ADDR ;
653
632
image .kernel_dest = (uint8_t * ) CONFIG_KERNEL_LOAD_ADDR ;
633
+ image .splash_dest = (uint8_t * ) CONFIG_SPLASH_LOAD_ADDR ;
654
634
655
635
strcpy (image .bl31_filename , CONFIG_BL31_FILENAME );
656
636
strcpy (image .scp_filename , CONFIG_SCP_FILENAME );
657
637
strcpy (image .extlinux_filename , CONFIG_EXTLINUX_FILENAME );
638
+ strcpy (image .splash_filename , CONFIG_SPLASH_FILENAME );
658
639
659
640
/* Initialize the SD host controller. */
660
641
if (sunxi_sdhci_init (& sdhci0 ) != 0 ) {
661
642
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 ;
663
645
} else {
664
646
printk (LOG_LEVEL_INFO , "SMHC: %s controller initialized\n" , sdhci0 .name );
665
647
}
@@ -670,34 +652,61 @@ int main(void) {
670
652
mdelay (30 );
671
653
if (sdmmc_init (& card0 , & sdhci0 ) != 0 ) {
672
654
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 ;
674
657
}
675
658
}
676
659
677
660
/* Load the DTB, kernel image, and configuration data from the SD card. */
678
661
if (load_sdcard (& image ) != 0 ) {
679
662
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 ;
681
665
}
682
666
667
+ LCD_Show_Splash (image .splash_dest );
668
+
669
+ LCD_Open_BLK ();
670
+
683
671
if (load_extlinux (& image , dram_size ) != 0 ) {
684
672
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 ;
686
675
}
687
676
688
677
printk (LOG_LEVEL_INFO , "EXTLINUX: load extlinux done, now booting...\n" );
689
678
690
- int bootdelay = CONFIG_DEFAULT_BOOTDELAY ;
679
+ atf_head_t * atf_head = ( atf_head_t * ) image . bl31_dest ;
691
680
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 ();
696
702
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 ();
698
708
699
- _shell :
700
- syterkit_shell_attach (commands );
709
+ abort ();
701
710
702
711
return 0 ;
703
712
}
0 commit comments