summaryrefslogtreecommitdiff
path: root/common/console.c
Commit message (Collapse)AuthorAgeFilesLines
* lm4: Use low speed clock in deep sleep.Alec Berg2013-10-211-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Changed the low power idle task to use the low speed clock in deep sleep. The low power idle task is currently only enabled for Peppy, Slippy, and Falco. This change decreases power consumption when the AP is not running. Note that the low speed clock is slow enough that the JTAG cannot be used and the EC console UART cannot be used. To work around that, this commit detects when the JTAG is in use and when the EC console is in use, and will not use the low speed clock if either is in use. The JTAG in use never clears after being set and the console in use clears after a fixed timeout period. BUG=None BRANCH=None TEST=Passes all unit tests. Tested that the EC console works when in deep sleep. Tested that it is possible to run flash_ec when in deep sleep and using the low speed clock. Change-Id: Ia65997eb8e607a5df9b2c7d68e4826bfb1e0194c Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/173326 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Move input character processing from UART interrupt to console taskRandall Spangler2013-08-021-12/+388
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, processing of arrow keys and control characters was done in the interrupt handler itself. This increased the impact of UART input on other interrupts and high-priority tasks. It also makes it harder to implement DMA-based UART input on STM32L (in an imminent CL), since the processing affected the circular UART input buffer in-place. This change turns uart_buffering.c back into a dumb I/O buffering module, and puts all the command line editing and history support into console.c. Console history is done via a simple array of input lines instead of a packed circular buffer of characters. This is a little less RAM-efficient, but is easier to implement and read. History depth is controlled via CONFIG_CONSOLE_HISTORY, and is 3 for STM32F and 8 for other platforms. If we really need a greater history depth, we can look into implementing a packed circular buffer again, but this time at task time in console.c. Also added a 'history' command to print the current console history. BUG=chrome-os-partner:20485 BRANCH=none TEST=console_edit unit test passes; 'history' command prints the last commands Change-Id: I142a0be0d67718c58341e4569f4e2908f191d8b0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64363 Reviewed-by: Vic Yang <victoryang@chromium.org>
* Clean up and document UART config optionsRandall Spangler2013-07-241-1/+1
| | | | | | | | | | | | No functional changes, just renaming config options. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms Change-Id: I91584cb1f8990dd0f980abd32c04465a66243e71 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/63244
* Accept a command if it's a full matchVic Yang2013-06-051-0/+6
| | | | | | | | | | | | | | | | On Spring, we now have commands 'i2c' and 'i2cscan'. Currently if we type 'i2c', it's rejected as it's also the prefix of 'i2cscan'. Since 'i2c' is a full match of a legal command, we should accept it. BUG=None TEST=On Spring, check 'i2c' invokes 'i2c' command, and 'i2cs'/'i2cscan' invokes 'i2cscan' command. Also check 'i2' is still rejected. BRANCH=all Change-Id: I65c4c148a5a3e9b025554fa8165ba76da7bc312f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/57576 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add console command to force enable consoleVic Yang2013-05-151-1/+23
| | | | | | | | | | | | | | | | | | | | | | When system is locked, the console is disabled. However, we need console for debugging and testing. This CL uses a bit from back-up register to indicate if the console should always be enabled. (This bit is currently used by fake WP, which is removed in this CL.) With this, we can set this bit with console command 'forceen 1' to ensure console is never disabled. To prevent device shipped in this state, the chip name is postfixed with '-unsafe' so that the device is not able to pass HWID check. BUG=chrome-os-partner:19293 TEST=Manual BRANCH=spring Change-Id: I88556e973ca542c1bdc27ba64988718291e01a26 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/51086 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* add option to de-activate EC console input when WP is onVincent Palatin2013-04-301-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | With a Toad cable, the user can access the EC serial console through the micro-B connector. We probably need to de-activate the input on the EC serial console when the Write-Protect is on, since we have fairly "powerful" commands on the EC command-line. Add a new CONFIG_CONSOLE_RESTRICTED_INPUT on platforms with externally accessible EC serial port. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=spring BUG=chrome-os-partner:18716 TEST=on Spring with CONFIG_CONSOLE_RESTRICTED_INPUT set, try with and without write-protect, use successfully the EC console in the former case, and see "Console is DISABLED" in the latter case. Change-Id: Ic9646d5468183f4d8f94b5e5e1d2a727941d7bbe Reviewed-on: https://gerrit.chromium.org/gerrit/49537 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Clean up uart buffering codeRandall Spangler2012-10-261-2/+2
| | | | | | | | | | | | | No functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST=help version -> prints help on version command Change-Id: I79c4b668513b6037aa6cf3fa1a2a8c0fc9856f41 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36612 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Clean up console moduleRandall Spangler2012-10-241-36/+44
| | | | | | | | | | | | Code cleanup and reformatting. No functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST=compile code; type a debug command like 'help list'. Change-Id: I641215ba3333628f658eec86d9d99718c43b111f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36387
* Split console output into its own moduleRandall Spangler2012-06-131-107/+0
| | | | | | | | | | | | | | No code changes, just rearranging source in preparation for an experiment to see how much the binary shrinks if we disable the interactive console. BUG=none TEST=none Change-Id: Ie21f1b3dcd04272e80fd40b2ed54d1eaf7fb1cdf Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25232 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Add basic SPI support to linkRandall Spangler2012-05-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds SPI transaction support, and a debug command to read a few values from the SPI EEPROM. Note that the SPI controller is normally *disabled* with all its I/Os high-Z, so this will not interfere with main processor or Servo on the SPI bus. The bus is only enabled during the SPIROM command itself. BUG=chrome-os-partner:7844 TEST=manual 1) Reboot system 2) on EC console, 'spirom'. Should print Man/Dev ID : 0xef 0x16 JEDEC ID : 0xef 0x40 0x17 Unique ID : 0xd1 0x61 0x44 0xb0 0x63 0x5d 0x40 0x32 Status reg 1: 0x00 Status reg 2: 0x00 Note that unique ID is, well, unique, so it won't match my value. But it should still be something not all 0xff's. 3) Power on the system. x86 should still boot normally, indicating that the EC isn't interfering with the SPI bus. Change-Id: I53bf5fdbbe7a37949375d0463e30e408cc6fb6a8
* Better help for console commandsRandall Spangler2012-05-251-24/+74
| | | | | | | | | | | | | | | | | | | | 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
* More debug command cleanup to save spaceRandall Spangler2012-05-211-1/+3
| | | | | | | | | | (saves another 1.5KB) BUG=none TEST=(run the commands) Change-Id: Id3ca58528fa68a4cec606edf2b98b9af38ac228f Signed-off-by: Randall Spangler <rspangler@chromium.org>
* Clean up debug commands to use less spaceRandall Spangler2012-05-211-23/+15
| | | | | | | | BUG=none TEST=(run the commands) Change-Id: I6ed4aee169311825190bcc386b86cdc32ba0866a Signed-off-by: Randall Spangler <rspangler@chromium.org>
* Sort console commands at build timeVincent Palatin2012-05-151-21/+4
| | | | | | | | | | | | Use the linker to sort console commands by name, this saves execution time and memory. BUG=none TEST=generate several images with 5N, 5N+1, 5N-1 commands and check the output of the "help" command. Change-Id: Ib5d8f3bca726621c68ab152f4fa662cee355abb1 Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
* Arrange help output to sort 'column first'Vadim Bendebury2012-05-141-25/+31
| | | | | | | | | | | | | | | Sort the command name index, and then print them in file columns (as before), but ordering columns first. This makes it much easier to examine the 'help' command output. BUG=none TEST=manual . program the new image . execute the 'help' command . observe output printed sorted 'columns first' Change-Id: I7b15cef09a61fe20eb4ba5ee274ba1d72063f1c0 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
* Allow console commands abbreviationVadim Bendebury2012-05-141-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The EC console input handling code is being enhanced to accept abbreviated command names. If the abbreviation is unique, the appropriate command is used, if the abbreviation is ambiguous, the command is handled as nonexistent. The error message is being modified to mention that the command either does not exist or is ambiguous. This change also makes it impossible to have command names matching the beginning of other command names. Two such cases are being fixed (`ch' renamed to `chan' and `thermal' renamed to 'thermalconf'). BUG=none TEST=manual . program the new EC image. Try entering at the console: > h Command 'h' either not found or ambiguous. Command returned error 1 > he Known commands: adc autofan battery ch charger ... > help Known commands: adc autofan battery ch charger ... Change-Id: Iaa3e91e1504e42daefb02d561e00c39003548197 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
* Allow boards to set the default console maskSimon Glass2012-05-101-6/+9
| | | | | | | | | | | | | | Some boards don't like to have every keyboard scan printed, but some devs find this info comforting. Add a way for boards to select the require console mask. BUG=none TEST=manual: build and boot on daisy, see that key scan messages are suppressed. build on all platforms Change-Id: I8e6e640eaabc0a08e5427cd97f7089dda1238025 Signed-off-by: Simon Glass <sjg@chromium.org>
* Fix truncated output from 'ch' commandRandall Spangler2012-05-101-0/+1
| | | | | | | | | Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=none TEST='ch' - prints all the channels now Change-Id: I38ebc3eed2476c44c26fc00d6ea79800ae427722
* Issue warning on fan stall.Vic Yang2012-04-261-0/+1
| | | | | | | | | | | | When PWM module detects fan stall, issue SMI warning and print warning message to console. Signed-off-by: Vic Yang <victoryang@google.com> BUG=chrome-os-partner:7497 TEST=Disconnect fan and power up. See warning message. Change-Id: I4d96595f7f3cdfab5df333afc35206304bacab9d
* Use console output instead of uart output for console commandsRandall Spangler2012-04-241-6/+10
| | | | | | | | | | | | This completes console output cleanup. The remaining calls to uart_puts() and uart_printf() actually need to be that way. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:7464 TEST=manual Change-Id: Ib1d6d370d30429017b3d11994894fece75fab6ea
* Refactor async console outputRandall Spangler2012-04-241-21/+124
| | | | | | | | | | | | | | | | | | This adds a 'ch' command which prints/sets which channels are active This handles all the async output; the remaining debug commands will be refactored to use ccprintf() / ccputs() in a followup CL. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:7464 TEST=manual ch --> all channels active ch 0x100 -> just port80 active powerbtn -> system boots; only port 80 codes shown on console Change-Id: I9efc43acec919b62b78c2c82c61946d32380adfe
* Move externs from .lds file into a header fileRandall Spangler2012-04-191-3/+1
| | | | | | | | | | | Fewer magic externs = good. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=none TEST=if it boots, it works Change-Id: Ifadeb1701400c5492c40d2eaf8f68f2d70189648
* Change task messages to eventsRandall Spangler2012-04-061-2/+2
| | | | | | | | | | | | | Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:7461 TEST=manual make BOARD={bds,link,daisy} make tests flash link system and make sure it boots Change-Id: I1241a1895c083e387e38ddab01ac346ca4474eb9
* Handle up/down arrow keys for UART console.Vic Yang2012-02-071-9/+1
| | | | | | | | | | | | | | | | | | | | | | Record commands used previously and use up/down arrow key to navigate in the command history. Also removed the command '.' of repeating last command as we can use up arrow key now. Also changed the behaviour of uart_write_char() to be blocking on transmit FIFO full, so that we do not lose echoed character and do not need to flush. BUG=chrome-os-partner:7815 TEST=Type 'help' and enter. Then type 'aaaa' and up arrow key, should show 'help', and pressing enter prints help. Type 'hellp' and enter. Then type 'aaaaaa' and up arrow key, should show 'hellp'. Should be able to use left/right arrow key and backspace to correct it to 'help', and pressing enter prints help. Type 'help' and enter. Then type 'aaa', up arrow key, and down arrow key. Should show 'aaa'. Change-Id: I65c615d61bf63acb31bea329aa91a3202d4db0ad
* Remove useless header includesVincent Palatin2012-01-261-1/+0
| | | | | | | | | | | | | | Preparatory work to introduce a second SoC : 2nd series 2/4 Avoid introducing platform specific dependencies in common files where they are not necessary. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=build for BDS and Link Change-Id: If2ccd022e4956425222b55a5a48ca7522857e7f0
* Help command prints a sorted multi-column list of commandsRandall Spangler2012-01-241-8/+25
| | | | | | | | | Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=none TEST=type 'help' from console Change-Id: If88610f35337243ca2550de2851bd1924083344d
* register console commands at compile-timeVincent Palatin2012-01-241-38/+12
| | | | | | | | | | | | | | | Instead of using a runtime callback to register the console commands, put them in a special linker section. So we can do a macro to "register" them during the build. It saves 684 bytes and a few microseconds at startup. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=run a few commands from the BDS command line. Change-Id: Id33ea210b9035bf76ed720373c74c5dd24ccd1b1
* Initial sources import 1/3Randall Spangler2011-12-071-0/+207
source files mainly done by Randall. Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: Iaff83a842b17f3350fb6f2a3f1597ad4c29bd12a