Commit Graph

98 Commits

Author SHA1 Message Date
Daisuke Nojiri
74c34bbad4 Saving the main stack pointer at the entry of exception_panic.
CPU creates an exception frame on the main stack instead of the process
stack when the exception happens in a handler's context. So, we need to
save both msp and psp, and pick the right one to locate the exception frame.

Tested by marking the stack (as you see in the dump below) then triggering
divzero in svc_handler.

> crash svc

=== HANDLER EXCEPTION: 03 ====== xPSR: 6100000b ===
r0 :00000000 r1 :0000e237 r2 :000015cf r3 :000015cf
r4 :00000001 r5 :22222222 r6 :11111111 r7 :0000df01
r8 :00000000 r9 :2000545e r10:00000000 r11:00000000
r12:0000000d sp :20000fb8 lr :000055d7 pc :00000b40
Divide by 0, Forced hard fault
mmfs = 2000000, shcsr = 70080, hfsr = 40000000, dfsr = 0

=========== Process Stack Contents ===========
20002738: 11111111 22222222 33333333 44444444
20002748: 00000000 000003ad 000003c0 81000000
20002758: 00000000 0000557d 0000557c 21000000
20002768: 00000000 00000000 00000000 00000000

Rebooting...

BUG=chrome-os-partner:16901
BRANCH=none
TEST=mentioned above

Change-Id: I3ca08a1df20375953552b3dc926350e262b78b2a
Signed-off-by: Daisuke Nojiri <dnojiri@google.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/47495
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-18 20:56:15 -07:00
Vic Yang
8a06eb1d35 Only includes necessary tasks for test binaries
This changes current TASK() syntax to TASK_BASE() and TASK_NORMAL(),
where TASK_BASE is necessary for the EC to boot on a board and
TASK_NORMAL represents the task that can be removed in a test binary.

Tasks introduced by a test should be listed as TASK_TEST().

Note that this CL breaks current tests (many of them are broken anyway),
which will be fixed in up coming CLs.

BUG=chrome-os-partner:18598
TEST=Build link/bds/spring/snow/daisy/mccroskey. (mccroskey failed for
unrelated issue)
BRANCH=none

Change-Id: Ic645cdae0906ed21dc473553f1f43c2537ec4bb9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47531
2013-04-10 01:08:45 -07:00
Daisuke Nojiri
0d1c48ea7c Dumping stack contents on crash.
> crash divzero

=== EXCEPTION: 06 ====== xPSR: 01000200 ===========
r0 :00000000 r1 :0000db92 r2 :4000c018 r3 :200029c8
r4 :00000001 r5 :00000000 r6 :200056e4 r7 :00000000
r8 :00000000 r9 :200056f2 r10:00000000 r11:00000000
r12:00000000 sp :20002958 lr :00000355 pc :00000360
Divide by 0
mmfs = 2000000, shcsr = 70008, hfsr = 0, dfsr = 0

=========== Process Stack Contents ===========
200029c4: 200029c8 0000033d 00000002 0000d1b8
200029d4: 000095ef 200056e4 200056ea 00000000
200029e4: 00000000 00000000 00000000 00000000
200029f4: 00000000 00000000 00000000 00000000

Rebooting...

BUG=chrome-os-partner:16901
TEST=build link
BRANCH=none

Change-Id: I040a9cadf443bfdb3781ffc25a3376bf4aea30ef
Signed-off-by: Daisuke Nojiri <dnojiri@google.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/46455
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-05 11:28:48 -07:00
Randall Spangler
a3dcfd54ef Improve deferred function calls
1) Check vs. number of allowable deferred function calls is made at
link time.

2) Added a check for whether hook_call_deferred() has been made after
the start of calculating the time when the hook task should wake.  If
it has, go back and recalculate the wake time.  This works around a
race condition.

BUG=chrome-os-partner:18473
BRANCH=none
TEST=add a bunch of deferrable functions and recompile; generates a link error

Change-Id: Ie833e2a699c47b6702957ed67bf7d3925f2df099
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47266
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-04 16:32:27 -07:00
Randall Spangler
5966f22a8a Add support for calling deferred functions
This is a cleaner way of deferring work from interrupt-time to
task-time without requiring a task for each module which needs this.

Replaces/supersedes delayed hook notification, which didn't scale well
(since every function would have needed to be its own hook type).

BUG=chrome-os-partner:18473
BRANCH=none
TEST=boot system.  plug/unplug AC power; notifies the host properly

Change-Id: I50263fe1ce37e74c1ef8db3671379098997102ed
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46953
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-02 14:12:55 -07:00
Randall Spangler
55645f87cb Reformat init.S to use tabs not spaces
And tidy a few comments.  No code changes, only comments and whitespace.

BUG=none
BRANCH=none
TEST=compile code (nothing to test)

Change-Id: I10faadc4f11147984cb911c4e630d05ac594cc56
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39796
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-12-17 14:24:39 -08:00
Randall Spangler
108754005d Fix potential deadlock in udelay()
If interrupts are disabled and the deadline is across a 32-bit timer
boundary from the current time, udelay() can lock up.  The fix is to
do 32-bit math directly in udelay().

BUG=chrome-os-partner:16472
BRANCH=link
TEST=manual

waitms 1 -> prompt returns almost instantly
waitms 500 -> prompt returns after 0.5 sec
waitms 1000 -> watchdog error printed, then prompt returns
waitms 2000 -> watchdog reboot

Change-Id: Ib8ca06cee414d48900c0142e629daa68aa0993c9
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/38924
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-11-29 12:02:28 -08:00
Vincent Palatin
e6bf4533c2 Prevent GCC4.7 from generating unaligned memory accesses
The behavior of GCC seems to have changed between 4.6 and 4.7,
now it might generate unaligned memory accesses, so we need to
explicitly set "-mno-unaligned-access".

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:16391
TEST=make BOARD=link dis, then check the generated assembly for
keyboard_scan_init

Change-Id: I326479a77d6319f1d74e17efe483f5cde56ff325
Reviewed-on: https://gerrit.chromium.org/gerrit/38758
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-11-27 15:55:15 -08:00
Randall Spangler
433f98c6b6 Add per-second hook
PWM and temp sensor monitoring want to happen every second,
vs. several times a second for watchdog and LPC.

This is still considerably simpler than having tick functions declare
an interval at which they want to be called, which would require a
RAM-based array of pending tick functions and alarm times.  If you
need that level of complexity, you still need a task.

BUG=chrome-os-partner:15714
BRANCH=none

TEST=temporarily add HOOK_TICK and HOOK_SECOND hooks and see that on
LM4, HOOK_TICK is called 4x a second and HOOK_SECOND is called every
second.

Change-Id: I5c09842fd356d3254021486949b2799142068b4f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36938
Commit-Ready: Simon Glass <sjg@chromium.org>
2012-10-30 15:33:25 -07:00
Randall Spangler
8b3a242ff0 Watchdog is reloaded by HOOK_TICK, not its own task
This reduces memory footprint.

BUG=chrome-os-partner:15714
BRANCH=none
TEST=system still boots; 'waitms 1500' prints watchdog error dump

Change-Id: Ieb0248a34655514b03d919cc36c2b369691da716
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36937
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-30 15:33:24 -07:00
Randall Spangler
4a0b4262d3 Add tick task
Adds a new HOOK_TICK event which is called every 250ms (LM4) or 500ms
(STM32).  This will be used to consolidate a number of tasks which do
small amounts of work infrequently, and previously needed their own
task functions.

This CL adds the tick task; subsequent CLs will consolidate watchdog
and other tasks into tick hooks.

BUG=chrome-os-partner:15714
BRANCH=none
TEST=taskinfo shows TICK task as lowest priority

Change-Id: I9068ee99d56a5bf5c12afd86ad51998c013f4954
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36908
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-30 12:42:40 -07:00
Randall Spangler
1d916d7c6b Use SECOND and MSEC constants
We'd defined them in a number of different files.  This moves
definitions to timer.h, and uses them everywhere we have large delays
(since 10*SECOND is less typo-prone than 10000000).

Also add msleep() and sleep() inline functions.  No need for mdelay()
or delay(), since any delays that long should use sleep funcs instead
of spin-waiting.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system; taskinfo displays similar numbers to before

Change-Id: I2a92a9f10f46b6b7b6571759b1f8ab4ecfbf8259
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36726
2012-10-29 16:52:49 -07:00
Randall Spangler
67aadcf614 Clean up core routines - cpu, task, watchdog
No functional changes.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system

Change-Id: I55cf9c60e92177fd441614a8f9fce2d3acca3d0e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36706
2012-10-29 12:02:41 -07:00
Randall Spangler
fc6b412589 Consolidate emergency debug output
This removes the duplicate uart_emergency_printf() vs. panic_printf()
/ uart_emergency_puts() vs. panic_puts() implementation and saves
~0.5kb of code size.

The other significant change is that uart_flush_output() is now smart
enough to determine if it's in an interrupt; if so, it will spin-flush
the output buffer instead of waiting on the uart interrupt.  This
removes the need for a separate panic_flush().

BUG=chrome-os-partner:15579
BRANCH=none
TEST=crash unaligned; should print well-formatted crash dump

Change-Id: Ifae756203dd1881806be563308077c1d68302e1f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36695
2012-10-29 10:36:05 -07:00
Randall Spangler
e72788ef96 Hook functions no longer return values
Previously, all hook functions returned EC_SUCCESS, which was
meaningless because nothing ever looked at the return value.  Changing
the return value to void saves ~100 bytes of code size and an equal
amount of source code size.

BUG=none
BRANCH=none
TEST=code still builds; link still boots

Change-Id: I2a636339894e5a804831244967a9c9d134df7d13
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36372
2012-10-23 16:49:29 -07:00
Bill Richardson
bc50e0cabb Enable FPU support for Link EC
With this CL, if CONFIG_FPU is defined (only for Link, ATM), the EC task
switcher will enable CONTROL.FPCA and expect all stack contexts to include
floating point state as well as normal state (an additional 18 words).

To support this, we need to increase the allocated stack space for each
task. The stack sizes are already chosen empirically, so I'm just rounding
them up a bit.

BUG=chrome-os-partner:14766
BRANCH=Link
TEST=manual

There should be no noticeable change. If you run the EC command "taskinfo"
you'll see the increased size each thread's stack, but everything that was
working before should continue to work just fine.

The additional overhead required to load and store another 18 words on each
context switch is not really measurable (I tried).

Change-Id: Ibaca7d7a2565285f049fda6906f32761e83207af
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34391
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-10-02 10:52:54 -07:00
Randall Spangler
a3d62a3700 Switch to variable-size stacks
Increase stack size slightly for vboot hash task since the vboot
SHA256 function allocates ~300 bytes of stack data.  Reduce stack size
for watchdog, power LED, and a few other tasks with simple call trees
where we can be sure an error path isn't going to blow past the
reduced stack.

This frees up ~1KB of RAM on STM32.

BUG=chrome-os-partner:13814
BRANCH=all
TEST=boot system; shmem should show more unused RAM; taskinfo should show
tasks still have unused stack

Change-Id: I47d6b77564a0180d15d86667cc0566a8919b776e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32608
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-09 11:00:34 -07:00
Randall Spangler
22d13781dc Allocate stacks separately from task context structs
This is a precursor to supporting task-specific stack sizes.

BUG=chrome-os-partner:13814
TEST=boot; taskinfo shouldn't print garbage
BRANCH=all

Change-Id: Iff6cee8b5f292dd026244239c99ba2252e75cf12
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32592
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-09 11:00:34 -07:00
Randall Spangler
d66ef1213d Track current task directly instead of computing from stack pointer
This is a precursor to supporting task-specific task sizes.  I've
benchmarked this vs. the current stack pointer method; no measurable
performance difference.

BUG=chrome-os-partner:13814
TEST=boot EC; taskinfo; if it boots and doesn't print garbage, it worked
BRANCH=all

Change-Id: Ia326c3ab499ac03cce78dbacaa52f735601a171e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32603
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-09 10:33:49 -07:00
Randall Spangler
a8a3c6d9be Track amount of stack used for each EC task
BUG=chrome-os-partner:13814
TEST=taskinfo; should show stack used per task
BRANCH=all

Change-Id: Ie40a70a8647c767ea6ec3d164f81c63b62b5008e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32590
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-09-07 16:54:31 -07:00
Randall Spangler
46ecb0913b Add host command to get panic info
This only adds support in the EC; it doesn't add an ectool command.
We'll add that later.  This also fixes a bug where the reserved byte
in the panic data structure wasn't being set to 0.

BUG=chrome-os-partner:7466
BRANCH=all
TEST=manual

1. crash unaligned -> system crashes
2. hostcmd 0xd3 -> returns a hex string 01010100...506e6321
3. hostcmd 0xd3 -> returns a hex string 01010500...506e6321

Change-Id: I1de8e19c44c835055d893986b42d152dc704c35f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32183
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-09-05 10:03:17 -07:00
Randall Spangler
96103ab32d Save panic data across reboots, and add panicinfo command
Jump data now precedes the panic data, if any, in memory.

BUG=chrome-os-partner:7466
BRANCH=all
TEST=manual

1. boot system
2. sysjump rw --> display should stay on and keyboard should still work
   (this verifies jump data is properly read across sysjump still)
3. crash unaligned --> system should reboot
4. panicinfo --> should print the same crash dump as before, with (NEW)
5. panicinfo --> ditto, without (NEW)
6. sysjump rw
7. panicinfo --> ditto, without (NEW)

Change-Id: I88285724e82a15553ab25877e3d8ec4c74a4dd5a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32051
2012-08-31 15:41:36 -07:00
Randall Spangler
66d3ad0170 Use new panic stack on all platforms
Now that the panic stack goes at the end of RAM, there's no overhead
to using it on all platforms.  When it was a dedicated block of
memory, we needed to turn it off on some low-RAM platforms
(e.g. Snow).

BUG=chrome-os-partner:7466
TEST='crash divzero' or 'crash unaligned'; should print dump and reboot
BRANCH=all

Change-Id: Iddfeb134e237538215df51abe4e16ee831b3ae2d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32037
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-08-31 15:41:35 -07:00
Randall Spangler
f3de461a35 Place panic data and stack at end of RAM
This is in preparation for saving panic data across reboots for later
retrieval.

BUG=chrome-os-partner:7466
TEST='crash divzero' or 'crash unaligned'; should print dump and reboot
BRANCH=all

Change-Id: I997d160b00d03759eb9c69b53ab0f7a5ae144183
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31951
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-08-31 15:41:33 -07:00
David Hendricks
8cb10aaf5b add a new hook for pre-chipset startup
This adds a new hook that is intended to be called immediately before
host chipset/AP startup to initialize components such as the PMU.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
BRANCH=snow
BUG=chrome-os-partner:13315
TEST=tested in subsequent patches

Change-Id: I2b38208de9f0f51abc0b22c49547ee0c4c889b82
Reviewed-on: https://gerrit.chromium.org/gerrit/31738
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2012-08-29 18:16:46 -07:00
Randall Spangler
7dbb17f07e Include 0xea byte as the last byte in RO/RW images
This is better than having the 0xea byte only appended in ec.bin,
since now the byte is present in ec.RW.flat and ec.RO.flat.  Needed
for EC software sync.

BUG=chrome-os-partner:12412
BRANCH=link,snow
CQ-DEPEND=30305
TEST=manual

1. xxd ec.RW.bin | tail; should end with 0xea
2. xxd -g4 build/link/ec.bin | grep -C3 454e44ea

That word should be the last one before a bunch of 0xfffffff bytes.
There should be 2 matches (since there's RO and RW firmware)

Change-Id: I0de5cc78083f1a9b49202fbe2305a3101f401db3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/30303
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-08-14 17:30:22 -07:00
Vincent Palatin
b081af1284 stm32f100: implement low power mode
When the AP is not running and we have enough time go to STOP mode
instead of simple idle.
The EC consumption should drop from 12mW to a few mW.

This is currently not activated by default, you need to type "sleepmask
0" in the EC console to activate it.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:8866
TEST=on Snow, check the software is still working properly when STOP
mode is activated and measure power consumption on 3v_alw rail.

Change-Id: I231d76fe6494c07b198c41694755b82d87c00e75
Reviewed-on: https://gerrit.chromium.org/gerrit/29315
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-08-09 11:55:03 -07:00
Vic Yang
a7d7297577 stm32f: Use FLASH_KEYR to lock entire flash
Writing wrong key to FLASH_KEYR locks entire flash and effectively
performs RW_NOW. Therefore we can use this and remove RW_AT_BOOT to
prevent having to reboot for RW to be protected.

BUG=chrome-os-partner:12043
TEST=1. fakewp 1         -> wp_gpio_asserted
     2. flashwp now      -> nothing happens
     2. flashwp enable   -> wp_gpio_asserted ro_at_boot
     3. reboot           -> wp_gpio_asserted ro_at_boot ro_now
     4. flasherase 0x10000 0x1000 -> success
     5. flashwp now      -> wp_gpio_asserted ro_at_boot ro_now rw_now
     6. flasherase 0x10000 0x1000 -> error
     7. reboot           -> wp_gpio_asserted ro_at_boot ro_now
     8. flasherase 0x10000 0x1000 -> success

Change-Id: I22df188e31404c190c5830c6d94c9646224eb9ab
Reviewed-on: https://gerrit.chromium.org/gerrit/29255
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-08-08 11:39:48 -07:00
Vincent Palatin
dbc861c5f0 add a function to fast forward system timer
When we wake up from a deep sleep mode, the system timer clock might
have been stopped. We need to be able to set using another time source
(e.g. the RTC).

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:8866
TEST=make BOARD=snow && make BOARD=link
on Snow, on a software implementing STOP mode, check the system time is
still accurate by comparing it to the wall clock.

Change-Id: Ieddbb423d052c7aceb398470866b25b25a74c0a0
Reviewed-on: https://gerrit.chromium.org/gerrit/29314
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-06 18:55:00 -07:00
Simon Glass
bb27b96f13 cpu: Enable reporting of faults
Faults should be enabled, otherwise we just get a hard fault whenever they
occur.

BUG=chrome-os-partner:10146
TEST=manual:
build and boot on snow; cause a fault and see that it is reported correctly
in the panic message, rather than just a hard fault.
Also tested on link, 'rw 1':

 > rw 1

=== EXCEPTION: 06 ====== xPSR: 01000000 ===========
r0 :0000000b r1 :00000041 r2 :00000001 r3 :20003720
r4 :00000000 r5 :0000bbb4 r6 :2000371c r7 :00000002
r8 :00000000 r9 :20003721 r10:00000000 r11:00000000
r12:00000000 sp :200019a0 lr :00004ad1 pc :000054f6
Unaligned
mmfs = 01000000, shcsr = 00070008, hfsr = 00000000, dfsr = 00000000
Time:     0x00000000006f0938 us
Deadline: 0x00000000006ec3d4 ->   -0.017764 s from now
Active timers:
  Tsk  1  0x000000000072bc1e ->    0.242406
  Tsk  4  0x00000000006ec3d4 ->   -0.017764
  Tsk  5  0x00000000007a2333 ->    0.727547
  Tsk  6  0x00000000007a2193 ->    0.727131
  Tsk  7  0x00000000007a1fd9 ->    0.726689
  Tsk  9  0x0000000000eeb452 ->    8.366874
Task Ready Name         Events      Time (s)
   0 R << idle >>       00000000    6.854007
   1   WATCHDOG         00000000    0.000442
   2   VBOOTHASH        00000000    0.286203
   3   LIGHTBAR         00000000    0.018957
   4   POWERSTATE       00000000    0.020656
   5   TEMPSENSOR       00000000    0.000851
   6   THERMAL          00000000    0.000643
   7   PWM              00000000    0.000243
   8   TYPEMATIC        00000000    0.000015
   9   X86POWER         00000000    0.010582
  10   I8042CMD         00000000    0.000015
  11   HOSTCMD          00000000    0.000014
  12 R CONSOLE          00000000    0.000336
  13   POWERBTN         00000000    0.003883
  14   KEYSCAN          00000000    0.000297

Rebooting...

Change-Id: I95a4a7fae14359aa4e2b645d2110f91161e7df88
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26170
2012-07-02 15:02:07 -07:00
Vic Yang
a6e24f1672 Add an option flag to intentionally shift binary code
We need a simple way to build an EC image that is binary-wise much
different from the original one, so that we can test EC update as much
thoroughly as possible. By padding useless space, we can have an image
with exactly same functionality but binary-wise different.

BUG=chrome-os-partner:10264
TEST=Build and run without error.

Change-Id: I070bec7cec71db1662238ca6af10e864c82ba428
Reviewed-on: https://gerrit.chromium.org/gerrit/26083
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-27 21:22:17 -07:00
Vincent Palatin
b8d7d8fc44 fix panic serial code
panic_putc was doing an infinite loop on platforms with a UART FIFO.
(e.g. LM4F)

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:10825
TEST=on Link EVT and Lucas DVT, type "rw 1" in the EC serial console and
see the panic trace.

Change-Id: I47f43183e6e938b88874c80244430ddf88c5a567
Reviewed-on: https://gerrit.chromium.org/gerrit/26052
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-25 17:52:47 -07:00
Vincent Palatin
faff1c6da6 Align .data section in flash
When copying .data section from flash to internal RAM at startup, we
assume the content of the section is aligned on a word size in flash.
Force the alignment in the linker file.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:10823
TEST=on Link EVT, type "sysjump RO" in EC console and see you are
jumping to RO partition and not getting a watchdog reset.

Change-Id: I1a1387ef8bff01d287d85ee2a660811c9e4620c6
Reviewed-on: https://gerrit.chromium.org/gerrit/26032
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-25 14:15:49 -07:00
Simon Glass
3977403642 Add a dedicated panic() function
In addition to ASSERT(), it might be useful to panic() sometimes, so add
a tidy way of doing it which will print a message and reset.

BUG=chrome-os-partner:10149
TEST=manual
Build a special version for snow where the 'rw' command calls panic()
See that a message is produced:
> rw 0
read 0x0 = 0x20001048

** PANIC: Address is 0

Change-Id: I4512c0193f4c1d52d0c256b2deefacf551056fd9
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25413
2012-06-22 11:12:40 -07:00
Simon Glass
d47905ce27 Make ASSERT() report assertion failures
Rather than just reset the board, report assertion failures to aid
debugging. To enable this, use CONFIG_ASSERT_HELP.

BUG=chrome-os-partner:10149
TEST=manual
Enable the option for snow, add a failing ASSERT() to the rw command
and see the a nice message is printed now.

ASSERTION FAILURE 'address' in command_read_word() at common/memory_commands.c:00000037

Change-Id: Ice59434c5daf610832dd0e1fcfa5630dc847bb67
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25411
2012-06-22 10:13:36 -07:00
Simon Glass
d5cb026142 Enable checking for divide by 0 and alignment faults
These likely indicate errors, so we shold trap them. Possibly this
should be reconsidered for production.

BUG=chrome-os-partner:10148
TEST=manual:
build on all boards
build and boot on snow with a special rw command containing a division
by 0. See that it is trapped:
> rw 0

=== EXCEPTION: 03 ====== xPSR: 01000000 ===========
r0 :0000000b r1 :08005eba r2 :00000000 r3 :20001048
r4 :00000000 r5 :08004fd4 r6 :08004f8c r7 :200012a8
r8 :08004fd4 r9 :00000002 r10:00000000 r11:00000000
r12:00000000 sp :200009a0 lr :08002861 pc :0800368a
Divide by 0, Forced hard fault, Vector catch
mmfs = 02000000, shcsr = 00000000, hfsr = 40000000, dfsr = 00000008

Turn off the cpu_init() setup, and see that it is ignored.

> rw 0
read 0x0 = 0x00000000
>

Similarly, try an unaligned access with the rw command with this enabled:

> rw 1

=== EXCEPTION: 03 ====== xPSR: 01000000 ===========
r0 :0000000b r1 :00000041 r2 :00000001 r3 :200012ac
r4 :00000000 r5 :08004fd4 r6 :08004f8c r7 :200012a8
r8 :08004fd4 r9 :00000002 r10:00000000 r11:00000000
r12:00000000 sp :200009a0 lr :08002861 pc :08003686
Unaligned, Forced hard fault, Vector catch
mmfs = 01000000, shcsr = 00000000, hfsr = 40000000, dfsr = 00000008

but disabled it works:

> rw 1
read 0x1 = 0x5d200010
>

Change-Id: Id84f737301e467b3b56a7ac22790e55d672df7d8
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25410
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-21 06:01:22 -07:00
Simon Glass
004c607a96 Add an option to report panic fault information
The fault status registers sometimes have useful information, so provide
an option to display these.

This adds about 1KB to the code size.

BUG=chrome-os-partner:10146
TEST=manual:
build for all boards
On snow, cause a panic and see that it is reported correctly.

=== EXCEPTION: 03 ====== xPSR: 01000000 ===========
r0 :0000000b r1 :00000047 r2 :60000000 r3 :200013dd
r4 :00000000 r5 :080053f4 r6 :200013d0 r7 :00000002
r8 :00000000 r9 :200013de r10:00000000 r11:00000000
r12:00000000 sp :200009a0 lr :08002b85 pc :08003a8a
Precise data bus error, Forced hard fault, Vector catch, bfar = 60000000
mmfs = 00008200, shcsr = 00000000, hfsr = 40000000, dfsr = 00000008

Change-Id: I1a18c85ee63760502c92b300f5a87e57468469a5
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24505
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-19 18:45:27 -07:00
Simon Glass
8c55761613 Add an option to report panics in a new stack
For particularly nasty errors the stack or stack pointer may be corrupt,
or in a place that we do not want overwritten. Provide and option to
place the stack in a fresh place, assuming you can reach exception_panic().

Note that exception_panic() does not write anything to stack itself.

BUG=chrome-os-partner:10146
TEST=manual:
build for all boards
On snow, cause a panic and see that it is reported correctly.

Change-Id: I21d8b9bb12455758309d54ef20de66640d8a2df6
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24504
2012-06-15 18:25:34 -07:00
Simon Glass
9f2e621d80 Move watchdog_trace() into the generic watchdog file
We want this function to be available for all chips, so move it into a
generic place.

The task_disable_irq() from the LM4 version can be left in
watchdog_check(), to keep the watchdog_trace() function generic.

BUG=chrome-os-partner:10145
TEST=build for all boards

Change-Id: I98c60ce5958f1498b84a233ef04290a68a7838c5
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24397
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-06-15 13:39:22 -07:00
Vincent Palatin
b4d996a5ea Move System Control Block registers to core header
The SCB registers are defined in the ARMv7-M architecture, so they are
common to all chips.

We will need System Control Register (SCR aka SYSCTRL) to implement
power management on stm32.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=make BOARD=link && make BOARD=snow

Change-Id: I35c283731306541b3d21398c96fdca89954fe20a
Reviewed-on: https://gerrit.chromium.org/gerrit/25392
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-15 13:18:40 -07:00
Simon Glass
3439e70a90 Convert panic() to C code
Move the implementation of panic into C code. Only a very small part
needs to be in assembler, and the reset is easier to maintain as C.

As part of this, define panic_putc() and panic_puts() which directly
wite to the UART.

To make things more convenience for the future, add a simple printf()
implementation in the panic path. This is not reliant on the uart
buffering system being in a happy state. However, we do call the
emergency flush so that our panic message will appear after previous
output rather that surpressing it (which would be extremely confusing).

Code/data size for panic.o grows by about 200 bytes, but this is mostly
due to the increased flexibility.

   text	   data	    bss	    dec	    hex	filename
    292	    272	      0	    564	    234	old panic.S
    692	      3	     48	    743	    2e7	new panic.c

BUG=chrome-os-partner:10146
TEST=manual:
build and boot on snow:
> rw 0x06000000

=== EXCEPTION: 03 ====== xPSR: 01000000 ===========
r0 :0000000b r1 :00000047 r2 :06000000 r3 :200013dd
r4 :00000000 r5 :080052cc r6 :200013d0 r7 :00000002
r8 :00000000 r9 :200013de r10:00000000 r11:00000000
r12:00000000 sp :200009a0 lr :08002a5d pc :08003962

Rebooting...

Change-Id: If3e3f572e0f32af780b6ebda235b1b3cde4de5e4
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24503
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-06-08 17:55:40 -07:00
Bill Richardson
12eecc012b Put correct RO_FRID, RW_FWID_A, RW_FWID_B entries in FMAP
BUG=chrome-os-partner:9495
TEST=manual

Build image, run dump_fmap. Look for those entries.

Change-Id: I6dfc38e00ce1e11ea24c8392d1691fab32a59d1f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24696
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2012-06-07 01:20:16 -07:00
Simon Glass
99845e2fd5 Add a common watchdog file
Some things about watchdogs are common across Cortex-M3, so create a
common watchdog file to hold these. Put the watchdog task in there as
the first customer.

BUG=chrome-os-partner:10145
TEST=build for all boards

Change-Id: Id55f71a807ee12bae3758afc213c30c731eadc07
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24395
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-05 09:30:21 -07:00
Randall Spangler
11ab34a721 Fix alignment of task scratchpad and system stack
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:10042
TEST=boot system, ctrl+alt+F2, type on console; shouldn't crash

Change-Id: I935bc141fbbc1e7d0d073f1754104808a24fe869
Reviewed-on: https://gerrit.chromium.org/gerrit/24232
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-05-31 15:03:17 -07:00
Randall Spangler
ef46903dea usleep() chains to udelay() if called before task_start()
...so I can use usleep() for eeprom delays in the CL coming next...

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:10200
TEST=if it boots, it worked

Change-Id: I564578f24452a4ac39abe79ff28cfff4b665ad2f
2012-05-29 09:38:58 -07:00
Randall Spangler
e704c712ad Better help for console commands
Additional help messages and usage are gated by
CONFIG_CONSOLE_CMDHELP, so we can turn it on if there's space (adds
about 3KB to image size) and turn it off when there isn't.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=manual

1) help
2) help list
3) help gpioset
4) gpioset -> wrong number of params
5) gpioset fred 0 -> param1 bad
6) gpioset cpu_prochot fred -> param2 bad

Change-Id: Ibe99f37212020f763ebe65a068e6aa83a809a370
2012-05-25 13:34:06 -07:00
Vincent Palatin
c7fcad2924 Init task contexts/stacks at runtime
Instead of storing task contexts in .data and wasting several kB of
flash with mostly 0s, move them to .bss and fill the initial context at EC
startup. The runtime overhead is small enough.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:9839
TEST=run on Link and check verified boot and chromeOS startup are OK.

Change-Id: Iaef23d46a4e3e80e49886dfbf7ab1f537c587362
2012-05-25 16:11:41 +00:00
Randall Spangler
9b44097d23 Add support for printing fixed-point numbers
This makes timestamps much easier to read.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9866
TEST=timerinfo, taskinfo, battery commands have fixed-point numbers,
and timestamps printed in the log look right.

Change-Id: If91c83f725984c8e04bfb7cdcff316d9c3bfe24c
2012-05-22 10:37:56 -07:00
Vincent Palatin
15854fa680 Add FMAP even if VBOOT is not activated
This simplifies the re-flashing for stm32 based platforms.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:8865
TEST=On Daisy, flashrom -p internal:bus=lpc -w ec.bin

Change-Id: I66860383c34110b1edf852929c244a2b682bc105
2012-05-22 15:04:13 +00:00
Vincent Palatin
16d8f6c8bc Fix regression on linking address
On platform where the flash base address is non null (e.g. stm32), we need to
take it into account.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=None
TEST=On Daisy, type "sysjump A" and "version" into the EC console
and observe that the commands succeed.

Change-Id: I95596d45f6970259d19d7063f6794fae0c400ab7
2012-05-22 15:04:13 +00:00