trying to add support for STM32F334 discovery


Daniel McBrearty <danielmcbrearty@...>
 

hello all,

I am new to Zephyr, just want to give it a try. I don't have any of the supported boards, but I have a STM32F334 Discovery which is close to several supported ones. I thought I'd see if I could add support by making a copy of STM32F3 Discovery. I also used some settings from Nucleo STM32F334R8 which seems to have a very similar chip.

I can build and flashing seems to work, but no blinking LED (the red user LED should be assigned to led0).

My build / flash output:

============

daniel@daniel-dev-laptop:~/work/zephyrproject/zephyr$ west build -p auto -b stm32f334_disco samples/basic/blinky/
[0/1] Re-running CMake...
-- Application: /home/daniel/work/zephyrproject/zephyr/samples/basic/blinky
-- Zephyr version: 2.2.99
-- Board: stm32f334_disco
-- Found west: /home/daniel/.local/bin/west (found suitable version "0.7.2", minimum required is "0.6.0")
-- Found toolchain: zephyr (/home/daniel/zephyr-sdk-0.11.2)
-- Loading /home/daniel/work/zephyrproject/zephyr/boards/arm/stm32f334_disco/stm32f334_disco.dts as base
Devicetree header saved to '/home/daniel/work/zephyrproject/zephyr/build/zephyr/include/generated/devicetree_unfixed.h'
Parsing /home/daniel/work/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/daniel/work/zephyrproject/zephyr/build/zephyr/.config'
No change to configuration in '/home/daniel/work/zephyrproject/zephyr/build/zephyr/.config'
No change to Kconfig header in '/home/daniel/work/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h'
-- Cache files will be written to: /home/daniel/.cache/zephyr
-- Configuring done
-- Generating done
-- Build files have been written to: /home/daniel/work/zephyrproject/zephyr/build
[52/82] Building C object zephyr/drivers...les/drivers__serial.dir/uart_stm32.c.obj
/home/daniel/work/zephyrproject/zephyr/drivers/serial/uart_stm32.c:653:12: warning: 'uart_stm32_init' defined but not used [-Wunused-function]
  653 | static int uart_stm32_init(struct device *dev)
      |            ^~~~~~~~~~~~~~~
/home/daniel/work/zephyrproject/zephyr/drivers/serial/uart_stm32.c:619:37: warning: 'uart_stm32_driver_api' defined but not used [-Wunused-const-variable=]
  619 | static const struct uart_driver_api uart_stm32_driver_api = {
      |                                     ^~~~~~~~~~~~~~~~~~~~~
[78/82] Linking C executable zephyr/zephyr_prebuilt.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       11160 B        64 KB     17.03%
            SRAM:        4100 B        12 KB     33.37%
        IDT_LIST:         120 B         2 KB      5.86%
[82/82] Linking C executable zephyr/zephyr.elf


daniel@daniel-dev-laptop:~/work/zephyrproject/zephyr$ west flash
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner openocd
-- runners.openocd: Flashing file: /home/daniel/work/zephyrproject/zephyr/build/zephyr/zephyr.hex
Open On-Chip Debugger 0.10.0+dev-01340-ga0e8edc4e-dirty (2020-02-14-05:38)
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
Info : clock speed 1000 kHz
Info : STLINK V2J25M13 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.221011
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
    TargetName         Type       Endian TapName            State      
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f3x.cpu       hla_target little stm32f3x.cpu       running

Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800100c msp: 0x200005f8
Info : device id = 0x10016438
Info : flash size = 64kbytes
auto erase enabled
wrote 12288 bytes from file /home/daniel/work/zephyrproject/zephyr/build/zephyr/zephyr.hex in 0.750689s (15.985 KiB/s)

Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800100c msp: 0x200005f8
verified 11160 bytes in 0.215123s (50.661 KiB/s)

Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
shutdown command invoked

================

A few warnings but I think it is progrming the board OK - I see the interface LED flash and from the above, OCD seems to verify the code.

The only thing I wonder about is which include file to use in my dts file. At the moment I have:

==========

/*
 * Copyright (c) 2017 I-SENSE group of ICCS
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/dts-v1/;
#include <st/f3/stm32f334X8.dtsi>

/ {
model = "STMicroelectronics STM32F334DISCOVERY board";
compatible = "st,stm32f334discovery", "st,stm32f334";

chosen {
zephyr,console = &usart2;
zephyr,shell-uart = &usart2;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
};

leds {
compatible = "gpio-leds";
red_led_U: led_3 {
gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>;
label = "User LD3";
};
blue_led_D: led_6 {
gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>;
label = "User LD6";
};
orange_led_L: led_4 {
gpios = <&gpiob 8 GPIO_ACTIVE_HIGH>;
label = "User LD4";
};
green_led_R: led_5 {
gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>;
label = "User LD5";
};
};

gpio_keys {
compatible = "gpio-keys";
user_button: button {
label = "User";
gpios = <&gpioa 0 GPIO_ACTIVE_LOW>;
};
};

aliases {
led0 = &red_led_U;
sw0 = &user_button;
can-primary = &can1;
};
};
.
.
.
&flash0 {
/*
* For more information, see:
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

/* Set 6Kb of storage at the end of the 64Kb of flash */
storage_partition: partition@e800 {
label = "storage";
reg = <0x0000e800 0x00001800>;
};
};
};

==========


If I change the include file:

#include <st/f3/stm32f334.dtsi>

I now get a build error:
daniel@daniel-dev-laptop:~/work/zephyrproject/zephyr$ west build -p auto -b stm32f334_disco samples/basic/blinky/
[0/1] Re-running CMake...
-- Application: /home/daniel/work/zephyrproject/zephyr/samples/basic/blinky
-- Zephyr version: 2.2.99
-- Board: stm32f334_disco
-- Found west: /home/daniel/.local/bin/west (found suitable version "0.7.2", minimum required is "0.6.0")
-- Found toolchain: zephyr (/home/daniel/zephyr-sdk-0.11.2)
-- Loading /home/daniel/work/zephyrproject/zephyr/boards/arm/stm32f334_disco/stm32f334_disco.dts as base
stm32f334_disco.dts.pre.tmp:49.26-54.6: ERROR (unit_address_vs_reg): /soc/flash-controller@40022000/flash@8000000: node has a unit name, but no reg property
  also defined at stm32f334_disco.dts.pre.tmp:409.9-419.3
stm32f334_disco.dts.pre.tmp:38.25-40.4: ERROR (unit_address_vs_reg): /memory@20000000: node has a unit name, but no reg property
ERROR: Input tree has errors, aborting (use -f to force output)
CMake Error at /home/daniel/work/zephyrproject/zephyr/cmake/dts.cmake:188 (message):
  command failed with return code: 2
Call Stack (most recent call first):
  /home/daniel/work/zephyrproject/zephyr/cmake/app/boilerplate.cmake:465 (include)
  CMakeLists.txt:4 (include)


-- Configuring incomplete, errors occurred!

=====
and the CMakeError is:
/home/daniel/zephyr-sdk-0.11.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/../../../../arm-zephyr-eabi/bin/ld: /home/daniel/zephyr-sdk-0.11.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/../../../../arm-zephyr-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x60): undefined reference to `_exit'
collect2: error: ld returned 1 exit status

====

I'm not sure if this the rason that I cannot seem to get blnky running on this board. Ideas? Thank you.

Daniel




Join users@lists.zephyrproject.org to automatically receive all group messages.