summaryrefslogtreecommitdiff
path: root/common/uart_buffering.c
Commit message (Collapse)AuthorAgeFilesLines
* Prepare for transitioning to packet mode consoleVadim Bendebury2020-03-311-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A very few changes are needed to support the packet mode: - provide functions to report how much room is left in USB/UART transmit buffers; - compile out cprintf/cprints/cputs just in case to be able to catch cases where util_precompile.py fails to convert them for whatever reason; - do not add CR to every LF, this messes up packet transmissions, and the terminal is doing the right thing anyways - there is a problem with the USB channel in packet mode: the device reboots as soon as an attempt to send something to the host is undertaken. The problem can be rectified by disabling the deferred function path in the Cr50 console USB channel. A bug was open to track it down, but in packet mode using deferred function in this path is less critical, as the amount of sent data always is at least as much as the packet header size BUG=b:149964350, b:152116489 TEST=with the rest of the patches applied packet mode console works fine. When packet mode is disabled the conventional mode console works fine. Change-Id: Ib010cede36adc87cf80f49e5d76ec9e274d9e608 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2114238 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* uart_buffer: ensure uart tx/rx buffer size are power of twoYilun Lin2019-11-071-1/+4
| | | | | | | | | | | | | | | | uart buffers are circular buffers and the pointer advancing needs the buffer size power of two. TEST=set CONFIG_UART_TX/RX_BUF_SIZE to various values and ensure the results are correct BUG=none BRANCH=kukui Change-Id: I53feb28f0397c67e282126faf25b0fbfdd8d5251 Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1902889 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-021-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* log: Preserve Kukui EC reset logs across every EC reboot on SRAM.Shannon Chen2019-08-211-3/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | On Kukui, we need to put console logs and reset reasons at fixed addresses on SRAM to save the information across each EC resets. Otherwise, EC will lose console logs and reset reasons after resetting EC. This CL ensures that the contents of reset and console logs will not be clobbered or cleared by putting mandatory symbols at a fixed location on SRAM. The values will only be reset when checksum or sanity check fails. BUG=b:133795403 TEST=1. On Kukui, shutdown AP, reboot AP, or sysjump, and see the previous logs before reboot will be kept on /var/log/croc_ec.log 2. Reset reasons can be viewed with ectool uptimeinfo BRANCH=master Change-Id: I19db49101fda1675dc2fdc047b7f14af77cdb6e6 Signed-off-by: Shannon Chen <shannc@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1716671 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Shannon Chen <shannc@chromium.org> Tested-by: Shannon Chen <shannc@chromium.org>
* uart_buffering: add tx_buffer_full() APIVadim Bendebury2019-06-271-0/+6
| | | | | | | | | | | | | | | | | To aid in system level UART console performance testing a test function needs to know when the UART console buffer is full. This patch provides an API for that. BRANCH=none BUG=b:38448364 TEST=verified proper operation of the chargen CLI command which uses this API. Change-Id: I5fbc6cf4031a5077c91cd4bb85ab6f4dfb18821e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1679710 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* UART: Export uart_clear_input APIDaisuke Nojiri2019-02-081-0/+8
| | | | | | | | | | | | | | | | This patch exports the uart_clear_input API. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/119329144 BRANCH=none TEST=buildall Change-Id: Ib78b9dbca8ef9efb21c566888fd495b6cf313ada Reviewed-on: https://chromium-review.googlesource.com/1454987 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* UART: Add uart_put APIDaisuke Nojiri2019-02-081-0/+14
| | | | | | | | | | | | | | | | | | The uart_puts API takes a null-terminated string. This patch adds the uart_put API, which works like uart_puts but allows the caller to specify the data size. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/119329144 BRANCH=none TEST=buildall Change-Id: I18b2625f9a2339b68ca586b6f1b3c36511cb725c Reviewed-on: https://chromium-review.googlesource.com/1457576 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* uart_buffering: expose interface to support non-host commandWei-Han Chen2018-08-201-46/+64
| | | | | | | | | | | | | | | | | | | UART buffer could only be accessed by host command. For detachable devices, we don't want to enable all host commands. Refactor and expose an API to support accessing UART buffer directly, host command is not necessary. BRANCH=none BUG=b:70482333 TEST=tested on whiskers TEST=tested on nocturne Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I8a9bbad23fbd3c02df54cd7b5d59b0e8376756ac Reviewed-on: https://chromium-review.googlesource.com/1177094 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* stm32: use D-cache on STM32H7Vincent Palatin2018-06-041-2/+3
| | | | | | | | | | | | | | | | | | | | Enable the D-cache on STM32H7. Use the ahb4 RAM region as uncached memory for DMA buffers. Mark the serial, SPI and fingerprint DMA buffers as uncached for proper operations. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=poppy BUG=b:78535052, b:75068419 TEST=On ZerbleBarn, run fingerprint match. CQ-DEPEND=CL:*616448 Change-Id: Ia33496ebde3508d3427e522cc7ba060829f8f3fd Reviewed-on: https://chromium-review.googlesource.com/1065822 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* uart: fix compile warning when !defined CONFIG_CONSOLE_ENABLE_READ_V1Wei-Ning Huang2017-05-121-2/+2
| | | | | | | | | | | | | | | Fix compile warning when CONFIG_CONSOLE_ENABLE_READ_V1 is undefined. BRANCH=none BUG=b:37584134 TEST=with CONFIG_CONSOLE_ENABLE_READ_V1 undefined, `make BOARD=rose -j` Change-Id: I86f57e6fe92032ad688e861688f99b3f430404f4 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/504687 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
* uart: add config to optionally enable EC_CMD_CONSOLE_READ v1Wei-Ning Huang2017-05-061-1/+7
| | | | | | | | | | | | | | | | | | | The cros_ec_debugfs creates the `console_log` debugfs entry if EC supports EC_CMD_CONSOLE_READ version 1. On device where i2c command latency is critical, periodic console_read is impacting the timing of commands. BRANCH=none BUG=b:37584134 TEST=on rose with CONFIG_CONSOLE_ENABLE_READ_V1 undefined, the kernel should not create cros_tp/console_log. Change-Id: I40d0b959ef36f2f410155fa30e01c8169032a3e9 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/494546 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* UART: Remove X-on/X-off flow controlAnton Staaf2016-04-271-50/+10
| | | | | | | | | | | | | | | | | | This doesn't appear to be used anymore, and the EC3PO replacement console doesn't support this yet. This also makes changing the UART driver API more difficult, so let's remove it. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: Ia6d9cf4c89e34683f38169dbec612a417c6ba630 Reviewed-on: https://chromium-review.googlesource.com/340842 Commit-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-2/+5
| | | | | | | | | | | | | | | | | | | | | Previously calls to hook_call_deferred were passed the function to call, which was then looked up in the .rodata.deferred section with a linear search. This linear search can be replaced with a subtract by passing the pointer to the deferred_data object created when DECLARE_DEFERRED was invoked. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None CQ-DEPEND=CL:*255812 TEST=make buildall -j Change-Id: I951dd1541302875b102dd086154cf05591694440 Reviewed-on: https://chromium-review.googlesource.com/334315 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* stm32: add synchronous debug printfAlec Berg2015-10-191-2/+2
| | | | | | | | | | | | | | | | | | Allow use of a synchronous debug printf instead of using the full console task to save space. This can be turned on with CONFIG_DEBUG_PRINTF, and will provide essentially a one-way console for debugging. This is essentially expanding upon the debug_printf work done for zinger. BUG=chrome-os-partner:41959 BRANCH=none TEST=tested with following CLs on glados_pd by verifying we get a one-way console. Change-Id: If028b5d873261890de5b270bbc00e06bdcaa7431 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/306782 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* uart: provide polling mode of operationVadim Bendebury2015-08-081-0/+7
| | | | | | | | | | | | | | | | | | | | | Early hardware bringup often is complicated by exceptions happening in the code all over the place. Using interrupt based console output to trace startup progress is inefficient - a lot of text gets buffered and never shows up on the console. The new config option enables the mode where the console output is supposed to be happening in polling mode, the character transmit function not exiting until the entire character is transmitted. BRANCH=none BUG=chrome-os-partner:43791 TEST=with the new config enabled (and the appropriate changes to chip/g/uart.c) was able to debug bringup on the new version. Change-Id: I85fd2f3990ac1d31097d58bd6a7fa658b2b5146e Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291852 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* uart_buffering: extend CONSOLE_READ command for easy log concatenationstabilize-7134.BEric Caruso2015-06-021-8/+56
| | | | | | | | | | | | | | | | | | | | | | | | I'm planning to add functionality to the kernel which periodically dumps the EC console log and concatenates it so we can use it in bug reports and feedback. However, stitching together logs collected using the existing SNAPSHOT/READ commands is difficult. This adds a new version of READ which acts mostly the same but will only give you the difference between the two most recent snapshots when you pass the corresponding argument. BRANCH=ToT BUG=chromium:492721 TEST=On samus with kernel interface, cat /sys/kernel/debug/cros_ec/console_log and verify that the most recent bit of the log is printed, use spammy commands like 'accelinfo on' and make sure nothing breaks, check that 'ectool console' behavior has not changed Change-Id: Ib8216caa917715820c3e265400f0db2125e8808b Signed-off-by: Eric Caruso <ejcaruso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/273581 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* Allow console-reading host commands on locked systemsRandall Spangler2015-04-211-14/+0
| | | | | | | | | | | | | | | | | | We allow reading the EC console via case-closed debugging on locked systems, so we should also allow reading it via host command. The original reason for denying this (EC printing keystrokes) no longer exists; we don't print keyboard matrix changes by default anymore. BUG=chromium:479223 BRANCH=none (well, could apply this anywhere...) TEST=on a system with both hard and soft WP enabled in the EC, 'ectool console' works instead of failing with access denied. Change-Id: Ie111bc130dd3f17cd4b658718d00d299786e3434 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/266701 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Sameer Nanda <snanda@chromium.org>
* common: Add the possibility to filter UART inputMyles Watson2015-02-211-0/+10
| | | | | | | | | | | | | | | | | | | Add CONFIG_UART_INPUT_FILTER, which is undefined by default. BUG=chrome-os-partner:36745 TEST=buildall for the case where it is not defined. Added a filter function to the btle code on hadoken. Tested reset, transmit test, receive test, test end, and test mode end. BRANCH=None Signed-off-by: Myles Watson <mylesgw@chromium.org> Change-Id: I3a9c067ffcb114449b61f468271a48491a8c7ec5 Reviewed-on: https://chromium-review.googlesource.com/250580 Tested-by: Myles Watson <mylesgw@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Myles Watson <mylesgw@chromium.org>
* Make Ctrl-S and Ctrl-Q match the rest of the worldBill Richardson2014-06-041-4/+4
| | | | | | | | | | | | | | | | | | | Traditionally, Ctrl-S means XOFF and Ctrl-Q means XON (http://en.wikipedia.org/wiki/Software_flow_control) We've had it reversed on the EC console, and it's kind of annoying. BUG=none BRANCH=ToT TEST=make buildall Boot, watch the EC console. Hit Ctrl-S to stop the output, Ctrl-Q to continue. Change-Id: Ib2b9ba9a2688229d5d44f3b3f845208499ef09ff Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202532 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: Remove checkpatch warningsRandall Spangler2013-12-191-3/+3
| | | | | | | | | | | | | | | | This make minor syntactic changes and renames some camel-cased symbols to keep checkpatch from complaining. The goal is to reduce the temptation to use 'repo upload --no-verify'. This is a big furball of find/replace, but no functional changes. BUG=chromium:322144 BRANCH=none TEST=build all boards; pass unit tests Change-Id: I0269b7dd95836ef9a6e33f88c003ab0f24f842a0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/180495
* lm4: Use low speed clock in deep sleep.Alec Berg2013-10-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* stm32: Use DMA for UART receiveRandall Spangler2013-09-161-23/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | STM32 has a single-byte mailbox for UART I/O. When the core clock runs at 16Mhz we can service interrupts fast enough to handle 115200 baud input, but when we drop to 1MHz we drop characters. Using DMA to receive input solves this problem. The STM32 DMA engine can only generate interrupts when the transfer is half-done / all-done, so we need to poll the DMA receive-head-pointer to see if individual characters have been received. Do this in the tick task (every 250ms). When a character is received, poll more quickly for a bit (5 times before the next tick) so the input console is more responsive to typing. BUG=chrome-os-partner:20485 BRANCH=none TEST=Console is responsive to debug commands. For example, help -> prints help apshutdown -> shuts down AP arrow keys -> move cursor and scroll through command history Ctrl+Q, help, wait a second, Ctrl+S -> help output printed after Ctrl+S Then in chip/stm32/config_chip.h, comment out #define CONFIG_UART_RX_DMA and rebuild/reflash the EC. When the AP is up, the console works normally but after 'apshutdown', the EC drops to 1MHz core clock, and the arrow keys don't work. (This step confirms that adding DMA support did not change the behavior of systems where CONFIG_UART_RX_DMA is not defined.) Change-Id: I199448354824bd747c7b290ea7fd5ccf354c11bb Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169406 Reviewed-by: Simon Glass <sjg@chromium.org>
* Simplify uart_tx_start()Randall Spangler2013-09-141-6/+5
| | | | | | | | | | | | | | | | | | | All calls to it did if (uart_tx_stopped()) uart_tx_start(); And that was the only use of uart_tx_stopped(). Merge the functions. BUG=chrome-os-partner:20485 BRANCH=none TEST=EC debug console still prints output and accepts commands. Ctrl+Q pauses output and Ctrl+S resumes it. Change-Id: I113c64f5fdfc6b02b63034a74b1a3c6c6a76c351 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169329 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Remove unused uart functionsRandall Spangler2013-09-131-42/+0
| | | | | | | | | | | | | | Nothing ever called uart_flush_input() or uart_gets(), so remove them. They're dead code, and make implementing UART DMA input more complex. BUG=chrome-os-partner:20485 BRANCH=none TEST=build all platforms; pass unit tests Change-Id: I94c2c372ac3f326b98e819b2c89b8995311b2868 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169345 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* stm32: Support DMA-based UART outputRandall Spangler2013-09-111-0/+49
| | | | | | | | | | | | | | | This reduces the number of UART interrupts by a factor of 12, and reduces the overall interrupt rate on STM32 by a factor of 2. BUG=chrome-os-partner:20485 BRANCH=none (not required for pit branch) TEST=Boot pit. Ctrl+Q pauses debug output; Ctrl+S resumes it. 'crash divzero' still prints a full crash dump. And util/makeall.sh passes builds all platforms and passes tests. Change-Id: I86993e14b436150298dcb2c6d29086cc3c9db418 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168814
* Split uart_process() into input and output processingRandall Spangler2013-09-111-48/+31
| | | | | | | | | | | | | | This is a precursor to DMA-based UART transfers, which require different processing for DMA vs PIO output types. BUG=chrome-os-partner:20485 BRANCH=pit TEST=Boot pit; verify EC console still works. Change-Id: I6d6f55561eeebe9bd2928b2bfb25278c86f689d1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168811 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Move input character processing from UART interrupt to console taskRandall Spangler2013-08-021-468/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-15/+2
| | | | | | | | | | | | 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
* Software flow control in consoleVic Yang2013-04-231-2/+17
| | | | | | | | | | | | | | | | This adds software flow control handling (a.k.a X-on/X-off). When Ctrl-Q is received, UART transmitting is paused until Ctrl-S is received. If the FIFO or buffer fill up during this period, console output is lost. BUG=chrome-os-partner:18680 TEST=Press Ctrl-Q and see console stopped. Press Ctrl-S and see buffered messages. BRANCH=spring Change-Id: I9ce1198a1119dadc558bb522c48037bb83bba415 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48887 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Consolidate emergency debug outputRandall Spangler2012-10-291-50/+29
| | | | | | | | | | | | | | | | | | | 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
* Clean up uart buffering codeRandall Spangler2012-10-261-87/+48
| | | | | | | | | | | | | 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>
* Add ectool command to read snapshot of EC's console outputRandall Spangler2012-08-091-1/+85
| | | | | | | | | | | | | | BUG=chrome-os-partner:12483 TEST=from root shell, 'ectool console', then on the ec console, type 'help list' a few times to generate lots of debug output, then repeat 'ectool console'. Then on EC console, 'syslock', and then 'ectool console' should fail. Change-Id: Ie1c74c7e35d6b8228615d20192fd90093977de64 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/29825 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Fix a bug that a line longer than 80 char kills EC consoleVic Yang2012-07-301-1/+1
| | | | | | | | | | | | | | BUG=chrome-os-partner:11938 TEST=Type a command longer than 80 char and press enter. Check console is still alive. Change-Id: Ib86c5f97cc12220ac62ab8855ef8e5c65ecd2d82 Reviewed-on: https://gerrit.chromium.org/gerrit/28679 Reviewed-by: Charlie Mooney <charliemooney@chromium.org> Tested-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
* Add console functionalityRandall Spangler2012-07-231-82/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keys I keep hitting should work like I expect them to. Home or Ctrl+A = move to beginning of line End or Ctrl+E = move to end of line Del = delete-right Ctrl+K = delete to end of line Ctrl+L = clear screen and reprint current line Ctrl+N = next command Ctrl+P = previous command Also, improve filtering of escape sequences and non-printable characters, so hitting unsupported keys or control codes doesn't mess up the current line of input. BUG=chrome-os-partner:11666 TEST=manual type 'fhelpbar' home -> cursor moves to beginning of line Ctrl+E -> cursor moves to end of line Ctrl+A -> cursor moves to beginning of line (of course, if you're using Minicom, you'll need to type Ctrl+A A, since Minicom uses Ctrl+A as its control key) del -> 'helpbar' end -> cursor moves to end of line left-arrow 3 times -> cursor moves under 'b' Ctrl+L -> screen clears, cursor still under 'b' Ctrl+K -> 'help' Ctrl+Y Page-Up Page-Down -> nothing printed enter -> prints known commands (output of 'help' command) Ctrl+P -> 'help' Ctrl+N -> empty command line Change-Id: Id893c93b26db8f3deed6ea8be5aab88a3daaead4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28143
* Increase UART output buffer size on LM4Randall Spangler2012-07-071-12/+23
| | | | | | | | | | | | | 512 bytes isn't enough to capture all the debug output early in the init process, and Link EC has lots of unused RAM. stm32 doesn't, so only do this for LM4 processor. BUG=none TEST=build; debug output during init shouldn't be garbled Change-Id: Ie4fd204fa4e0c6ca99ea7eae94b095ef175836e4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/26877
* console: Support delete as well as backspaceSimon Glass2012-06-071-2/+2
| | | | | | | | | | | | | | | | Some terminals do not generate backspace correctly, so accept delete as a substitute. BUG=chrome-os-partner:10147 TEST=manual: ssh into workstation, then telnet to serial port (with ser2net running) See that the backspace key now works correctly, instead of injecting strange characters into the terminal. Change-Id: Ief6f2bcab9b8e82cb5720d18c596326b49ffc336 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24715 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Move printf() formatting to its own file to enable re-useRandall Spangler2012-06-071-173/+48
| | | | | | | | | | | | | Also add snprintf(), and %X format code. BUG=chrome-os-partner:10206 TEST=timerinfo; should print correctly. 'ectool battery' on host side should print same serial as 'battery' on EC console. Change-Id: I5c9f69d1a20ee5d0a59440c122655adbf62c9aea Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24635 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
* Add support for printing fixed-point numbersRandall Spangler2012-05-221-1/+21
| | | | | | | | | | | | 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
* Enable verified boot for EC firmwareBill Richardson2012-05-101-0/+5
| | | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:7459 TEST=manual In the chroot: cd src/platform/ec make BOARD=link The firmware image (build/link/ec.bin) is signed with dev-keys. Reflash the EC and try it, and it should verify and reboot into RW A. Additional tests (setting USE_RO_NORMAL, poking random values into VBLOCK_A or FW_MAIN_A to force RW B to run, etc.) are left as an exercise for the reader. I've done them and they work, though. Change-Id: I29a23ea69aef02a11aebd4af3b043f6864723523 Signed-off-by: Bill Richardson <wfrichar@chromium.org>
* Refactor async console outputRandall Spangler2012-04-241-5/+15
| | | | | | | | | | | | | | | | | | 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
* Implement 64-bit integer printing in uart_printf()Randall Spangler2012-04-201-13/+28
| | | | | | | | | Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:7490 TEST=timerinfo; numbers should look reasonable Change-Id: I698be99c87bf311013427ac0ed9e93e5687f40c0
* Add %T format code to print current timestamp.Randall Spangler2012-04-031-1/+7
| | | | | | | | | Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:8724 TEST=if timestamps show up in the debug output, it works Change-Id: I5264a3a40a07a824cc15b39a7bd81f2db02a3c13
* Add %b format output via uart_printfRong Chang2012-03-031-3/+9
| | | | | | | | | Useful when debug dump binary flags. BUG=chrome-os-partner:8287 TEST=none Change-Id: I646d80befafca07074847f2f09eeb23126533f67
* uart: fix race condition in flow controlVincent Palatin2012-02-291-5/+2
| | | | | | | | | | | | | | | The previous TX might end in the middle of the buffer filling and stop TX. So we need to check if we want to restart the transmission. With 1-byte deep FIFO, it's easy to trigger that race condition. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=run console commands with lots of traces on BDS, Link and ADV and check we are not stuck. Change-Id: Ia57e974a3a51af694e736d4cf36d9d01eafd2251
* Fix a bug causing console history to miss a character.Vic Yang2012-02-291-1/+1
| | | | | | | | | | | | If the last command is saved at the beginning of the buffer, loading this command will lead to a character missing. Signed-off-by: Vic Yang <victoryang@chromium.org> BUG=chrome-os-partner:8261 TEST=Manual Change-Id: I0afd4a264f342137955075fe2950444691f79d35
* Handle up/down arrow keys for UART console.Vic Yang2012-02-071-48/+191
| | | | | | | | | | | | | | | | | | | | | | 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
* Handle left and right arrow key in UART console.Vic Yang2012-02-011-14/+108
| | | | | | | | | | | | | | | Handle left and right arrow key to move cursor around. Other escape sequences are still ignored. BUG=chrome-os-partner:7865 TEST=type some text and use left and right arrow key. Cursor should move. type 'hellp', left key, and backspace. Should show 'help' and hitting enter prints help. type 'hexp', left key, backspace, 'l'. Should show 'help and hitting enter prints help. Change-Id: If9ac4504c56f023f824175de2daf565ce72d4560
* Eat terminal escape sequencesRandall Spangler2012-01-271-1/+15
| | | | | | | | | | | | | I keep hitting the darn arrow keys. Until we can do something more elegant like a real command history, this will at least keep me from corrupting the display and input buffer. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=none TEST=type 'help' and some arrow keys, then enter. Should print help, not an error. Change-Id: Idb552e9c22876fc2dc1f349f0038e94048f00aa7
* Split UART codeVincent Palatin2012-01-261-0/+414
Preparatory work to introduce a second SoC : 3rd series 1/2 Most of the code is handling the buffering and the printf, thus put it in an hardware independant location and only implement the UART dependant portions in the chip driver. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=run on BDS and stress the console. Change-Id: I9376f2fa1dad341eac808e1756dbeff32900bd51