WBUS-EMMC how to tell if it's present

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
mischko
Posts: 18
Joined: Tue Feb 03, 2015 12:32 am

WBUS-EMMC how to tell if it's present

Post by mischko » Fri Jun 21, 2019 3:33 am

This doesn't work in boot.py:

# Mount the WBUS-EMMC if it's there and set it up
mmc = pyb.MMCard()
if mmc.present():
import os
os.mount(mmc, '/mmc')
sys.path.append('/mmc')
pyb.usb_mode('VCP+MSC', msc=(mmc,))

The present() method returns False if the EMMC is present or not.
There does not appear to be a way to resolve this. the mmc.power(1) method never returns if it's not there. The mount() never returns if it's not there.
The info() method doesn't work ahead of mounting either.

This is a SF6W that I just received and it's working great otherwise.

I think this is a bug with the present() function. Any help would be greatly appreciated.

Scott

User avatar
jimmo
Posts: 2263
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: WBUS-EMMC how to tell if it's present

Post by jimmo » Fri Jun 21, 2019 6:01 am

Yeah, the `present()` function is only implemented for SDCard. (But both SD and MM share the same type -- it's hardcoded to return false for MM).

I did notice the MMC's nRST line is connected to SD_SW. So SD_SW will be floating when not present, and high when present. Unfortunately setting the internal STM32 pull-down is too strong, so you're stuck trying to measure a floating pin. In practise this actually worked quite well - I got consistent results, but don't rely on it!

Code: Select all

>>> p = machine.Pin.board.SD_SW
>>> p.init(mode=machine.Pin.IN, pull=machine.Pin.PULL_NONE)
>>> p.value()
0
I'll raise a bug for this, at least might be good to fix on a future version of the WBUS-EMMC.

chuckbook
Posts: 129
Joined: Fri Oct 30, 2015 11:55 pm

Re: WBUS-EMMC how to tell if it's present

Post by chuckbook » Fri Jun 21, 2019 5:19 pm

Wouldn't the usual way be to just try mounting and evaluate except? EMMC is definitely not a hot-plug device.

Stevo52
Posts: 38
Joined: Sun Feb 03, 2019 10:28 pm

Re: WBUS-EMMC how to tell if it's present

Post by Stevo52 » Sat Jun 22, 2019 3:30 am

chuckbook wrote:
Fri Jun 21, 2019 5:19 pm
Wouldn't the usual way be to just try mounting and evaluate except? EMMC is definitely not a hot-plug device.
I have not fitted my WBUS-EMMC as yet but I am interested in this topic because I will start experimenting soon.

The WBUS-EMMC documentation states "This WBUS-EMMC replaces an SD-Card. It's not possible to use an SD card and the WBUS-EMMC together." so I figured that there must be something in the firmware that detects it and disables the SD card, but it sounds like that is NOT the case? Any comment from those who have used the EMMC board?

Online
User avatar
pythoncoder
Posts: 5151
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: WBUS-EMMC how to tell if it's present

Post by pythoncoder » Sat Jun 22, 2019 6:57 am

Apologies for asking a doubtless dumb question, but what is the benefit of an EMMC device over an SD card?
Peter Hinch

chuckbook
Posts: 129
Joined: Fri Oct 30, 2015 11:55 pm

Re: WBUS-EMMC how to tell if it's present

Post by chuckbook » Sat Jun 22, 2019 7:20 am

Where to start.. :)
Most important (for MCU applications) there is no need for flaky connectors.
But there are more:
- extended temperature range
- much more configuration options
- trade in space for reliability (SLC emulation)
- power efficiency
- space requirements
- better sourcing (who knows what' inside an SD card?)

Online
User avatar
pythoncoder
Posts: 5151
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: WBUS-EMMC how to tell if it's present

Post by pythoncoder » Sat Jun 22, 2019 7:53 am

Thank you.
Peter Hinch

User avatar
saulo
Posts: 16
Joined: Thu May 26, 2016 9:05 am
Location: Brasil

Re: WBUS-EMMC how to tell if it's present

Post by saulo » Mon Oct 05, 2020 7:47 pm

Stevo52 wrote:
Sat Jun 22, 2019 3:30 am
chuckbook wrote:
Fri Jun 21, 2019 5:19 pm
Wouldn't the usual way be to just try mounting and evaluate except? EMMC is definitely not a hot-plug device.
I have not fitted my WBUS-EMMC as yet but I am interested in this topic because I will start experimenting soon.

The WBUS-EMMC documentation states "This WBUS-EMMC replaces an SD-Card. It's not possible to use an SD card and the WBUS-EMMC together." so I figured that there must be something in the firmware that detects it and disables the SD card, but it sounds like that is NOT the case? Any comment from those who have used the EMMC board?
Micropython uses one storage to run the scripts inside, this is one reason to only mount 1 filesystem, the other reason is hardware:

The STM32F7 series have up to two SD/SDIO/MMC interfaces, there is one connected on murata 1DX wireless module (configured as 4bit bus) and another SDIO (also 4bits bus) are shared with SDcard and WBUS. I'm assuming a design choice by mr. George, since there will be high speeds for SDcard OR eMMC instead low speed for SDcard (using ordinary SPI interface (1 bit bus) for SD w/r) AND high speed for eMMC.

i don't think you can share SD/SDIO/MMC interfaces with 2 devices, DMA could become crazy with buffer control :(

I guess you can add another sdcard connector over an spi bus if you really need dual storage (there is need to drivers/filesystem modules to use it? i don't know if someone already did it or we can use native upython modules to do that), but you must use one of each original options to initialize the micropython correctly.

Stevo52
Posts: 38
Joined: Sun Feb 03, 2019 10:28 pm

Re: WBUS-EMMC how to tell if it's present

Post by Stevo52 » Mon Oct 05, 2020 8:57 pm

That wasn't really what I was asking, I understand the benefits of EMMC and the single file system etc. My question was if it is not possible to use EMMC and SDCard together (as the documentation says), how is that detected/managed? I got around it with a try/except, checking for EMMC before the SD..

And I have added an external SD on SPI for user accessible card actions.

Faloten
Posts: 1
Joined: Tue Oct 20, 2020 7:40 pm

Re: WBUS-EMMC how to tell if it's present

Post by Faloten » Tue Oct 20, 2020 7:42 pm

Dual storage is also possible as you told for that kind hardware spi (https://911electronic.com/spi-communica ... spi-works/) connections

Post Reply