stm32f4

310 views
Skip to first unread message

sabota...@gmail.com

unread,
Oct 28, 2013, 3:06:11 PM10/28/13
to python-o...@googlegroups.com
hi, i'm trying to port pymite to stm32f417 mcu. its on the board similar to stm32f4 discovery (f407 and f417 are practicaly indentical).
im using this version: https://bitbucket.org/tuck/pymite, it has stm32f4 platform. 

i changed USART for communication with ipm-host from USART2 to USART1, but ipm doesent work,(i dont get any respond when i'm running ipm host).
if only difference in my board and discovery is my crystal oscillator (16 Mhz, discovery 8 Mhz), and im suspect that is problem.

If anybody has some suggestions, i will be very grateful

Thank you in advance,
Sabotage

sabota...@gmail.com

unread,
Oct 31, 2013, 9:21:46 AM10/31/13
to python-o...@googlegroups.com
Ipm is working now, but i have one question about load command.
after i write "load test.py" in ipm-host, how can i call for function in test.py?
for example, test.py is looking like this:
def def func():
             print "Hello"

bard stéphane

unread,
Oct 31, 2013, 6:18:52 PM10/31/13
to python-o...@googlegroups.com
you should embed it inside your scons script
like

PY_SOURCES = ["main.py", "stm32f4discovery.py", "gpio.py", "pin.py", "lcd.py", "wire.py"]

I try to write rst documentation
https://bitbucket.org/tuck/pymite_stm32f4

hope to be helpfull. Tell me if you'll be sucessfull :)
--
--
You are subscribed to the "python-on-a-chip" (or p14p for short) Google Group.
Site: http://groups.google.com/group/python-on-a-chip
 
---
You received this message because you are subscribed to the Google Groups "python-on-a-chip" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-on-a-ch...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

sabota...@gmail.com

unread,
Nov 5, 2013, 10:39:31 AM11/5/13
to python-o...@googlegroups.com
I solved my problem, you misunderstood me, i just wanted to load a script with ipm, when program is already flashed on chip. But thanks anyway :)
I have another question, is it posible to "port" ipm application to start from SD card, for example: my microcontroller is doing some unrelated work, and then i insert sd card. On sd card is some testing script (in python), and then that scripts load, and do some work (its like ipm host on UART, buth without host, and on SD card)
Thank you
Sabotage

Dean Hall

unread,
Nov 5, 2013, 10:17:59 PM11/5/13
to python-o...@googlegroups.com
Sabotage,

I don't fully understand what you mean by "ipm application."
But my guess is that you mean you want to launch a pre-compiled program that is on the SD card;
and there is no user interaction except for inserting the card.

Yes it is possible, but it requires a lot of work from you and hasn't been exercised much (i.e. it may have bugs).
The doc that describes this ability is in the v10 branch of the repository in the file:
docs/src/PlatformMarshalledModules.rst

You will then be responsible for reacting to the card insertion event and launching p14p at that point.

!!Dean

sabota...@gmail.com

unread,
Nov 6, 2013, 9:41:30 AM11/6/13
to python-o...@googlegroups.com
dwhall,
thank you very much.
Just one more question, if you will be so kind. Please understand that i don't know much about python, i'm more embedded/electronics guy.
Is it possible to run just pymite interpreter on processor (stm32f417). For example, i have project with RTOS, writen in c. is it possible to run pymite interpreter, for example in one separate process and then load scripts through UART (normal ipm). So i would have project in c, but with pymite interpreter .
I'm sory if im asking silly things, 
thank you in advance.

kittipon meesompop

unread,
Nov 13, 2013, 11:30:40 AM11/13/13
to python-o...@googlegroups.com
Hi tuck,
i also am working on stm32f4 for a university's project and interested to program it by using pymite.
your documention would be helpful but unfortunately i can not understand the language.
Are there such docs in english?

best regards


On Thursday, October 31, 2013 11:18:52 PM UTC+1, tuck wrote:

bard stéphane

unread,
Nov 13, 2013, 4:11:06 PM11/13/13
to python-o...@googlegroups.com
no sorry
I just write this documentation for pycon fr [ french :( ]
I will be glad to help you if google trad can't help you
french and english are closer

kittipon meesompop

unread,
Nov 19, 2013, 3:18:09 AM11/19/13
to python-o...@googlegroups.com
Thanks alot for your advise.
I translated it with google. It seemed to be going well. But i also have problem with python2.6 because
i can not use virtualenv on it. And another condition: i need finally to run on windows and i tried to connect
the platform stm32f4. i ran "scons PLATFORM=stm32f4" on command prompt and got the error;

'src' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [src\platform\stm32f4\pmfeatures.h] Error 1
scons: building terminated because of errors.

May you help me to fix this out please

best regards
Kittipon

bard stéphane

unread,
Nov 20, 2013, 3:34:35 PM11/20/13
to python-o...@googlegroups.com
you should avoid windows. sorry.
because all the compilation tool chain is linux aware :'(

I will be glad to help you, but porting all that stuff on windows
is really painfull :'(

could you test with cygwin ?

kittipon meesompop

unread,
Nov 22, 2013, 2:31:24 PM11/22/13
to python-o...@googlegroups.com
Thanks for the answer.
 i have already compromised with my professor to use run it on linux.
now i am working on your description about ipm and would like ask some questions

your text:
      En effet, si vous modifiez le fichier ./src/platform/stm32f4/main.py pour exécuter
      la fonction ipm, ce sera toujours ce programme qui sera exécuté au démarrage du
      STM32F4. Lorsque votre programme sera prêt vous pourrez modifier le fichier
      ./src/platform/stm32f4/main.py pour exécutez votre fonction principale. Le fichier
      ./src/platform/stm32f4/main.py contient quelques exemples qui vous permettrons aisément
      de débuter.

i dont understand which file i should change to run ./src/platform/stm32f4/main.py ipm function.


and one more question: now it seems that i can transfer main.elf to stm-board. can run it by
starting gdb. i tried to change the main.py (just to turn on an led) and compile it by using scons PLATFORM=stm32f4
then i transfered to the board and ran gdb. but nothing happens. Therefore, i would to ask you if i did it the right way.

Thank again in advance for your help

best regards
Kittipon Meesompop

bard stéphane

unread,
Nov 22, 2013, 3:24:13 PM11/22/13
to python-o...@googlegroups.com
main.py is your main program.
My sentences just explain that you should choose what
you want to start on STM32F4.

When python start on STM32F4, he runs your main.py
(which has compiled in C++, him and the others you've declared
in scons file)

You have to decide which program you want to start.

ipm is just one of them, but you can't have both
(maybe with green thread, I could not be so categorical)
Your main.py program could be a simple loop to control
a led or something else.

But, like python on a real terminal, you can use python
shell to test your own function. So you can develop your
own class, keep main.py launching ipm.py check to
embed your new module inside scons python modules list
 that should be compiled and then import it when using
ipm and test your class or method etc ...


small ipm description :
ipm.py are in fact two programs  discussing on a serial link (usb).
One is in your terminal (we could call it ipm.py_terminal)
and the other is executed by main.py inside STM32F4
(we could call it ipm.py_stm32f4)

you should execute first stm32f4 main.py then Inside ipm.py_terminal
every command you type (after return) ipm.py_termin sends typed characters
to ipm.py_stm32f4.
ipm.py_stm32f4 receives characters on USART (I don't remember which one)
and wait for some kind of end of transmission. ipm.py_stm32f4 then
evaluate the received string inside STM32F4 python VM.

I had a small bug for the end of transmission event. I had to write
some blank chars to flush buffer to be sure that ipm.py_stm32f4 correctly
receive all the line. I didn't find a better workaround :(

finally main.py contains other thing than just launching ipm part.
Check the other part of main.py
You should also have an breakout board to receive printed messages,
if you want to debug (I don't know about sending message with embeded
debug part of the STM32F4 :(   ).

that's all

kittipon meesompop

unread,
Nov 23, 2013, 4:26:16 AM11/23/13
to python-o...@googlegroups.com
thanks so much for the usefull infos. now i understand more about pymite.
But i cant even not start up correctly.

i am following your text and did the step
compiling for stm32f4 (scons PLATFORM=stm32f4)
and transfer to the board (load main.elf)
now in the translated text:

More concretely
    connect to port
        connect the TXD port PA3
        connect the RXD port PA2

i do not really understand what this means.
and i tried the make ipm, what does not work and shows me this errors:

:~/pymite$ make ipm
make -C src/platform/desktop64 cleanvmpath
make[1]: Entering directory `~/pymite/src/platform/desktop64'
make[1]: *** No rule to make target `cleanvmpath'.  Stop.
make[1]: Leaving directory `~/pymite/src/platform/desktop64'
make: *** [ipm] Error 2

thanks a lot for your effort with helping me :)

best regards

bard stéphane

unread,
Nov 23, 2013, 5:13:03 AM11/23/13
to python-o...@googlegroups.com
did you buy a FOCA (look at IM120525005 model) ?
the FOCA switch should be positioned side 3.3v


some url sample (
http://shop.boxtec.ch/foca-v22-ft232rl-tiny-breakout-p-40332.html?language=en

and the TX foca pin should be connected to the STM32F4 / PA3 pin
and the RX foca pin should be connected to the STM32F4 / PA2 pin

The japanese guy, who develop this link use PA3/PA2 USART for communication
with the terminal

I don't remember if check the 64bit desktop in my project. my terminal
is just a tiny 32bits ubuntu :)
I will try to look at it If I had time this weekend to better understand your
problem

kittipon meesompop

unread,
Nov 23, 2013, 6:49:06 AM11/23/13
to python-o...@googlegroups.com
i am using only an STM32F4-Discoveryboard and did not buy the FOCA.
is there an another choice without buying it? because it will be complicated and long time to
order something throught university (need a permittation of professor and etc.)
may be, can i change the hardware configurature in an source-file or something like that?

kittipon meesompop

unread,
Nov 24, 2013, 3:41:20 AM11/24/13
to python-o...@googlegroups.com
Hello satoa,

i'm trying to run ipm too. I would like to ask you how you can change communication from USART2 to USART1. Did you change it in Hardware or software?

best regards
Kittipon

sabota...@gmail.com

unread,
Nov 24, 2013, 7:17:13 AM11/24/13
to python-o...@googlegroups.com
First, you need to connect USART1 TX and RX ( PB6 and PB7 pins) with  RS232 to USB cable.
 Then if you using tucks port to stm32f4, if i remember correctly, you will have to change init.c, usart2.c and usart.h (mostly init.c) to change from USART2 to USART1. Remember that USART1 and USART2 are not on same bus (usart1 - apb2 , usart2 - apb1), so make sure that you change that too.

bard stéphane

unread,
Nov 24, 2013, 7:48:40 AM11/24/13
to python-o...@googlegroups.com
yeap
STM32F4 has serveral USART, you can use one of them.
pay attention to the documentation for changing the right boolean mode SCI-> etc ...
and maybe bus frequency...

kittipon meesompop

unread,
Nov 24, 2013, 9:47:40 AM11/24/13
to python-o...@googlegroups.com
thanks alot for your answer.
To follow your suggestion, do i need an extra device or can i solder cables to connect pins?
if i can do it without extra device can you tell me please how to do.

kittipon meesompop

unread,
Dec 2, 2013, 7:26:29 AM12/2/13
to python-o...@googlegroups.com
Hello Simon,
now i have got the FOCA. But i am not sure with changing USART, because i have to change pin-config like

// GPIOA configure
    GPIOA->PUPDR = 0x00005556; // GPIOA_15..9:input GPIOA_7..1:input_PullUp GPIOA_0:input_PullDown
// PA0=USER_BTN PA2=USART2_Tx PA3=USART2_Rx PA8=MCO1
// PA15..13=JTAG(SWD)
    GPIOA->MODER = default_GPIOA_MODER | GPIO_MODER_MODER8_1 | GPIO_MODER_MODER3_1 | GPIO_MODER_MODER2_1 ;
    GPIOA->ODR = 0;
    GPIOA->AFR[0]= 0x00007700; // GPIOA3,2 as USART2_Rx,Tx
    GPIOA->AFR[1]= 0x00000000; // GPIOA8 as MCO1

Can u show me please how to do?

best regards

Reply all
Reply to author
Forward
0 new messages