Execute from external SRAM

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Execute from external SRAM

Postby Pito » Mon Jan 09, 2017 11:48 am

Updated the xLOADER to v1.01 - added a measurement of Loading time. Now you shall see something like:

Code: Select all

Loading the APP.bin took 7490 usecs
0 0
1 F8
2 7
3 68
4 39
5 6
6 0
7 68
25836 B8
25837 52
25838 0
25839 68
25840 78
25841 4D
25842 0
25843 68
Starting the APP.bin:
Dhrystone Benchmark, Version 2.1 (Language: C)
Execution starts, 300000 runs through Dhrystone

Execution ends
Microseconds for one run through Dhrystone: 57.41
Dhrystones per Second: 17418.90
VAX MIPS rating = 9.91
***

Enclosed the bin.h for Dhrystone - built for EXRAM, 0x68.., 10ns SRAM, 128MHz F_CPU, Serial1 115k2 :)
Attachments
bin.rar
(22.66 KiB) Downloaded 3 times
Last edited by Pito on Mon Jan 09, 2017 1:07 pm, edited 3 times in total.

User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Execute from external SRAM

Postby Pito » Mon Jan 09, 2017 12:27 pm

EXRAM_Guide_1.JPG
EXRAM_Guide_1.JPG (94.52 KiB) Viewed 103 times

victor_pv
Posts: 734
Joined: Mon Apr 27, 2015 12:12 pm

Re: Execute from external SRAM

Postby victor_pv » Mon Jan 09, 2017 4:45 pm

stevestrong wrote:Just as a layman for return from RAM App to Flash: wouldn't be this handled automatically by the CPU when returning from

Code: Select all

Jump_To_Application();

?


Steve, I think I have seen in the assembly code generated that saving the registers is left to the function being called, not the one calling it. I may be wrong, but I think that's what I saw.

If that is the case, then I'm sure it is not being done in the App code, since the compiler is using the standard startup code, which is not written to return back to anything later.
Also the App has no way to just return with a "return" in c, because at most that would jump back to main(), then we would have to jump back from main() too.

I think it is easier to rather just jump to the return address, and restore registers, SP, VTOR etc, from there.

I'm thinking that an sdcard loader should easily fit in a maple mini, so less than 20KB of RAM. I can use an RET board to reserve bottom 10-20KB for the loader (or just compile for a RBT target), then load a bin program and run it from the next chunk of RAM, reserving the top 10-15KB for variables. heap and stack.

Something like:
0KB-----------16KB------------48KB----------64KB
Loader RAM ---- App Code ---- App RAM

Sorry I am not as good as Pito at drawing diagrams ;)

User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Execute from external SRAM

Postby Pito » Mon Jan 09, 2017 5:09 pm

No worries Victor, drawing skills are not important at this stage :)
Would be great if you may simulate the jumpin-jumpout on your board.
The xLOADER with SdFat will be around 38kB flash and 6kB IRAM (derived from the readCSV example).
The smallest APP I've built - toggling a pin - is 15kB :) 30y back I did it with 15..

victor_pv
Posts: 734
Joined: Mon Apr 27, 2015 12:12 pm

Re: Execute from external SRAM

Postby victor_pv » Mon Jan 09, 2017 5:29 pm

Pito wrote:No worries Victor, drawing skills are not important at this stage :)
Would be great if you may simulate the jumpin-jumpout on your board.
The xLOADER with SdFat will be around 38kB flash and 6kB IRAM (derived from the readCSV example).
The smallest APP I've built - toggling a pin - is 15kB :) 30y back I did it with 15..


20 years ago I programmed a pic 12c508 to read some pins and send information on a bitbanged serial port.
I dont remember how much I used, but just checked the specs and has 750bytes of rom and 25 of RAM... and it fit...

EDIT: That was assembler, not sure how much would C have wasted, I suspect it may have still fit

As far as it all fit in the 64KB of ram, I can test loading a bunch of small sketches and returning from each, drystones, serial printing, but even if it doesn't really fit, I would try splitting the flash in 2, and leading the bins to an upper section of flash, that way I can also test with larger sketches.

I checked my stash of boards this weekend and have a VET one, but doesn't have pads for any SRAM, so testing in IRAM and flash is the most feasible at the moment for me.

User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Execute from external SRAM

Postby Pito » Mon Jan 09, 2017 6:56 pm

Btw, I purchased this 407ZET board http://www.ebay.com/itm/STM32F407ZET6-S ... Swxg5XyT1Q (the SRAM pads and the Sdcard socket at the bottom side) on Dec4th and since Dec5th the board is in air, according to the parcel tracker :)


User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Execute from external SRAM

Postby Pito » Tue Jan 10, 2017 5:48 am

SRAM MEMORIES: ! Always double check with the seller and/or datasheet it is a 3.3V memory.
The memory voltage (5V or 3.3V) usually differs based on a 1-2 different letters in the part name (sometimes a letter after the dash). Even large suppliers have problems to distinguish..

zmemw16
Posts: 873
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Execute from external SRAM

Postby zmemw16 » Tue Jan 10, 2017 2:32 pm

Pito wrote:Btw, I purchased this 407ZET board http://www.ebay.com/itm/STM32F407ZET6-S ... Swxg5XyT1Q (the SRAM pads and the Sdcard socket at the bottom side) on Dec4th and since Dec5th the board is in air, according to the parcel tracker :)


this one ranged from £11.46 to £12.77
https://www.aliexpress.com/item/Free-shipping-STM32F407ZET6-development-board-M4-STM32F4-core-board-arm-development-board-cortex-M4/32689262341.html?spm=2114.13010608.0.0.4i6Xle

btw there's a slightly smaller pcb 407VET variant, no sram pads underneath.

order date to delivery varied from 18 to 33 days

stephen

User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Execute from external SRAM

Postby Pito » Wed Jan 11, 2017 12:44 pm

This is the SdFat's benchmark off the EXRAM.
BlueZEX board with an SDcard socket attached, @72MHz, SPI1 @36MHz, in EXRAM.
Look at the Free Stack message :shock:

Code: Select all

Loading the APP.bin took 15829 usecs
0 0
1 F8
2 7
3 68
4 A1
5 2C
6 0
7 68
39264 20
39265 28
39266 30
39267 38
39268 A0
39269 7F
39270 0
39271 68
Starting the APP.bin:

Use a freshly formatted SD for best performance.

Type any character to start
FreeStack: 472455
Type is FAT32
Card size: 8.03 GB (GB = 1E9 bytes)

Manufacturer ID: 0X1B
OEM ID: SM
Product: 00000
Version: 1.0
Serial number: 0X8C5663D3
Manufacturing date: 6/2015

File size 5 MB
Buffer size 8192 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
1140.37,96194,5806,7164
1048.93,96772,5814,7789
1073.26,97157,5812,7612
1065.48,96412,5814,7668
1098.51,96416,5810,7439
1078.13,97167,5821,7579

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
856.26,11804,9471,9559
856.40,10969,9472,9556
856.40,11138,9477,9556
856.40,10954,9451,9556
856.40,11139,9475,9557
856.55,11133,9473,9556

Done
Type any character to start


For comparison the same in flash:

Code: Select all

..
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
2083.00,97942,2362,3922
1811.86,93615,2360,4510
1884.99,92760,2358,4334
1985.35,105730,2362,4114
1892.13,96379,2362,4318
1905.12,93066,2362,4289

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
2924.00,4797,2742,2800
2927.43,3597,2742,2797
2929.14,3600,2741,2795
2927.43,3600,2741,2797
2929.14,3593,2741,2795
2927.43,3590,2741,2797

Done
Last edited by Pito on Thu Jan 12, 2017 10:27 am, edited 1 time in total.


Return to “Generic STM32F103”

Who is online

Users browsing this forum: No registered users and 2 guests