← index #6605Issue #7416
Off-topic · high · value 1.010
QUERY · ISSUE

STM32L432KC "can't" create flash filesystem

openby ZSorcereropened 2020-11-08updated 2024-09-08
port-stm32

I have designed a custom pyboard used STM32L432KC as the controller and downloaded both V1.12 and V1.13 NUCLEO_L432KC as the firmare. Neither of them works,the file system can not be loaded. I can not mount the flash.

I already set the following parameters:

#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)  //   in file mpconfigboard.h
#define MICROPY_HW_ENABLE_USB       (1)   //   in file mpconfigboard.h
#define MICROPY_HW_USB_MSC          (1)    //   in file mpconfigboard.h
#define MICROPY_HW_USB_HID          (1)    //   in file mpconfigboard.h

And

MEMORY    //   in file stm32l432.ld
{
    FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 246K /* sectors 0-114 */    
    FLASH_FS (rx)    : ORIGIN = 0x0803D800, LENGTH = 10K /* sectors 115-127 */          I want 10k file system, therefore  ORIGIN = 0x0803D800
    RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 64K /* SRAM1, 48K + SRAM2, 16K */
}

And

MICROPY_VFS_FAT = 1         //   in file mpconfigboard.mk

I have successfully compiled the code and downloaded it into my L432 board. After I reset the board, I got the following output:

mpy

The REPL works fine.
But, there are 2 ERRORS:
(1)Can't create flash system.
(2)Can't mount flash.

I know the flash size for STM32L432KC is only 256kb which is tiny, but 5kb~10kb file system is enough for me. I only need to implement some basic GPIO operations.

I also used the printf function to check where the program went wrong.

in main.c , the following function gives nonzero value of ret which is -5.

int vfs_mount_and_chdir(mp_obj_t bdev, mp_obj_t mount_point)

because the expression

 (nlr_push(&nlr)  ≠ 0

Here is the complete function:

#if MICROPY_HW_ENABLE_STORAGE
STATIC int vfs_mount_and_chdir(mp_obj_t bdev, mp_obj_t mount_point) {
    nlr_buf_t nlr;
    mp_int_t ret = -MP_EIO;
    nlr_push_test();
    if (nlr_push(&nlr) == 0) {
        mp_obj_t args[] = { bdev, mount_point };
        mp_vfs_mount(2, args, (mp_map_t*)&mp_const_empty_map);
        mp_vfs_chdir(mount_point);
        ret = 0; // success
        nlr_pop();
    } else {
        mp_obj_base_t *exc = nlr.ret_val;
        if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(exc->type), MP_OBJ_FROM_PTR(&mp_type_OSError))) {
            mp_obj_t v = mp_obj_exception_get_value(MP_OBJ_FROM_PTR(exc));
            mp_obj_get_int_maybe(v, &ret); // get errno value
            ret = -ret;
        }
    }
    return ret;
}

Why this expression (nlr_push(&nlr) ≠ 0 , how to slove this problem? I think this caused the failure of the flash FS.

Another error came from factoryreset.c . in the following function:

MP_WEAK int factory_reset_create_filesystem(void) {
    // LED on to indicate creation of local filesystem
    led_state(PYB_LED_GREEN, 1);
    uint32_t start_tick = HAL_GetTick();

    fs_user_mount_t vfs;
    pyb_flash_init_vfs(&vfs);
    uint8_t working_buf[FF_MAX_SS];
    FRESULT res = f_mkfs(&vfs.fatfs, FM_FAT, 0, working_buf, sizeof(working_buf));
    if (res != FR_OK) {
        mp_printf(&mp_plat_print, "MPY: can't create flash filesystem\n");    // **This is the ERROR message**
        return -MP_ENODEV;
    }

    // Set label
    f_setlabel(&vfs.fatfs, MICROPY_HW_FLASH_FS_LABEL);

    // Populate the filesystem with factory files
    factory_reset_make_files(&vfs.fatfs);

    // Keep LED on for at least 200ms
    systick_wait_at_least(start_tick, 200);
    led_state(PYB_LED_GREEN, 0);

    return 0; // success
}

#endif // MICROPY_HW_ENABLE_STORAGE

it means the condition (res != FR_OK) is not satisfied.

Can anyone tell me how to revise the code to creat the file system for this L432 board, thanks.

@dpgeorge @boochow @chrismas9 @davehylands

CANDIDATE · ISSUE

Issues with STM32WB port

closedby mtk11opened 2021-06-18updated 2021-08-25
port-stm32

I am trying to use micropython with STM32WB55CE (512KB flash). Although I created a custom stm32wb55xe.ld with the following settings:

FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 432K /* sectors 0-127 */
FLASH_APP (rx)  : ORIGIN = 0x08004000, LENGTH = 416K /* sectors 4-127 */

which suppose to leave space for FUS and wireless stack firmwares, just by pressing in STM32CubeProgrammer – Read FUS infos button, makes micropython not operational.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied