EMMC Flash Mounting issues

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
redjmc
Posts: 3
Joined: Tue May 28, 2019 11:25 pm

EMMC Flash Mounting issues

Post by redjmc » Wed May 29, 2019 12:29 am

Having trouble mounting my EMMC flash storage chip.
I have the the pybd SF3W. Have tried on Linux and Windows with the same result.

Running into the following issue:

>>> import os
>>> pyb.MMCard().info()
(3825205248, 512, 0)
>>> os.mount(pyb.MMCard(), '/mmc')
Traceback (most recent call last):
File "<stdin>", line1, in <module>
OSError: [Errno 19] ENODEV

Any help would be greatly appreciated.

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

Re: EMMC Flash Mounting issues

Post by pythoncoder » Wed May 29, 2019 7:32 am

Puzzling. You might try

Code: Select all

import os
mmc = pyb.MMCard()
mmc.power(1)
mmc.info()
os.mount(mmc, '/mmc')
This is based on looking at the mmc_format script - alas I don't have an MMC card to actually try this.
Peter Hinch

redjmc
Posts: 3
Joined: Tue May 28, 2019 11:25 pm

Re: EMMC Flash Mounting issues

Post by redjmc » Wed May 29, 2019 2:03 pm

Thank you for your reply!

Some more information about my firmware and board:

MicroPython v1.10-347-ga13e5862c on 2019-04-30; PYBD_SF3W with STM32F733IEK

Tried your suggestion no luck:

>>> import os
>>> mmc = pyb.MMCard()
>>> mmc.power(1)
True
>>> mmc.info()
(3825205248, 512, 0)
>>> os.mount(mmc, '/mmc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV


Going to flash the board with the latest firmware again today and try again.

User avatar
Roberthh
Posts: 1469
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: EMMC Flash Mounting issues

Post by Roberthh » Wed May 29, 2019 2:25 pm

I had the same problem. As first step, the MMC has to be formatted. Being not at my usual place, I have to check later how formatting worked, using the mmc_format() script.

redjmc
Posts: 3
Joined: Tue May 28, 2019 11:25 pm

Re: EMMC Flash Mounting issues

Post by redjmc » Thu May 30, 2019 1:57 pm

Yay! Problem solved. Thank you for your help.

So here is what I did.

1. Download the mmc_format.py file from here: https://pybd.io/resources/mmc_format.py

2. Copy and past to main.py and reboot.

3. Open up repl and call mmc_format() <- you can be sure that the function is available by calling dir(). It should be listed there.

Once formatted, the storage needs to be handled just like an sd card.

e.g., mount: os.mount(pyb.MMCard(), '/mmc')
append partition to path: sys.path.append('/mmc')
and now you can os.chdir('/mmc') and voila!


The more I understand this board the more I am amazed at how capable a device it is!






Here is the format script in case the above link ever changes.

# Support functions for a factory format of WBUS-EMMC

FAT = """000001b0 00 00 00 00 00 00 00 00 98 96 af 9c 00 00 00 21 |...............!|
000001c0 03 00 06 17 ea fd 00 08 00 00 00 f8 71 00 00 00 |............q...|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00100000 eb 58 90 6d 6b 66 73 2e 66 61 74 00 02 08 20 00 |.X.mkfs.fat... .|
00100010 02 00 00 00 00 f8 00 00 3e 00 76 00 00 08 00 00 |........>.v.....|
00100020 00 f8 71 00 70 1c 00 00 00 00 00 00 02 00 00 00 |..q.p...........|
00100030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00100040 80 00 29 88 8c 78 e6 50 59 42 4d 4d 43 20 20 20 |..)..x.PYBMMC |
00100050 20 20 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac | FAT32 ...w|.|
00100060 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00100070 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00100080 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00100090 73 6b 2e 20 20 50 6c 65 61 73 65 20 69 6e 73 65 |sk. Please inse|
001000a0 72 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 66 6c |rt a bootable fl|
001000b0 6f 70 70 79 20 61 6e 64 0d 0a 70 72 65 73 73 20 |oppy and..press |
001000c0 61 6e 79 20 6b 65 79 20 74 6f 20 74 72 79 20 61 |any key to try a|
001000d0 67 61 69 6e 20 2e 2e 2e 20 0d 0a 00 00 00 00 00 |gain ... .......|
001001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00100200 52 52 61 41 00 00 00 00 00 00 00 00 00 00 00 00 |RRaA............|
001003e0 00 00 00 00 72 72 41 61 df 37 0e 00 02 00 00 00 |....rrAa.7......|
001003f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00100c00 eb 58 90 6d 6b 66 73 2e 66 61 74 00 02 08 20 00 |.X.mkfs.fat... .|
00100c10 02 00 00 00 00 f8 00 00 3e 00 76 00 00 08 00 00 |........>.v.....|
00100c20 00 f8 71 00 70 1c 00 00 00 00 00 00 02 00 00 00 |..q.p...........|
00100c30 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00100c40 80 00 29 88 8c 78 e6 50 59 42 4d 4d 43 20 20 20 |..)..x.PYBMMC |
00100c50 20 20 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac | FAT32 ...w|.|
00100c60 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00100c70 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00100c80 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00100c90 73 6b 2e 20 20 50 6c 65 61 73 65 20 69 6e 73 65 |sk. Please inse|
00100ca0 72 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 66 6c |rt a bootable fl|
00100cb0 6f 70 70 79 20 61 6e 64 0d 0a 70 72 65 73 73 20 |oppy and..press |
00100cc0 61 6e 79 20 6b 65 79 20 74 6f 20 74 72 79 20 61 |any key to try a|
00100cd0 67 61 69 6e 20 2e 2e 2e 20 0d 0a 00 00 00 00 00 |gain ... .......|
00100df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00104000 f8 ff ff 0f ff ff ff 0f f8 ff ff 0f 00 00 00 00 |................|
00492000 f8 ff ff 0f ff ff ff 0f f8 ff ff 0f 00 00 00 00 |................|
"""

def _mkfs(bdev, fat):
lar = fat.split('\n')
cbla = -1
for x in lar:
xar = x.split(' ')
if len(xar) >= 17:
a = int(xar[0], 16)
bla = a >> 9
offset = a & 0x1ff
if bla != cbla:
if cbla >= 0:
bdev.writeblocks(cbla, ba)
print('%x' % (cbla*512))
ba = bytearray(512)
cbla = bla
print(x)
print(end='%08X' % (a))
for i in range(16):
ba[offset+i] = int(xar[1+i], 16)
print(end=' %02X' % (ba[offset+i]))
print()
for x in ba:
if x:
bdev.writeblocks(cbla, ba)
print('%x' % (cbla*512))
break

def mmc_format():
import pyb
mmc = pyb.MMCard()
mmc.power(1)
print('Formatting...')
_mkfs(mmc, FAT)
print('Done')

print('Run mmc_format() to format the WBUS-EMMC flash memory')

mnelsoneorm
Posts: 14
Joined: Wed Jul 20, 2016 4:53 am

Re: EMMC Flash Mounting issues

Post by mnelsoneorm » Thu May 30, 2019 11:00 pm

Just received my emmc today and wondering - why is the connector set un-keyed and which way is up? Looks like it can be rotated 180 degrees and still plugged in? I see on the description when purchasing the emmc module that it should have a 'positioning' marker in the corner but for one, mine does not, and second, what would that do anyway? I don't see anything on the pyboard that shows where that marker should go. Can the modules actually be put on either way? I've been looking thru docs online but haven't found this information.

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

Re: EMMC Flash Mounting issues

Post by jimmo » Thu May 30, 2019 11:47 pm

mnelsoneorm wrote:
Thu May 30, 2019 11:00 pm
I see on the description when purchasing the emmc module that it should have a 'positioning' marker in the corner but for one, mine does not, and second, what would that do anyway?
So it has no bump in that corner at all? (Unlike the photo)

I think the idea is that bump fits just alongside the SD card holder.

I'm fairly sure from looking at the pybd schematics that they are not reversible.

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

Re: EMMC Flash Mounting issues

Post by pythoncoder » Fri May 31, 2019 9:46 am

redjmc wrote:
Thu May 30, 2019 1:57 pm
...
2. Copy and paste to main.py and reboot.
...
The normal way to run external programs is to copy the file to flash memory. There is no need to reboot: you should be able to issue

Code: Select all

import mmc_format
mmc_format.mmc_format()
You only need to modify main.py if you want code to run automatically on boot, when main.py would typically contain something along the lines of

Code: Select all

import my_module
my_module.run()
The W-bus connectors on the Pyboard D are not mechanically keyed: they will mate in either orientation. The DIP28 and DIP68 boards are designed to allow only correct orientation. On the assumption that orientation matters with the EMMC board, the documentation should illustrate correct installation.
Peter Hinch

mnelsoneorm
Posts: 14
Joined: Wed Jul 20, 2016 4:53 am

Re: EMMC Flash Mounting issues

Post by mnelsoneorm » Sat Jun 01, 2019 6:31 am

jimmo wrote:
Thu May 30, 2019 11:47 pm
mnelsoneorm wrote:
Thu May 30, 2019 11:00 pm
I see on the description when purchasing the emmc module that it should have a 'positioning' marker in the corner but for one, mine does not, and second, what would that do anyway?
So it has no bump in that corner at all? (Unlike the photo)

I think the idea is that bump fits just alongside the SD card holder.

I'm fairly sure from looking at the pybd schematics that they are not reversible.
There's no bump, but I did just try to align the connectors and it can only go on one way. One whole end of the board is too long (by like 0.5mm) and bumps into the SD card holder. I guess that would be considered keyed? Or is my board missing the cutout and I will be mounting it upside down?

User avatar
Roberthh
Posts: 1469
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: EMMC Flash Mounting issues

Post by Roberthh » Sat Jun 01, 2019 6:57 am

This is a picture of my assembled module.
Attachments
IMG_20190601_085211245.jpg
IMG_20190601_085211245.jpg (69.86 KiB) Viewed 264 times

Post Reply