summaryrefslogtreecommitdiff
path: root/core/cortex-m
Commit message (Collapse)AuthorAgeFilesLines
* Reformat init.S to use tabs not spacesRandall Spangler2012-12-171-62/+64
| | | | | | | | | | | | | 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>
* Fix potential deadlock in udelay()Randall Spangler2012-11-291-3/+13
| | | | | | | | | | | | | | | | | | | | | 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>
* Prevent GCC4.7 from generating unaligned memory accessesVincent Palatin2012-11-271-0/+1
| | | | | | | | | | | | | | | | | | | 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>
* Add per-second hookRandall Spangler2012-10-302-0/+6
| | | | | | | | | | | | | | | | | | | | | | 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>
* Watchdog is reloaded by HOOK_TICK, not its own taskRandall Spangler2012-10-302-10/+1
| | | | | | | | | | | | | 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>
* Add tick taskRandall Spangler2012-10-302-0/+6
| | | | | | | | | | | | | | | | | | | 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>
* Use SECOND and MSEC constantsRandall Spangler2012-10-292-55/+45
| | | | | | | | | | | | | | | | | | 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
* Clean up core routines - cpu, task, watchdogRandall Spangler2012-10-293-72/+72
| | | | | | | | | | | | 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
* Consolidate emergency debug outputRandall Spangler2012-10-294-93/+50
| | | | | | | | | | | | | | | | | | | 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
* Hook functions no longer return valuesRandall Spangler2012-10-231-5/+1
| | | | | | | | | | | | | | | 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
* Enable FPU support for Link ECBill Richardson2012-10-025-37/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Switch to variable-size stacksRandall Spangler2012-09-091-17/+8
| | | | | | | | | | | | | | | | | | | | 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>
* Allocate stacks separately from task context structsRandall Spangler2012-09-091-42/+63
| | | | | | | | | | | | | 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>
* Track current task directly instead of computing from stack pointerRandall Spangler2012-09-092-45/+14
| | | | | | | | | | | | | | | 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>
* Track amount of stack used for each EC taskRandall Spangler2012-09-071-5/+28
| | | | | | | | | | | 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>
* Add host command to get panic infoRandall Spangler2012-09-051-0/+22
| | | | | | | | | | | | | | | | | | | 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>
* Save panic data across reboots, and add panicinfo commandRandall Spangler2012-08-311-34/+27
| | | | | | | | | | | | | | | | | | | | | 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
* Use new panic stack on all platformsRandall Spangler2012-08-311-18/+11
| | | | | | | | | | | | | | | | 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>
* Place panic data and stack at end of RAMRandall Spangler2012-08-311-55/+154
| | | | | | | | | | | | | | 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>
* add a new hook for pre-chipset startupDavid Hendricks2012-08-292-0/+6
| | | | | | | | | | | | | | | | | 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>
* Include 0xea byte as the last byte in RO/RW imagesRandall Spangler2012-08-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | 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>
* stm32f100: implement low power modeVincent Palatin2012-08-091-1/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* stm32f: Use FLASH_KEYR to lock entire flashVic Yang2012-08-081-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* add a function to fast forward system timerVincent Palatin2012-08-061-0/+8
| | | | | | | | | | | | | | | | | | | 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>
* cpu: Enable reporting of faultsSimon Glass2012-07-022-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add an option flag to intentionally shift binary codeVic Yang2012-06-271-0/+4
| | | | | | | | | | | | | | | | 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>
* fix panic serial codeVincent Palatin2012-06-251-2/+1
| | | | | | | | | | | | | | | | | 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>
* Align .data section in flashVincent Palatin2012-06-251-0/+1
| | | | | | | | | | | | | | | | | | 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>
* Add a dedicated panic() functionSimon Glass2012-06-221-0/+6
| | | | | | | | | | | | | | | | | | 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
* Make ASSERT() report assertion failuresSimon Glass2012-06-221-0/+12
| | | | | | | | | | | | | | | | 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
* Enable checking for divide by 0 and alignment faultsSimon Glass2012-06-213-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add an option to report panic fault informationSimon Glass2012-06-192-0/+158
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add an option to report panics in a new stackSimon Glass2012-06-151-0/+9
| | | | | | | | | | | | | | | | | 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
* Move watchdog_trace() into the generic watchdog fileSimon Glass2012-06-151-0/+38
| | | | | | | | | | | | | | | | | 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>
* Move System Control Block registers to core headerVincent Palatin2012-06-151-0/+2
| | | | | | | | | | | | | | | | | | | 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>
* Convert panic() to C codeSimon Glass2012-06-083-110/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Put correct RO_FRID, RW_FWID_A, RW_FWID_B entries in FMAPBill Richardson2012-06-071-0/+1
| | | | | | | | | | | | 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>
* Add a common watchdog fileSimon Glass2012-06-052-0/+20
| | | | | | | | | | | | | | 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>
* Fix alignment of task scratchpad and system stackRandall Spangler2012-05-313-6/+14
| | | | | | | | | | | | | 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>
* usleep() chains to udelay() if called before task_start()Randall Spangler2012-05-292-0/+16
| | | | | | | | | | | ...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
* Better help for console commandsRandall Spangler2012-05-252-7/+29
| | | | | | | | | | | | | | | | | | | | 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
* Init task contexts/stacks at runtimeVincent Palatin2012-05-252-29/+42
| | | | | | | | | | | | | 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
* Add support for printing fixed-point numbersRandall Spangler2012-05-222-12/+12
| | | | | | | | | | | | 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
* Add FMAP even if VBOOT is not activatedv1.0.0Vincent Palatin2012-05-221-2/+2
| | | | | | | | | | | 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
* Fix regression on linking addressVincent Palatin2012-05-221-1/+1
| | | | | | | | | | | | | 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
* Disable touchscreen when lid is closed and in S3Randall Spangler2012-05-212-0/+6
| | | | | | | | | | | | | | | | | | | (Touchscreen was already disabled in S5) Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:9736 TEST=from console, 'gpioget touchscreen_resetn' in these cases: 1) system is off -> 0 2) system is on with lid open -> 1 3) system is on with lid closed -> 1 4) system is suspended with lid open -> 1 5) system is suspended with lid closed -> 1 6) system is shut back down -> 0 7) suspend system with lid open, THEN close lid -> 0 Change-Id: I5fc80b72ea9dcfbf11f5280d79ae805c2ef1b6df
* Clean up linker scripts; detect out-of-flash problem.Bill Richardson2012-05-211-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | The VMA of the .data segment is in RAM, but we actually put it into FLASH. The linker doesn't notice if it runs out of flash, so it creates an invalid image. This adds an explicit check to be sure it all fits. It also refactors the region declarations to be more explicit. For vboot-enabled configurations, CONFIG_SECTION_* - describes the extent of flash for one entire image CONFIG_FW_* - the region within the SECTION for the firmware only CONFIG_VBLOCK_* - the region within the RW SECTIONs for the vblocks CONFIG_VBOOT_ROOTKEY - the region within the RO SECTION for the root key Look at chip/lm4/config.h for the best example. BUG=chrome-os-partner:9839 TEST=manual Build it, run it. Change-Id: I3c652e82d58a5328115cc750c80ecba6a3fd99a3 Signed-off-by: Bill Richardson <wfrichar@chromium.org>
* Add LM4 support for hard resetRandall Spangler2012-05-211-1/+2
| | | | | | | | | | | | (And add STM32 support for disabling interrupts before reset, which got missed before.) Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:7470 TEST=from console, "reboot", then "reboot hard" Change-Id: Ib98792abc0c91a01e2230b419fc876052380655a
* Add AC state change hookRandall Spangler2012-05-172-0/+6
| | | | | | | | | | | | | | And start wiring to x86_power so it can detect AC state changes (needed to enable/disable turbo). *YES*, this compiles for BDS/Daisy now... Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:9069 TEST=plug/unplug AC power and look for "x86 AC on" / "x86 AC off" in debug log Change-Id: I8399fab9637d6635a1c615f07448fd45b86bc25f
* Rearrange task prioritiesRandall Spangler2012-05-151-2/+2
| | | | | | | | | | | | | | Charging state machine doesn't need to be able to preempt everybody. Keyboard scanning and power button should preempt, because they need to debounce/scan at a stable rate. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=none TEST=system still boots Change-Id: Id57c680b9fa4652bc10d19270620d63788a7b269