1

I'm new to embedded linux and I am trying to boot linux on stm32h7 with only internal flash and ram.

FLASH SIZE = 2MByte

RAM SIZE = 1MByte

I have downloaded the mainline linux kernel and I configured the kernel with stm32_def config and then customized it and I removed the unnecessary drivers from it. and I configured it to boot from flash (XIP).

I have a custom board and it does not have any external ram or flash but it is similar to stm32h743i_discovery board. so, I'm using the stm32h743i_disco device tree.

my output xipImage size is about 1.4MByte and I wrote a boot loader for it.

I merged the binaries together like this:

loader at offset: 0x08000000

device tree blob (dtb) at offset: 0x08000F00

xipImage at offset: 0x08008000

my loader program:

LDR R1, =0x0FFFFFFFF
LDR R2, =0x08000F00
LDR PC, =0x08008000

r1 is machine type and when I have dt, I should set it to 0x0ffffffff. and r2 is the address of dtb in the internal flash storage. and then I set the program counter register (PC) to the xipImage start address. and when I watch it in the debugger, when the linux wants to start booting, after a few moments, the PC (program counter) becomes 0x0 and the cpu goes to hardfault interrupt handler.

Note: I have a stlink v2 programmer/debugger.

this is my cpu registers when it crashes.

  • 3
    It has far not enough resources run Linux. Stm3@h7 disco has 8MB RAM & qspi flash – 0___________ Jul 26 '20 at 07:45
  • 1
    @P__J__ you mean it is RAM issue? I know it is not flash issue because my kernel image is 1.4MBytes but my internal flash is 2Mbytes. so that's not a flash issue. how much RAM I need to run linux with minimal config? is 1MBytes enough? – Mahyar Shokraeian Jul 26 '20 at 09:56
  • 1MB will be not enough,. This 1MB is not linear. I was running linux on sTM32 uC for tests. But I always had at leadt 8MB external RAM – 0___________ Jul 26 '20 at 10:05
  • @P__J__ did you did it with xip (execute in place) kernel? because xip consume less ram – Mahyar Shokraeian Jul 26 '20 at 13:13
  • You should use some kind of RTOS instead. Linux is definitely not right here. I highly recommend RIOT OS btw. – Citrullin Jul 27 '20 at 00:33
  • 1
    @Citrullin why linux is not right here? I can connect an external ram to my board if it's a RAM problem. I want to use linux libraries. I heard that linux is very good for embedded systems. isn't it? – Mahyar Shokraeian Jul 27 '20 at 09:48

1 Answers1

1

as dear @P__J__ mentioned in the first comment, it was a RAM problem! 1MB wasn't enough. And this 1MB was not linear. So, I config the external 8MB onboard dram.