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

cpu/stm32g0: add basic support + add nucleo-g070rb board #14163

Merged
merged 7 commits into from
Jul 21, 2020

Conversation

aabadie
Copy link
Contributor

@aabadie aabadie commented May 28, 2020

Contribution description

This PR adds an initial support for the stm32g0 family of CPUs. The nucleo-g070rb board is also added so people can test.

Only a few peripheral APIs are supported for the moment: gpio (no IRQ!), timer, uart, i2c, spi, flashpage. The riotboot feature is also available.

Important features that are missing: gpio_irq, rtc

Note that even if the clock configuration is quite similar to L4/WB families, I decided to add a new file for g0, to avoid even more ifdef there.
The clock configuration is shared with the G4 family because they are very similar.
The clock configuration defined in the board was also adapted to allow choosing between HSE, HSI or PLL (itself clocked by either HSI or HSE) as system source clock. The PLL clock source is the default.
Since there's no HSE available on the nucleo-g070rb, the default PLL clock source is HSI (@16MHz). The core clock is configured to be 64MHz.

Testing procedure

  • A green Murdock
  • Run ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py . nucleo-g070rb --jobs=4 and check the results are ok

The script reported these failures:

Failures during test:
- [tests/driver_grove_ledbar](tests/driver_grove_ledbar/test.failed)
- [tests/driver_my9221](tests/driver_my9221/test.failed)
- [tests/emcute](tests/emcute/test.failed)
- [tests/gnrc_dhcpv6_client](tests/gnrc_dhcpv6_client/test.failed)
- [tests/gnrc_dhcpv6_client_6lbr](tests/gnrc_dhcpv6_client_6lbr/test.failed)
- [tests/gnrc_ipv6_ext](tests/gnrc_ipv6_ext/test.failed)
- [tests/gnrc_ipv6_ext_frag](tests/gnrc_ipv6_ext_frag/test.failed)
- [tests/gnrc_ipv6_ext_opt](tests/gnrc_ipv6_ext_opt/test.failed)
- [tests/gnrc_ipv6_nib_dns](tests/gnrc_ipv6_nib_dns/test.failed)
- [tests/gnrc_rpl_srh](tests/gnrc_rpl_srh/test.failed)
- [tests/gnrc_sock_dns](tests/gnrc_sock_dns/test.failed)
- [tests/gnrc_tcp](tests/gnrc_tcp/test.failed)
- [tests/periph_timer_short_relative_set](tests/periph_timer_short_relative_set/test.failed)
- [tests/pkg_libfixmath_unittests](tests/pkg_libfixmath_unittests/test.failed)

Most of them are related to network setup or root priviledge missing. tests/pkg_libfixmath_unittests, tests/driver_grove_ledbar and tests/driver_my9221 are problematic but I haven't looked at them in detail for the moment.

Issues/PRs references

depends on #14166

@aabadie aabadie added Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports labels May 28, 2020
@aabadie aabadie requested a review from fjmolinas May 28, 2020 16:35
@aabadie aabadie added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 28, 2020
@aabadie aabadie requested a review from miri64 as a code owner May 28, 2020 18:24
@aabadie aabadie added the State: waiting for other PR State: The PR requires another PR to be merged first label May 30, 2020
@aabadie aabadie force-pushed the pr/cpu/stm32g0 branch 4 times, most recently from 8530feb to e3b8954 Compare June 2, 2020 07:44
@kaspar030 kaspar030 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 2, 2020
@aabadie aabadie removed the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 19, 2020
@aabadie
Copy link
Contributor Author

aabadie commented Jun 19, 2020

rebased

@aabadie
Copy link
Contributor Author

aabadie commented Jul 21, 2020

I found the solution for the EXTI configuration and now gpio_irq is working: tests/buttons behaves as expected

make BOARD=nucleo-g070rb -C tests/buttons flash term
make: Entering directory '/work/riot/RIOT/tests/buttons'
Building application "tests_buttons" for "nucleo-g070rb" with MCU "stm32".

"make" -C /work/riot/RIOT/boards/nucleo-g070rb
"make" -C /work/riot/RIOT/boards/common/nucleo
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/stm32
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/stm32/bootloader
"make" -C /work/riot/RIOT/cpu/stm32/periph
"make" -C /work/riot/RIOT/cpu/stm32/stmclk
"make" -C /work/riot/RIOT/cpu/stm32/vectors
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/isrpipe
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/pm_layered
"make" -C /work/riot/RIOT/sys/stdio_uart
"make" -C /work/riot/RIOT/sys/test_utils/interactive_sync
"make" -C /work/riot/RIOT/sys/tsrb
   text	   data	    bss	    dec	    hex	filename
  10112	    132	   2760	  13004	   32cc	/work/riot/RIOT/tests/buttons/bin/nucleo-g070rb/tests_buttons.elf
/work/riot/RIOT/dist/tools/openocd/openocd.sh flash /work/riot/RIOT/tests/buttons/bin/nucleo-g070rb/tests_buttons.elf
### Flashing Target ###
Open On-Chip Debugger 0.10.0+dev-01293-g7c88e76a-dirty (2020-07-01-21:36)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2-1.cfg is deprecated, please switch to interface/stlink.cfg
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : clock speed 2000 kHz
Info : STLINK V2J31M21 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.221340
Info : stm32g0x.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for stm32g0x.cpu on 0
Info : Listening on port 41327 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32g0x.cpu       hla_target little stm32g0x.cpu       reset

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: 0xf1000000 pc: 0x08000424 msp: 0x20000200
Info : device idcode = 0x20006460 (STM32G07/G08xx - Rev: B)
Info : flash size = 128kbytes
Info : flash mode : single-bank
Info : Padding image section 1 at 0x08002804 with 4 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x08002808 .. 0x08002fff
auto erase enabled
wrote 10248 bytes from file /work/riot/RIOT/tests/buttons/bin/nucleo-g070rb/tests_buttons.elf in 0.314087s (31.863 KiB/s)

verified 10244 bytes in 0.079028s (126.587 KiB/s)

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
Done flashing
/work/riot/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" 
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2020-07-21 11:18:43,275 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
s
2020-07-21 11:18:45,957 # START
2020-07-21 11:18:45,964 # main(): This is RIOT! (Version: 2020.10-devel-284-g15b1e-pr/cpu/stm32g0_gpio_irq)
2020-07-21 11:18:45,967 # GPIO_INIT_INT pin, 1342179341
2020-07-21 11:18:45,969 # GPIO_INIT_INT pin num, 13
2020-07-21 11:18:45,971 # GPIO_INIT_INT port num, 2
2020-07-21 11:18:45,973 # On-board button test
2020-07-21 11:18:45,973 # 
2020-07-21 11:18:45,975 #  -- Available buttons: 1
2020-07-21 11:18:45,976 # 
2020-07-21 11:18:45,978 #  -- Try pressing buttons to test.
2020-07-21 11:18:45,979 # 
2020-07-21 11:18:45,980 # [SUCCESS]
2020-07-21 11:18:46,509 # Pressed BTN0
2020-07-21 11:18:46,885 # Pressed BTN0
2020-07-21 11:18:47,026 # Pressed BTN0
2020-07-21 11:18:47,230 # Pressed BTN0
2020-07-21 11:18:47,366 # Pressed BTN0
2020-07-21 11:18:48,177 # Exiting Pyterm

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Great, code looks good too - let's go!

Comment on lines 137 to 141
typedef enum
{
SUCCESS = 0,
ERROR = !SUCCESS
} ErrorStatus;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say patch MQTTClient.h, but that's from an external source too 😕

@benpicco
Copy link
Contributor

Needs a rebase 😃

@aabadie
Copy link
Contributor Author

aabadie commented Jul 21, 2020

Now that #14152 is merged, I adapted this one accordingly. If Murdock is green, it should be good.

@benpicco
Copy link
Contributor

benpicco commented Jul 21, 2020

examples/paho-mqtt will still fail to compile due to conflicting global definitions of SUCCESS

@aabadie
Copy link
Contributor Author

aabadie commented Jul 21, 2020

examples/paho-mqtt will still fail to compile due to conflicting global definitions of SUCCESS

It will work without any change because there's an ifdef for all STM32 (added in #14152).

@benpicco
Copy link
Contributor

Please squash.

@aabadie aabadie merged commit 185f703 into RIOT-OS:master Jul 21, 2020
@aabadie aabadie deleted the pr/cpu/stm32g0 branch July 21, 2020 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants