Commit Graph

42 Commits

Author SHA1 Message Date
Stefan Reinauer
9939855231 Fix inconsistent task function declarations
Tasks are defined inconsistently across the code base.

Signed-off-by: Stefan Reinauer <reinauer@google.com>
BRANCH=none
TEST=make buildall -j, also verify kevin boots to OS
BUG=none

Change-Id: I19a076395a9a8ee1e457e67a89d80d2f70277c97
Reviewed-on: https://chromium-review.googlesource.com/602739
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-08-08 14:56:13 -07:00
Shawn Nematbakhsh
8a16e6483a task: Wait for HOOK_INIT completion before scheduling tasks
Until HOOK_INIT has completed, do not allow any tasks other than HOOKS
or IDLE to be scheduled. Programmers often make the assumption that
a HOOK_INIT function is guaranteed to be run before task code that depends
on it, so let's make it so.

BUG=chromium:649398
BRANCH=None
TEST=Manual on kevin, compare boot without patch:

...
[0.004 power state 0 = G3, in 0x0008] <-- from chipset task
RTC: 0x00000000 (0.00 s)
[0.004 power state 4 = G3->S5, in 0x0008]
RTC: 0x00000000 (0.00 s)
[0.005 clear MKBP fifo]
[0.006 clear MKBP fifo]
[0.006 KB init state: ... <-- from keyscan task
[0.012 SW 0x05]
[0.155 hash start 0x00020000 0x00019a38]
[0.158 HOOK_INIT DONE!]

... to boot with patch:

...
RTC: 0x58cc614c (1489789260.00 s)
[0.004 clear MKBP fifo]
[0.005 clear MKBP fifo]
[0.010 SW 0x05]
[0.155 hash start 0x00020000 0x000198e0]
[0.157 HOOK_INIT DONE!]
...

Also, verify kevin boots to OS and is generally functional through
sysjump and basic tasks, and verify elm (stm32f0 / cortex-m0) boots.

Change-Id: If56fab05ce9b9650feb93c5cfc2d084aa281e622
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/456628
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-19 15:33:10 -07:00
philipchen
e78307e242 console: ensure "Console is enabled" string is intact
BUG=chromium:687228
BRANCH=none
TEST=boot 10 times on kevin, and
see the complete string "Console is enabled..."

Change-Id: I9bb7358eb0a3d8172b5584329b9837cf62def635
Reviewed-on: https://chromium-review.googlesource.com/457421
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-03-20 19:30:15 -07:00
Bill Richardson
8c4421759d Cr50: Mark several console commands as safe
Even when CONFIG_RESTRICTED_CONSOLE_COMMANDS is enabled, there
are many commands that can't do anything dangerous. This marks
some of those commands as safe to use, even when restrictions are
enforced.

I'm only marking commands that are used by the Cr50, since that's
the only board that has restrictions.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall, test on Cr50 hardware

Change-Id: I6289d332830175b6adcb6b20cb4c21d01d27a25e
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376188
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-31 17:20:26 +00:00
Bill Richardson
70341959e6 Add console support for restricted commands
This adds support for CONFIG_RESTRICTED_CONSOLE_COMMANDS. If the
appropriate options are configured, restricted commands can be
prevented from running.

Nothing in this CL actually uses that, but it works if you turn
it on.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall, test on Cr50 hardware

I also tested it manually. If you add this to board.h:

  #define CONFIG_CONSOLE_COMMAND_FLAGS
  #define CONFIG_RESTRICTED_CONSOLE_COMMANDS
  #define CONFIG_CONSOLE_COMMAND_FLAGS_DEFAULT CMD_FLAG_RESTRICTED

and this to board.c:

  static int restricted_state;

  int console_is_restricted(void)
  {
         return restricted_state;
  }

  static int command_lock(int argc, char **argv)
  {
         int enabled;

         if (argc > 1) {
                 if (!parse_bool(argv[1], &enabled))
                         return EC_ERROR_PARAM1;
                 restricted_state = enabled;
         }

         ccprintf("The restricted console lock is %s\n",
                  restricted_state ? "enabled" : "disabled");

         return EC_SUCCESS;
  }
  DECLARE_CONSOLE_COMMAND_FLAGS(lock, command_lock,
                                "[<BOOLEAN>]",
                                "Get/Set the restricted console lock",
                                0);               /* no restrictions */

then you can use the "lock" command to enable and disable every
other console command except for it and "help".

Change-Id: Ic9517f9ea7a9867f15e5d14b302246070163d558
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376186
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-31 17:12:58 +00:00
Bill Richardson
6d805476ba Add configs to add flags to console commands
If we add a .flags field to the console commands data structure,
we can use it to distinguish some commands from others, for
example to mark some commands as safe and others as dangerous.

This just adds the undefined CONFIG_ options. They aren't used
anywhere, so there's no behavioral difference yet.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall

Change-Id: I17fdf177dcb4324c77565bd95344da1405ea15ed
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376185
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-31 16:02:36 +00:00
Bill Richardson
3071b82b58 Remove unused CONFIG_CONSOLE_RESTRICTED_INPUT option
Nothing has used this config option since Spring and Skate, back
in early 2014. There's nothing in ToT that uses it at all. I want
to add something similar for other purposes, and having two
similar-sounding options will just cause confusion.

NOTE: Although the comments in include/system.h said that the two
functions

  system_get_console_force_enabled()
  system_set_console_force_enabled()

were only useful when CONFIG_CONSOLE_RESTRICTED_INPUT is defined,
they were being used in chip/stm32/system.c. But since the
bkpdata registers are only accessible to the EC, there was no way
to initialize or modify the one relevant bit that those functions
cared about, so they almost certainly had no effect.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall

Change-Id: Id41541193d4559f5c507bdd0268b049166af4497
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374525
2016-08-24 17:41:12 -07:00
Bill Richardson
bb15561db5 cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args
Since pretty much always, we've declared console commands to take
a "longhelp" argument with detailed explanations of what the
command does. But since almost as long, we've never actually used
that argument for anything - we just silently throw it away in
the macro. There's only one command (usbchargemode) that even
thinks it defines that argument.

We're never going to use this, let's just get rid of it.

BUG=none
BRANCH=none
CQ-DEPEND=CL:*279060
CQ-DEPEND=CL:*279158
CQ-DEPEND=CL:*279037
TEST=make buildall; tested on Cr50 hardware

Everything builds. Since we never used this arg anyway, there had
better not be any difference in the result.

Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374163
Reviewed-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-24 16:30:10 +00:00
Aseda Aboagye
4b35daffd1 common: console: Change console_init() string.
For enhanced EC images, change the string telling the user that the
console is enabled.  This is such that EC-3PO can distinguish between
non-enhanced ECs and enhanced ECs during EC boot.

BUG=chromium:588611
BRANCH=None
TEST=Build for chell with CONFIG_EXPERIMENTAL_CONSOLE and verify that
the new string is printed.
TEST=Repeat above test but without the config option and verify that the
old string is printed.
TEST=make -j buildall tests

Change-Id: Ic8ed0a028ecb701b999fa6c6a376704f375dbc62
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/329161
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-23 22:40:17 -08:00
Aseda Aboagye
f14dd412ce ec3po: Add compatibility for older EC images.
The EC-3PO console and interpreter could be used to talk to EC images
which do not have the necessary changes to support the new enhancements.
If this was the case, the interpreter would be very confused and the
user wouldn't be able to use the console.  This commit adds
compatibility support for talking to both non-enhanced and enhanced EC
images.

When the console and interpreter are instantiated, they assume by
default that the EC image they are talking to is non-enhanced.  When the
user presses the carriage return key, the console initiates an
interrogation with the EC image.  The interrogation is a simple
EC_SYN(0xEC) and waits EC_INTERROGATION_TIMEOUT for the correct
EC_ACK(0xC0).  Enhanced EC images will try to reply immediately to a
EC_SYN. Non-enhanced EC images will just ignore the EC_SYN as it's not a
printable character.  Once the interrogation is complete, the console
will either simply pass everything forwards to the EC or provide the
console interface itself.

BUG=chrome-os-partner:46063
BRANCH=None
TEST=Enabled CONFIG_EXPERIMENTAL_CONSOLE on GLaDOS.  Entered some
commands and verified console was working.  Disabled
CONFIG_EXPERIMENTAL_CONSOLE on GLaDOS, reflashed, and verified console
was still working without restarting the EC-3PO console.
TEST=./util/ec3po/console_unittest.py -b
TEST=./util/ec3po/interpreter_unittest.py -b
TEST=cros lint --debug util/ec3po/console.py
TEST=cros lint --debug util/ec3po/console_unittest.py
TEST=cros lint --debug util/ec3po/interpreter.py
TEST=cros lint --debug util/ec3po/interpreter_unittest.py

Change-Id: I4f472afbdd7e898bee308c239b68ace0f4049842
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/313002
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-26 01:39:36 -08:00
Aseda Aboagye
397dbec3d6 console: Add support for using EC-3PO console.
This commit introduces a new CONFIG_* option.  To utilise the
experimental console, simply define the following config option in the
board's board.h file.

     #define CONFIG_EXPERIMENTAL_CONSOLE

This is a temporary option which allows the EC console to be work with
the EC-3PO interactive console interface.  When this option is enabled,
the EC expects commands to packed in a particular format.  This is for
command integrity and allows the interpreter to perform automatic
command retrying in the event that a character is dropped from the sent
command.

It also removes a lot of the console editing methods since they are now
being served by EC-3PO.

Once the EC-3PO interpreter is pulled into servod, we can enable this
feature by default and the config option can go away.

BUG=chrome-os-partner:46054
BRANCH=None
TEST=make -j buildall tests
TEST=Enable CONFIG_EXPERIMENTAL_CONSOLE on GLaDOS; Flash EC and verify
that console works via the EC-3PO interactive console interface.
TEST=Build and flash on GLaDOS and verify normal console operation on
standard EC UART.

CQ-DEPEND=CL:308615

Change-Id: I5e66eb94e31299b27ce029b7f7ce6ba0a7fb6816
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/309991
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-11 12:58:34 -08:00
Vic Yang
80aa3da22c Only process console input after console task started
If a character is received between uart_init() and task_start(), we
shouldn't try to wake console task. Usually this shouldn't happen
because the input shouldn't be floating, but still, the EC should not
crash in this case.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Boot on Glower without servo connected. Check the LED is not
blinking.

Change-Id: I62157c3ecd50b5eca6b09c1cf594b65a605546f9
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241512
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 23:19:58 +00:00
Vincent Palatin
a975c98fb2 usb: add USB console driver
Provide access to the EC console through 2 USB bulk endpoints.
(which can be used through the usbserial driver)

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

BRANCH=none
BUG=none
TEST=run on Fruitpie and use the console over USB

Change-Id: Ia897764f3a030972ee2ed323f293c5fca899765a
Reviewed-on: https://chromium-review.googlesource.com/204167
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2014-07-17 00:40:23 +00:00
Bill Richardson
3f3a2e20a1 Add a few more error messages to the EC console
This adds explanations for all the error codes in enum ec_error_list, so
that console commands that fail can print the reason.

BUG=none
BRANCH=ToT
TEST=none

I can't find any console commands that return errors without explanations,
but I'm planning to add some. This is just preparation.

Change-Id: I26a730acb60a73c269c39ae2f24273b7e9920cec
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/191781
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-03-27 18:45:01 +00:00
Alec Berg
10bd1db6d7 lm4: Use low speed clock in deep sleep.
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>
2013-10-21 23:59:38 +00:00
Randall Spangler
889f7bdd3b Move input character processing from UART interrupt to console task
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>
2013-08-02 17:32:26 -07:00
Randall Spangler
e6f0c272a0 Clean up and document UART config options
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
2013-07-24 16:31:14 -07:00
Vic Yang
3e0e15d185 Accept a command if it's a full match
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>
2013-06-05 11:25:09 -07:00
Vic Yang
c8b7b430fe Add console command to force enable console
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>
2013-05-15 20:12:47 -07:00
Vincent Palatin
980df54979 add option to de-activate EC console input when WP is on
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>
2013-04-30 11:45:58 -07:00
Randall Spangler
cf7f33d158 Clean up uart buffering code
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>
2012-10-26 09:49:38 -07:00
Randall Spangler
dc53e4db7f Clean up console module
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
2012-10-24 12:55:46 -07:00
Randall Spangler
3e14c8f8be Split console output into its own module
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>
2012-06-13 13:17:33 -07:00
Randall Spangler
858d87cfaa Add basic SPI support to link
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
2012-05-30 13:12:34 -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
Randall Spangler
eac46a9194 More debug command cleanup to save space
(saves another 1.5KB)

BUG=none
TEST=(run the commands)

Change-Id: Id3ca58528fa68a4cec606edf2b98b9af38ac228f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
2012-05-21 10:21:10 -07:00
Randall Spangler
01e94792e7 Clean up debug commands to use less space
BUG=none
TEST=(run the commands)

Change-Id: I6ed4aee169311825190bcc386b86cdc32ba0866a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
2012-05-21 09:17:51 -07:00
Vincent Palatin
33b03d5a39 Sort console commands at build time
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>
2012-05-15 01:32:44 +00:00
Vadim Bendebury
336944e951 Arrange help output to sort 'column first'
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>
2012-05-14 17:44:45 -07:00
Vadim Bendebury
6a324c1de5 Allow console commands abbreviation
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>
2012-05-14 13:35:03 -07:00
Simon Glass
f8f5599178 Allow boards to set the default console mask
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>
2012-05-10 14:16:07 -07:00
Randall Spangler
013a930082 Fix truncated output from 'ch' command
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST='ch' - prints all the channels now

Change-Id: I38ebc3eed2476c44c26fc00d6ea79800ae427722
2012-05-10 12:41:50 -07:00
Vic Yang
7710ed563a Issue warning on fan stall.
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
2012-04-26 13:45:43 +08:00
Randall Spangler
470916fb0f Use console output instead of uart output for console commands
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
2012-04-24 18:34:46 -07:00
Randall Spangler
135f14bf49 Refactor async console output
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
2012-04-24 17:46:54 -07:00
Randall Spangler
24dafefb3a Move externs from .lds file into a header file
Fewer magic externs = good.

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

BUG=none
TEST=if it boots, it works

Change-Id: Ifadeb1701400c5492c40d2eaf8f68f2d70189648
2012-04-19 14:29:07 -07:00
Randall Spangler
a61d8db3d3 Change task messages to events
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
2012-04-06 09:06:53 -07:00
Vic Yang
730f099c83 Handle up/down arrow keys for UART console.
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
2012-02-07 10:23:59 +08:00
Vincent Palatin
1008124533 Remove useless header includes
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
2012-01-26 01:32:30 +00:00
Randall Spangler
8c56cc4fa7 Help command prints a sorted multi-column list of commands
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=type 'help' from console

Change-Id: If88610f35337243ca2550de2851bd1924083344d
2012-01-24 10:32:29 -08:00
Vincent Palatin
c21f07e58e register console commands at compile-time
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
2012-01-24 00:50:08 +00:00
Randall Spangler
bdf7da5b08 Initial sources import 1/3
source files mainly done by Randall.

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

Change-Id: Iaff83a842b17f3350fb6f2a3f1597ad4c29bd12a
2011-12-07 19:10:02 +00:00