MCUDev Black STM32F407VET6 + STM32F407ZET6 dev boards

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
okwatts
Posts: 2
Joined: Tue Jul 16, 2019 6:30 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by okwatts » Tue Jul 16, 2019 6:50 pm

I am also a newbie with micropython and this VET6 board. I have installed micropython on this and a couple of ESP boards. I also have a question regarding using the sdcard on the board. I have seen in the mbed forum (https://os.mbed.com/users/hudakz/code/S ... /shortlog/) a posting on using the sdcard by connecting some of the pins together and running a c program. One of the reasons I am drawn to micropython for this board is to avoid using the mbed environment and I must admit I have had no success with using an ST-link (under linux) to program even the examples.
The procedure for installing and running micropython by mcauser was flawless and I have been blinking the leds happily and tried the spiflash example also. But of course I want more! I am not sure of the status of using the sdcard but it would make for a real project by logging data.
If someone can provide an example code or otherwise illuminate my understanding that would be much appreciated.
Thanks
Larry

User avatar
JohnLittle
Posts: 11
Joined: Mon Oct 08, 2018 7:10 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by JohnLittle » Tue Jul 16, 2019 9:52 pm

Hey @okwatts, just got the sdcard working I think.

I modified ports/stm32/sdcard.c as per @lmamakos's instructions viewtopic.php?f=12&t=3086#p18286

Code: Select all

    // configure the SD card detect pin
    // we do this here so we can detect if the SD card is inserted before powering it on
    #if defined(MICROPY_HW_SDCARD_DETECT_PRESENT) 
      mp_hal_pin_config(MICROPY_HW_SDCARD_DETECT_PIN, MP_HAL_PIN_MODE_INPUT, MICROPY_HW_SDCARD_DETECT_PULL, 0);
    #endif
and

Code: Select all

bool sdcard_is_present(void) {
    #if MICROPY_HW_ENABLE_MMCARD
    if (pyb_sdmmc_flags & PYB_SDMMC_FLAG_MMC) {
        return false;
    }
    #endif

    #if defined(MICROPY_HW_SDCARD_DETECT_PRESENT)
      return HAL_GPIO_ReadPin(MICROPY_HW_SDCARD_DETECT_PIN->gpio, MICROPY_HW_SDCARD_DETECT_PIN->pin_mask) == MICROPY_HW_SDCARD_DETECT_PRESENT;
    #else
      return true;
    #endif
}
I then enabled sdcard support in micropython-1.11/ports/stm32/boards/BLACK_F407VE/mpconfigboard.h

Code: Select all

#define MICROPY_HW_ENABLE_SDCARD    (1)         // it has a sd scard, but i am not sure what the detect pin is, yet
#define MICROPY_HW_SDCARD_MOUNT_AT_BOOT     (1)
(Not sure if the second line is needed... spur of the moment!)

Anything else stays commented as it was, especially the following:

Code: Select all

// SD card detect switch
//      #define MICROPY_HW_SDCARD_DETECT_PIN        (pin_A8)    // nope
//      #define MICROPY_HW_SDCARD_DETECT_PULL       (GPIO_PULLUP)
//      #define MICROPY_HW_SDCARD_DETECT_PRESENT    (GPIO_PIN_RESET)
After I followed @mcauser's instructions for building and deploying, I had a running system: https://github.com/mcauser/BLACK_F407VE

cd micropython-1.11/ports/stm32
make BOARD=BLACK_F407VE
make BOARD=BLACK_F407VE deploy

I formatted a 2GB sdcard in FAT32 and gave it the volume name "BLACK_F407VE". Then after a reset with the sdcard in, that's the name I see mounted as a drive (/dev/sdc1).

Code: Select all

jl@kitkat:~/projects/micropython-1.11/ports/stm32/boards/BLACK_F407VE$ df
Filesystem                1K-blocks     Used Available Use% Mounted on
[...]
/dev/sdc1                   1938724        8   1938716   1% /media/jl/BLACK_F407V
Also, main.py on the sdcard is launched when the board is powered.

And if the card is removed and the board reset, the original content on the flash memory becomes visible (and executed) instead.

Hope this helps :-)

Cheers,
John

okwatts
Posts: 2
Joined: Tue Jul 16, 2019 6:30 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by okwatts » Wed Jul 17, 2019 5:25 am

I followed your detailed instructions and the work of mcauser and it works just as you described. I can now happily read either flash or sdcard.

Thanks John for the instructions and to all who contributed to the development of micropython particularly for the STM32.
Now to put it to use in logging some data.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by OutoftheBOTS_ » Wed Jul 17, 2019 6:05 am

I am also trying to build for this board and altered the sdcard.c and cloned mcauser config then altered to enable the sdcard.

but my build is failing when it tried to build frozen module lcd160cr_test.py as it says mpy-cross: command not found

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by Roberthh » Wed Jul 17, 2019 6:10 am

mpy-cross has to be built manually. It is not included any more in the standard build process.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by OutoftheBOTS_ » Wed Jul 17, 2019 6:39 am

Roberthh wrote:
Wed Jul 17, 2019 6:10 am
mpy-cross has to be built manually. It is not included any more in the standard build process.
So how would one go about undertaking this process? :)

edit : ok I have found it :)
Last edited by OutoftheBOTS_ on Wed Jul 17, 2019 6:42 am, edited 1 time in total.

DJShadow1966
Posts: 60
Joined: Sun Jun 23, 2019 4:55 am
Location: Gateshead, Tyne and Wear

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by DJShadow1966 » Wed Jul 17, 2019 6:40 am

Hello

Many thanks to JohnLittle for the code to get the SDCard working I have just put in place on my board with the latest version of MP.

Regards Mike

rpr
Posts: 99
Joined: Sat Oct 27, 2018 5:17 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by rpr » Wed Jul 17, 2019 6:42 am

See the main page (https://github.com/micropython/micropython). From the base MicroPython directory:

Code: Select all

$ cd mpy-cross
$ make
Last edited by rpr on Wed Jul 17, 2019 6:43 am, edited 1 time in total.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by OutoftheBOTS_ » Wed Jul 17, 2019 6:43 am

rpr wrote:
Wed Jul 17, 2019 6:42 am
See the main page. From the base MicroPython directory:

Code: Select all

$ cd mpy-cross
$ make
yep found it just before you posted.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Post by OutoftheBOTS_ » Wed Jul 17, 2019 6:54 am

Ok so now the build gets further but still fails.

Code: Select all

LINK build-MCUDEV_DEVEBOX_F407VGT6/firmware.elf
build-MCUDEV_DEVEBOX_F407VGT6/main.o: In function `stm32_main':
main.c:(.text.stm32_main+0x2d0): undefined reference to `_sstack'
build-MCUDEV_DEVEBOX_F407VGT6/stm32_it.o: In function `HardFault_C_Handler':
stm32_it.c:(.text.HardFault_C_Handler+0x13c): undefined reference to `_sstack'
build-MCUDEV_DEVEBOX_F407VGT6/modmachine.o: In function `machine_info':
modmachine.c:(.text.machine_info+0x1b8): undefined reference to `_sstack'
Makefile:537: recipe for target 'build-MCUDEV_DEVEBOX_F407VGT6/firmware.elf' failed
make: *** [build-MCUDEV_DEVEBOX_F407VGT6/firmware.elf] Error 1

Post Reply