/Solutions/STM32F4DISCOVERY/DeviceCode/Blockstorage/STM32F4/STM32F4_BlConfig.cpp

https://github.com/NETMF/netmf-interpreter · C++ · 145 lines · 110 code · 21 blank · 14 comment · 0 complexity · aaaf34d0d3b97406e17db3cf1c839ab8 MD5 · raw file

  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  6. //
  7. // Copyright (c) Microsoft Corporation. All rights reserved.
  8. // Implementation for the MCBSTM32F400 board (STM32F4): Copyright (c) Oberon microsystems, Inc.
  9. //
  10. // *** STM32F4DISCOVERY Block Storage Configuration ***
  11. //
  12. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  13. #include <tinyhal.h>
  14. #define FLASH_MANUFACTURER_CODE 0x0000 // not used
  15. #define FLASH_DEVICE_CODE 0x0000 // not used
  16. #define FLASH_BASE_ADDRESS1 0x08000000
  17. #define FLASH_BLOCK_COUNT1 4
  18. #define FLASH_BYTES_PER_BLOCK1 0x04000
  19. #define FLASH_BASE_ADDRESS2 0x08010000
  20. #define FLASH_BLOCK_COUNT2 1
  21. #define FLASH_BYTES_PER_BLOCK2 0x10000
  22. #define FLASH_BASE_ADDRESS3 0x08020000
  23. #define FLASH_BLOCK_COUNT3 7
  24. #define FLASH_BYTES_PER_BLOCK3 0x20000
  25. #define FLASH_BYTES_PER_SECTOR 2
  26. #define FLASH_BLOCK_ERASE_TYPICAL_TIME_USEC 1000000 // not used
  27. #define FLASH_SECTOR_WRITE_TYPICAL_TIME_USEC 10 // not used
  28. #define FLASH_BLOCK_ERASE_MAX_TIME_USEC 4000000 // not used
  29. #define FLASH_SECTOR_WRITE_MAX_TIME_USEC 100 // not used
  30. #define FLASH_BLOCK_ERASE_ACTUAL_TIME_USEC 10000 // not used
  31. // EBIU Information
  32. #define STM32F4__CHIP_SELECT 0
  33. #define STM32F4__WAIT_STATES 5 // not used
  34. #define STM32F4__RELEASE_COUNTS 0
  35. #define STM32F4__BIT_WIDTH 16
  36. #define STM32F4__BASE_ADDRESS 0x08000000
  37. #define STM32F4__SIZE_IN_BYTES 0x00100000
  38. #define STM32F4__WP_GPIO_PIN GPIO_PIN_NONE
  39. #define STM32F4__WP_ACTIVE FALSE
  40. // BlockDeviceInformation
  41. #define STM32F4__IS_REMOVABLE FALSE
  42. #define STM32F4__SUPPORTS_XIP TRUE
  43. #define STM32F4__WRITE_PROTECTED FALSE
  44. #define STM32F4__SUPP_COPY_BACK FALSE
  45. #define STM32F4__NUM_REGIONS 3
  46. const BlockRange g_STM32F4_BlockRange1[] =
  47. {
  48. { BlockRange::BLOCKTYPE_BOOTSTRAP , 0, 2 }, // 08000000 bootloader 48k
  49. { BlockRange::BLOCKTYPE_CONFIG , 3, 3 }, // 0800C000 config 16k
  50. };
  51. const BlockRange g_STM32F4_BlockRange2[] =
  52. {
  53. { BlockRange::BLOCKTYPE_CODE , 0, 0 }, // 08010000 CLR 64k
  54. };
  55. const BlockRange g_STM32F4_BlockRange3[] =
  56. {
  57. { BlockRange::BLOCKTYPE_CODE , 0, 3 }, // 08020000 CLR 512k
  58. { BlockRange::BLOCKTYPE_DEPLOYMENT, 4, 6 }, // 08080000 deployment 384k
  59. };
  60. const BlockRegionInfo g_STM32F4_BlkRegion[STM32F4__NUM_REGIONS] =
  61. {
  62. {
  63. FLASH_BASE_ADDRESS1, // ByteAddress Start; // Starting Sector address
  64. FLASH_BLOCK_COUNT1, // UINT32 NumBlocks; // total number of blocks in this region
  65. FLASH_BYTES_PER_BLOCK1, // UINT32 BytesPerBlock; // Total number of bytes per block
  66. ARRAYSIZE_CONST_EXPR(g_STM32F4_BlockRange1),
  67. g_STM32F4_BlockRange1,
  68. },
  69. {
  70. FLASH_BASE_ADDRESS2, // ByteAddress Start; // Starting Sector address
  71. FLASH_BLOCK_COUNT2, // UINT32 NumBlocks; // total number of blocks in this region
  72. FLASH_BYTES_PER_BLOCK2, // UINT32 BytesPerBlock; // Total number of bytes per block
  73. ARRAYSIZE_CONST_EXPR(g_STM32F4_BlockRange2),
  74. g_STM32F4_BlockRange2,
  75. },
  76. {
  77. FLASH_BASE_ADDRESS3, // ByteAddress Start; // Starting Sector address
  78. FLASH_BLOCK_COUNT3, // UINT32 NumBlocks; // total number of blocks in this region
  79. FLASH_BYTES_PER_BLOCK3, // UINT32 BytesPerBlock; // Total number of bytes per block
  80. ARRAYSIZE_CONST_EXPR(g_STM32F4_BlockRange3),
  81. g_STM32F4_BlockRange3,
  82. }
  83. };
  84. const BlockDeviceInfo g_STM32F4_DeviceInfo=
  85. {
  86. {
  87. STM32F4__IS_REMOVABLE, // BOOL Removable;
  88. STM32F4__SUPPORTS_XIP, // BOOL SupportsXIP;
  89. STM32F4__WRITE_PROTECTED, // BOOL WriteProtected;
  90. STM32F4__SUPP_COPY_BACK // BOOL SupportsCopyBack
  91. },
  92. FLASH_SECTOR_WRITE_TYPICAL_TIME_USEC, // UINT32 MaxSectorWrite_uSec;
  93. FLASH_BLOCK_ERASE_ACTUAL_TIME_USEC, // UINT32 MaxBlockErase_uSec;
  94. FLASH_BYTES_PER_SECTOR, // UINT32 BytesPerSector;
  95. FLASH_MEMORY_Size, // UINT32 Size;
  96. STM32F4__NUM_REGIONS, // UINT32 NumRegions;
  97. g_STM32F4_BlkRegion, // const BlockRegionInfo* pRegions;
  98. };
  99. struct MEMORY_MAPPED_NOR_BLOCK_CONFIG g_STM32F4_BS_Config =
  100. {
  101. { // BLOCK_CONFIG
  102. {
  103. STM32F4__WP_GPIO_PIN, // GPIO_PIN Pin;
  104. STM32F4__WP_ACTIVE, // BOOL ActiveState;
  105. },
  106. &g_STM32F4_DeviceInfo, // BlockDeviceinfo
  107. },
  108. { // CPU_MEMORY_CONFIG
  109. STM32F4__CHIP_SELECT, // UINT8 CPU_MEMORY_CONFIG::ChipSelect;
  110. TRUE, // UINT8 CPU_MEMORY_CONFIG::ReadOnly;
  111. STM32F4__WAIT_STATES, // UINT32 CPU_MEMORY_CONFIG::WaitStates;
  112. STM32F4__RELEASE_COUNTS, // UINT32 CPU_MEMORY_CONFIG::ReleaseCounts;
  113. STM32F4__BIT_WIDTH, // UINT32 CPU_MEMORY_CONFIG::BitWidth;
  114. STM32F4__BASE_ADDRESS, // UINT32 CPU_MEMORY_CONFIG::BaseAddress;
  115. STM32F4__SIZE_IN_BYTES, // UINT32 CPU_MEMORY_CONFIG::SizeInBytes;
  116. 0, // UINT8 CPU_MEMORY_CONFIG::XREADYEnable
  117. 0, // UINT8 CPU_MEMORY_CONFIG::ByteSignalsForRead
  118. 0, // UINT8 CPU_MEMORY_CONFIG::ExternalBufferEnable
  119. },
  120. 0, // UINT32 ChipProtection;
  121. FLASH_MANUFACTURER_CODE, // UINT32 ManufacturerCode;
  122. FLASH_DEVICE_CODE, // UINT32 DeviceCode;
  123. };
  124. struct BlockStorageDevice g_STM32F4_BS;