diff --git a/Makefile b/Makefile index 85317c6..ed88e6b 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,21 @@ LIBS_McciBootloader_4801 := \ LDSCRIPT_McciBootloader_4801 := $(BOOTLOADER_LDSCRIPT_ABZ) +############################################################################## +# +# The 491x bootloader +# +############################################################################## + +BOOTLOADERS += McciBootloader_491x + +LIBS_McciBootloader_491x := \ + ${BOOTLOADER_LIBS_ABZ} \ + ${T_OBJDIR}/libmcci_bootloader_model491x.a \ +### end LIBS_McciBootloader_491x + +LDSCRIPT_McciBootloader_491x := $(BOOTLOADER_LDSCRIPT_ABZ) + ############################################################################## # # The 46xx bootloader @@ -97,6 +112,21 @@ LIBS_McciBootloader_46xx := \ LDSCRIPT_McciBootloader_46xx := $(BOOTLOADER_LDSCRIPT_ABZ) +############################################################################## +# +# The 51xx bootloader +# +############################################################################## + +BOOTLOADERS += McciBootloader_51xx + +LIBS_McciBootloader_51xx := \ + ${BOOTLOADER_LIBS_ABZ} \ + ${T_OBJDIR}/libmcci_bootloader_catena51xx.a \ +### end LIBS_McciBootloader_51xx + +LDSCRIPT_McciBootloader_51xx := $(BOOTLOADER_LDSCRIPT_ABZ) + ############################################################################## # # The cm0plus library @@ -215,6 +245,29 @@ SOURCES_libmcci_bootloader_catena4801 := \ $_/src/mccibootloaderboard_catena4801_storageinit.c \ # end SOURCES_libmcci_bootloader_catena4801 +############################################################################## +# +# The model491x library +# +############################################################################## + +LIBRARIES += libmcci_bootloader_model491x + +_ := platform/board/mcci/model491x + +CFLAGS_OPT_libmcci_bootloader_model491x += -Os + +INCLUDES_libmcci_bootloader_model491x := \ + $(INCLUDES_libmcci_bootloader_catena_abz) \ + platform/driver/flash_mx25v8035f/i \ + $_/i \ +# end INCLUDES_libmcci_bootloader_model491x + +SOURCES_libmcci_bootloader_model491x := \ + $_/src/mccibootloaderboard_model491x_platforminterface.c \ + $_/src/mccibootloaderboard_model491x_storageinit.c \ +# end SOURCES_libmcci_bootloader_model491x + ############################################################################## # # The catena46xx library @@ -238,6 +291,29 @@ SOURCES_libmcci_bootloader_catena46xx := \ $_/src/mccibootloaderboard_catena46xx_storageinit.c \ # end SOURCES_libmcci_bootloader_catena46xx +############################################################################## +# +# The catena51xx library +# +############################################################################## + +LIBRARIES += libmcci_bootloader_catena51xx + +_ := platform/board/mcci/catena51xx + +CFLAGS_OPT_libmcci_bootloader_catena51xx += -Os + +INCLUDES_libmcci_bootloader_catena51xx := \ + $(INCLUDES_libmcci_bootloader_catena_abz) \ + platform/driver/flash_mx25v8035f/i \ + $_/i \ +# end INCLUDES_libmcci_bootloader_catena51xx + +SOURCES_libmcci_bootloader_catena51xx := \ + $_/src/mccibootloaderboard_catena51xx_platforminterface.c \ + $_/src/mccibootloaderboard_catena51xx_storageinit.c \ +# end SOURCES_libmcci_bootloader_catena51xx + ############################################################################## # # mcci_tweetnacl diff --git a/platform/board/mcci/catena51xx/i/mcci_bootloader_board_catena51xx.h b/platform/board/mcci/catena51xx/i/mcci_bootloader_board_catena51xx.h new file mode 100644 index 0000000..4e63451 --- /dev/null +++ b/platform/board/mcci/catena51xx/i/mcci_bootloader_board_catena51xx.h @@ -0,0 +1,37 @@ +/* + +Module: mcci_bootloader_board_catena51xx.h + +Function: + Definitions for bootloader on MCCI Catena 51xx. + +Copyright and License: + This file copyright (C) 2023 by + + MCCI Corporation + 3520 Krums Corners Road + Ithaca, NY 14850 + + See accompanying LICENSE file for copyright and license information. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation October 2023 + +*/ + +#ifndef _mcci_bootloader_board_catena51xx_h_ +#define _mcci_bootloader_board_catena51xx_h_ /* prevent multiple includes */ + +#pragma once + +#include "mcci_bootloader_platform.h" +#include "mcci_bootloader_board_catena_abz.h" + +MCCI_BOOTLOADER_BEGIN_DECLS + +McciBootloaderPlatform_StorageInitFn_t +McciBootloaderBoard_Catena51xx_storageInit; + +MCCI_BOOTLOADER_END_DECLS + +#endif /* _mcci_bootloader_board_catena51xx_h_ */ diff --git a/platform/board/mcci/catena51xx/src/mccibootloaderboard_catena51xx_platforminterface.c b/platform/board/mcci/catena51xx/src/mccibootloaderboard_catena51xx_platforminterface.c new file mode 100644 index 0000000..3b1a6b4 --- /dev/null +++ b/platform/board/mcci/catena51xx/src/mccibootloaderboard_catena51xx_platforminterface.c @@ -0,0 +1,78 @@ +/* + +Module: mccibootloaderboard_catena51xx_platforminterface.c + +Function: + gk_McciBootloaderPlatformInterface for MCCI Catena 51xx boards. + +Copyright and License: + This file copyright (C) 2023 by + + MCCI Corporation + 3520 Krums Corners Road + Ithaca, NY 14850 + + See accompanying LICENSE file for copyright and license information. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation October 2023 + +*/ + +#include "mcci_bootloader_board_catena51xx.h" + +#include "mcci_bootloader_flash_mx25v8035f.h" + +/****************************************************************************\ +| +| Manifest constants & typedefs. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + +const McciBootloaderPlatform_Interface_t +gk_McciBootloaderPlatformInterface = + { + .pSystemInit = McciBootloaderBoard_CatenaAbz_systemInit, + .pPrepareForLaunch = McciBootloaderBoard_CatenaAbz_prepareForLaunch, + .pFail = McciBootloaderBoard_CatenaAbz_fail, + .pDelayMs = McciBootloaderBoard_CatenaAbz_delayMs, + .pGetUpdate = McciBootloaderBoard_CatenaAbz_getUpdate, + .pSetUpdate = McciBootloaderBoard_CatenaAbz_setUpdate, + .pSystemFlashErase = McciBootloader_Stm32L0_systemFlashErase, + .pSystemFlashWrite = McciBootloader_Stm32L0_systemFlashWrite, + .Storage = + { + .pInit = McciBootloaderBoard_Catena51xx_storageInit, + .pRead = McciBootloaderFlash_Mx25v8035f_storageRead, + .pGetPrimaryAddress = McciBootloaderBoard_CatenaAbz_getPrimaryStorageAddress, + .pGetFallbackAddress = McciBootloaderBoard_CatenaAbz_getFallbackStorageAddress, + }, + .Spi = + { + .pInit = McciBootloaderBoard_CatenaAbz_spiInit, + .pTransfer = McciBootloaderBoard_CatenaAbz_spiTransfer, + }, + .Annunciator = + { + .pInit = McciBootloaderBoard_CatenaAbz_annunciatorInit, + .pIndicateState = McciBootloaderBoard_CatenaAbz_annunciatorIndicateState, + }, + }; + +/****************************************************************************\ +| +| Variables. +| +\****************************************************************************/ + + + +/**** end of mccibootloaderboard_catena51xx_platforminterface.c ****/ diff --git a/platform/board/mcci/catena51xx/src/mccibootloaderboard_catena51xx_storageinit.c b/platform/board/mcci/catena51xx/src/mccibootloaderboard_catena51xx_storageinit.c new file mode 100644 index 0000000..6c56484 --- /dev/null +++ b/platform/board/mcci/catena51xx/src/mccibootloaderboard_catena51xx_storageinit.c @@ -0,0 +1,85 @@ +/* + +Module: mccibootloaderboard_catena51xx_storageinit.c + +Function: + McciBootloaderBoard_Catena51xx_storageInit() + +Copyright and License: + This file copyright (C) 2023 by + + MCCI Corporation + 3520 Krums Corners Road + Ithaca, NY 14850 + + See accompanying LICENSE file for copyright and license information. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation October 2023 + +*/ + +#include "mcci_bootloader_board_catena51xx.h" + +#include "mcci_bootloader_flash_mx25v8035f.h" + +/****************************************************************************\ +| +| Manifest constants & typedefs. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Variables. +| +\****************************************************************************/ + + +/* + +Name: McciBootloaderBoard_Catena51xx_storageInit() + +Function: + Initialize the Catena51xx external storage. + +Definition: + typedef McciBootloaderPlatform_StorageInit_t + McciBootloaderBoard_Catena51xx_storageInit; + + void McciBootloaderBoard_Catena51xx_storageInit( + void + ); + +Description: + Initialize SPI, init the external flash, and we're ready. + +Returns: + No explicit result. + +Notes: + + +*/ + +void +McciBootloaderBoard_Catena51xx_storageInit( + void + ) + { + McciBootloaderPlatform_spiInit(); + McciBootloaderFlash_Mx25v8035f_storageInit(); + } + + +/**** end of mccibootloaderboard_catena51xx_storageinit.c ****/ diff --git a/platform/board/mcci/model491x/i/mcci_bootloader_board_model491x.h b/platform/board/mcci/model491x/i/mcci_bootloader_board_model491x.h new file mode 100644 index 0000000..9611483 --- /dev/null +++ b/platform/board/mcci/model491x/i/mcci_bootloader_board_model491x.h @@ -0,0 +1,37 @@ +/* + +Module: mcci_bootloader_board_model491x.h + +Function: + Definitions for bootloader on MCCI Catena 491x boards. + +Copyright and License: + This file copyright (C) 2023 by + + MCCI Corporation + 3520 Krums Corners Road + Ithaca, NY 14850 + + See accompanying LICENSE file for copyright and license information. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation September 2023 + +*/ + +#ifndef _mcci_bootloader_board_model491x_h_ +#define _mcci_bootloader_board_model491x_h_ /* prevent multiple includes */ + +#pragma once + +#include "mcci_bootloader_platform.h" +#include "mcci_bootloader_board_catena_abz.h" + +MCCI_BOOTLOADER_BEGIN_DECLS + +McciBootloaderPlatform_StorageInitFn_t +McciBootloaderBoard_Model491x_storageInit; + +MCCI_BOOTLOADER_END_DECLS + +#endif /* _mcci_bootloader_board_model491x_h_ */ diff --git a/platform/board/mcci/model491x/src/mccibootloaderboard_model491x_platforminterface.c b/platform/board/mcci/model491x/src/mccibootloaderboard_model491x_platforminterface.c new file mode 100644 index 0000000..1efce68 --- /dev/null +++ b/platform/board/mcci/model491x/src/mccibootloaderboard_model491x_platforminterface.c @@ -0,0 +1,78 @@ +/* + +Module: mccibootloaderboard_model491x_platforminterface.c + +Function: + gk_McciBootloaderPlatformInterface for MCCI Catena 491x boards. + +Copyright and License: + This file copyright (C) 2023 by + + MCCI Corporation + 3520 Krums Corners Road + Ithaca, NY 14850 + + See accompanying LICENSE file for copyright and license information. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation September 2023 + +*/ + +#include "mcci_bootloader_board_model491x.h" + +#include "mcci_bootloader_flash_mx25v8035f.h" + +/****************************************************************************\ +| +| Manifest constants & typedefs. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + +const McciBootloaderPlatform_Interface_t +gk_McciBootloaderPlatformInterface = + { + .pSystemInit = McciBootloaderBoard_CatenaAbz_systemInit, + .pPrepareForLaunch = McciBootloaderBoard_CatenaAbz_prepareForLaunch, + .pFail = McciBootloaderBoard_CatenaAbz_fail, + .pDelayMs = McciBootloaderBoard_CatenaAbz_delayMs, + .pGetUpdate = McciBootloaderBoard_CatenaAbz_getUpdate, + .pSetUpdate = McciBootloaderBoard_CatenaAbz_setUpdate, + .pSystemFlashErase = McciBootloader_Stm32L0_systemFlashErase, + .pSystemFlashWrite = McciBootloader_Stm32L0_systemFlashWrite, + .Storage = + { + .pInit = McciBootloaderBoard_Model491x_storageInit, + .pRead = McciBootloaderFlash_Mx25v8035f_storageRead, + .pGetPrimaryAddress = McciBootloaderBoard_CatenaAbz_getPrimaryStorageAddress, + .pGetFallbackAddress = McciBootloaderBoard_CatenaAbz_getFallbackStorageAddress, + }, + .Spi = + { + .pInit = McciBootloaderBoard_CatenaAbz_spiInit, + .pTransfer = McciBootloaderBoard_CatenaAbz_spiTransfer, + }, + .Annunciator = + { + .pInit = McciBootloaderBoard_CatenaAbz_annunciatorInit, + .pIndicateState = McciBootloaderBoard_CatenaAbz_annunciatorIndicateState, + }, + }; + +/****************************************************************************\ +| +| Variables. +| +\****************************************************************************/ + + + +/**** end of mccibootloaderboard_model491x_platforminterface.c ****/ diff --git a/platform/board/mcci/model491x/src/mccibootloaderboard_model491x_storageinit.c b/platform/board/mcci/model491x/src/mccibootloaderboard_model491x_storageinit.c new file mode 100644 index 0000000..91b559b --- /dev/null +++ b/platform/board/mcci/model491x/src/mccibootloaderboard_model491x_storageinit.c @@ -0,0 +1,92 @@ +/* + +Module: mccibootloaderboard_model491x_storageinit.c + +Function: + McciBootloaderBoard_Model491x_storageInit() + +Copyright and License: + This file copyright (C) 2023 by + + MCCI Corporation + 3520 Krums Corners Road + Ithaca, NY 14850 + + See accompanying LICENSE file for copyright and license information. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation September 2023 + +*/ + +#include "mcci_bootloader_board_model491x.h" + +#include "mcci_bootloader_board_catena_abz.h" +#include "mcci_bootloader_flash_mx25v8035f.h" +#include "mcci_stm32l0xx.h" +#include +#include +#include + +/****************************************************************************\ +| +| Manifest constants & typedefs. +| +\****************************************************************************/ + +static void +storagePowerOn(void); + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Variables. +| +\****************************************************************************/ + +static void +storagePowerOn(void) + { + // enable GPIOH + McciArm_putRegOr( + MCCI_STM32L0_REG_RCC_IOPENR, + MCCI_STM32L0_REG_RCC_IOPENR_IOPHEN + ); + + // turn on power to the storage chip (491x) by making PH1 an output and + // driving it to a one. + McciArm_putRegMasked( + MCCI_STM32L0_REG_GPIOH + MCCI_STM32L0_GPIO_MODER, + MCCI_STM32L0_GPIO_MODE_P(1), + MCCI_BOOTLOADER_FIELD_SET_VALUE(MCCI_STM32L0_GPIO_MODE_P(1), MCCI_STM32L0_GPIO_MODE_OUT) + ); + + McciArm_putRegOr( + MCCI_STM32L0_REG_GPIOH + MCCI_STM32L0_GPIO_BSRR, + MCCI_STM32L0_GPIO_BSRR_BS_P(1) + ); + + // delay 50 ms + McciBootloaderPlatform_delayMs(50); + } + + +void +McciBootloaderBoard_Model491x_storageInit( + void + ) + { + storagePowerOn(); + McciBootloaderPlatform_spiInit(); + McciBootloaderFlash_Mx25v8035f_storageInit(); + } + + +/**** end of mccibootloaderboard_model491x_storageinit.c ****/