| 1 |
/* |
| 2 |
* This file is part of the MicroPython project, http://micropython.org/ |
| 3 |
* |
| 4 |
* The MIT License (MIT) |
| 5 |
* |
| 6 |
* Copyright (c) 2018-2019 Damien P. George |
| 7 |
* |
| 8 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 |
* of this software and associated documentation files (the "Software"), to deal |
| 10 |
* in the Software without restriction, including without limitation the rights |
| 11 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 |
* copies of the Software, and to permit persons to whom the Software is |
| 13 |
* furnished to do so, subject to the following conditions: |
| 14 |
* |
| 15 |
* The above copyright notice and this permission notice shall be included in |
| 16 |
* all copies or substantial portions of the Software. |
| 17 |
* |
| 18 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 |
* THE SOFTWARE. |
| 25 |
*/ |
| 26 |
|
| 27 |
// Take PYBD_SF2 as base configuration |
| 28 |
#include "boards/PYBD_SF2/mpconfigboard.h" |
| 29 |
|
| 30 |
#undef MICROPY_HW_BOARD_NAME |
| 31 |
#undef MICROPY_HW_MCU_NAME |
| 32 |
#undef MICROPY_HW_CLK_PLLM |
| 33 |
#undef MICROPY_HW_CLK_PLLN |
| 34 |
#undef MICROPY_HW_CLK_PLLP |
| 35 |
#undef MICROPY_HW_CLK_PLLQ |
| 36 |
#undef MICROPY_HW_FLASH_LATENCY |
| 37 |
|
| 38 |
#define MICROPY_HW_BOARD_NAME "PYBD-SF6W" |
| 39 |
#define MICROPY_HW_MCU_NAME "STM32F767IIK" |
| 40 |
|
| 41 |
// HSE is 25MHz, run SYS at 144MHz |
| 42 |
#define MICROPY_HW_CLK_PLLM (25) |
| 43 |
#define MICROPY_HW_CLK_PLLN (288) |
| 44 |
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2) |
| 45 |
#define MICROPY_HW_CLK_PLLQ (6) |
| 46 |
#define MICROPY_HW_FLASH_LATENCY (FLASH_LATENCY_4) |
| 47 |
|
| 48 |
// ROMFS config |
| 49 |
#define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_QSPI (1) |
| 50 |
#define MICROPY_HW_ROMFS_QSPI_SPIFLASH_OBJ (&spi_bdev2.spiflash) |
| 51 |
#define MICROPY_HW_ROMFS_ENABLE_PART0 (1) |
| 52 |
|
| 53 |
// Extra UART config |
| 54 |
#define MICROPY_HW_UART7_TX (pyb_pin_W16) |
| 55 |
#define MICROPY_HW_UART7_RX (pyb_pin_W22B) |
| 56 |
|
| 57 |
// Extra CAN buses |
| 58 |
#define MICROPY_HW_CAN2_NAME "Y" |
| 59 |
#define MICROPY_HW_CAN2_TX (pyb_pin_Y6) |
| 60 |
#define MICROPY_HW_CAN2_RX (pyb_pin_Y5) |
| 61 |
|
| 62 |
// Ethernet via RMII |
| 63 |
#define MICROPY_HW_ETH_MDC (pyb_pin_W24) |
| 64 |
#define MICROPY_HW_ETH_MDIO (pyb_pin_W15) |
| 65 |
#define MICROPY_HW_ETH_RMII_REF_CLK (pyb_pin_W17) |
| 66 |
#define MICROPY_HW_ETH_RMII_CRS_DV (pyb_pin_W14) |
| 67 |
#define MICROPY_HW_ETH_RMII_RXD0 (pyb_pin_W51) |
| 68 |
#define MICROPY_HW_ETH_RMII_RXD1 (pyb_pin_W47) |
| 69 |
#define MICROPY_HW_ETH_RMII_TX_EN (pyb_pin_W8) |
| 70 |
#define MICROPY_HW_ETH_RMII_TXD0 (pyb_pin_W45) |
| 71 |
#define MICROPY_HW_ETH_RMII_TXD1 (pyb_pin_W49) |
| 72 |
|
| 73 |
// The below code reconfigures SPI flash for dynamic size detection. |
| 74 |
|
| 75 |
#undef MICROPY_BOARD_EARLY_INIT |
| 76 |
#undef MICROPY_HW_SPIFLASH_SIZE_BITS |
| 77 |
#undef MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 |
| 78 |
#undef MBOOT_SPIFLASH_BYTE_SIZE |
| 79 |
#undef MBOOT_SPIFLASH_LAYOUT |
| 80 |
#undef MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE |
| 81 |
#undef MBOOT_SPIFLASH2_BYTE_SIZE |
| 82 |
#undef MBOOT_SPIFLASH2_LAYOUT |
| 83 |
#undef MBOOT_SPIFLASH2_ERASE_BLOCKS_PER_PAGE |
| 84 |
|
| 85 |
// These are convenience macros to refer to the SPI flash chip parameters for the external SPI flash. |
| 86 |
#define MICROPY_BOARD_SPIFLASH_CHIP_PARAMS0 (spi_bdev.spiflash.chip_params) // SPI flash #1, R/W storage |
| 87 |
#define MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1 (spi_bdev2.spiflash.chip_params) // SPI flash #2, memory mapped |
| 88 |
|
| 89 |
// Early init is needed to initialise the default SPI flash chip parameters. |
| 90 |
#define MICROPY_BOARD_EARLY_INIT board_early_init_sf6 |
| 91 |
|
| 92 |
// Enable dynamic detection of SPI flash. |
| 93 |
#define MICROPY_HW_SPIFLASH_CHIP_PARAMS (1) |
| 94 |
#define MICROPY_HW_SPIFLASH_DETECT_DEVICE (1) |
| 95 |
|
| 96 |
// Settings for SPI flash #1. |
| 97 |
#define MICROPY_HW_SPIFLASH_SIZE_BITS (1 << (MICROPY_BOARD_SPIFLASH_CHIP_PARAMS0->memory_size_bytes_log2 + 3)) |
| 98 |
|
| 99 |
// Settings for SPI flash #2. |
| 100 |
#define MICROPY_HW_QSPI_PRESCALER (MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1->qspi_prescaler) |
| 101 |
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1->memory_size_bytes_log2 + 3) |
| 102 |
|
| 103 |
// ROMFS partition 0 is dynamically sized (SPI flash #2). |
| 104 |
#define MICROPY_HW_ROMFS_PART0_START (uintptr_t)(&_micropy_hw_romfs_part0_start) |
| 105 |
#define MICROPY_HW_ROMFS_PART0_SIZE (1 << MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1->memory_size_bytes_log2) |
| 106 |
|
| 107 |
// Mboot SPI flash #1 configuration. |
| 108 |
#define MBOOT_SPIFLASH_LAYOUT_DYNAMIC_MAX_LEN (20) |
| 109 |
#define MBOOT_SPIFLASH_LAYOUT (MICROPY_BOARD_SPIFLASH_CHIP_PARAMS0->memory_size_bytes_log2 == 21 ? "/0x80000000/512*4Kg" : "/0x80000000/2048*4Kg") |
| 110 |
#define MBOOT_SPIFLASH_BYTE_SIZE (1 << MICROPY_BOARD_SPIFLASH_CHIP_PARAMS0->memory_size_bytes_log2) |
| 111 |
#define MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE (1) |
| 112 |
|
| 113 |
// Mboot SPI flash #2 configuration. |
| 114 |
#define MBOOT_SPIFLASH2_LAYOUT_DYNAMIC_MAX_LEN (20) |
| 115 |
#define MBOOT_SPIFLASH2_LAYOUT (MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1->memory_size_bytes_log2 == 21 ? "/0x90000000/512*4Kg" : "/0x90000000/2048*4Kg") |
| 116 |
#define MBOOT_SPIFLASH2_BYTE_SIZE (1 << MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1->memory_size_bytes_log2) |
| 117 |
#define MBOOT_SPIFLASH2_ERASE_BLOCKS_PER_PAGE (1) |
| 118 |
|
| 119 |
extern unsigned char _micropy_hw_romfs_part0_start; |
| 120 |
|
| 121 |
void board_early_init_sf6(void); |