Porting to STM32L476Discovery/LimiFrog
Re: Porting to STM32L476Discovery/LimiFrog
If you are using stlink from https://github.com/texane/stlink: There is a bug in eraseing block 0 of the second bank which I fixed and created a pull request (https://github.com/texane/stlink/pull/388). (see my repo: https://github.com/tobbad/stlink).
badi
Re: Porting to STM32L476Discovery/LimiFrog
I wrote some very simple drivers for the sensors on limifrog board which are available here:
https://github.com/tobbad/limifrog
I maybe convert them to a more micropythonic style.
There is very simple support for the LCD (see seps525.py) which can be instantiated with:
then you can switch the display on `disp.on()` and fill some area `disp.fill(80, 160,0,100,0x00FF)`. To speed up the code I pre allocate the buffer and use micropython.viper to fill a memory area. Further the SPI transfer is done at 80 MHz. The speed is awesome
There is a main.py in the repo to demonstrate the LCD code.
https://github.com/tobbad/limifrog
I maybe convert them to a more micropythonic style.
There is very simple support for the LCD (see seps525.py) which can be instantiated with:
Code: Select all
from limifrog import limifrog
from SEPS525 import LimiFrogDisplay
b = limifrog()
disp = LimiFrogDisplay(b)
There is a main.py in the repo to demonstrate the LCD code.
badi
Re: Porting to STM32L476Discovery/LimiFrog
Hi I have try compile micropython for STM32L476 for my nucleo board with enabled DAC but I get this error
I read here that Dac is working, please can anybody help?
dac.c: In function 'pyb_dac_deinit':
dac.c:255:36: error: 'DAC_CR_BOFF1' undeclared (first use in this function)
DAC_Handle.Instance->CR |= DAC_CR_BOFF1;
^
dac.c:255:36: note: each undeclared identifier is reported only once for each function it appears in
dac.c:258:36: error: 'DAC_CR_BOFF2' undeclared (first use in this function)
DAC_Handle.Instance->CR |= DAC_CR_BOFF2;
^
../py/mkrules.mk:47: recipe for target 'build-LIMIFROG/dac.o' failed
make: *** [build-LIMIFROG/dac.o] Error 1
I read here that Dac is working, please can anybody help?
dac.c: In function 'pyb_dac_deinit':
dac.c:255:36: error: 'DAC_CR_BOFF1' undeclared (first use in this function)
DAC_Handle.Instance->CR |= DAC_CR_BOFF1;
^
dac.c:255:36: note: each undeclared identifier is reported only once for each function it appears in
dac.c:258:36: error: 'DAC_CR_BOFF2' undeclared (first use in this function)
DAC_Handle.Instance->CR |= DAC_CR_BOFF2;
^
../py/mkrules.mk:47: recipe for target 'build-LIMIFROG/dac.o' failed
make: *** [build-LIMIFROG/dac.o] Error 1
Re: Porting to STM32L476Discovery/LimiFrog
Hi, Is possible increase mass storage flash disk size to maximum? MCU have 1Mb flash but python board show only 100kb I read that it is not posible no F405 but on L476 ???
Re: Porting to STM32L476Discovery/LimiFrog
On the L476 you should be able to increase the storage size by changing some of the constants in storage.c:
https://github.com/micropython/micropyt ... .c#L92-L93
The SMT32L476DISC board has a STM32L476VG which has 1 Mb of flash.
So if you put the start of the filesystem around 512K (i.e. set FLASH_MEM_SEG1_START_ADDR to 0x08080000) and set FLASH_MEM_SEG1_NUM_BLOCKS to 1024 (each block is 512 bytes, so this would map to 512K) then you should get a 512K flash drive.
Note that the above is untested.
The LimiFrog only has 512K flash, so you wouldn't be able to use that technique.
https://github.com/micropython/micropyt ... .c#L92-L93
The SMT32L476DISC board has a STM32L476VG which has 1 Mb of flash.
So if you put the start of the filesystem around 512K (i.e. set FLASH_MEM_SEG1_START_ADDR to 0x08080000) and set FLASH_MEM_SEG1_NUM_BLOCKS to 1024 (each block is 512 bytes, so this would map to 512K) then you should get a 512K flash drive.
Note that the above is untested.
The LimiFrog only has 512K flash, so you wouldn't be able to use that technique.
Re: Porting to STM32L476Discovery/LimiFrog
Thanks. And I read that problem with low flash size is because F405 have many 128kb flash blocks. Do you think that L476 not have this problem ?
Can you help my with compilation with DAC enabled? I want create small sound fx player with sounds stored on internal flash.
Can you help my with compilation with DAC enabled? I want create small sound fx player with sounds stored on internal flash.
Re: Porting to STM32L476Discovery/LimiFrog
dhylands: Thanks very much. It is working. I have 512KB. Do you think that is possible get more memory? ...700 or more
Re: Porting to STM32L476Discovery/LimiFrog
MicroPython itself takes about 307K (that's for the STM32L476DISC image built using the latest source).
storage.c allows the filesystem flash to be split into 2 segments.
So you could leave the definitions for FLASH_MEM_SEG1_START_ADDR and FLASH_MEM_SEG1_NUM_BLOCKS as they were and then add definitions for FLASH_MEM_SEG2_START_ADDR and FLASH_MEM_SEG2_NUM_BLOCKS.
The tricky bit is figuring out where FLASH_MEM_SEG2_START_ADDR should go. If you run: then we can see that the firmware goes to 0x8020000 + 0x45dc4 = 0x8065dc4. So you can start SEG2 on any 2K boundary higher than that, Keep in mind that as the firmware grows in size, you need to make sure that FLASH_MEM_SEG2_START_ADDR stays above the end of the firmware or your filesystem will wind up corrupting part of the firmware.
If you picked 0x8070000 that would give you about 40K of firmware expansion room, and would give you 576K + 126K = 702K for filesystem.
Also keep in mind that you need to reinitialize the filesystem anytime you change FLASH_MEM_SEG2_START_ADDR.
storage.c allows the filesystem flash to be split into 2 segments.
So you could leave the definitions for FLASH_MEM_SEG1_START_ADDR and FLASH_MEM_SEG1_NUM_BLOCKS as they were and then add definitions for FLASH_MEM_SEG2_START_ADDR and FLASH_MEM_SEG2_NUM_BLOCKS.
The tricky bit is figuring out where FLASH_MEM_SEG2_START_ADDR should go. If you run:
Code: Select all
$ objdump -h --section=.text build-STM32L476DISC/firmware.elf
build-STM32L476DISC/firmware.elf: file format elf32-little
Sections:
Idx Name Size VMA LMA File off Algn
1 .text 00045dc4 08020000 08020000 00020000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
If you picked 0x8070000 that would give you about 40K of firmware expansion room, and would give you 576K + 126K = 702K for filesystem.
Also keep in mind that you need to reinitialize the filesystem anytime you change FLASH_MEM_SEG2_START_ADDR.
Re: Porting to STM32L476Discovery/LimiFrog
DAC Support:
@bobricius: As you can see the adding of the deinit function broke the code for STM32L4. The DAC_CR_BOFF1/2 is just defined for the stm32F4. As quick fix you can comment out the lines referencing DAC_CR_BOFFX (x=1,2). In my opinion these line should be conditional compiled only for F4 but not included on L4. Be aware that there were no extensive tests done for DAC functionality - so if you could give some feedback if DAC with this hacks works?
I may look into a proper solution.
@bobricius: As you can see the adding of the deinit function broke the code for STM32L4. The DAC_CR_BOFF1/2 is just defined for the stm32F4. As quick fix you can comment out the lines referencing DAC_CR_BOFFX (x=1,2). In my opinion these line should be conditional compiled only for F4 but not included on L4. Be aware that there were no extensive tests done for DAC functionality - so if you could give some feedback if DAC with this hacks works?
I may look into a proper solution.
badi