iRAM (OCRAM) i.MX6 SDK Application

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iRAM (OCRAM) i.MX6 SDK Application

iRAM (OCRAM) i.MX6 SDK Application

In many cases (test certain modules, first boot-ups, DDR is not available), writing bare-metal (SDK) code with runs on iRAM (OCRAM) is the only possible scenario. The first (attached) patch creates a new linker file with proper sections and the second includes a tiny app (it should be tiny, by definition) using the previous file. These are the steps to have the setup ready:

1. Dowload latest i.MX6 SDK (v1.1.0 is the latest when writing this document).

2. Let GIT take the control (git init; git add .; git commit -m '1st commit')

3. Apply patches (git am < patch1; git am < patch2 )

4. Compile

            # This example is intended for a mx6q sabreSD, revision C

            $ ./tools/build_sdk -target=mx6dq \

                                -board=smart_device \

                                -board_rev=c \

                                -app=iram

   

5. SD Card Flashing & Running:

5.1. ELF file & U-boot:

   # Output image is located on:

                #   elf=output/mx6dq/minimal/smart_device_rev_c/minimal.elf

                $ dd if=$elf \

                     of=/dev/sdb \

                     seek=2048 bs=512; sync

                # Boot your board with your favorite u-boot version, just make

                # sure the bootelf command is presnet

                > mmc dev Y

                > mmc read 0x10800000 0x800 XXX

                > bootelf 0x10800000

               where Y is the SD device and XXX are the records seen when dd flashing.

           

5.2  BIN file:

   # Output image is located on:

                #   bin=output/mx6dq/minimal/smart_device_rev_c/minimal.bin

                $ dd if=$bin \

                     of=/dev/sdb \

                     seek=2 skip=2 bs=512; sync

                # Place the SD into your board and power-on.

NOTES:

+ The first patch was taken from the internal discussion MX6 SDK (PLATLIB): has anyone created a stripped down version that will run from internal RAM?

Attachments
Comments

Leonardo,

What is the reason of defining OCRAM ORIGIN = 0x0091_0000? This leaves no space for i.MX6SDL boards.

Right. The setup was done for Q due to bigger OCRAM. Not sure the right numbers for DL, let me know if you are able to run something on it.

Leo

Leonardo, this seems to be not so straightforward. The smallest .text area that I have achieved with minimal application and -Os flag is about 75Kb, but we have only 68Kb of OCRAM that could be used. So it has to be optimized some way. The biggest portion is consumed by standard runtime libraries.

Frias / ChristopherWilliams do you have any idea how to reduce the standard runtime libraries or any other way to reduce the binary so it can fit inside the MX6DL OCRAM?

Leo

I got it running on a imx6DL, needed to confirm issues with DDR

Small adjustments

  • I moved origin to start of the "free area"  OCRAM (rwx) : ORIGIN = 0x00907000,
  • Adjusted length to fit the origin change, #define OCRAM_LEN (128K - 28K)
  • Shrunk the sizes for stack and L1

#define STACK_SIZE 8K
#define L1_PAGE_TABLE_SIZE 8K

  • Fixed the overlapping heap VS ram vectros and L1 cache.

    /* define section for the malloc heap */

    .heap (NOLOAD) : ALIGN(32)

    {

        free_memory_start = .; /* malloc starts allocating from here */

        . += ORIGIN(OCRAM) + LENGTH(OCRAM)  - RAM_VECTORS_SIZE - L1_PAGE_TABLE_SIZE - .;

        free_memory_end = .;

    } > OCRAM

2

2

Interesting.  I'm attempting the same after applying the patches and the changes from andreas, albeit with a Solo.  But I get a build failure:

.../basic_iram_sdk_app.ld:113 cannot move location counter backwards (from 00924200 to 0091dfb8)

The line location is in the .ivt (ORIGIN(OCRAM)) section.  I'll try to get to the bottom of it.  Any pointers appreciated.

If you compile for a DL, do you see the same issue?

You can try adding compiler flag -ffunction-sections and linker --gc-sections

I could reproduce it, I must have forgot that I also used the follwing flags

Add in flags.mk

CFLAGS += -ffunction-sections

LDFLAGS += --gc-sections

Do a clean build, and then it should pass. At least it did for me.

2

I wasn't able to get back to work on this until just recently, but your suggestion is fantastic.  Works great, thanks, when loaded with my debugger.

My next project is to figure out why the boot ROM doesn't want to load it (using the USB loader tool over the OTG port) even though it does fine with the sdk_unit_test binaries.

If you read the RM the internal RAM is used by the the internal boot. Might be some conflict. I've only run it from debugger.

2

Been looking at that.  The region from 907000 - 918000 is marked as OCRAM Free Area.  Not sure what the problem could be on that end.  Right now my best bet is the USB loader - it complains about an 'unknown load address' whereas with the sdk .bin it loads successfully to 0x1000_0000.  I've tried messing with the conf file, but no luck yet.

The optimization described by andreaskarlsson is really good, but a bit too aggressive.

The linker indeed get rid off all the informations contained in the IVT and DCD resulting in an unusable binary (by the ROM I mean).
To keep this information you should add the word KEEP in the linker script around the ivt and dcd related sections wildcards.

example : KEEP(*(.ivt)), KEEP(*.(boot_data))...

I hope it helps (or will help :-).

Hello together,

I compiled iRam for imx6 Solo ./tools/build_sdk -t mx6sdl -b smart_device -app iram -clean

Could you please help me on this?

[Error]

Linking iram

/home/lia1hc/projects/sdk/iMX6_Platform_SDK/output/mx6sdl/iram/smart_device_rev_a/obj/apps/common/basic_iram_sdk_app.ld:113 cannot move location counter backwards (from 009376c0 to 00920000)

make[1]: *** [/home/lia1hc/projects/sdk/iMX6_Platform_SDK/output/mx6sdl/iram/smart_device_rev_a/iram.elf] Error 1

make: *** [iram] Error 2

{Error} !

Hi guys,

Are there any ways to initialize; read and write from/to external DDR3?

Hello everybody,

It's ok when I build iram for mx6dq but with mx6sdl I met this error :

$./tools/build_sdk -t mx6sdl -b smart_device -v c -app iram -clean

Linking iram
/home/pod1hc/data/sdk_zcam/zcam_sdk/output/mx6sdl/iram/smart_device_rev_c/obj/apps/common/basic_iram_sdk_app.ld:113 cannot move location counter backwards (from 00937b80 to 00920000)
make[1]: *** [/home/pod1hc/data/sdk_zcam/zcam_sdk/output/mx6sdl/iram/smart_device_rev_c/iram.elf] Error 1
make: *** [iram] Error 2

Build mx6sdl smart_device rev_c ALL failed with return code 2

Could you please give me some suggest to resolve this error? Thanks !

No ratings
Version history
Last update:
‎09-19-2013 12:41 PM
Updated by: