@@ -500,22 +500,21 @@ void hal_prepare_boot(void)
500500
501501}
502502
503- #ifdef __CCRX__
504- /* copy RAM functions from ROM to RAM */
505- static void copyfuncs (void )
506- {
507- unsigned char * dst , * src ;
508- src = __sectop ("PFRAM" );
509- dst = __sectop ("RPFRAM" );
510- while (src < __secend ("PFRAM" )) {
511- * dst ++ = * src ++ ;
512- }
513- }
514- #endif
515503int hal_flash_init (void )
516504{
517505#ifdef __CCRX__
518- copyfuncs ();
506+ unsigned char * src , * dst ;
507+ size_t n ;
508+
509+ src = (unsigned char * )__sectop ("PFRAM" );
510+ dst = (unsigned char * )__sectop ("RPFRAM" );
511+
512+ n = (size_t )((unsigned char * )__secend ("PFRAM" ) -
513+ (unsigned char * )__sectop ("PFRAM" ));
514+ wolfBoot_printf ("RAM Function start = 0x%p\n" , __sectop ("RPFRAM" ));
515+ wolfBoot_printf ("RAM Function end = 0x%p\n" , __secend ("RPFRAM" ));
516+ wolfBoot_printf ("RAM Function size = %d\n" , n );
517+ memcpy (dst , src , n );
519518#endif
520519 /* Flash Write Enable */
521520 FLASH_FWEPROR = FLASH_FWEPROR_FLWE ;
@@ -542,7 +541,7 @@ int hal_flash_init(void)
542541int RAMFUNCTION hal_flash_write (uint32_t addr , const uint8_t * data , int len )
543542{
544543 int i ;
545- uint8_t codeblock [FLASH_FACI_CODE_BLOCK_SZ ] = { 0 } ;
544+ uint8_t codeblock [FLASH_FACI_CODE_BLOCK_SZ ];
546545 uint16_t * data16 = (uint16_t * )data ;
547546 uint32_t block_base ;
548547 uint32_t offset ;
@@ -554,15 +553,14 @@ int RAMFUNCTION hal_flash_write(uint32_t addr, const uint8_t *data, int len)
554553 block_base = addr & ~(FLASH_FACI_CODE_BLOCK_SZ - 1 );
555554 offset = addr - block_base ;
556555
557- XMEMCPY (codeblock , (uint8_t * )block_base , FLASH_FACI_CODE_BLOCK_SZ );
556+ memcpy (codeblock , (uint8_t * )block_base , FLASH_FACI_CODE_BLOCK_SZ );
558557 write_size = FLASH_FACI_CODE_BLOCK_SZ - offset ;
559558 if (write_size > len )
560559 write_size = len ;
561560
562- XMEMCPY (& codeblock [offset ], data , write_size );
561+ memcpy (& codeblock [offset ], data , write_size );
563562 data16 = (uint16_t * )codeblock ;
564563
565-
566564 FLASH_FSADDR = block_base ;
567565 /* flash program command */
568566 FLASH_FACI_CMD8 = FLASH_FACI_CMD_PROGRAM ;
0 commit comments