Porting to STM32L476Discovery/LimiFrog

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
bobricius
Posts: 14
Joined: Sat Jul 30, 2016 11:07 pm

Re: Porting to STM32L476Discovery/LimiFrog

Post by bobricius » Tue Aug 09, 2016 6:29 pm

Thanks for help. I commented this dac defs and compilation is ok. But I can not found where is command \ script for filesystem initialisation ? ... And one stupid question I have read that L4 have crystal less usb, can I set this feature ? I can not found where is oscilator defined and which type ... HSI ????

User avatar
dhylands
Posts: 3268
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Porting to STM32L476Discovery/LimiFrog

Post by dhylands » Tue Aug 09, 2016 9:19 pm

This is where the filesystem is initialized:
https://github.com/micropython/micropyt ... #L183-L223

I'm not sure what's involved (if anything) with getting crytalless USB to work. It looks like its been enabled.

The oscillator defines can be found here:
https://github.com/micropython/micropyt ... h#L98-L168

The code which initializes all of the oscillator stuff is here:
https://github.com/micropython/micropyt ... em_stm32.c

User avatar
badi
Posts: 51
Joined: Mon Aug 10, 2015 2:18 pm
Location: Bern, Switzerland

Re: Porting to STM32L476Discovery/LimiFrog

Post by badi » Thu Aug 11, 2016 9:38 am

Clock for USB: On STM32L4-Disco I configured the clock in the "Hardware auto calibration with LSE (PLL-mode)" as described in AN4555 of STM. In this mode the external 32768 crystal is used with a pll to produce via MSI a clock accurate enough for USB *Full Speed*. See as well the STM32L4 reference manual RM0351 (rev 2) page 200.

@bobricius:I think that for a proper working Nucleo board you have to adapt the clock configuration. The STM32L476 Nucleo board has an external 8MHz crystal whereas the STM32L476-discovery only has a 32768 Hz crystal - so you have to adapt the clock configuration in
https://github.com/micropython/micropyt ... em_stm32.c
accordingly. As starting point use the stm32cubex to explore the target clock configuration.

@bobricius: Where did you read about running STM32L4 with USB without crystal? Can you please elaborate on this? In my opinion this configuration is not necessary on the nucleo board as it has a crystal.
badi

bobricius
Posts: 14
Joined: Sat Jul 30, 2016 11:07 pm

Re: Porting to STM32L476Discovery/LimiFrog

Post by bobricius » Thu Aug 11, 2016 4:31 pm

@badi: I read in this maketing presentation on page 3.
http://www.st.com/resource/en/product_p ... g-pres.pdf
I am sorry, I am absolute beginer. I know that F072, F042 have crystal less mode.

User avatar
marfis
Posts: 194
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

Re: Porting to STM32L476Discovery/LimiFrog

Post by marfis » Thu Aug 11, 2016 7:34 pm

from what I remember reading on crystal less operation was that it was using the SOF (start of frame) 1kHz timing on the USB bus to drive a FLL for the 48Mhz clock.

bobricius
Posts: 14
Joined: Sat Jul 30, 2016 11:07 pm

Re: Porting to STM32L476Discovery/LimiFrog

Post by bobricius » Thu Aug 11, 2016 10:29 pm

http://www.emcu.it/STM32_USB/STM32_USB.pdf there is also something about clock recovery on internal oscilator.

User avatar
badi
Posts: 51
Joined: Mon Aug 10, 2015 2:18 pm
Location: Bern, Switzerland

Re: Porting to STM32L476Discovery/LimiFrog

Post by badi » Fri Aug 12, 2016 7:49 am

@bobricius: The presentation you mentions is from September 2014 and discusses USB clock recovery on F0/L0 done in a way as @marfis described. BTW there is an application note by NXP (AN4905) describing crystall less operation on Kinetis MCUs. Further in the Marketing presentation you mention they say that a "Dedicated crystal oscillator is no longer needed for USB functions". In the STM32L476 datasheet (Rev 4) page 52 they say:
The USB OTG controller requires a dedicated 48 MHz clock that can be provided by the internal multispeed oscillator (MSI) automatically trimmed by 32.768 kHz external oscillator (LSE).This allows to use the USB device without external high speed crystal (HSE).
They do not mention SOF clock recovery which is not implemented for STM32L476 and STM32L486. This is mentioned in Application note AN4809 (http://www.st.com/resource/en/applicati ... 260952.pdf) of STMicro. There are two categories of STM32L Chips (Page 6):
  • Cat. 2: STM32L476xx, STM32L486xx
    Cat. 4: STM32L433xx, STM32L443xx, STM32L432xx, STM32L442xx
On Page 40 they say:
The STM32L4 Cat. 4 and the STM32L0 Cat.3 and Cat.5 implement the same USB 2.0
device full-speed controller. This version supports a crystal-less device by using a clock
recovery system (CRS) peripheral. The CRS provides a precise clock to the USB
peripheral. The synchronization signal is derived from the start-of-frame (SOF) packet
signalization on the USB bus, which is sent by a USB host at precise 1 ms intervals.
This is as well obvious if you check the product page on http://www.st.com/content/st_com/en/pro ... tId=SS1580 => Crystal-less are only STM32L4x2 and STM32L4x3. But theses chips do not have enough flash for micropython.
Last edited by badi on Fri Aug 26, 2016 7:06 am, edited 1 time in total.
badi

bobricius
Posts: 14
Joined: Sat Jul 30, 2016 11:07 pm

Re: Porting to STM32L476Discovery/LimiFrog

Post by bobricius » Fri Aug 12, 2016 10:07 pm

badi: thanks for explanation. ... Ok if I understand for design my board I need just connect 32.768crystal to PC14 and PC15 no other crystal ...

User avatar
badi
Posts: 51
Joined: Mon Aug 10, 2015 2:18 pm
Location: Bern, Switzerland

Re: Porting to STM32L476Discovery/LimiFrog

Post by badi » Sun Aug 14, 2016 2:08 pm

Have a look at the STM32L476-discovery design:
http://www.st.com/content/st_com/en/pro ... overy.html
Use it as starting point for your design.
badi

andrew.beck
Posts: 1
Joined: Fri Aug 26, 2016 5:05 am

Re: Porting to STM32L476Discovery/LimiFrog

Post by andrew.beck » Fri Aug 26, 2016 5:12 am

@badi: thanks for your work getting the STM32L476DISCO port up and running. Having just built and installed your port, it was a real pleasure that my first introduction to micropython was a working REPL prompt! Flashing LEDs is always a joy, but even more so from a REPL prompt.

I'm actually more interested in the NUCLEO-L476RG board so will see if I can get this going as my first dabble in the code base.

Thanks again for your work and the great start its provided!

andrew

Post Reply