PreenFM Forum

PreenFM => PreenFM2 => Topic started by: norbim1 on June 26, 2014, 11:10:19 AM

Title: Stm32F4Discovery port
Post by: norbim1 on June 26, 2014, 11:10:19 AM
Hi,

First of all thank you Xavier for this wonderful project and making it open source.

I've started to port the project to the STM32F4Discovery board, which has a nice audio codec on board. I haven't built the control surface yet, but in the current state I'm able to play notes from USB midi. The board have enough free IO pins left to direct connect the CS buttons and enc-s, so I'll try to eliminate the cs s/p converters too.
To use the onboard I2S audio codec I changed the Systic interrupt to DMA int. Currently I'm using 32 samples long DMA buffer, and it works perfectly. In that way the DMA int is fired only at every 16th sample.
I'm wondering if I can use the full 24 bit resolution of the codec. As far as I see the sample block contains 18 bit normalized uint samples, but I couldn't find where it is normalized. I plan to change the timbre summing at the end of the buildNewSampleBlock(), but I'm sure that it has a better place for it.
Would You mind helping me with the place of the "float to 18 bit" normalizing?

Thank's a lot,
Norbert
Title: Re: Stm32F4Discovery port
Post by: pld on June 26, 2014, 02:32:15 PM
Cool, I've been meaning to look into the DMA/i2s stuff myself :)

IIRC, the way things are calculated is
- the voice calculations produce float values (-1,1) and these are summed per timbre
- Timbre::fxAfterBlock scales the the timbre output from (-n,n) to (-131072,131072) via ratioTimbres and numberOfVoiceInverse to avoid clipping in the final mix
- during the final mixing of the timbre samples in buildNewSampleBlock, the sum is offset from float (-131072,131072) to int (0,2^18) for the DAC

So I guess you mainly have to replace the 131072.f (2^17) constants with 8388609.f (2^23).

Does the codec accept padded 24bit samples (i.e. 32bit), or how does that work with DMA?
Title: Re: Stm32F4Discovery port
Post by: norbim1 on June 26, 2014, 02:59:22 PM
Thanks for the info. I found the offset, but didn't found the scale. I'll try it today evening.

Yes, the codec accepts padded 32 bit samples, the 24 bit part has to be justified to the right. Actually the codec accepts 2*16bit words for one stereo side sample, so I need to swap the half words of the 32 bit int when filling the DMA buffer.
Title: Re: Stm32F4Discovery port
Post by: norbim1 on June 27, 2014, 09:50:13 AM
It works! Thanks again for the info.
Title: Re: Stm32F4Discovery port
Post by: Xavier on June 27, 2014, 11:08:25 AM


Great project  :)
I'm glad to see open source code is usefull to others.
Did you fork the github project ? Don't forget to share your changes  ;)

And thanks Patrick for the very accurate answers....

Xavier
Title: Re: Stm32F4Discovery port
Post by: norbim1 on June 27, 2014, 02:49:50 PM
Hi Xavier,

I'm just a hobbyist so I  don't have registered yet to Github and I'm quite new with it.
The CS part of my project is still left. As soon as it's ready, i'll fork it.

Thanks, Norbert
Title: Re: Stm32F4Discovery port
Post by: norbim1 on August 12, 2014, 12:24:40 PM
Hi,

I've managed to fork it and merged with the latest 1.04 fw:

https://github.com/norbim1/preenFM2

- STM32F4Discovery module based PreenFM2
- uses the onboard I2S codec, audio data send through DMA
- the CS buttons and encoders are directly connected to the IO ports of the module
- made some minor changes to the display driver, (I use a cheaper OLED module: Raystar REC002004AYPP5N00000)

I'll post the schematic and some pics of my newly built module soon. It was built on veroboard, so no PCB design has been made for it.

Regards Norbert
Title: Re: Stm32F4Discovery port
Post by: pld on August 12, 2014, 08:06:17 PM
Awesome, thanks for sharing. Definitely have to take a look at that...
Title: Re: Stm32F4Discovery port
Post by: norbim1 on August 12, 2014, 09:45:45 PM
Some pics about the gadget:

Title: Re: Stm32F4Discovery port
Post by: norbim1 on August 12, 2014, 09:47:14 PM
Schematic and a suggested veroboard wiring:
Title: Re: Stm32F4Discovery port
Post by: Xavier on August 13, 2014, 10:49:32 AM

Great project...  :D
Congrats and thanks for sharing.
Title: Re: Stm32F4Discovery port
Post by: norbim1 on August 13, 2014, 03:20:00 PM
Thanks a lot, but it's definitely your fantastic project's merit.
I'll try to keep the fork sync with the upstream repository.
Title: Re: Stm32F4Discovery port
Post by: yogi on November 26, 2014, 07:39:17 PM
  Norbim1,  Thank You very much for your port project (and your post over @ Midibox.org), I'm so very excited to find this! For along time I have watched the Preen project (had not seen the FM2 ver till now), so very cool; but could not bring myself to spend on 'yet another project' when my wish list is so long. BUT the Disco board is very inexpensive and very complete. So now there is a new build in my future.
 Not to take anything away from the great work of Xavier, but the 'F407 Discovery port opens this up for me :) Again Thank You both, life is good :)
Yogi
Title: Re: Stm32F4Discovery port
Post by: elea on December 22, 2014, 05:26:08 PM
norbim1: would it be possible to upload the compiled binaries (regular, overclocked & bootloader)?

I'm running 3 different STM32Fx toolchains right now (Spark Core, MIDIbox NG & Mutable Instruments) and am having trouble installing a fourth one that's compatible with your code :(
Title: Re: Stm32F4Discovery port
Post by: norbim1 on December 22, 2014, 09:29:59 PM
I'm using Eclips and MidiBox toolchain without any problem.
Anyway here is the binaries. I've made only the overclocked version for Stm32F4Discovery, so bootloader and overclocked only.
Title: Re: Stm32F4Discovery port
Post by: elea on December 22, 2014, 11:55:45 PM
Many thanks! I don't know why Eclipse was giving weird errors. I'll try this out tonight and compare it to my FS1r.
Title: Re: Stm32F4Discovery port
Post by: elea on December 23, 2014, 04:05:16 PM
Quick question: will this firmware work without an LCD attached?


Here were my errors compiling the boot binary:

Code: [Select]
C:\preenFM2\trunk>make boot
arm-none-eabi-c++  -Tlinker_bootloader/stm32f4xx.ld  -mthumb -mcpu=cortex-m4 -mf
loat-abi=hard -mfpu=fpv4-sp-d16 -gc-sections --specs=nano.specs   build/BootLoad
er.o build/usb_storage_usr.o build/usbd_storage_desc.o build/usbd_storage.o buil
d/usbKey_usr.o build/usb_bsp.o build/Encoders.o build/LiquidCrystal.o build/UsbK
ey.o build/Storage.o build/Common.o build/system_stm32f4xx.o build/stm32f4xx_gpi
o.o build/stm32f4xx_rcc.o build/stm32f4xx_flash.o build/stm32f4xx_usart.o build/
ff.o build/fattime.o build/usb_core.o build/usb_hcd.o build/usb_hcd_int.o build/
usb_dcd.o build/usb_dcd_int.o build/usbh_core.o build/usbh_hcs.o build/usbh_iore
q.o build/usbh_stdreq.o build/usbh_msc_core.o build/usbh_msc_bot.o build/usbh_ms
c_scsi.o build/usbh_msc_fatfs.o build/usbd_core.o build/usbd_ioreq.o build/usbd_
req.o build/usbd_msc_bot.o build/usbd_msc_core.o build/usbd_msc_data.o build/usb
d_msc_scsi.o build/misc.o build/startup_bootloader.o -o build/p2_boot_1.11.elf
build/BootLoader.o: In function `BootLoader::initKey()':
C:\preenFM2\trunk/src/bootloader/BootLoader.cpp:121: undefined reference to `Usb
Key::firmwareInit()'
build/BootLoader.o: In function `BootLoader::burnFlash()':
C:\preenFM2\trunk/src/bootloader/BootLoader.cpp:384: undefined reference to `Usb
Key::loadFirmwarePart(char*, int, void*, int)'
build/BootLoader.o: In function `BootLoader::process()':
C:\preenFM2\trunk/src/bootloader/BootLoader.cpp:141: undefined reference to `Usb
Key::readNextFirmwareName(char*, int*)'
C:\preenFM2\trunk/src/bootloader/BootLoader.cpp:157: undefined reference to `Usb
Key::firmwareInit()'
build/usbd_storage.o: In function `STORAGE_GetCapacity(unsigned char, unsigned l
ong*, unsigned short*)':
C:\preenFM2\trunk/src/bootloader/usbd_storage.c:138: undefined reference to `Usb
Key::diskioGetSectorNumber()'
build/usbd_storage.o: In function `STORAGE_Read(unsigned char, unsigned char*, u
nsigned long, unsigned short)':
C:\preenFM2\trunk/src/bootloader/usbd_storage.c:180: undefined reference to `Usb
Key::diskioRead(unsigned char*, int, int)'
build/usbd_storage.o: In function `STORAGE_Write(unsigned char, unsigned char*,
unsigned long, unsigned short)':
C:\preenFM2\trunk/src/bootloader/usbd_storage.c:195: undefined reference to `Usb
Key::diskioWrite(unsigned char*, int, int)'
build/Storage.o: In function `Storage::copy(char*, char const*, int)':
C:\preenFM2\trunk/src/hardware/Storage.cpp:36: undefined reference to `preenMain
Preset'
build/Storage.o: In function `Storage::copy_string(char*, char const*)':
C:\preenFM2\trunk/src/hardware/Storage.cpp:554: undefined reference to `midiConf
ig'
C:\preenFM2\trunk/src/hardware/Storage.cpp:554: undefined reference to `midiConf
ig'
build/Storage.o: In function `Storage::copy(char*, char const*, int)':
C:\preenFM2\trunk/src/hardware/Storage.cpp:36: undefined reference to `preenMain
Preset'
build/Storage.o: In function `Storage::getValue(char*, char*)':
C:\preenFM2\trunk/src/hardware/Storage.cpp:601: undefined reference to `midiConf
ig'
collect2.exe: error: ld returned 1 exit status
make: *** [build/p2_boot_1.11.elf] Error 1
Title: Re: Stm32F4Discovery port
Post by: norbim1 on December 23, 2014, 04:20:51 PM
I've never tried it without LCD. The control surface works exactly the same way as the original pFM2, I didn't change it.
Related to build errors I'm sorry, but I'm not an expert in it.
Title: Re: Stm32F4Discovery port
Post by: elea on December 23, 2014, 04:28:16 PM
No problem - I at least have your bootloader and I finally managed to get the rest compiled.

I'll get an LCD to test it.

Thanks again, norbim1.
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 21, 2016, 04:29:30 PM
Hi,
I built a low budget PreenFM (first version) using home made pcb and a maple mini clone, with a cheap 2004 LCD bought fm ebay...It works quite well!
Now I want to start the PreenFM 2 project on a low budget! I don't have the skill to code and compile the firmware...
Your stm32f4 Discovery porting is the best choice for me..
The questions are:
1) Is it possible to use your compiled bin (boot and firmware) using an ordinary (not oled) lcd (20*04)?
2) Once I've uploaded your boot loader to the Discovery board, is it possible to use the official and updated compiled firmware without any change?
2) What about the audio out quality of the Discovery? Could you please post some audio demo?

Thank you very much for your kindly reply!

S. Rizzo
Title: Re: Stm32F4Discovery port
Post by: Xavier on September 21, 2016, 10:11:03 PM

Hi,

1) I'm almost sure the answer is yes, as there's not reason the low level display code has been changed.
And the preenfm2 works with regular LCD.

2) No. Norbim's firmware uses the DAC of the discovery and different pins for devices.
But i just noticed the firmware is regularly updated on https://github.com/norbim1/preenFM2
Nice job by the way :)

Xavier
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 21, 2016, 10:27:45 PM
Thank you very much for your fast reply!
Your synth is fantastic!
Could you please compile them (boot and firmware) for me?
I don't have the necessary skill to do it now..  :(

Regards!
Title: Re: Stm32F4Discovery port
Post by: Xavier on September 22, 2016, 08:44:38 AM

You can start with the zip file from previous page.
It contains the bootlooder 1.11 (latest version) and an old firmware but that will allow you to setup and check your hardware.

I'll try to compile Norbim's latest firmware later.

Let us know how the build goes,

Xavier
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 22, 2016, 10:23:43 AM
Wonderful!

I'll try to begin with the old firmware...waiting for the (compiled) new one!

Many, many thanks!
Title: Re: Stm32F4Discovery port
Post by: norbim1 on September 22, 2016, 08:21:41 PM
Hi,
Here is the latest compiled fw.
Norbim
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 22, 2016, 11:34:43 PM
Hi,

thank you for the fw!
Can you please confirm, I can use an ordinary LCD 20*04... I read that you did some change on the display driver...
What about the audio quality of The Discovery DAC? Are you happy with it?

Tks again for your help!

Salvo
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 22, 2016, 11:57:11 PM
To Xavier...

Hi,

I've downloaded and study your schematics...I can't find the one relative to your uC board (FPreen405)?
Does it is open-hardware or not?
What type of minimum system do you use? The one of the CERB40?
Is it possible to have the schematic?
I'm looking to redesign the pcb to embed the uC...or at least to use a smd chip to dip converter and some THT components for resistors, xtal and caps...

Thank a lot for your beautiful project!

Salvo

p.s. in attached "my" PreenFM modular version
 
Title: Re: Stm32F4Discovery port
Post by: Xavier on September 24, 2016, 07:04:36 PM

I just uploaded the preenF405 schematic here :
https://github.com/Ixox/preenFM2/tree/master/hardware/preenF405

I don't understand your "minimum system" question.


Best,

Xavier
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 25, 2016, 08:58:58 AM
Hi,

fantastic, I've just dwnld the schematics! Thank you so much!

I meant with or without 32khz rtc xtal... as for CERB40 version one or two..

What I'm thinking is to use an lqfp64 to dip converter for the stm32f405 chip and put caps, resistors and xtal near it on a custom board... with the other components: dacs, opamps, conectors and so on.
What do you think, may be work?

Do you use stlink-v2 and the pins "P1" and "jump3" on the main PreenFM2 board to program (at least for the boot-loader) the preenF405 uC?

I made my own "singe side" pcb... to lower the cost for my projects (as I did with the version one of the PreenFM) so I want to try this way for your new project.

Best regards and tks again!  ;)

Salvo
Title: Re: Stm32F4Discovery port
Post by: opus.quatre on September 25, 2016, 10:03:55 AM
Hello there..
I dont understand much to this thread, but Norbim's box is absolutely beautiful !! Both the box, with the wooden sides, and the knobs..  a very delightful one..
Have a nice week-end..
Thierry
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 25, 2016, 10:22:23 AM
Hi,
sorry, I've digressed too much...
Yes, Norbim's solution is probably the best way for me... to get a working PFM2.

Tks again for your kindly help,

regards,

Salvo
Title: Re: Stm32F4Discovery port
Post by: norbim1 on September 25, 2016, 06:17:30 PM
Hi Salvo,

Sorry for the late answer. I'm sure any standard 20*4 LCD works with my code. At first my OLED didn't work properly, so I made some timing change to better follow the datasheet. Later it turned out, that the problem was with the supply voltage instead.
I'm really happy with the audio quality of the Discovery. In one of my projects I use an external I2S board with a Discovery, because I need audio input too. The onboard codec have way less noise than the external one. I think STMicro made a really good job with the F4Discovery board.

Thank You Thierry, I use this box design for my other small projects too. The wooden sides are made from bamboo cutting board.

Regards Norbim
Title: Re: Stm32F4Discovery port
Post by: rsproduction on September 26, 2016, 04:21:41 PM
Hi Norbim,

don't worry,  Tks for your reply.
I'm going to buy a Discovery to try your solution.
I'll keep you updated about the progress...

Regards, Salvo
Title: Re: Stm32F4Discovery port
Post by: opus.quatre on September 30, 2016, 06:26:29 PM
Thanx Norbim for your answer..
I see there is no volume knob on your version..
And where did you get those wonderful black and white knobs ??
Have a nice week end..
Thierry
Title: Re: Stm32F4Discovery port
Post by: norbim1 on October 01, 2016, 12:12:07 PM
Hi Thierry,

yes there is no hardware volume control, but I implemented midi CC 7, so you can control it via midi.
The knobs are form MidiBox forum group buy. AFAIK last batch was a year ago:
http://midibox.org/forums/topic/19657-albs-waldorf-knobs-bulk-order-2015-2016/
Title: Re: Stm32F4Discovery port
Post by: opus.quatre on October 01, 2016, 09:58:05 PM
Thanx Norbim.. I already knew that Waldorf were making beautiful machine.. but i didnt know they were also selling gorgeous knobs.. Thanx again..
Title: Re: Stm32F4Discovery port
Post by: opus.quatre on October 02, 2016, 01:04:42 PM
I've been browsing eBay to search for Stm32F4Discovery..
It seems that there are so many different versions.. I don't know which module is the ciorrect one..
Can you help ??
Have a nice sunday..
Thierry
Title: Re: Stm32F4Discovery port
Post by: norbim1 on October 04, 2016, 12:47:21 PM
Hi Thierry,
first check the original STMicroelectronics product page to know the orginal version:
http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-discovery-kits/stm32f4discovery.html
I bought all my Discovery boards from Farnell (farnell.com). The part number is STM32F407G-DISC1.
Title: Re: Stm32F4Discovery port
Post by: opus.quatre on October 04, 2016, 06:29:30 PM
Thanx Norbim..  I'll have a look..
Title: Re: Stm32F4Discovery port
Post by: rsproduction on December 05, 2016, 01:45:41 PM
Hi,
Here is the latest compiled fw.
Norbim

Hi,

I finally got my Discovery Board.

I'm doing my own "motherboard" pcb for the encoders, lcd and switchs...

How can I upload Your bootloader and firmware using the on-board USB connections?

I'm a newbie... ::)
 
Title: Re: Stm32F4Discovery port
Post by: norbim1 on December 05, 2016, 05:26:56 PM
Use the STM32 ST-LINK utility via the mini USB on the debugger side of the board.

http://www.st.com/content/st_com/en/products/embedded-software/development-tool-software/stsw-link004.html

Norbim
Title: Re: Stm32F4Discovery port
Post by: rsproduction on December 06, 2016, 07:32:09 AM
Hi Norbim,

many thanks for your kindly reply!
Can you confirm that I must Flash the bootloader at the adress 0×8000000 and the  firmware at the adress 0×8040000 ?

Best regrards,

Salvo
Title: Re: Stm32F4Discovery port
Post by: norbim1 on December 06, 2016, 08:49:02 AM
Yes, it should work this way.

Norbim
Title: Re: Stm32F4Discovery port
Post by: rsproduction on December 06, 2016, 11:40:06 AM
Perfect,

I'll try it!

Salvo
Title: Re: Stm32F4Discovery port
Post by: rsproduction on March 09, 2017, 07:19:36 PM
Finally got mine working!!

Thank you Norbim!

Thank you Xavier!

I hope to upload soon, on my website, some other info on how I built it.
I made my own "motherboard" pcb to host the stm32discovery board...
The total cost has been kept low!  ;)
Title: Re: Stm32F4Discovery port
Post by: Xavier on March 09, 2017, 09:49:28 PM

Very nice  and totally unique :)
Thanks for sharing !!!