filesystem not mounted on custom hw using stm32f405vg

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

filesystem not mounted on custom hw using stm32f405vg

Post by lnsri22 » Thu Jan 31, 2019 2:37 pm

Hello Everyone!!

I have done a custom bootloader for my custom hw using the stm32 series stm32f405vgt6.

The bootloader resides at 0x08000000 (32K space has been allocated out of which 25K is the bootloader)
Firmware0.bin resides at 0x08008000 (16K space has been allocated)
Filesystem resides at 0x0800C000 (208K space has been allocated)
Firmware1.bin resides at 0x08040000 (768K space has been allocated)

This is the memory map which I have in stm32f405.ld and my mpconfigboard.mk looks like the following

MCU_SERIES = f4
CMSIS_MCU = STM32F405xx
AF_FILE = boards/stm32f405_af.csv
LD_FILES = boards/stm32f405.ld boards/common_ifs.ld
TEXT0_ADDR = 0x08008000
TEXT1_ADDR = 0x08040000


I have been trying to put up main.py as a frozen module using "pyexec_frozen_module(main_py)"



// At this point everything is fully configured and initialised.

// Run the main script from the current directory.
if ((reset_mode == 1 || reset_mode == 3) && pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
const char *main_py;
if (MP_STATE_PORT(pyb_config_main) == MP_OBJ_NULL) {
main_py = "main.py";
} else {
main_py = mp_obj_str_get_str(MP_STATE_PORT(pyb_config_main));
}
mp_import_stat_t stat = mp_import_stat(main_py);
if (stat == MP_IMPORT_STAT_FILE) {
int ret = pyexec_frozen_module(main_py);
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
}
if (!ret) {
flash_error(3);
}
}
}


Above is the code snippet that I have in main.c . But this part of code is not at all executed.


This works as expected without custom bootloader. i.e(firmware0.bin @0x08000000 and firmware1.bin @ 0x08020000)

Any help is greatly appreciated!!

Thanks in advance
lnsri22 :)

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: filesystem not mounted on custom hw using stm32f405vg

Post by dhylands » Thu Jan 31, 2019 4:25 pm

You'll also need to modify flashbdev.c
https://github.com/micropython/micropyt ... lashbdev.c
to tell it the new location of the flash blocks for the filesystem, keeping in mind that you can only include 16K or 64K blocks.

lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

Re: filesystem not mounted on custom hw using stm32f405vg

Post by lnsri22 » Fri Feb 01, 2019 7:48 am

Thanks Dave for the quick reply !!

I took a look into it and changed the file accordingly. But it didn't help either.

My modifications to the file :

Code: Select all

#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)

#define CACHE_MEM_START_ADDR (0x10000000) // CCM data RAM, 64k
#define FLASH_SECTOR_SIZE_MAX (0x10000) // 64k max, size of CCM
#define FLASH_MEM_SEG1_START_ADDR (0x08008000) // sector 2
#define FLASH_MEM_SEG1_NUM_BLOCKS (160) // sectors 1,2,3,4: 16k+16k+16k+64k=112k


with the linker being below (Ignore the /* comments at each line */)

FLASH (rx)      : ORIGIN = 0x08008000, LENGTH = 992K /* entire flash */
FLASH_ISR (rx)  : ORIGIN = 0x08008000, LENGTH = 16K /* sector 0 */
FLASH_FS (rx)   : ORIGIN = 0x0800C000, LENGTH = 80K /* sectors 1,2,3,4 are for filesystem */
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 896K /* sectors 5,6,7,8,9,10,11 */
CCMRAM (xrw)    : ORIGIN = 0x10000000, LENGTH = 64K
RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 128K
    
 


What actually worked was increasing the FileSystem size to 96K (modifying the file flashbdev.c to contain the below)

Code: Select all

#define CACHE_MEM_START_ADDR (0x10000000) // CCM data RAM, 64k
#define FLASH_SECTOR_SIZE_MAX (0x10000) // 64k max, size of CCM
#define FLASH_MEM_SEG1_START_ADDR (0x08008000) // sector 2
#define FLASH_MEM_SEG1_NUM_BLOCKS (192) // sectors 2,3,4: 16k+16k+64k=96k
while the linker being

Code: Select all

FLASH (rx)      : ORIGIN = 0x08008000, LENGTH = 992K /* entire flash */
FLASH_FS (rx)   : ORIGIN = 0x08008000, LENGTH = 96K /* sectors 1,2,3,4 are for filesystem */
FLASH_ISR (rx)  : ORIGIN = 0x08020000, LENGTH = 128K /* sector 0 */
FLASH_TEXT (rx) : ORIGIN = 0x08040000, LENGTH = 768K /* sectors 5,6,7,8,9,10,11 */
CCMRAM (xrw)    : ORIGIN = 0x10000000, LENGTH = 64K
RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 128K

I don't understand why this mounted the filesystem.

Anyways , thanks for saving my time Dave!!
lnsri22 :)

Post Reply