Hello, i'm trying to boot nuttx from external FMC sdra on the stm32f746
(disco), i will use sdram for .data and .bss later, and nuttx stucks.
I've modified the linker script as follow :
add memory
sdram (rx) : ORIGIN = 0xc0000000, LENGTH = 8M
Replace all "flash" occurrences by sdram (see provided file).
I've compiled and installed u-boot to flash (0x08000000), and i try to boot
nuttx as follow :
PS : i've added a "gobin" command to u-boot that get reset vector and stack
pointer initialization (see cmd/boot.c modified command)
U-Boot SPL 2020.10-00002-g451cd0c64d (Jan 21 2021 - 14:47:45 +0100)
Trying to boot from XIP
U-Boot 2020.10-00002-g451cd0c64d (Jan 21 2021 - 14:47:45 +0100)
Model: STMicroelectronics STM32F746-DISCO board
DRAM: 8 MiB
set_rate not implemented for clock index 4
set_rate not implemented for clock index 4
set_rate not implemented for clock index 4
Flash: 1 MiB
MMC: sdio1@40012c00: 0
Loading Environment from SPIFlash... SF: Detected s25fl128s with page size
256 Bytes, erase size 64 KiB, total 16 MiB
OK
In: serial
Out: serial
Err: serial
usr button is at LOW LEVEL
Net:
Warning: ethernet@40028000 (eth0) using random MAC address -
da:6c:8c:f1:bb:ad
eth0: ethernet@40028000
Hit SPACE in 1 seconds to stop autoboot.
U-Boot > setenv ipaddr 192.168.1.210
U-Boot > setenv serverip 192.168.1.51
U-Boot > tftpboot 0xC0000000 nuttx.bin
Speed: 100, full duplex
Using ethernet@40028000 device
TFTP from server 192.168.1.51; our IP address is 192.168.1.210
Filename 'nuttx.bin'.
Load address: 0xc0000000
Loading: ############
3.9 MiB/s
done
Bytes transferred = 164324 (281e4 hex)
U-Boot > gobin 0xC0000000
## Starting application at 0xC0000000 ...
Stack 0x20011048 ...
Entry point 0xC0000211 ...
nx_start: Entry
mm_initialize: Heap: start=0x2001104c size=241588
mm_addregion: Region 1: base=0x2001104c size=241584
mm_malloc: Allocated 0x20011060, size 32
mm_malloc: Allocated 0x20011080, size 112
mm_malloc: Allocated 0x200110f0, size 208
mm_malloc: Allocated 0x200111c0, size 80
mm_malloc: Allocated 0x20011210, size 144
mm_malloc: Allocated 0x200112a0, size 1072
mm_malloc: Allocated 0x200116d0, size 2128
mm_malloc: Allocated 0x20011f20, size 64
mm_addregion: Region 2: base=0x2004c000 size=16384
mm_addregion: Region 3: base=0x20000000 size=65536
mm_malloc: Allocated 0x2004c010, size 48
mm_malloc: Allocated 0x2004c040, size 48
uart_register: Registering /dev/console
mm_malloc: Allocated 0x2004c070, size 48
uart_register: Registering /dev/ttyS0
mm_malloc: Allocated 0x2004c0a0, size 48
mm_malloc: Allocated 0x2004c0d0, size 656
work_start_highpri: Starting high-priority kernel worker thread(s)
mm_malloc: Allocated 0x2004c360, size 256
mm_malloc: Allocated 0x2004c460, size 656
mm_malloc: Allocated 0x2004c6f0, size 2080
up_release_pending: From TCB=0x200103e0
Have you any idea ?
I've tried to boot another binary file without problems (that uses
interruptions, etc...)
For info, first lines of disassembly
nuttx: file format elf32-littlearm
Disassembly of section .text:
c0000000 <_vectors>:
c0000000: 20011048 andcs r1, r1, r8, asr #32
c0000004: c0000211 andgt r0, r0, r1, lsl r2
c0000008: c000060d andgt r0, r0, sp, lsl #12
c000000c: c000060d andgt r0, r0, sp, lsl #12
c0000010: c000060d andgt r0, r0, sp, lsl #12
c0000014: c000060d andgt r0, r0, sp, lsl #12
c0000018: c000060d andgt r0, r0, sp, lsl #12
c000001c: c000060d andgt r0, r0, sp, lsl #12
c0000020: c000060d andgt r0, r0, sp, lsl #12
...
c0000210 <__start>:
* This is the reset entry point.
*
****************************************************************************/
void __start(void)
{
c0000210: b580 push {r7, lr}
c0000212: b082 sub sp, #8
c0000214: af00 add r7, sp, #0
/* Clear .bss. We'll do this inline (vs. calling memset) just to be
* certain that there are no issues with the state of global variables.
*/
for (dest = &_sbss; dest < &_ebss; )
c0000216: 4b16 ldr r3, [pc, #88] ; (c0000270 <__start+0x60>)
c0000218: 603b str r3, [r7, #0]
c000021a: e004 b.n c0000226 <__start+0x16>
{
*dest++ = 0;
c000021c: 683b
You see, the stack pointer 20011048 and reset handler c0000211 (the lsb is
for thumb) are goods
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2000-2003
* Wolfgang Denk, DENX Software Engineering, [email protected].
*/
/*
* Misc boot support
*/
#include <common.h>
#include <command.h>
#include <net.h>
#include <asm/armv7m.h>
#ifdef CONFIG_CMD_GO
/* Allow ports to override the default behavior */
__attribute__((weak))
unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
char *const argv[])
{
return entry (argc, argv);
}
static int do_go(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
ulong addr, rc;
int rcode = 0;
if (argc < 2)
return CMD_RET_USAGE;
addr = simple_strtoul(argv[1], NULL, 16);
printf ("## Starting application at 0x%08lX ...\n", addr);
/*
* pass address parameter as argv[0] (aka command name),
* and all remaining args
*/
rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
if (rc != 0) rcode = 1;
printf ("## Application terminated, rc = 0x%lX\n", rc);
return rcode;
}
/* -------------------------------------------------------------------- */
U_BOOT_CMD(
go, CONFIG_SYS_MAXARGS, 1, do_go,
"start application at address 'addr'",
"addr [arg ...]\n - start application at address 'addr'\n"
" passing 'arg' as arguments"
);
#endif
#ifdef CONFIG_CMD_GOBIN
/* Allow ports to override the default behavior */
__attribute__((weak))
unsigned long do_gobin_exec(ulong (*entry)(int, char * const []), int argc,
char *const argv[])
{
return entry (argc, argv);
}
static int do_gobin(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
ulong addr, rc;
ulong *ptr;
ulong stack, jump;
int rcode = 0;
if (argc < 2)
return CMD_RET_USAGE;
addr = simple_strtoul(argv[1], NULL, 16);
printf ("## Starting application at 0x%08lX ...\n", addr);
ptr = (ulong *)addr;
stack = ptr[0];
jump = ptr[1];
printf (" Stack 0x%08lX ...\n", stack);
printf (" Entry point 0x%08lX ...\n", jump);
cleanup_before_linux();
asm volatile(
"mov sp,%0\r\n"
"dsb\r\n"
"isb\r\n"
"mov r3,%1\r\n"
"bx r3"
:
: "r" (stack), "r" (jump)
: "r3", "sp"
);
//asm("ldr sp, =0xC0084028");
//asm("bl 0xC0000211");
//asm("cpsid i");
//V7M_SCB->vtor = 0xc0000000;
//disable_interrupts();
//reset_misc();
//reset_cpu(0);
//asm("ldr sp, =0x20050000");
//asm("dsb");
//asm("isb");
//asm("ldr pc, =0x080003fc");
//asm("ldr sp, =0x20050000");
//asm("ldr r0, =0xC0000211");
//asm("dsb");
//asm("isb");
//asm("bx r0");
/*
* pass address parameter as argv[0] (aka command name),
* and all remaining args
*/
rc = do_go_exec ((void *)ptr[1], argc - 1, argv + 1);
if (rc != 0) rcode = 1;
printf ("## Application terminated, rc = 0x%lX\n", rc);
return rcode;
}
/* -------------------------------------------------------------------- */
U_BOOT_CMD(
gobin, CONFIG_SYS_MAXARGS, 1, do_gobin,
"start arm application at address 'addr'",
"addr [arg ...]\n - start arm application at address 'addr'\n"
" passing 'arg' as arguments"
);
#endif
U_BOOT_CMD(
reset, 1, 0, do_reset,
"Perform RESET of the CPU",
""
);
#ifdef CONFIG_CMD_POWEROFF
U_BOOT_CMD(
poweroff, 1, 0, do_poweroff,
"Perform POWEROFF of the device",
""
);
#endif