Access to the on-board flash memory (eMMC) of a CM3+

Discussion and questions about programming with Ultibo.
garfield
Posts: 5
Joined: Sat Mar 16, 2019 7:33 am

Access to the on-board flash memory (eMMC) of a CM3+

Postby garfield » Sat Mar 16, 2019 8:01 am

Hi folks,

I don't know if this is the right place for my question / problem.

I'd like to make a little datalogger with a Raspberry Pi Compute Module (CM3+) and a selfmade carrier board. Uptime will be about 10 hours and in this time approx. 2.8 GB data needs to be written. Because the heavy write-load (and I'm a bit lazy and want to save the SD-Card) I'd like to use the on-board flash memory (32GB).

In Ultibo I have tried to get the eMMC to work without success. Even a try with FSGetValidDrives returns a 0. What is it, that im overlooking? Is there even a support for the eMMC?

Thanks for any answer
Garfield

P.S.: Sorry for my english but it is not my mothers tongue.

P.P.S: What I have forgotten to mention: flashing the firmware and the kernel7 to the eMMC and booting works like a charm. Only the access at runtime is the problem!
User avatar
Ultibo
Site Admin
Posts: 2280
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby Ultibo » Sun Mar 17, 2019 9:59 am

garfield wrote:In Ultibo I have tried to get the eMMC to work without success. Even a try with FSGetValidDrives returns a 0. What is it, that im overlooking? Is there even a support for the eMMC?

Hi and welcome to Ultibo.

We don't have a CM3+ but we've done some checking of the schematic and device tree info to see what should be happening.

All models of the Pi have 2 SD card controllers, an Arasan device that supports SD/MMC/SDIO etc and a somewhat unknown device that is described as Broadcom specific and only supports SD and MMC.

Ultibo currently only has drivers for the Arasan device and officially (according to Raspbian) that device is now used for the on-board WiFi SDIO access whereas the other SD is used to access the SD card or eMMC on a Compute Module.

It's possible all that is needed is to modify some GPIO pin settings to switch the alternate function to the SD host device that Ultibo supports. A really simple way to check is to dump the function assignments of all the GPIO pins to text and post them here so we can see which SD device is being configured.

You can output all of the GPIO function assignments using something as simple as this:

Code: Select all

for Count:=0 to GPIO_PIN_COUNT - 1 do
  begin
   LoggingOutput('GPIOFunctionGet(' + GPIOPinToString(Count) + ') = ' + GPIOFunctionToString(GPIOFunctionGet(Count)));
  end;


Obviously the best choice for outputting the logging would be either serial or syslog since console wouldn't allow you to save the output and file logging possibly won't work if the SD isn't accessible (unless you connect a USB disk).

You can find some examples of how to configure logging in the Forum Quick Reference.
Ultibo.org | Make something amazing
https://ultibo.org
garfield
Posts: 5
Joined: Sat Mar 16, 2019 7:33 am

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby garfield » Sun Mar 17, 2019 11:23 am

Hi Ultibo,

I have run the program. Logging was to an USB-Stick.

Code: Select all

0000005D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_0) = GPIO_FUNCTION_IN
0000005E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_1) = GPIO_FUNCTION_IN
0000005F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_2) = GPIO_FUNCTION_IN
00000060 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_3) = GPIO_FUNCTION_IN
00000061 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_4) = GPIO_FUNCTION_IN
00000062 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_5) = GPIO_FUNCTION_IN
00000063 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_6) = GPIO_FUNCTION_IN
00000064 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_7) = GPIO_FUNCTION_IN
00000065 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_8) = GPIO_FUNCTION_IN
00000066 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_9) = GPIO_FUNCTION_IN
00000067 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_10) = GPIO_FUNCTION_IN
00000068 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_11) = GPIO_FUNCTION_IN
00000069 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_12) = GPIO_FUNCTION_IN
0000006A - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_13) = GPIO_FUNCTION_IN
0000006B - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_14) = GPIO_FUNCTION_ALT0
0000006C - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_15) = GPIO_FUNCTION_ALT0
0000006D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_16) = GPIO_FUNCTION_IN
0000006E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_17) = GPIO_FUNCTION_IN
0000006F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_18) = GPIO_FUNCTION_IN
00000070 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_19) = GPIO_FUNCTION_IN
00000071 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_20) = GPIO_FUNCTION_IN
00000072 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_21) = GPIO_FUNCTION_IN
00000073 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_22) = GPIO_FUNCTION_IN
00000074 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_23) = GPIO_FUNCTION_IN
00000075 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_24) = GPIO_FUNCTION_IN
00000076 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_25) = GPIO_FUNCTION_IN
00000077 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_26) = GPIO_FUNCTION_IN
00000078 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_27) = GPIO_FUNCTION_IN
00000079 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_28) = GPIO_FUNCTION_IN
0000007A - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_29) = GPIO_FUNCTION_IN
0000007B - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_30) = GPIO_FUNCTION_IN
0000007C - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_31) = GPIO_FUNCTION_IN
0000007D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_32) = GPIO_FUNCTION_IN
0000007E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_33) = GPIO_FUNCTION_IN
0000007F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_34) = GPIO_FUNCTION_IN
00000080 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_35) = GPIO_FUNCTION_IN
00000081 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_36) = GPIO_FUNCTION_IN
00000082 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_37) = GPIO_FUNCTION_IN
00000083 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_38) = GPIO_FUNCTION_IN
00000084 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_39) = GPIO_FUNCTION_IN
00000085 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_40) = GPIO_FUNCTION_IN
00000086 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_41) = GPIO_FUNCTION_IN
00000087 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_42) = GPIO_FUNCTION_IN
00000088 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_43) = GPIO_FUNCTION_IN
00000089 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_44) = GPIO_FUNCTION_IN
0000008A - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_45) = GPIO_FUNCTION_IN
0000008B - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_46) = GPIO_FUNCTION_IN
0000008C - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_47) = GPIO_FUNCTION_OUT
0000008D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_48) = GPIO_FUNCTION_ALT3
0000008E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_49) = GPIO_FUNCTION_ALT3
0000008F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_50) = GPIO_FUNCTION_ALT3
00000090 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_51) = GPIO_FUNCTION_ALT3
00000091 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_52) = GPIO_FUNCTION_ALT3
00000092 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_53) = GPIO_FUNCTION_ALT3


I hope this will help.
Garfield
User avatar
Ultibo
Site Admin
Posts: 2280
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby Ultibo » Sun Mar 17, 2019 11:25 pm

garfield wrote:

Code: Select all

0000008D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_48) = GPIO_FUNCTION_ALT3
0000008E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_49) = GPIO_FUNCTION_ALT3
0000008F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_50) = GPIO_FUNCTION_ALT3
00000090 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_51) = GPIO_FUNCTION_ALT3
00000091 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_52) = GPIO_FUNCTION_ALT3
00000092 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_53) = GPIO_FUNCTION_ALT3


So these 6 lines show that the correct (supported) SD host device is configured after boot so there must be another explanation for why the eMMC storage isn't visible.

Can we get you to do another test that delays starting the MMC subsystem until after boot and logs the results of MMC initialization?

In other posts and examples we've shown how to add an init unit to a program to modify some of the global configuration settings during boot, this time we want to change MMC_AUTOSTART to False in order to prevent the MMC subsystem from automatically initializing.

An simple init unit would look like this:

Code: Select all

unit InitUnit;

interface

uses GlobalConfig;

implementation


initialization

 //Disable MMC Autostart for testing
 MMC_AUTOSTART := False;
 
end.


Save that as InitUnit.pas and include it into your test program as the very first item in the uses clause, like this:

Code: Select all

program MyPrograml

uses
 InitUnit,
 MMC,   //Include the MMC unit for our test below
 ... Other units go here
 


Then in your test program with logging enabled as before add a delay of at least 5 to 10 seconds before starting the MMC subsystem.

Code: Select all

begin

 ... code to enable logging etc
 
 
 Sleep(10000);
 MMCStart;



The log should show at a minimum a sign on message from the "Arasan SD Host Controller" driver and hopefully any errors or other relevant messages during initialization.
Ultibo.org | Make something amazing
https://ultibo.org
garfield
Posts: 5
Joined: Sat Mar 16, 2019 7:33 am

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby garfield » Mon Mar 18, 2019 5:07 am

Hi Ultibo,

here the output of the logging:

Code: Select all

00000053 - 0066A298:0 - Network: IP: Configuring adapter Loopback with CONFIG_TYPE_LOOPBACK
00000054 - 0066A298:0 - Network: IP: Configuration completed for adapter Loopback
00000055 - 0066A298:0 - Network: IP:  Config = CONFIG_TYPE_LOOPBACK
00000056 - 0066A298:0 - Network: IP:  Address = 127.0.0.1
00000057 - 0066A298:0 - Network: IP:  Netmask = 255.0.0.0
00000058 - 0066A298:0 - Network: IP:  Gateway = 0.0.0.0
00000059 - 0066A298:0 - Network: IP:  Server = 0.0.0.0
0000005A - 003EC9E0:0 - MMC: SDHCI BCM2710 Powering on Arasan SD Host Controller
0000005B - 003EC9E0:0 - [ERROR] MMC: SDHCI Failed to initialize new MMC device
0000005C - 003EC9E0:0 - MMC: SDHCI BCM2710 Powering off Arasan SD Host Controller
0000067 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_10) = GPIO_FUNCTION_IN
00000068 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_11) = GPIO_FUNCTION_IN
00000069 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_12) = GPIO_FUNCTION_IN
0000006A - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_13) = GPIO_FUNCTION_IN
0000006B - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_14) = GPIO_FUNCTION_ALT0
0000006C - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_15) = GPIO_FUNCTION_ALT0
0000006D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_16) = GPIO_FUNCTION_IN
0000006E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_17) = GPIO_FUNCTION_IN
0000006F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_18) = GPIO_FUNCTION_IN
00000070 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_19) = GPIO_FUNCTION_IN
00000071 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_20) = GPIO_FUNCTION_IN
00000072 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_21) = GPIO_FUNCTION_IN
00000073 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_22) = GPIO_FUNCTION_IN
00000074 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_23) = GPIO_FUNCTION_IN
00000075 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_24) = GPIO_FUNCTION_IN
00000076 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_25) = GPIO_FUNCTION_IN
00000077 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_26) = GPIO_FUNCTION_IN
00000078 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_27) = GPIO_FUNCTION_IN
00000079 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_28) = GPIO_FUNCTION_IN
0000007A - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_29) = GPIO_FUNCTION_IN
0000007B - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_30) = GPIO_FUNCTION_IN
0000007C - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_31) = GPIO_FUNCTION_IN
0000007D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_32) = GPIO_FUNCTION_IN
0000007E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_33) = GPIO_FUNCTION_IN
0000007F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_34) = GPIO_FUNCTION_IN
00000080 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_35) = GPIO_FUNCTION_IN
00000081 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_36) = GPIO_FUNCTION_IN
00000082 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_37) = GPIO_FUNCTION_IN
00000083 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_38) = GPIO_FUNCTION_IN
00000084 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_39) = GPIO_FUNCTION_IN
00000085 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_40) = GPIO_FUNCTION_IN
00000086 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_41) = GPIO_FUNCTION_IN
00000087 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_42) = GPIO_FUNCTION_IN
00000088 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_43) = GPIO_FUNCTION_IN
00000089 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_44) = GPIO_FUNCTION_IN
0000008A - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_45) = GPIO_FUNCTION_IN
0000008B - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_46) = GPIO_FUNCTION_IN
0000008C - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_47) = GPIO_FUNCTION_OUT
0000008D - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_48) = GPIO_FUNCTION_ALT3
0000008E - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_49) = GPIO_FUNCTION_ALT3
0000008F - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_50) = GPIO_FUNCTION_ALT3
00000090 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_51) = GPIO_FUNCTION_ALT3
00000091 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_52) = GPIO_FUNCTION_ALT3
00000092 - 003EC9E0:0 - GPIOFunctionGet(GPIO_PIN_53) = GPIO_FUNCTION_ALT3


Garfield
User avatar
Ultibo
Site Admin
Posts: 2280
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby Ultibo » Mon Mar 18, 2019 9:00 am

garfield wrote:

Code: Select all

0
0000005A - 003EC9E0:0 - MMC: SDHCI BCM2710 Powering on Arasan SD Host Controller
0000005B - 003EC9E0:0 - [ERROR] MMC: SDHCI Failed to initialize new MMC device
0000005C - 003EC9E0:0 - MMC: SDHCI BCM2710 Powering off Arasan SD Host Controller


Hi Garfield,

That narrows it down to one function at least and from a quick look it appears there is a little bit that hasn't been completed yet because we don't have an MMC (as opposed to SD) device to test with.

If you are willing to do another test it might just tell us enough to complete the missing details.

We need to enable debug logging this time in order to collect some more detailed information including the decode of the card specific data returned by the MMC.

To enable MMC debug open the file globaldefines.inc which is normally found in the folder C:\Ultibo\Core\fpc\3.1.1\source\rtl\ultibo\core (unless you are using Linux).

Find the line that looks like this:

Code: Select all

{--$DEFINE MMC_DEBUG}


and change it to this:

Code: Select all

{$DEFINE MMC_DEBUG}


Then rebuild your RTL by using Tools, Build Ultibo RTL... from the Lazarus menu, then compile and run your test again.

The debug logging might produce a file too large for the forum so you can either email it to us at info@ultibo.org or upload it somewhere and provide us a link.

Hopefully there will be enough info to tell us what we need to know.
Ultibo.org | Make something amazing
https://ultibo.org
garfield
Posts: 5
Joined: Sat Mar 16, 2019 7:33 am

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby garfield » Mon Mar 18, 2019 11:10 am

Hi Ultibo,

here is the link: https://we.tl/t-vA18AMigSC
User avatar
Ultibo
Site Admin
Posts: 2280
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby Ultibo » Tue Mar 26, 2019 11:42 pm

garfield wrote:here is the link: https://we.tl/t-vA18AMigSC

Okay so we've followed it a bit further and determined that it currently fails at decoding the card specific data (CSD) because the structure version value is not being accepted.

After checking against the Linux driver it seems we should accept the version returned and that would allow it to proceed one step further. However it also appears that eMMC might need the extended card specific data as well which we currently don't decode.

We've gone ahead and ordered a CM3+ development kit but it is currently on back order for about a month so in the meantime we've updated the MMC driver to accept that CSD version reported and continue to the next step.

If you could update your RTL with the latest version from GitHub and rebuild your RTL using the Build RTL tool (or following the instructions in the wiki) and then rerun the same test with debug logging enable it should produce some additional output which might allow us to make some further progress while waiting for our CM3+ to arrive.

Thanks.
Ultibo.org | Make something amazing
https://ultibo.org
garfield
Posts: 5
Joined: Sat Mar 16, 2019 7:33 am

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby garfield » Wed Mar 27, 2019 8:04 am

Hi folks,

here the next test: https://we.tl/t-q9a1VLvIRK

Seems like the next step to world domina... ehh in the right direction :D
User avatar
Ultibo
Site Admin
Posts: 2280
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Access to the on-board flash memory (eMMC) of a CM3+

Postby Ultibo » Fri May 10, 2019 12:07 am

So after waiting several weeks for the CM3+ to arrive we were suddenly informed that the expected delivery date had changed from April to July.

After some checking it seems there is some sort of worldwide shortage of the new CM3+ with some distributors showing estimated delivery as far away as September, so we hunted down one of the few remaining CM3 dev kits instead and that finally arrived yesterday, we can now begin to look at this in more detail and work out the changes needed to make the eMMC work.

We'll post an update when we know more.
Ultibo.org | Make something amazing
https://ultibo.org

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest