6666#include "xip/fsl_flexspi_nor_boot.h"
6767
6868/* #define DEBUG_EXT_FLASH */
69- /* #define TEST_FLASH */
70-
71- #ifdef TEST_FLASH
72- static int test_flash (void );
73- #endif
74-
7569
7670#ifdef __WOLFBOOT
7771
@@ -891,11 +885,6 @@ void hal_init(void)
891885 uart_write ("wolfBoot HAL Init\n" , 18 );
892886#endif
893887 hal_flash_init ();
894- #ifdef TEST_FLASH
895- if (test_flash () != 0 ) {
896- wolfBoot_printf ("Flash Test Failed!\n" );
897- }
898- #endif
899888}
900889
901890void hal_prepare_boot (void )
@@ -976,7 +965,7 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
976965 /**
977966 * Flash is memory mapped, so the address range must be invalidated in data cache
978967 * to ensure coherency between flash and cache.
979- *
968+ *
980969 * Also, both the address and size must be 32-byte aligned as cache-lines are 32 bytes
981970 * (see definition of DCACHE_InvalidateByRange).
982971 * To ensure all data is included we align the address downwards, and the length upwards.
@@ -1020,7 +1009,7 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
10201009 /**
10211010 * Flash is memory mapped, so the address range must be invalidated in data cache
10221011 * to ensure coherency between flash and cache.
1023- *
1012+ *
10241013 * Also, both the address and size must be 32-byte aligned as cache-lines are 32 bytes
10251014 * (see definition of DCACHE_InvalidateByRange).
10261015 * To ensure all data is included we align the address downwards, and the length upwards.
@@ -1034,43 +1023,3 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
10341023 return -1 ;
10351024 return 0 ;
10361025}
1037-
1038- #ifdef TEST_FLASH
1039-
1040- #ifndef TEST_ADDRESS
1041- #define TEST_ADDRESS (FLASH_BASE + 0x700000) /* 7MB */
1042- #endif
1043- /* #define TEST_FLASH_READONLY */
1044-
1045- static uint32_t pageData [WOLFBOOT_SECTOR_SIZE /4 ]; /* force 32-bit alignment */
1046-
1047- static int test_flash (void )
1048- {
1049- int ret ;
1050- uint32_t i ;
1051-
1052- #ifndef TEST_FLASH_READONLY
1053- /* Erase sector */
1054- ret = hal_flash_erase (TEST_ADDRESS , WOLFBOOT_SECTOR_SIZE );
1055- wolfBoot_printf ("Erase Sector: Ret %d\n" , ret );
1056-
1057- /* Fill data into the page_buffer */
1058- for (i = 0 ; i < sizeof (pageData )/sizeof (pageData [0 ]); i ++ ) {
1059- pageData [i ] = (i << 24 ) | (i << 16 ) | (i << 8 ) | i ;
1060- }
1061- /* Write Page */
1062- ret = hal_flash_write (TEST_ADDRESS , (uint8_t * )pageData , sizeof (pageData ));
1063- wolfBoot_printf ("Write Page: Ret %d\n" , ret );
1064- #endif /* !TEST_FLASH_READONLY */
1065-
1066- /* Compare Page */
1067- ret = memcmp ((void * )TEST_ADDRESS , pageData , sizeof (pageData ));
1068- if (ret != 0 ) {
1069- wolfBoot_printf ("Check Data @ %d failed\n" , ret );
1070- return ret ;
1071- }
1072-
1073- wolfBoot_printf ("Flash Test Passed\n" );
1074- return ret ;
1075- }
1076- #endif /* TEST_FLASH */
0 commit comments