• AVR Freaks

Hot!Is that able to run the whole application on RAM?

Author
phuockal
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2014/06/05 02:19:10
  • Location: 0
  • Status: offline
2019/04/12 02:31:30 (permalink)
0

Is that able to run the whole application on RAM?

Hello,
I am evaluating PIC32mzda2064DAG169 for my project.
My application need to save data to internal flash. but from some documents, saving data to internal flash while executing application from internal flash and the same bank can not be done in parallel. executing must hold and wait for writing to be done.
My application has heavy graphic and can not be fixed in a bank (1MB), it must use 2 banks of Flash. so that can not spend a bank of flash to just store persist data.
since the MCU has huge internal DDR2 (32MB), I have an idea to execute the application on RAM. at the start up, application will be loaded from Flash to RAM and execute directly from RAM. 1). Is that possible?; 2). Is that faster than execute from Flash?; 3). Is that safe?; 4). Are there any guide line available?
 
Best regards
#1

10 Replies Related Threads

    bastl
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2018/12/27 07:25:34
    • Location: 0
    • Status: offline
    Re: Is that able to run the whole application on RAM? 2019/04/12 14:31:44 (permalink)
    0
    That sounds good. but if you want that to do because of graphics manipulation,
    you should better load your bitmaps to ram and store them on a external flash (usb) or (spi - display + flash)
    I don't think your programm can be executed faster.
    32 Mb ram - don't you have 640 kB of ram ? and that is really much.
    And later you have to write your programm back to flash, before sleep or power off, then you will overwrite your
    data ?  It seams you have to change the hardware, if your project grows a little more....
    You would have linkage problems and you need a "ram loader" like a boot loader for ram.
    You have to link your program in the ram section and include that binary in your hexfile as data block to load to ram and start at your defined absolute address (lw $t0 ; jr $t0)  You can't use names like extern main or extern mystartfunc etc. but you can
    use a pointer to a void function and type the address in there.
    readelf can show you the address to use.
    post edited by bastl - 2019/04/12 15:11:51
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 17236
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Is that able to run the whole application on RAM? 2019/04/12 14:58:32 (permalink)
    0
    You could move all your graphics to RAM.
    Or in the same page as the data.
    Or get an external EEPROM.

    Or
    How often are these writes? The CPU does not stall for very long.
    #3
    aschen0866
    Super Member
    • Total Posts : 4423
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: Is that able to run the whole application on RAM? 2019/04/12 15:54:53 (permalink)
    0
    phuockal
    ...
    since the MCU has huge internal DDR2 (32MB), I have an idea to execute the application on RAM. at the start up, application will be loaded from Flash to RAM and execute directly from RAM. 1). Is that possible?
    ...

    The XC32 Compiler has supported Position-Independent Embedded Executables since version 1.42, according to the Release Notes:

    Position-Independent Embedded Executables -- The XC32 toolchain now supports optionally building an application as a Position Independent Embedded Executable (PIE). An application built for PIE will be position independent but self contained. In a PIE application, every global symbol is accessed via a Global Offset Table (GOT). This table maps symbol references to absolute addresses. To build a PIE, build the application project with the -mgen-pie-static xc32-gcc option. Pass this option to xc32-gcc when compiling, assembling, and linking.
    This feature requires a runtime ELF loader, which runs on the target device. This ELF loader:
    1. reads an ELF file,
    2. allocates memory,
    3. resolves relocations and populates the GOT,
    4. loads the application into executable RAM, and
    5. transfers control to the application.
    More details on Position-Independent Embedded Executables and the required runtime ELF Loader will be available on the Microchip website after the release of XC32 v1.42.

    I have no firsthand experience. If you play with it, please come back and let us know how it goes.
    #4
    phuockal
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2014/06/05 02:19:10
    • Location: 0
    • Status: offline
    Re: Is that able to run the whole application on RAM? 2019/04/15 20:51:19 (permalink)
    0
    Dear all,
    Thank you very much for your help,
    It seem that possible to execute application from RAM, but less benefit and high risk. I should not go that way.
    Since my application is cost sensitive, adding external EEPROM/Flash is the last solution to be counted.
     
    my application use internal flash to save setting and log, frequency is not constant.
     
    To make the CPU does not stall, Should I save persist data to Boot Flash? I intend to use from 32KB to 64 KB for persist data.
     
    #5
    bastl
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2018/12/27 07:25:34
    • Location: 0
    • Status: offline
    Re: Is that able to run the whole application on RAM? 2019/04/18 13:05:43 (permalink)
    0
    Boot flash is the same as normal flash but separated that you don't overwrite it while programming
    a too big programm, accidently. If you use a second flash for data than it would be very secure!
    So you can programm your executables to the internal Flash and store and handle data on the external
    flash without risk of overwrite them while you do a update.
     
    #6
    Mysil
    Super Member
    • Total Posts : 3321
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: online
    Re: Is that able to run the whole application on RAM? 2019/04/18 16:11:10 (permalink)
    5 (2)
    Hi,
    A Graphics application program typically consist of executable code stored in flash, and constant data that is also stored in flash memory.
    In a graphics application, constant data typically store Font data, Images and Icons.
    Font data, images and icons, may be larger than executable code.
    Are you really sure that Executable code without font data, images and icons, will be more than 1 Megabyte?
     
    With careful structuring of the image file, using a tailored linker file,
    it may be possible to move all constant data containing font data, images and icons to DDRAM storage,
    while the prgram is running.
    It may be easier to move data, creating a copy of font data, images and icons,
    and access those by pointer, rather than trying to move executable code to a another location.
     
    PIC32MZ2064DAG169 have 2 Flash panels, each 1 Megabyte, 640 kByte of Static RAM in the PIC32 chip,
    and 32 MByte Dynamic RAM.
    The dynamic RAM is a separate DDR2 SDRAM chip inside the same package.
     
    Boot Flash Memory (BFM) are parts of the same 2 flash panels as Program Flash Memory(PFM), 
    so if you cannot store persistent updates in the other Flash panel without stalling, then messing with BFM will not help.
     
        Mysil
    post edited by Mysil - 2019/04/18 16:16:06
    #7
    andersm
    Super Member
    • Total Posts : 2581
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Is that able to run the whole application on RAM? 2019/04/19 02:45:13 (permalink)
    0
    The linker supports this scenario by allowing you to specify both a virtual address and a load address for sections.
    #8
    phuockal
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2014/06/05 02:19:10
    • Location: 0
    • Status: offline
    Re: Is that able to run the whole application on RAM? 2019/05/12 00:28:26 (permalink)
    0
    Dear all,
     
    Thank you every body are trying to help,
     
    After trying to consider yours opinions and review the software system design, I believe that I should store constant data like images, font, settings, usage history, ... to external SQI flash, something like SST26. The internal flash only for program execution image. Because I have to display something like progress bar, ... while upgrading software. So that, embed graphic library to boot loader will make the boot loader more complicated and have to maintenance it, then I decide to use live update and, of course, I have only 1MB internal Flash for application image. 1MB for pure code is huge space I believe my application never reach to.
     
    I am finding the way to store fonts and images to SST26 and then load them to 32MB DDRAM at start up to use for graphic display. I believe loading them to DDRAM will make graphic perform better than accessing directly to SST26. Is that a good way? if storing fonts and images to SQI flash, should I use file system or just raw data as traditional way?
     
    Are there any example or document teach me to store data on SQI flash as raw data and read them back to DDRAM. As I understand, we should change something on linker script but I don't know exactly what I should do. Please guide me.
     
    Best regards,
    #9
    friesen
    Super Member
    • Total Posts : 2047
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: Is that able to run the whole application on RAM? 2019/05/13 05:47:34 (permalink)
    0
    A couple notes:
     
    If your application doesn't require SQI speed, I'd consider using SPI instead.  The Harmony SQI driver and pic32 hardware is not real mature, you likely will face a few challenges.  It will work, but its probably going to take some fiddling.
     
    I'd check out the newer lines of pic32MZDA parts, they don't have the DDR 0-70C errata or the SQI XIP.
     
    Another alternative would be to use XIP and SQI, it could be that it would be fast enough running out of cached space.
     
    As to the linker, you can do something like this:
     
    MEMORY
    {
        kseg1_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x480
        kseg0_program_mem (rx) : ORIGIN = 0x9D000000 + 0x480, LENGTH = 0x200000 - 0x480 /* All C files will be located here */
        kseg0_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x0
      kseg0_data_mem (w!x) : ORIGIN = 0x80000000, LENGTH = 0x9FF00/*0xa0000*/
      sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
      kseg2_ebi_data_mem : ORIGIN = 0xC0000000, LENGTH = 0x4000000
      kseg2_sqi_data_mem : ORIGIN = 0xD0000000, LENGTH = 0x4000000
      kseg3_ebi_data_mem : ORIGIN = 0xE0000000, LENGTH = 0x4000000
      kseg3_sqi_data_mem : ORIGIN = 0xF0000000, LENGTH = 0x4000000
      flash_mem (ra) : ORIGIN = 0xF0000000, LENGTH = 0x200000
    }

    SECTIONS
    {
      .flash_mem :
      {
        KEEP(*(flash_mem.media_data))
     KEEP(*(flash_mem))
      } >flash_mem

     
    const uint8_t __attribute__((section ("flash_mem.media_data"),space(prog))) SST26_MEDIA_DATA[DRV_SST26_MEDIA_SIZE*1024] = { \
     
    0xF000000 is uncached XIP cs 0.
     
    Of course you'll have to figure out a bootloader or something to put the data into your device.  The data will be in the hex file at any rate.
     
     
     
     

    Erik Friesen
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 17236
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Is that able to run the whole application on RAM? 2019/05/13 05:53:02 (permalink)
    0
    The SST26 can be used in SPI or SQI modes. PIC32 SQI Ports can be used in SPI mode. But I have never tried it. And I do not know if Harmony driver supports it.
    #11
    Jump to:
    © 2019 APG vNext Commercial Version 4.5