micropython / micropython

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
https://micropython.org
Other
19.1k stars 7.64k forks source link

STM32 Nucleo F4x1 boards support #989

Closed nuraci closed 8 years ago

nuraci commented 9 years ago

Hi all,

I'm trying to run (with lots of fun) MicroPython on the STM32F401RE, some things are already good, but there is still much work to do (obviously), the big challenge is, from my point of view, how the user can manage easily the internal file system...

Another little issue is related to the build system as the "Nucleo" approach uses almost the same "stmhal" source tree but with a different point of view and with different CPUs.

Let me know if there is interest in this porting :)

Anyway, I will publish soon my work here: https://github.com/nuraci/micropython

Thank you Damien, your MicroPython is great!!

Hoping is the right place for write this.... Regards, Nunzio

dpgeorge commented 9 years ago

The Nucleo board is lacking in a USB connector and SD card slot, so that really limits its utility. You'd need to use UART for the REPL (not so bad), but the filesystem would be just the internal one, and there'd be no way to access it from the PC (since there is no USB, so no MSD). So from this point of view I don't think it's worth supporting this hardware (otherwise people are going to ask many questions about how to get the filesystem working, etc).

What is your motivation for using the Nucleo board? The pyboard is a better option :)

nuraci commented 9 years ago

Hi Damien, yes, you are right, your board is really superb, what I love using the Nucleo board is the capability to use its shields, probably simply adding a .py file as python library. Regarding Nucleo limits, my proposal is to add a "recv()" command and so send the .py file through the xmodem protocol. What do you think about?

dpgeorge commented 9 years ago

my proposal is to add a "recv()" command and so send the .py file through the xmodem protocol.

You could probably write this in Python itself, a Python function that receives using the xmodem protocol.

nuraci commented 9 years ago

Of course, also send the file could be made from an IDE, avoiding the user to perform the command by hand...

dpgeorge commented 9 years ago

@nuraci did you get something working for the F401?

nuraci commented 9 years ago

@dpgeorge yes, some things work and pass the tests, I am currently trying to use the REPL_RAW feature in order to obtain the "Run" functionality through an IDE.

dpgeorge commented 9 years ago

Is it something we can merge into this repository?

nuraci commented 9 years ago

I'd love to, but I should probably talk to you before about some choices I took (1) and how to address some issues(2). some examples: (1) Some files contain substantial changes, so I created the subdirectory "nucleo". (2) Other "common" files need changes due the different micro e.g. https://github.com/nuraci/micropython/commit/645aa424f5104740f6d389b6a836cdffdf923591 or https://github.com/nuraci/micropython/commit/8effc8438ead61d25df493737cd2fd49984331b1

dpgeorge commented 9 years ago

As long as it mostly fits the stmhal framework we should merge it. We can provide macro options for RTC, ADC, timer etc differences.

nuraci commented 9 years ago

I agree and happy to hear this, could you help me in order to go ahead?

AWCharlie commented 9 years ago

Can MicroPython run as an app on top of the mbed OS? Mbed alpha 1 is scheduled for this month, so we don't know much about it unless very involved, but it looks like a good horse to be hitched to for IoT.

-- Charlie

On Sun, Dec 21, 2014 at 2:02 PM, Nunzio Raciti notifications@github.com wrote:

I agree and happy to hear this, could you help me in order to go ahead?

— Reply to this email directly or view it on GitHub https://github.com/micropython/micropython/issues/989#issuecomment-67786804 .

aniljava commented 9 years ago

Sorry to revive the old thread.

Is the nucleo support working yet. I did a quick make deploy with nuraci port, files gets copied to the MBED file system but nothing after that.

Or the os is not picking up the micropython fs.

Linux 3.18.6-1-ARCH #1 SMP PREEMPT Sat Feb 7 08:44:05 CET 2015 x86_64 GNU/Linux

Dmesg logs:

[254979.244635] usb 4-1: new full-speed USB device number 37 using xhci_hcd
[254979.526716] usb 4-1: ep 0x84 - rounding interval to 1024 microframes, ep desc says 2040 microframes
[254979.584597] usb-storage 4-1:1.1: USB Mass Storage device detected
[254979.584729] scsi host30: usb-storage 4-1:1.1
[254979.585151] cdc_acm 4-1:1.2: This device cannot do calls on its own. It is not a modem.
[254979.585164] cdc_acm 4-1:1.2: ttyACM0: USB ACM device
[254980.586665] scsi 30:0:0:0: Direct-Access     MBED     microcontroller  1.0  PQ: 0 ANSI: 2
[254980.587327] sd 30:0:0:0: [sdd] 1072 512-byte logical blocks: (548 kB/536 KiB)
[254980.587546] sd 30:0:0:0: [sdd] Write Protect is off
[254980.587548] sd 30:0:0:0: [sdd] Mode Sense: 03 00 00 00
[254980.587771] sd 30:0:0:0: [sdd] No Caching mode page found
[254980.587773] sd 30:0:0:0: [sdd] Assuming drive cache: write through
[254980.605564]  sdd:
[254980.606867] sd 30:0:0:0: [sdd] Attached SCSI removable disk
nuraci commented 9 years ago

Hi,

are you sure that the file you have copied was the firmware.bin?

(see in attach).

Nunzio

2015-04-01 1:18 GMT+02:00 aniljava notifications@github.com:

Sorry to revive the old thread.

Is the nucleo support working yet. I did a quick make deploy with nuraci port, files gets copied to the MBED file system but nothing after that.

Or the os is not picking up the micropython fs.

Linux 3.18.6-1-ARCH #1 SMP PREEMPT Sat Feb 7 08:44:05 CET 2015 x86_64 GNU/Linux

Dmesg logs:

[254979.244635] usb 4-1: new full-speed USB device number 37 using xhci_hcd [254979.526716] usb 4-1: ep 0x84 - rounding interval to 1024 microframes, ep desc says 2040 microframes [254979.584597] usb-storage 4-1:1.1: USB Mass Storage device detected [254979.584729] scsi host30: usb-storage 4-1:1.1 [254979.585151] cdc_acm 4-1:1.2: This device cannot do calls on its own. It is not a modem. [254979.585164] cdc_acm 4-1:1.2: ttyACM0: USB ACM device [254980.586665] scsi 30:0:0:0: Direct-Access MBED microcontroller 1.0 PQ: 0 ANSI: 2 [254980.587327] sd 30:0:0:0: [sdd] 1072 512-byte logical blocks: (548 kB/536 KiB) [254980.587546] sd 30:0:0:0: [sdd] Write Protect is off [254980.587548] sd 30:0:0:0: [sdd] Mode Sense: 03 00 00 00 [254980.587771] sd 30:0:0:0: [sdd] No Caching mode page found [254980.587773] sd 30:0:0:0: [sdd] Assuming drive cache: write through [254980.605564] sdd: [254980.606867] sd 30:0:0:0: [sdd] Attached SCSI removable disk

— Reply to this email directly or view it on GitHub https://github.com/micropython/micropython/issues/989#issuecomment-88280376 .

aniljava commented 9 years ago

(see in attach), I did not see attachment in github or in email if there was one.

I retried the whole process, was able to access over serial console but could not mount fatfs. Here is the overview: LAST FEW LINES OF MAKE

# make
...
arm-none-eabi-size build-STM32NUCF401/firmware.elf
   text    data     bss     dec     hex filename
 222956      20   21980  244956   3bcdc build-STM32NUCF401/firmware.elf
Create the (mbed Enabled) binary build-STM32NUCF401/firmware.bin
arm-none-eabi-objcopy -O binary -j .isr_vector -j .text -j .data build-STM32NUCF401/firmware.elf build-STM32NUCF401/firmware.bin

DMESG AFTER CONNECTING NUCLEO

[47269.169610] usb 5-1: new full-speed USB device number 24 using xhci_hcd
[47269.451807] usb 5-1: ep 0x84 - rounding interval to 1024 microframes, ep desc says 2040 microframes
[47269.509711] usb-storage 5-1:1.1: USB Mass Storage device detected
[47269.509936] scsi host17: usb-storage 5-1:1.1
[47269.510556] cdc_acm 5-1:1.2: This device cannot do calls on its own. It is not a modem.
[47269.510574] cdc_acm 5-1:1.2: ttyACM0: USB ACM device
[47270.514815] scsi 17:0:0:0: Direct-Access     MBED     microcontroller  1.0  PQ: 0 ANSI: 2
[47270.515575] sd 17:0:0:0: [sdc] 1072 512-byte logical blocks: (548 kB/536 KiB)
[47270.515858] sd 17:0:0:0: [sdc] Write Protect is off
[47270.515863] sd 17:0:0:0: [sdc] Mode Sense: 03 00 00 00
[47270.516086] sd 17:0:0:0: [sdc] No Caching mode page found
[47270.516092] sd 17:0:0:0: [sdc] Assuming drive cache: write through
[47270.534041]  sdc:
[47270.535584] sd 17:0:0:0: [sdc] Attached SCSI removable disk

# mount /dev/sdc /media/root/NUCLEO

# ls -l /media/root/NUCLEO/
total 8
-rwxr-xr-x 1 root root  512 Dec 14  2012 mbed.htm
drwxr-xr-x 2 root root 4096 Nov 19  2013 System Volume Information

COPIED THE FIRMWARE

# cp build-STM32NUCF401/firmware.bin /media/root/NUCLEO/

ACCESS OVER THE SERIAL CONSOLE AND VERIFY THE /flash exists with files

Press CTRL-A Z for help on special keys

import os
>>> os.listdir('/flash')
['main.py', 'demo.py', 'README.txt', 'boot.py']
>>> 

AFTER RESET / RECONNECTION :

# ls /media/root/NUCLEO/
mbed.htm  System Volume Information

I also tried 0 and 1 for ,

define MICROPY_HW_HAS_SDCARD (1)

nucleo/boards/STM32NUCF401/mpconfigboard.h
dpgeorge commented 9 years ago

@nuraci I recently added support for the F401 and F411 MCUs so maybe this helps you?

pfalcon commented 9 years ago

Any updates on this ticket? Proposed closing it, forum can be used for further communications, patches can be submitted to patch tracker when ready.

dpgeorge commented 9 years ago

We could perhaps merge the board config file from: https://github.com/cnoviello/micropython/tree/master/stmhal/boards/STM32F4NUCLEO . @cnoviello is that ready to merge?

cnoviello commented 9 years ago

Yes. It's ready, Feel free to merge.

mikeredbike commented 8 years ago

Anyone got a NUCLEO F746 board running?

dpgeorge commented 8 years ago

@mikeredbike the F746 discovery board is (partially) supported. The nucleo version would be very similar. Please discuss this at forum.micropython.org if you want further info/help.

dpgeorge commented 8 years ago

@cnoviello's board config files for the STM32F401NUCLEO board have been merged in 3d42aa07dd6e94942b3721ee42ba5454cd0edf55. His original commits were used but they were all squashed together.