Multiple Applications from SD card

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Multiple Applications from SD card

Postby Vader_Mester » Thu Jun 28, 2018 9:06 am

Hey Guys,

I'm thinking about a method to have multiple different applications to be run from a uSD card.
I had the thought that I have an additional uC (referred to as SMC - System Management Controller) in the design. The SMC has functions anyways, eg providing USB connectivity, managing system power, display, so why not do this also.
Basically the user would use the LCD to select an app to run on the ESP which is the main processor.

I thought about using flash, and reflash every time an app needs to be switched during runtime (SMC can manage this, but it will be slow, and would wear down the fash quickly).
Clearly the flash is not designed for this.

Instead can I use the ESP32 with a PSRAM in the place of the flash?
This is the plan:
- Boot board and SMC, keep the ESP deactivated with CHIP_EN line.
- Copy the first running .bin image to the PSRAM.
- Boot ESP from the PSRAM like you would with the flash, and let the app run.
- When app is switched, the ESP is reset with CHIP_EN and kept disabled
- New bin is copied into the PSRAM
- ESP boots again.

Small schema of the system concerning the ESP and PSRAM
Image

SInce the flash and PSRAM interface is the same, since they are used in parallel, write and read commands are the same, although the Flash implements a ton more other commands to provide write protection, and more wait and dummy cycles.
Is it technically possible? Where should I keep looking for modifying things software wise?

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Multiple Applications from SD card

Postby WiFive » Thu Jun 28, 2018 2:10 pm

https://github.com/tobozo/M5Stack-SD-Updater

Whether you can get the mmu to address a spiram on the instruction bus I don't know.

mikemoy
Posts: 604
Joined: Fri Jan 12, 2018 9:10 pm

Re: Multiple Applications from SD card

Postby mikemoy » Thu Jun 28, 2018 3:58 pm

I wonder if you could remove the SMC option to simplify it. Use OTA1 when it boots to read the uSD and copy the app you want to PSRAM. When that is done re-boot using PSAM. Of course you would have to disable the RAM testing stuff in menuconfig.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Multiple Applications from SD card

Postby Vader_Mester » Fri Jun 29, 2018 6:33 am

The SMC is there to houskeep the board anyways. It's like a BIOS chip on a PC motherboard.
It is supposed to have tons of GPIOs, USB, OSB-OTG, and serial.
It will manage power, and LCD screen, USB, and on-board debugging via the LCD.
(This is handy, so I don't need to plug the ESP into a PC for debugging, but the serial messages will be displayed on the LCD (without the ESP needing to drive it. This will be mounted to the wall, so this is more convenient. And the LCD will be 800x480, driven by an FT813.)
This would be a UI based system. The LCD is always working. I'm still in the overall design phase, but I want to use a common QSPI bus between my SMC and ESP32.
I will use an STM32L467RC6T, which is Arm cortex M4, maximum 80Mhz, but it is the cheapest (about 5EUR/pc), and it has 64pins, QSPI, and all sorts of jazz right there.
The ESP is there for the unlimeted raw Xtensa pooweeeeer :D

I was also thinking about using multiple Ota partitions instead, and a 16MB flash, but using RAM would be much more convenient...at least from a speed standpoint.

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

Pibbotley
Posts: 45
Joined: Fri Feb 16, 2018 7:06 pm

Re: Multiple Applications from SD card

Postby Pibbotley » Fri Jun 29, 2018 4:32 pm

I was recently researching something similar. If its a one-off, flash is cheap, so you could connect external flash by modifying the efuses and replace it when its worn.
https://esp32.com/viewtopic.php?f=12&t=2884

Agree007
Posts: 102
Joined: Mon Sep 18, 2017 7:11 pm
Location: Copenhagen

Re: Multiple Applications from SD card

Postby Agree007 » Fri Jun 29, 2018 5:40 pm

Pibbotley wrote:I was recently researching something similar. If its a one-off, flash is cheap, so you could connect external flash by modifying the efuses and replace it when its worn.
https://esp32.com/viewtopic.php?f=12&t=2884
Try look at PocketSprite, it should be open source and they can load different games and its based on esp32 :-)

Pibbotley
Posts: 45
Joined: Fri Feb 16, 2018 7:06 pm

Re: Multiple Applications from SD card

Postby Pibbotley » Fri Jun 29, 2018 6:15 pm

Switching apps is easy with web ota if waiting 30 secs is ok, the problem was wearing out the flash, but even reflashing several times a day ends up not being an issue so I didn't bother with external flash.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Multiple Applications from SD card

Postby Vader_Mester » Sat Jun 30, 2018 9:20 am

Well, no need to use Wifi.
AFAIK there is a way to copy an app from the SD card to an OTA part., so there is no need to use Wifi.

But you actually put the bug in my ear with that one :D

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

Pibbotley
Posts: 45
Joined: Fri Feb 16, 2018 7:06 pm

Re: Multiple Applications from SD card

Postby Pibbotley » Sat Jun 30, 2018 9:38 am

I store the app bin files on a nas drive and upload them via a browser on my tablet

Who is online

Users browsing this forum: Cemal5454 and 109 guests