NUCLEO_F412ZG

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.
Post Reply
Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

NUCLEO_F412ZG

Post by Turbinenreiter » Mon Oct 10, 2016 3:04 pm

I'm trying to add board definition files for the NUCLEO F412ZG. First step, I simply copied the files for the 411 and changed the names.
I'm getting this build error:

Code: Select all

make BOARD=NUCLEO_F412ZG
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build-NUCLEO_F412ZG/genhdr
Create build-NUCLEO_F412ZG/genhdr/pins.h
make: *** No rule to make target 'build-NUCLEO_F412ZG/modstm_qstr.h', needed by 'build-NUCLEO_F412ZG/genhdr/qstrdefs.generated.h'.  Stop.
My changes can be found here:
https://github.com/turbinenreiter/micro ... LEO_F412ZG
The commit:
https://github.com/turbinenreiter/micro ... d1cfa530d1

As far as I understand, there is 4 files to create for the board in the new board directory and two in boards for the microcontroller:
├── NUCLEO_F412ZG
│   ├── mpconfigboard.h
│   ├── mpconfigboard.mk
│   ├── pins.csv
│   └── stm32f4xx_hal_conf.h
├── stm32f412_af.csv
├── stm32f412.ld

Any ideas?

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: NUCLEO_F412ZG

Post by shaoziyang » Mon Oct 10, 2016 4:35 pm

Because hal and cmsis files has not update, they are still v2.1.0, and last version is v2.10.0 now, so STM32F412 is not support now.

You may try to update these files from Keil.STM32F4xx_DFP.2.10.0.pack first,.

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: NUCLEO_F412ZG

Post by Turbinenreiter » Fri Oct 14, 2016 4:55 pm

After merging this pull request and adding defines in storage.c and adc.c I was able to almost compile.

Code: Select all

make BOARD=NUCLEO_F412ZG
...
CC main.c
main.c: In function 'main':
main.c:377:9: error: implicit declaration of function '__HAL_RCC_CCMDATARAMEN_CLK_ENABLE' [-Werror=implicit-function-declaration]
         __CCMDATARAMEN_CLK_ENABLE();
         ^
cc1: all warnings being treated as errors
../py/mkrules.mk:47: recipe for target 'build-NUCLEO_F412ZG/main.o' failed
make: *** [build-NUCLEO_F412ZG/main.o] Error 1
Which I find very strange, as '__HAL_RCC_CCMDATARAMEN_CLK_ENABLE' is not to be found in main.c

I'm also not sure if my changes to storage.c are correct. At the moment, I'm just trying to get it to compile, getting all the configs right is another step :roll:

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

Re: NUCLEO_F412ZG

Post by dhylands » Fri Oct 14, 2016 5:39 pm

The real issue is that the STM32F412 doesn't have any DTCM, so these lines in main.c:

Code: Select all

    #if defined(MCU_SERIES_F4) ||  defined(MCU_SERIES_F7)
        #if defined(__HAL_RCC_DTCMRAMEN_CLK_ENABLE)
        // The STM32F746 doesn't really have CCM memory, but it does have DTCM,
        // which behaves more or less like normal SRAM.
        __HAL_RCC_DTCMRAMEN_CLK_ENABLE();
        #else
        // enable the CCM RAM
        __CCMDATARAMEN_CLK_ENABLE();
        #endif
    #endif
should be changed to be something like this:

Code: Select all

    #if defined(MCU_SERIES_F4) ||  defined(MCU_SERIES_F7)
        #if defined(__HAL_RCC_DTCMRAMEN_CLK_ENABLE)
        // The STM32F746 doesn't really have CCM memory, but it does have DTCM,
        // which behaves more or less like normal SRAM.
        __HAL_RCC_DTCMRAMEN_CLK_ENABLE();
        #endif
    #endif
since after that PR, all of the HALs that have DTCM all have __HAL_RCC_DTCMRAMEN_CLK_ENABLE defined

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: NUCLEO_F412ZG

Post by Turbinenreiter » Fri Oct 14, 2016 7:11 pm

Thanks, that solved it.
The next two problems I could 'solve' myself, now I'm stuck on this:

Code: Select all

modmachine.c: In function 'machine_init':
modmachine.c:80:55: error: 'RCC_CSR_BORRSTF' undeclared (first use in this function)
         } else if (state & RCC_CSR_PORRSTF || state & RCC_CSR_BORRSTF) {
                                                       ^
... where I will resume tomorrow.

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

Re: NUCLEO_F412ZG

Post by dhylands » Fri Oct 14, 2016 7:22 pm

That flag comes from the cmsis file. I'd take a look at the 412 cmsis file and see if they changed the definition?

Looking at the 412 datasheet, it appears to still have that flag.

Here's the RCC_CSR_xxx definitions for the 411:
https://github.com/micropython/micropyt ... 2493-L2503

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: NUCLEO_F412ZG

Post by Turbinenreiter » Sat Oct 15, 2016 1:00 pm

I got it compiling!
I had to patch stlink with the new chipid and finally I managed to flash it. It also proudly announces that the fie was written and verified.

However, I'm not sure if that's actually true. When I connect the board I still get the mbed NODE whatever MSD and when I connect to ACM0 there is no MicroPython prompt. Which kinda makes sense, as I'm connecting to the on-board ST-LINK. When I connect directly to PA11 and PA12 (wich are the micrcontrollers D- and D+) I also neither get an MSD nor a REPL.

I'll now look into actually getting the config right. I'm not sure if especially on the flash configuration I used the right values.

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

Re: NUCLEO_F412ZG

Post by dhylands » Sat Oct 15, 2016 9:17 pm

Normally the nucleo boards wire one of the UARTs through to the stlink processor which it then presents as a USB-serial interface.

Looking at the NUCLEO-F412 schematics, it looks like USART3 (PD8/PD9) is connected through.

So if you add something like:

Code: Select all

#define MICROPY_HW_UART_REPL        PYB_UART_3
#define MICROPY_HW_UART_REPL_BAUD   115200
to your mpconfigboard.h then the repl will also be on the usb-serial thru the stlink USB connector.

I'd compare the sample code for the 412 against the sample code for the 411 and see if there is anything different needed for setting up the clocks and stuff.

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: NUCLEO_F412ZG

Post by Turbinenreiter » Sun Oct 16, 2016 2:28 pm

Still nothing.
I decided to try a simple blinky example using mbed, just to check if the board is working all right, but then I saw that the board isn't even supported there yet.

Post Reply