Trying Nucleo-64 STM32F411RE


Piotr Król <piotr.krol at 3mdeb.com...>
 

Hi all,

I'm trying to run some examples (ie. hello_world, blinky) from arm
branch on Nucleo-64 STM32F411RE, but have problem with verifying if it
works. What I tried:

In hello_world directory:
make BOARD=nucleo_f411re
make BOARD=nucleo_f411re flash

Board seem to flash correctly. I OpenOCD master branch compiled locally.

$ make BOARD=nucleo_f411re flash
make[1]: Entering directory '/path/to//src/zephyr-project'
make[2]: Entering directory '/path/to//src/zephyr-project/samples/hello_world/outdir/nucleo_f411re'
Using /path/to//src/zephyr-project as source for kernel
GEN ./Makefile
CHK include/generated/version.h
CHK misc/generated/configs.c
CHK include/generated/offsets.h
CHK misc/generated/sysgen/prj.mdef
Flashing nucleo_f411re
Flashing Target Device
Open On-Chip Debugger 0.9.0-dirty (2016-08-02-16:04)
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
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v15 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.234714
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32f4x.cpu hla_target little stm32f4x.cpu running
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800203c msp: 0x20000750
auto erase enabled
Info : device id = 0x10006431
Info : flash size = 512kbytes
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000042 msp: 0x20000750
wrote 16384 bytes from file /path/to//src/zephyr-project/samples/hello_world/outdir/nucleo_f411re/zephyr.bin in 0.727563s (21.991 KiB/s)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800203c msp: 0x20000750
verified 12876 bytes in 0.118510s (106.103 KiB/s)
shutdown command invoked
Done flashing
make[2]: Leaving directory '/path/to//src/zephyr-project/samples/hello_world/outdir/nucleo_f411re'
make[1]: Leaving directory '/path/to//src/zephyr-project'

IIUC from defconfig:
# enable USART2 - passthrough to STLINK v2 connector
CONFIG_UART_STM32_PORT_2=y
CONFIG_UART_STM32_PORT_2_BAUD_RATE=115200
# enable console on this port by default
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_2"

I should have output on UART exposed by STLINK, in my case /dev/ttyACM0 under
Debian Linux. Unfortunately no output. What more is needed to push printk
output to UART ?

I tried also to compile blinky example, but it fails during compilation. My
understanding is that defines used there were not provided for F411. disco
example compiles fine, but doesn't seem to blink with LED1 and LED2.

I also tried to use debugger to step through and see what happen but it looks
like STM32 never hit main: https://gist.github.com/pietrushnic/c2e74de9ff1d11e8e2d442dd30d8ae0a

What is correct procedure to verify STM32 F411RE code ?

Best Regards,
--
Piotr Król
Embedded Systems Consultant
http://3mdeb.com | @3mdeb_com


Erwan Gouriou
 

Hi Piotr,

There was an issue on F411RE clock initialisation steps.
I've submitted following change to correct it:
https://gerrit.zephyrproject.org/r/9571

Hope it helps.

Cheers
Erwan

On 20 December 2016 at 01:44, Piotr Król <piotr.krol(a)3mdeb.com> wrote:

Hi all,

I'm trying to run some examples (ie. hello_world, blinky) from arm
branch on Nucleo-64 STM32F411RE, but have problem with verifying if it
works. What I tried:

In hello_world directory:
make BOARD=nucleo_f411re
make BOARD=nucleo_f411re flash

Board seem to flash correctly. I OpenOCD master branch compiled locally.

$ make BOARD=nucleo_f411re flash
make[1]: Entering directory '/path/to//src/zephyr-project'
make[2]: Entering directory '/path/to//src/zephyr-project/
samples/hello_world/outdir/nucleo_f411re'
Using /path/to//src/zephyr-project as source for kernel
GEN ./Makefile
CHK include/generated/version.h
CHK misc/generated/configs.c
CHK include/generated/offsets.h
CHK misc/generated/sysgen/prj.mdef
Flashing nucleo_f411re
Flashing Target Device
Open On-Chip Debugger 0.9.0-dirty (2016-08-02-16:04)
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
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v15 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.234714
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32f4x.cpu hla_target little stm32f4x.cpu running
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800203c msp: 0x20000750
auto erase enabled
Info : device id = 0x10006431
Info : flash size = 512kbytes
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000042 msp: 0x20000750
wrote 16384 bytes from file /path/to//src/zephyr-project/
samples/hello_world/outdir/nucleo_f411re/zephyr.bin in 0.727563s (21.991
KiB/s)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800203c msp: 0x20000750
verified 12876 bytes in 0.118510s (106.103 KiB/s)
shutdown command invoked
Done flashing
make[2]: Leaving directory '/path/to//src/zephyr-project/
samples/hello_world/outdir/nucleo_f411re'
make[1]: Leaving directory '/path/to//src/zephyr-project'

IIUC from defconfig:
# enable USART2 - passthrough to STLINK v2 connector
CONFIG_UART_STM32_PORT_2=y
CONFIG_UART_STM32_PORT_2_BAUD_RATE=115200
# enable console on this port by default
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_2"

I should have output on UART exposed by STLINK, in my case /dev/ttyACM0
under
Debian Linux. Unfortunately no output. What more is needed to push printk
output to UART ?

I tried also to compile blinky example, but it fails during compilation. My
understanding is that defines used there were not provided for F411. disco
example compiles fine, but doesn't seem to blink with LED1 and LED2.

I also tried to use debugger to step through and see what happen but it
looks
like STM32 never hit main: https://gist.github.com/pietrushnic/
c2e74de9ff1d11e8e2d442dd30d8ae0a

What is correct procedure to verify STM32 F411RE code ?

Best Regards,
--
Piotr Król
Embedded Systems Consultant
http://3mdeb.com | @3mdeb_com


Piotr Król <piotr.krol at 3mdeb.com...>
 

On Mon, Jan 02, 2017 at 03:03:58PM +0100, Erwan Gouriou wrote:
Hi Piotr,
Hi Erwan,


There was an issue on F411RE clock initialisation steps.
I've submitted following change to correct it:
https://gerrit.zephyrproject.org/r/9571

Hope it helps.
This helps sample code works correctly. With that I can continue with my
target project, which is i2c driver for F411RE.

Can you point me to information how I should approach adding i2c driver
for this board ?

I assume first I should familiarize myself with Zephyr documentation and
contribution guidelines, but have you got any reference code for i2c
driver ?

Best Regards,
--
Piotr Król
Embedded Systems Consultant
http://3mdeb.com | @3mdeb_com


Erwan Gouriou
 

Hi Piotr,

You should indeed first look at Zephyr documentation, and particularly i2c
API.
Then, regarding STM32 driver/IP, there are several sources that could help
you to develop I2C driver for STM32F4xx family
(as your driver should benefit to other SoCs from the F4 family):
-Zephyr native implementation of stm32lx i2c driver:
https://gerrit.zephyrproject.org/r/gitweb?p=zephyr.git;a=tree;f=drivers/i2c
-HAL implementation from STM32Cube SDK (that you could get here
http://www.st.com/en/embedded-software/stm32cubef4.html)
Inside SDK, you'll find i2c code examples using HAL
(Projects/xx/Examples/I2C/)
-stm32f411re Refence Manual for information about stm32f411re I2C (
http://www.st.com/en/microcontrollers/stm32f411re.html)

Then, you have two options:
-based on STM32Cube HAL, develop a generic STM32 driver that will benefit
to all STM32 based boards.
-develop a Zephyr "native" STM32F4 I2C API that will benefit to STM32F4
family devices (similar to stm32lx.c driver)

Either ways, note that you could use STM32Cube SDK
(ext/hal/st/stm32cube/stm32f4xx/soc/stm32f411xe.h) to benefit from
useful structures, macros and defines that provide abstraction capability
so you don't have to deal with subtle differences between
similar SoCs (such as stm32f401re and stm32f411re).

Good luck with your project
Erwan

On 14 January 2017 at 23:26, Piotr Król <piotr.krol(a)3mdeb.com> wrote:

On Mon, Jan 02, 2017 at 03:03:58PM +0100, Erwan Gouriou wrote:
Hi Piotr,
Hi Erwan,


There was an issue on F411RE clock initialisation steps.
I've submitted following change to correct it:
https://gerrit.zephyrproject.org/r/9571

Hope it helps.
This helps sample code works correctly. With that I can continue with my
target project, which is i2c driver for F411RE.

Can you point me to information how I should approach adding i2c driver
for this board ?

I assume first I should familiarize myself with Zephyr documentation and
contribution guidelines, but have you got any reference code for i2c
driver ?

Best Regards,
--
Piotr Król
Embedded Systems Consultant
http://3mdeb.com | @3mdeb_com


jack ma
 

if someone can write some document for how to use hal drivers(eg,stm32
cube) to write drivers or give an example for that ?
I really want use Zephyr for new project, but not familiar with the driver
develop. after browse the code tree, I did not find a method, so
temporarily abandoned.

2017-01-16 17:42 GMT+08:00 Erwan Gouriou <erwan.gouriou(a)linaro.org>:

Hi Piotr,

You should indeed first look at Zephyr documentation, and particularly i2c
API.
Then, regarding STM32 driver/IP, there are several sources that could help
you to develop I2C driver for STM32F4xx family
(as your driver should benefit to other SoCs from the F4 family):
-Zephyr native implementation of stm32lx i2c driver:
https://gerrit.zephyrproject.org/r/gitweb?p=zephyr.git;a=
tree;f=drivers/i2c
-HAL implementation from STM32Cube SDK (that you could get here
http://www.st.com/en/embedded-software/stm32cubef4.html)
Inside SDK, you'll find i2c code examples using HAL
(Projects/xx/Examples/I2C/)
-stm32f411re Refence Manual for information about stm32f411re I2C (
http://www.st.com/en/microcontrollers/stm32f411re.html)

Then, you have two options:
-based on STM32Cube HAL, develop a generic STM32 driver that will benefit
to all STM32 based boards.
-develop a Zephyr "native" STM32F4 I2C API that will benefit to STM32F4
family devices (similar to stm32lx.c driver)

Either ways, note that you could use STM32Cube SDK (ext/hal/st/stm32cube/stm32f4xx/soc/stm32f411xe.h)
to benefit from
useful structures, macros and defines that provide abstraction capability
so you don't have to deal with subtle differences between
similar SoCs (such as stm32f401re and stm32f411re).

Good luck with your project
Erwan


On 14 January 2017 at 23:26, Piotr Król <piotr.krol(a)3mdeb.com> wrote:

On Mon, Jan 02, 2017 at 03:03:58PM +0100, Erwan Gouriou wrote:
Hi Piotr,
Hi Erwan,


There was an issue on F411RE clock initialisation steps.
I've submitted following change to correct it:
https://gerrit.zephyrproject.org/r/9571

Hope it helps.
This helps sample code works correctly. With that I can continue with my
target project, which is i2c driver for F411RE.

Can you point me to information how I should approach adding i2c driver
for this board ?

I assume first I should familiarize myself with Zephyr documentation and
contribution guidelines, but have you got any reference code for i2c
driver ?

Best Regards,
--
Piotr Król
Embedded Systems Consultant
http://3mdeb.com | @3mdeb_com


Erwan Gouriou
 

Hi Jack


If you want to develop driver based on STM32Cube HAL, you could check
serial or pwm drivers as example.
You can also find other examples of using HAL in Cube SDK that you could
download from st website:
For instance, for STM32F4 family:
http://www.st.com/en/embedded-software/stm32cubef4.html ("get software" at
the very bottom of the page)
You'll find a Examples sections in the provided code.
If you need specific support on using the HAL, you'll find support in ST
community website:
https://community.st.com/

Finally, use of hal should not be a blocker, you could implement native
driver if you feel more comfortable.

Good luck
Erwan

On 16 January 2017 at 17:33, jack ma <assangema(a)gmail.com> wrote:

if someone can write some document for how to use hal drivers(eg,stm32
cube) to write drivers or give an example for that ?
I really want use Zephyr for new project, but not familiar with the
driver develop. after browse the code tree, I did not find a method, so
temporarily abandoned.

2017-01-16 17:42 GMT+08:00 Erwan Gouriou <erwan.gouriou(a)linaro.org>:

Hi Piotr,

You should indeed first look at Zephyr documentation, and particularly
i2c API.
Then, regarding STM32 driver/IP, there are several sources that could
help you to develop I2C driver for STM32F4xx family
(as your driver should benefit to other SoCs from the F4 family):
-Zephyr native implementation of stm32lx i2c driver:
https://gerrit.zephyrproject.org/r/gitweb?p=zephyr.git;a=tre
e;f=drivers/i2c
-HAL implementation from STM32Cube SDK (that you could get here
http://www.st.com/en/embedded-software/stm32cubef4.html)
Inside SDK, you'll find i2c code examples using HAL
(Projects/xx/Examples/I2C/)
-stm32f411re Refence Manual for information about stm32f411re I2C (
http://www.st.com/en/microcontrollers/stm32f411re.html)

Then, you have two options:
-based on STM32Cube HAL, develop a generic STM32 driver that will benefit
to all STM32 based boards.
-develop a Zephyr "native" STM32F4 I2C API that will benefit to STM32F4
family devices (similar to stm32lx.c driver)

Either ways, note that you could use STM32Cube SDK
(ext/hal/st/stm32cube/stm32f4xx/soc/stm32f411xe.h) to benefit from
useful structures, macros and defines that provide abstraction capability
so you don't have to deal with subtle differences between
similar SoCs (such as stm32f401re and stm32f411re).

Good luck with your project
Erwan


On 14 January 2017 at 23:26, Piotr Król <piotr.krol(a)3mdeb.com> wrote:

On Mon, Jan 02, 2017 at 03:03:58PM +0100, Erwan Gouriou wrote:
Hi Piotr,
Hi Erwan,


There was an issue on F411RE clock initialisation steps.
I've submitted following change to correct it:
https://gerrit.zephyrproject.org/r/9571

Hope it helps.
This helps sample code works correctly. With that I can continue with my
target project, which is i2c driver for F411RE.

Can you point me to information how I should approach adding i2c driver
for this board ?

I assume first I should familiarize myself with Zephyr documentation and
contribution guidelines, but have you got any reference code for i2c
driver ?

Best Regards,
--
Piotr Król
Embedded Systems Consultant
http://3mdeb.com | @3mdeb_com