Skip to content

Commit a9d3ad8

Browse files
committed
Fix flash size, add filesystem disable flag
1 parent 0fdb5a0 commit a9d3ad8

8 files changed

Lines changed: 84 additions & 197 deletions

File tree

ports/stm32f4/boards/STM32F411VETx_FLASH.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ MEMORY
77
{
88
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */
99
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */
10-
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 112K /* sectors 1,2,3 are 16K, 4 is 64K */
11-
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5,6,7 are 128K */
10+
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */
11+
FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */
1212
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
1313
}
1414

ports/stm32f4/boards/stm32f411.ld

Lines changed: 0 additions & 189 deletions
This file was deleted.

ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737

3838
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
3939

40-
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0x01C000 - CIRCUITPY_INTERNAL_NVM_SIZE)
40+
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4141

4242
#define AUTORESET_DELAY_MS 500

ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ USB_PID = 0x572B
33
USB_PRODUCT = "STM32F412ZG Discovery Board - CPy"
44
USB_MANUFACTURER = "STMicroelectronics"
55

6+
DISABLE_FILESYSTEM = 1
7+
68
MCU_SERIES = m4
79
MCU_VARIANT = stm32f4
810
MCU_SUB_VARIANT = stm32f412zx

ports/stm32f4/common-hal/busio/SPI.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t* self) {
8787

8888
uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) {
8989
return 0;
90+
}

ports/stm32f4/supervisor/internal_flash.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,17 @@
3333

3434
#ifdef STM32F411xE
3535
#define STM32_FLASH_SIZE 0x80000 //512KiB
36-
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x1C000 //112KiB
36+
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //112KiB
3737
#endif
3838

3939
#ifdef STM32F412Zx
4040
#define STM32_FLASH_SIZE 0x100000 //1MB
41-
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x1C000 //112KiB
41+
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //112KiB
4242
#endif
4343

4444
#define STM32_FLASH_OFFSET 0x8000000 //All STM32 chips map to this flash location
4545

4646
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000
47-
//#define INTERNAL_FLASH_FILESYSTEM_START_ADDR ((STM32_FLASH_SIZE + STM32_FLASH_OFFSET) - INTERNAL_FLASH_FILESYSTEM_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE)
4847
#define INTERNAL_FLASH_FILESYSTEM_NUM_BLOCKS (INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE)
4948

5049
#define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms

supervisor/stub/internal_flash.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*f
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2013, 2014 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+
#include "supervisor/internal_flash.h"
27+
28+
#include <stdint.h>
29+
#include <string.h>
30+
31+
#include "extmod/vfs.h"
32+
#include "extmod/vfs_fat.h"
33+
#include "py/mphal.h"
34+
#include "py/obj.h"
35+
#include "py/runtime.h"
36+
#include "lib/oofatfs/ff.h"
37+
38+
void supervisor_flash_init(void) {
39+
}
40+
41+
uint32_t supervisor_flash_get_block_size(void) {
42+
return 0;
43+
}
44+
45+
uint32_t supervisor_flash_get_block_count(void) {
46+
return 0;
47+
}
48+
49+
void supervisor_flash_flush(void) {
50+
}
51+
52+
static int32_t convert_block_to_flash_addr(uint32_t block) {
53+
return -1;
54+
}
55+
56+
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
57+
return 0; // success
58+
}
59+
60+
bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) {
61+
return true;
62+
}
63+
64+
mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) {
65+
return 0; // success
66+
}
67+
68+
void supervisor_flash_release_cache(void) {
69+
}
70+

supervisor/supervisor.mk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SRC_SUPERVISOR = \
1313
supervisor/shared/translate.c
1414

1515
ifndef $(NO_USB)
16-
NO_USB = $(wildcard supervisor/usb.c)
16+
NO_USB = $(wildcard supervisor/usb.c)
1717
endif
1818

1919
ifneq ($(INTERNAL_FLASH_FILESYSTEM),)
@@ -44,7 +44,11 @@ ifdef EXTERNAL_FLASH_DEVICES
4444
SRC_SUPERVISOR += supervisor/qspi_flash.c supervisor/shared/external_flash/qspi_flash.c
4545
endif
4646
else
47-
SRC_SUPERVISOR += supervisor/internal_flash.c
47+
ifneq ($(DISABLE_FILESYSTEM),1)
48+
SRC_SUPERVISOR += supervisor/internal_flash.c
49+
else
50+
SRC_SUPERVISOR += supervisor/stub/internal_flash.c
51+
endif
4852
endif
4953

5054
ifeq ($(USB),FALSE)

0 commit comments

Comments
 (0)