[Gnuk-users] Porting Chopstx (and later Gnuk) to STM32L432

Aurelien Jarno aurelien at aurel32.net
Thu Oct 12 20:11:25 UTC 2017


Hi,

I have just sent some patches to support and improve Gnuk for Cortex M4
and alter MCU. For those patches to be actually useful, support for such
an MCU also needs to be added to Chopstx (and later some parts of Gnuk).
I would like first to add support for the STM32L432 chip and the ST
Nucleo L432KC. Using such a development board make it easy for people to
try themselves and is also really cheap.

I would like to get some guidelines how I should do things. Here are some
proposals, don't hesitate to make comments and suggestions.

* mcu/sys.h: This file defaults to STM32F103 when no MCU_ variables are
defined. This is really error prone as some files (mostly on the GnuK
side) do not include board.h first. I wonder if it should not error out
in this case. Also it can include board.h before to make sure MCU_ is
defined.

* chopstx.c: In the same way the current Chopstx code assume a 72MHz
clock unless MHZ is defined at the pre-processor level. In practice it
is defined to another value in some example Makefile. What about moving
this value to board.h instead?

* mcu/clk_gpio_init-stm32.c: It would make sense to reuse this file to
support the STM32L432. However instead of redefining many registers with
#ifdef, I wonder if we can just include mcu/$(chip).h instead. This
means creating mcu/stm32f0.h which doesn't exist and mcu/stm32l432.h.

* mcu/usb-stm32f103.c: It looks like ST uses (at least) 2 different USB
IP cores for their product, one for the USB device FS and the other for
the USB OTG FS/HS. The STM32L432 chip uses the same IP than the
STM32F103, but connected slightly differently to the bus. I would like
to rename this file into usb-stm32.c and create usb-stm32f103.c and 
usb-stm32l432.c which just set a few #define and include usb-stm32.c.
This is basically similar to what is done with clk_gpio_init-stm32.c.

* USB interrupt: currently the USB interrupt is hardcoded to IRQ 20. I
plan to add a #define in mcu/sys-*.h. That would also remove the #ifdef
in src/usb-ccid.c for the GNU_LINUX_EMULATION.

* On the Gnuk side, at least src/mcu-stm32f103.c and src/neug.c include
mcu/$(chip).h, for accessing the CRC module on one side and to get the
SRAM address on the other side. I wonder if those should be abstracted
in chopstx:mcu/sys-$chip.h so that a simple include of sys.h would
provide those functions.

Once we agree I'll implement that while cleaning my patches and will
submit the result. All the above changes don't deal with the abstraction
code for the flash memory that has already been discussed in another
thread, and which will require more refactoring work. For now I use
SRAM2 (which can be battery backuped) to emulate the flash.

Thanks,
Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien at aurel32.net                 http://www.aurel32.net



More information about the gnuk-users mailing list