This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
RE: eCos booting w/ interrupts disabled
- From: Nathan French <nathan dot french at onrampwireless dot com>
- To: Lambrecht Jürgen <J dot Lambrecht at TELEVIC dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Wed, 16 Sep 2009 14:15:52 -0700
- Subject: RE: [ECOS] eCos booting w/ interrupts disabled
- References: <1253132712.6673.12460.camel@localhost.localdomain> <6EE7D1502C48E44E92DCADF9DD3E0DB9D73985FE59@SRV-VS06.TELEVIC.COM>
Thanks for the reply Lambrecht,
I learned two things today:
1. The scheduler enables interrupts when the first thread is loaded.
This happens after cyg_user_start() finishes.
2. Putting a while(1) at the bottom of cyg_user_start() is a really
boneheaded thing to do :). This was my actual problem. Interrupts are
working now.
You'd think vectors.S would be the place to do it, but it actually
doesn't.
Thanks,
Nathan
On Wed, 2009-09-16 at 16:58 -0400, Lambrecht JÃrgen wrote:
> As a fast evening reply: I would say it is done in ecos\packages\hal\arm\arch\current\src\vectors.S
>
> Success,
> JÃrgen
>
> P.S.: Here an overview I made for myself of the ARM boot sequence:
>
> 1.11 Startup (boot) sequence
>
> Cf.: A.J. Massa, p. 28, section 2.1.4 "HAL Startup"
>
> Mark that during steps 1. and 2. a printf() will block the processor, so use the leds to debug:
>
> led(x) == LED x [assembly] == hal_diag_led(x) [c code] == hal_at91_set_leds(x)
> 1. Reset vector
>
> in arm/arch/current/src/vectors.S, reset_vector: PLATFORM_SETUP1
>
> <cyg/hal/hal_platform_setup.h>: #define PLATFORM_SETUP1 _setup (applied to IMS/DPIS ARM7):
>
> 1. _led_init: sets all status leds (smd) off: led(0) [sets all leds on: led(15)]
> #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) //only for ROM and ROMRAM mode
> [led(0)]
> #ifndef CYGHWR_HAL_ARM_AT91_DPIS_BOOT_APPLIC //if this is not an application loaded by the bootloader
> 2. [led(1)]
> Clock initialization: startup 16MHz Xtal [led(2)], wait for oscillator to stablize [toggle led(3) and led(2) in the loop] [led(4)] and start PLL to double the clock [led(5)], wait for PLL to stablize [led(6)], switch clock from oscillator to PLL [led(7)]
> result: the 16MHz xtal is running; MCKO, the clk to the fpga is 32MHz
> 3. Initialize memory controller; [led(9)] chip selects are configured; remap
> #endif //if this is not an application loaded by the bootloader
> [led(10)] In ROMRAM mode, the code is copied from ROM to RAM.
> #endif //only for ROM and ROMRAM mode
> 4. [led(11)] _pclock_init: Enable peripheral [clocks]: PIOs, TCs, and USARTs
> 5. [led(12)] _pio_init: Program pins: uarts and TC, set output pins: cpu led steered by TC, LED2 (play), LED3 (show), LED4 (gps) off
> 6. [led(13)] _tc_init
> 7. [led(14)] _delay (very short)
> 8. [led(15)]
>
> For 33.96.7308 ARM9, more or less the same happens, but the leds go from 15 to 10.
> 2. _start
>
> in arm/arch/current/src/vectors.S, reset_vector:
>
> (only for warm reset: LED 7)
>
> 1. LED 5 Reset software interrupt pointer
> 2. LED 4 Set up reset vector, // Relocate [copy] data from ROM to RAM, // initialize interrupt/exception environments, // initialize CPSR (machine state register), // initialize stack, // clear BSS, // Run kernel + application in THUMB mode
> 3. LED 3 Call platform specific hardware initialization: arm/arch/current/include/arch.inc, arm/arch/at91/var/current/src/at91_misc.c:
> hal_hardware_init() ->
> 1. HAL_PLF_HARDWARE_INIT() (defined in platform specific code; e.g. at91sam7s in plf_io.h, or 33967308_misc.c)
> 1. LED 4 Setup the Reset controller. Allow user resets
> 2. LED 5 Setup USARTs
> 3. LED 6 Setup TC
> 4. LED 7 Setup EMAC
> 5. LED 9 Setup EBI to FPGA
> 2. hal_if_init()
> 4. LED 2 call hal_misc.c/cyg_hal_invoke_constructors()
> 5. LED 1 This starts up the eCos kernel: cyg_start()
>
> 3. Application (RedBoot), cyg_start()
>
> 1. // Make sure the channels are properly initialized.
> diag_init_putc(_mon_write_char);
> hal_if_diag_init();
> ***** So only from here onwards the prinf(); works!! *****
> 2. do_flash_init: at the end: led(8) ; all 3 external leds burn
> 3. print version: led(4)
> 4. do_idle(): the 2 external leds toggle very fast, the last goes out
> 5. If
> 1. RedBoot bootscript is interrupted: led(6)
> 2. then the fis is initialized: fis_init: led(5)
>
> Else
> the application is started by Redboot.
>
> 4. Application
>
> The application does step 1.1, copies the binary to SRAM, and continues with steps 1.[4,5,6,7].
>
> Then it does step 2, which ends with led(1).
>
> cyg_start():
>
> 1. cyg_prestart()
> 2.
> 3. cyg_user_start():
> The default kernel implementation is empty.
> The defailt ISO C-library implementation is to create a thread that starts main(). The settings for that main thread are in ecos, now in configs/scheduler.ecm for the priority and in configs/kernel.ecm for the stack size.
> main.c: After mounting jffs2, the run led is started (1Hz) in the while(1) loop.
> 4. cyg_scheduler_start()
>
>
> > -----Original Message-----
> > From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-
> > owner@ecos.sourceware.org] On Behalf Of Nathan French
> > Sent: woensdag 16 september 2009 22:25
> > To: ecos-discuss@ecos.sourceware.org
> > Subject: [ECOS] eCos booting w/ interrupts disabled
> >
> > I'm doing a variant port for some new piece of hardware we're building.
> > I have copied the AT91 which our previous hardware was based on and am
> > porting to a custom chip with an ARM7 and custom interrupt controller
> > (and other peripherals).
> >
> > My current problem is that the IRQ/FIQ disable bits in the ARM7 CPSR
> > are
> > never cleared. I'm having difficulty finding where the ARM/AT91 code
> > enables interrupts. Does anyone know? I'm sure I've commented the
> > code
> > responsible for this but I can't find it.
> >
> > Thanks,
> >
> > Nathan French
> >
> >
> > --
> > Before posting, please read the FAQ:
> > http://ecos.sourceware.org/fom/ecos
> > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss