Showing results for 
Search instead for 
Did you mean: 

How to set up IRAM1/IRAM2 in Keil with STM32H742VIT6?

Associate III


I'm having weird problems with code crashing, perhaps related to how I have IRAM1/IRAM2 set up in my project:


Looking in the reference manual, I see that the SRAM starting at 0x2000_0000 is the DTCM_RAM on TCM interface (data RAM?), the SRAM starting at 0x2400_0000 is the D1 domain, AXI SRAM but I don't see any documentation for how big either of these are.  I also can't figure out what is meant in Keil by IRAM1 vs. IRAM2 (Google is not very helpful), although I suspect that question might not be within the scope of the STM forums...

If anyone can help with this I will really appreciate it!


Accepted Solutions

I edited the stack size in startup_stm32h742xx.s.  It used to be 0x400 and I changed it thus:

Stack_Size		EQU     0x800

Problem solved!

I'm still not sure why this project needs a bigger stack than an equivalent project on an STM32F3* MCU, but I'll take it!

View solution in original post



Simple way is edit your linker file:


uint8_t __attribute__(( section(".ram1section") )) buf[1000];


.ram1block (NOLOAD) :



  } > RAM_D1

Sorry, but I don't understand a single line of the code you wrote... :(


Memory sizes are in the datasheet and reference manual.


You have AXI SRAM set to 0x80000 but its size is only 0x60000. Could be the issue, could be issues with the code itself.


IRAM = internal RAM. This is Keil terminology.


If you feel a post has answered your question, please click "Accept as Solution".

Ok wait a minute — isn’t 384kB actually 0x6000 and not 0x60000?

EDIT:  Sorry, I was getting 0000 confused with 000!

No, that's 24KB

0x20000 is 128KB

0x40000 is 256KB

0x80000 is 512KB


Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

How is this? Doesn’t each 0x1 count as one byte?

Thus 1KB = 1,024 = 0x200 etc.?

EDIT:  Sorry, was getting confused!  All is clear now.

384K = 384 x 1024 = 393216 Bytes (decimal) = 60000(hex)

1K = 1024Bytes (decimal) = 400(hex)

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

No, it's not.

If you feel a post has answered your question, please click "Accept as Solution".


I figured out an issue with the code itself but I want to describe it here to get more clarification on what's really going on.

I used to have code that looks like this:

In file bsp_io.h:

typedef struct
    GPIO_TypeDef    *port;           /*!< IO port */
    uint32_t        pin;             /*!< IO pin */
    uint32_t        mode;            /*!< IO mode - IN/OUT/AF */
    uint32_t        otype            /*!< IO output type - PP/OD */
    uint32_t        af;              /*!< IO alternate mode # */
    uint32_t        speed;           /*!< IO speed - LO/MED/HI */
    uint32_t        pull;            /*!< IO pull res. - UP/DOWN/NONE */
} bsp_io_handle_t;

In file bsp_usr_ctrl.c (where variables in all CAPS are #defined and their exact values are unimportant):

#include bsp_io.h
static bsp_io_handle_t io_handle;
void bsp_usr_ctrl_init(void)
    io_handle.mode      = BSP_IO_MODE_IN;       = MENU_BTN_PIN | BACK_BTN_PIN;
    io_handle.port      = USR_BTNS_PORT;
    io_handle.pull      = BSP_IO_NOPULL;
    io_handle.speed     = BSP_IO_SPEED_LOW;
    bsp_io_init(&io_handle);                 // Configures I/Os accordingly
void bsp_usr_ctrl_deinit(void)
    bsp_io_deinit(&io_handle);               // Return I/Os to reset state

 And in my main.c I have something like this:

__NO_RETURN int main(void)
    // Some other code...
    // Other code...

And I've seen the io_handle structure, whose fields should have remained untouched since when it was initialized with bsp_usr_ctrl_init(), get reset mainly to 0's when bsp_usr_ctrl_deinit() is called.  This raises an exception and stops the code to avoid writing values to any illegal memory locations.  I've also seen this cause hard fault type exceptions which I haven't exactly been able to trace since I'm not sure what code was being executed when the hard fault(s) occurred.

I managed to fix these problems by allocating memory for io_handle with malloc() as follows:

#include bsp_io.h
#include <stdlib.h>                // For malloc(), free()
static bsp_io_handle_t *io_handle;
void bsp_usr_ctrl_init(void)
    io_handle = malloc(sizeof(bsp_io_handle_t));
    io_handle->mode      = BSP_IO_MODE_IN;
    io_handle->pin       = MENU_BTN_PIN | BACK_BTN_PIN;
    io_handle->port      = CAL_BTNS_PORT;
    io_handle->pull      = BSP_IO_NOPULL;
    io_handle->speed     = BSP_IO_SPEED_LOW;   
void bsp_usr_ctrl_deinit(void)

OK, here's the thing I don't understand (and I don't know if this is an STM issue or just a vanilla C programming issue):

Since the structure was declared with "static" in the original code, why did that code allow the structure to be overwritten?  BTW the original code was working without any issues on an STM32F3* family MCU.  That's why I suspected that I may have set something up incorrectly in the memory specification in project settings.  Like a stack vs. heap issue or something like that?

If anyone can shed any light on this it would be great!