/* hal.c * * Copyright (C) 2024 wolfSSL Inc. * * This file is part of wolfBoot. * * wolfBoot is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * wolfBoot is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ /* Code shared between all HAL's */ #include #include "hal.h" #include "string.h" #include "printf.h" /* Test for internal flash erase/write */ /* Use TEST_EXT_FLASH to test ext flash (see spi_flash.c or qspi_flash.c) */ #ifdef TEST_FLASH #ifndef TEST_ADDRESS #define TEST_SZ WOLFBOOT_SECTOR_SIZE #define TEST_ADDRESS WOLFBOOT_PARTITION_UPDATE_ADDRESS #define TEST_ADDRESS_BANKA WOLFBOOT_PARTITION_BOOT_ADDRESS #define TEST_ADDRESS_BANKB WOLFBOOT_PARTITION_UPDATE_ADDRESS #endif int hal_flash_test(void) { int ret = 0; uint32_t i, len; uint8_t* pagePtr = (uint8_t*)TEST_ADDRESS; static uint8_t pageData[TEST_SZ]; wolfBoot_printf("Internal flash test at 0x%x\n", TEST_ADDRESS); /* Setup test data */ for (i=0; i