]> git.karo-electronics.de Git - karo-tx-redboot.git/blobdiff - packages/hal/arm/mx51/babbage/v2_0/src/redboot_cmds.c
TX51 pre-release
[karo-tx-redboot.git] / packages / hal / arm / mx51 / babbage / v2_0 / src / redboot_cmds.c
index bf295b85b4607d24803222a5042205ee6dd5f411..68423fa5701ef7c23fb3aeab76cc92375bd6b93f 100644 (file)
@@ -60,59 +60,7 @@ RedBoot_config_option("Board specifics",
                      );
 #endif  //CYGSEM_REDBOOT_FLASH_CONFIG
 
-char HAL_PLATFORM_EXTRA[20] = "PASS x.x [x32 DDR]";
-
-static void runImg(int argc, char *argv[]);
-
-RedBoot_cmd("run",
-            "Run an image at a location with MMU off",
-            "[<virtual addr>]",
-            runImg
-           );
-
-void launchRunImg(unsigned long addr)
-{
-    asm volatile ("mov r12, r0;");
-    HAL_CACHE_FLUSH_ALL();
-    HAL_DISABLE_L2();
-    HAL_MMU_OFF();
-    asm volatile (
-                 "mov r0, #0;"
-                 "mov r1, r12;"
-                 "mov r11, #0;"
-                 "mov r12, #0;"
-                 "mrs r10, cpsr;"
-                 "bic r10, r10, #0xF0000000;"
-                 "msr cpsr_f, r10;"
-                 "mov pc, r1"
-                 );
-}
-
-extern unsigned long entry_address;
-
-static void runImg(int argc,char *argv[])
-{
-    unsigned int virt_addr, phys_addr;
-
-    // Default physical entry point for Symbian
-    if (entry_address == 0xFFFFFFFF)
-        virt_addr = 0x800000;
-    else
-    virt_addr = entry_address;
-
-    if (!scan_opts(argc,argv,1,0,0,(void*)&virt_addr,
-                   OPTION_ARG_TYPE_NUM, "virtual address"))
-        return;
-
-    if (entry_address != 0xFFFFFFFF)
-        diag_printf("load entry_address=0x%lx\n", entry_address);
-    HAL_VIRT_TO_PHYS_ADDRESS(virt_addr, phys_addr);
-
-    diag_printf("virt_addr=0x%x\n",virt_addr);
-    diag_printf("phys_addr=0x%x\n",phys_addr);
-
-    launchRunImg(phys_addr);
-}
+char HAL_PLATFORM_EXTRA[40] = "PASS x.x [x32 DDR]. Board Rev 2.0";
 
 #if defined(CYGSEM_REDBOOT_FLASH_CONFIG) && defined(CYG_HAL_STARTUP_ROMRAM)
 
@@ -129,6 +77,7 @@ extern unsigned char *ram_end; //ram end is where the redboot starts FIXME: use
 extern cyg_uint32 mmc_data_read (cyg_uint32 *,cyg_uint32 ,cyg_uint32);
 extern int spi_nor_erase_block(void* block_addr, unsigned int block_size);
 extern int spi_nor_program_buf(void *addr, void *data, int len);
+extern void __attribute__((__noinline__)) launchRunImg(unsigned long addr);
 
 #ifdef CYGPKG_IO_FLASH
 void romupdate(int argc, char *argv[])
@@ -139,6 +88,17 @@ void romupdate(int argc, char *argv[])
 
     if (IS_FIS_FROM_MMC() || IS_BOOTING_FROM_MMC()) {
         diag_printf("Updating ROM in MMC/SD flash\n");
+        /* eMMC 4.3 and eSD 2.1 supported on TO 2.0 and higher */
+        if(!emmc_set_boot_partition((cyg_uint32*)(SDRAM_BASE_ADDR + SDRAM_SIZE - 0x100000), CYGBLD_REDBOOT_MIN_IMAGE_SIZE)) {
+            /* eMMC 4.3 */
+            diag_printf("Card supports MMC-4.3, programming for boot operation.\n");
+            return;
+        } else if(!esd_set_boot_partition((cyg_uint32*)(SDRAM_BASE_ADDR + SDRAM_SIZE - 0x100000), CYGBLD_REDBOOT_MIN_IMAGE_SIZE)) {
+            /* eSD 2.1 */
+            diag_printf("Card supports SD-2.1, programming for boot operation.\n");
+            return;
+        }
+
         base_addr = (void*)0;
         /* Read the first 1K from the card */
         mmc_data_read((cyg_uint32*)(SDRAM_BASE_ADDR + SDRAM_SIZE - 0x100000),
@@ -184,7 +144,6 @@ extern reset_func_t reset_vector;
 
 void factive(int argc, char *argv[])
 {
-    unsigned long phys_addr;
     unsigned int *fis_addr = IRAM_BASE_ADDR;
 
     if (argc != 2) {
@@ -212,18 +171,22 @@ void factive(int argc, char *argv[])
 #define POST_SIZE                       0x100000
 #define POST_MAGIC_MARKER               0x43
 
-
 void imx_launch_post(void)
 {
     mmc_data_read(0x100000,     // ram location
                   0x40000,      // length
                   0x100000);    // from MMC/SD offset 0x100000
+    /* Need this to recognize the SPI-NOR part */
+    if (spi_norflash_hwr_init() != 0)
+        return;
+
     spi_nor_erase_block(0, 0x10000);
     spi_nor_erase_block(0x10000, 0x10000);
     spi_nor_erase_block(0x20000, 0x10000);
     spi_nor_erase_block(0x30000, 0x10000);
     // save the redboot to SPI-NOR
-    spi_nor_program_buf(0, 0x100000, 0x40000);
+    if (spi_nor_program_buf(0, 0x100000, 0x40000) != 0)
+        return;
 
     diag_printf("Reading POST from MMC to SDRAM...\n");
     mmc_data_read(SDRAM_BASE_ADDR + POST_SDRAM_START_OFFSET,    // ram location