Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nucleo_f746zg board #396

Merged
merged 2 commits into from
May 11, 2020
Merged

Add nucleo_f746zg board #396

merged 2 commits into from
May 11, 2020

Conversation

FelixPetriconi
Copy link
Contributor

Improve slightly the docs

Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first contribution to modm.
Just some minor polish required!

src/modm/board/nucleo_f746zg/board.hpp Outdated Show resolved Hide resolved
src/modm/board/nucleo_f746zg/board.hpp Show resolved Hide resolved
src/modm/board/nucleo_f746zg/board.hpp Outdated Show resolved Hide resolved
@salkinium
Copy link
Member

You'll also need remove the trailing whitespace and sync the docs or the CI will complain again:

python3 tools/scripts/synchronize_docs.py

then squash all of that into one commit.

@salkinium
Copy link
Member

Oh, and you should add your example to the CI: .circleci/config.yml

Copy link
Member

@rleh rleh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clock configuration seems to be wrong.

static bool inline
enable()
{
Rcc::enableExternalClock(); // 25 MHz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The external oscillator frequency always depends on the board, in the case the Nucleo linked above.

Comment on lines 84 to 93
.pllM = 25, // 25MHz / M=25 -> 1MHz
.pllN = 432, // 1MHz * N=432 -> 432MHz
.pllP = 2 // 432MHz / P=2 -> 216MHz = F_cpu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No:
grafik

Comment on lines 93 to 96
// APB1 is running only at 27MHz, since AHB / 4 = 54MHz > 45MHz limit!
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div8);
// APB2 is running only at 54MHz, since AHB / 2 = 108MHz > 90MHz limit!
Rcc::setApb2Prescaler(Rcc::Apb2Prescaler::Div4);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Comment on lines 34 to 35
static constexpr uint32_t Apb1 = Frequency / 8;
static constexpr uint32_t Apb2 = Frequency / 4;
Copy link
Member

@rleh rleh May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the settings are wrong. I am very sorry. So the input clock is 8Mhz. But I have no clue, how Apb1/2 have to be set. I would appreciate a hint very much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem.
I will add a suggestion of changes (with explanations) later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to create the SystemClock struct

The easies way using STs CubeMX tool.

1. CubeMX clock graph

First we create a project in CubeMX with the desired microcontroller using the largest (pin-count, flash) variant.
CubeMX will display something like this in the "Clock configuration" tab:
ST CubeMX Clock Configuration example

Than configure all the clocks, muxes, multipliers and dividers to the highest allowed clock speeds (*).

(*) Some exceptions: USB mostly needs exactly 48 MHz, tbc...

This settings are reflected in the static constexpr uint32_t Frequency, Apb1 and Apb2 constants and in const Rcc::PllFactors pllFactors{...} and the following lines.
The PllFactors struct should be pretty self-explanatory.

2. Peripheral mapping to clocks

As we can see in the graphic above, there are different clock domains. Each peripheral is connected to a clock domain.
Some peripherals have an upstream clock mux, this is currently ignored in modm and the default clock mux setting is assumed.

The mapping is shown is the controllers block diagram located at the begin of the datasheet (not in the reference manual).

grafik

For every peripheral we create a static constexpr uint32_t member in the struct SystemClock and assign the value of the clock domain the peripheral is connected to.

Copy link
Member

@rleh rleh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a some commits to your fork.

Comment on lines 34 to 35
static constexpr uint32_t Apb1 = Frequency / 8;
static constexpr uint32_t Apb2 = Frequency / 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to create the SystemClock struct

The easies way using STs CubeMX tool.

1. CubeMX clock graph

First we create a project in CubeMX with the desired microcontroller using the largest (pin-count, flash) variant.
CubeMX will display something like this in the "Clock configuration" tab:
ST CubeMX Clock Configuration example

Than configure all the clocks, muxes, multipliers and dividers to the highest allowed clock speeds (*).

(*) Some exceptions: USB mostly needs exactly 48 MHz, tbc...

This settings are reflected in the static constexpr uint32_t Frequency, Apb1 and Apb2 constants and in const Rcc::PllFactors pllFactors{...} and the following lines.
The PllFactors struct should be pretty self-explanatory.

2. Peripheral mapping to clocks

As we can see in the graphic above, there are different clock domains. Each peripheral is connected to a clock domain.
Some peripherals have an upstream clock mux, this is currently ignored in modm and the default clock mux setting is assumed.

The mapping is shown is the controllers block diagram located at the begin of the datasheet (not in the reference manual).

grafik

For every peripheral we create a static constexpr uint32_t member in the struct SystemClock and assign the value of the clock domain the peripheral is connected to.

static bool inline
enable()
{
Rcc::enableExternalClock(); // 25 MHz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The external oscillator frequency always depends on the board, in the case the Nucleo linked above.

Comment on lines 84 to 86
It may be that the linux' version of openocd is out of date. In this case install it
directly from the [openocd][openocd] home page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It may be that the linux' version of openocd is out of date. In this case install it
directly from the [openocd][openocd] home page.
The latest openocd release _0.10.0_ (as of May 2020) is too old for some targets (e.g. _STM32G0_, _STM32G4_).
In this case it might be necessary to compile openocd from git _HEAD_.

.circleci/config.yml Outdated Show resolved Hide resolved
@salkinium
Copy link
Member

How good are you with git and how much motivation do you have to cleaning up your PR history @FelixPetriconi (squashing and rebasing onto develop)? Otherwise I can just quickly do it, if you're ok with that.

@rleh
Copy link
Member

rleh commented May 9, 2020

@FelixPetriconi Is it possible for you to test if my changes to the SystemClock struct work?
Unfortunately I don't have a Nucleo F764ZG board in my dev board collection.

@FelixPetriconi
Copy link
Contributor Author

How good are you with git and how much motivation do you have to cleaning up your PR history @FelixPetriconi (squashing and rebasing onto develop)? Otherwise I can just quickly do it, if you're ok with that.

I have never done it, because we are working in a regulated environment (medical devices) and for us are changes in the history forbidden. I looked into the git docs and I probably would figure out how to do it. But You are probably faster and the risk is lower, that bad things happens ;-). So could you do this please. But first I would like to test the changes tomorrow on the board.

@rleh
Copy link
Member

rleh commented May 9, 2020

@salkinium What about using Githubs Squash-Merge Feature?

@FelixPetriconi
Copy link
Contributor Author

@FelixPetriconi Is it possible for you to test if my changes to the SystemClock struct work?
Unfortunately I don't have a Nucleo F764ZG board in my dev board collection.

I will do it tomorrow and report to you. My day is already too long to do something useful. But many thanks for the explanation.
It was in 1994 when I was woking with TMS320 processors at the university and I have forgotten many details. I am just starting to come back into uController. (Fabian Greif from our UG in HB introduced me into modm and now I am using it at our project to build an open source ventilator and more stuff for the virus crisis https://diy-vent.org/)

@FelixPetriconi
Copy link
Contributor Author

I just run test blink test program and while uploading I receive the following messages:

xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:25)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
modm_program
Info : clock speed 2000 kHz
Info : STLINK V2J29M18 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.243415
Warn : Silicon bug: single stepping may enter pending exception handler!
Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000ba0 msp: 0x20000c00
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
** Programming Started **
Info : device id = 0x10016449
Info : flash size = 1024 kbytes
** Programming Finished **
** Verify Started **
** Verified OK **
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
shutdown command invoked
scons: done building targets.

The program works and pressing the button has the effect - as expected - that the blinking is faster.

Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased/squashed your commits and polished the install instructions.

docs/src/guide/installation.md Outdated Show resolved Hide resolved
@salkinium salkinium merged commit c38550a into modm-io:develop May 11, 2020
@salkinium
Copy link
Member

Thanks, @FelixPetriconi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants