1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00

135 Commits

Author SHA1 Message Date
Bogdan Marinescu
5d97e95489 Shell commands are now callable from the 'elua' module
Simply use 'elua.shell( <command> )', for example:

elua.shell( "ls /rom" )

In called like this, "lua" and "exit" are disallowed.
2012-11-14 00:00:24 +02:00
Bogdan Marinescu
e42b88561a 'mv' command and shell code refactoring
There is a new command in the shell ('mv' - move/rename files).
Also, the shell code was refactored into its own directory (src/shell).
The 'help' command in the shell was updated and supports 'help <command>'.
There is a new BUILD_ADVANCED_SHELL build time macro that enables the
advanced shell features (currently 'cp' with recursion (and other improvements),
'mv' and 'rm').
2012-10-07 23:54:28 +03:00
Bogdan Marinescu
2402627a10 Adding rm and rmdir commands to the shell (WIP) 2012-10-03 02:52:39 +03:00
Bogdan Marinescu
389ce9b41a More improvements to the shell (WIP)
- file masks ('*' and '?' are now accepted)
- recursive operations for ls/cp
- new FS-specific functions (src/common_fs.c)
2012-09-19 00:09:39 +03:00
Bogdan Marinescu
9e7f1ab4cd Preliminary directory support
- For now only supported for MMCFS
- 'dir' function in shell augmented to show directories and
  to traverse a path recursively if requested
- new command 'mkdir' in shell
2012-09-10 19:12:15 +03:00
Bogdan Marinescu
a9ebeac525 WOFS fix: at most one file opened in write mode
Due to the nature of WOFS, at most one file can be opened on WOFS
in write mode at any given time.
2012-06-25 20:32:29 +03:00
Bogdan Marinescu
e9a24cac11 Added WOFS + other stuff
This should really be more than one commit, but I wrote everything in one
shot and I don't feel like arranging the changes logically into different
commits. So, these are the changes:

- added WOFS (Write Once File System). This is a writeable file system that
  exists in the MCU's internal Flash memory and allows files to be written,
  but only once, in a single shot. More details to follow.
- the platform interface has a new MCU flash access interface.
- added WOFS "reference implementations" for two CPUs: LM3S8962 and
  STM32F103RE. They are easily extendable to other CPUs in the same platform
  and can be taken as a model for other platforms.
- the ROMFS file layout in memory was slightly changed.
- the simulator (src/platform/sim) got a new function (lseek).
- shell: now each shell command receives its arguments in a C-main-style
  (argc, argv) pair. This was originally Marcelo's idea and it finally
  made it to the master (although this particular implementation is mine),
  after I got fed up with all the argument parsing in the shell functions.
- new shell command: wofmt ("formats" a WOFS, effectively clearing it).
- a couple of small fixes in the shell code
2012-06-24 23:07:32 +03:00
Bogdan Marinescu
ed54aec47a Added FS registration data as argument to all FS functions
All the functions that implement a FS receive the instance data
of the FS (given at registration time to dm_register) as their
last argument. ROMFS was changed to take advantage of this.
2012-06-19 00:51:56 +03:00
Bogdan Marinescu
a199d47615 Changed FS registration mechanism
Now it's possible to have more than one instance of a given file
system. For example, one could use more that one ROM file system
in different physical locations (a possible configuration is
internal Flash and external serial memories). This mechanism is
currently implemented only in the device manager (devman.c),
actual instance implementation require per-FS support (to be
implemented later).
2012-06-17 14:04:51 +03:00
Bogdan Marinescu
d54659b572 RAM optimizations: pseudo RO strings, functions in Flash
This patch adds more RAM optimizations to eLua:

- direct file memory mapping: files in ROMFS will be read directly from Flash,
  without allocating any additional buffers. This doesn't help with RAM
  consumption in itself, but enables the set of optimizations below.

- pseudo read-only strings. These are still TStrings, but the actual string
  content can point directly to Flash. Original Lua strings are kept in
  TStrings structures (lobject.h):

  typedef union TString {
    L_Umaxalign dummy;  /* ensures maximum alignment for strings */
    struct {
      CommonHeader;
      lu_byte reserved;
      unsigned int hash;
      size_t len;
    } tsv;
  } TString;

  The actual string content comes right after the union TString above.
  Pseudo RO strings have the same header, but instead of having the string
  content after TString, they have a pointer that points to the actual
  string content (which should exist in a RO memory (Flash) that is directly
  accesbile from the MCU bus (like its internal Flash memory)). lua_newlstr
  detects automatically if it should create a regular string or a pseudo RO
  string by checking if the string pointer comes from the Flash region of the
  MCU. This optimization works for both precompiled (.lc) files that exist in
  ROMFS and for internal Lua strings (C code).

- functions in Flash: for precompiled (.lc) files that exist in ROMFS, the code
  of the functions and a part of the debug information will be read directly
  from Flash.

- ROMFS was changed to support files that are larger than 2**16 bytes and it
  aligns all its files to an offset which is a multiple of 4 in order to prevent
  data alignment issues with precompiled Lua code.

- the Lua bytecode dumper was changed to align all the instructions in a Lua
  function and a part of the debug information to an offset which is a multiple
  of 4. This might slightly increase the size of the precompiled Lua file.

These changes were succesfully checked against the Lua 5.1 test suite.
These changes were tested in eLua on LM3S and AVR32.
2012-05-10 00:39:42 +03:00
Martin Guy
90897d2d02 Save 4 bytes RAM per structure by reordering struct members
Structure size is 12 byte instead of 16 with GCC on x86,
probably also on others.
2012-02-26 04:14:53 +01:00
Martin Guy
69eb5cc478 Put the order of timer parameters back to what it used to be
This patch undoes the change in the order of timer parameters for:
net.accept() net.recv() tmr.delay() tmr.setclock() tmr.set_match_int()
tmr.gettimediff()  and also changes the new tmr.getdiffnow() to have the
same parameter ordering as the others.
The default timer ID (the systimer), which previously was obtained with an
optional last parameter, is now obtained by supplying nil as the timer ID.
2012-01-21 17:30:38 +02:00
Martin Guy
a5a20783a9 Fix tmr.getmaxdelay() with virtual and system timers when LUA_NUMBER_INTEGRAL
tmr.getmaxdelay() used to return -1 for the system timer and -2 for
virtual timers in the integer build due to Lua integers being signed.
This makes them return 2147483647 and 2147483646 resectively.
2012-01-15 06:37:13 +01:00
Bogdan Marinescu
66975786cf Fixed error in getmindelay/getmaxdelay
Fixed an error which made the getmindelay/getmaxdelay functions
invalid (thanks to Martin for spotting this). Also refactored the
code that computes min/max delay from platform files to common code.
2011-11-28 22:58:10 +02:00
James Snyder
1b678dfea2 Merge branch 'master' into lm3s_usb_cdc 2011-11-13 17:41:23 -06:00
James Snyder
8c0f82198f Fix CRLF 2011-10-24 19:11:35 -05:00
James Snyder
b7b6a6e7eb Add build-time check for system timer for MMCFS 2011-10-21 18:15:14 -05:00
James Snyder
c4f7fe94c1 Adjust MMCFS to use the system timer 2011-10-21 18:08:43 -05:00
Bogdan Marinescu
a46cc203c8 fix timeout data type in the RFS implementation 2011-10-13 14:12:05 +03:00
Bogdan Marinescu
026f72dd46 System timer support is now optional
Since the system timer might be too demanding for some platforms
(although this isn't currently the case for any eLua plarform) it
is now optional. Any platform that implements it must define the
PLATFORM_HAS_SYSTIMER macro in its platform_conf.h
2011-10-11 13:59:02 +03:00
Bogdan Marinescu
b1b82b127e Change systimer overflow handling from timer stop to interrupt disable
When a systimer timer overflow is detected, handle it by temporarily disabling
the systimer interrupt rather than disabling the systimer completely. It gives
better accuracy and fixes some hardware-related issues on some platforms.
2011-10-11 00:44:06 +03:00
Bogdan Marinescu
7f94e898e1 Added a function to directly specify the interrupt period 2011-10-10 01:22:56 +03:00
Bogdan Marinescu
720d62909e new timer convenience function 2011-10-09 19:41:30 +03:00
Bogdan Marinescu
a9e69c72d4 Update net module with the new timer infrastructure
- change timeouts in elua_uip.c to the timer data type
- make all timer IDs in the net module default to the system timer
2011-10-08 23:24:19 +03:00
Bogdan Marinescu
9ded6db852 Implementing system timer capabilities
- the infinite timeout value is again represented by a special value
  (not a special timer ID), but this time it's a non-negative value
- all timers in the UART module default to the system timer
- all timers in the TMR module default to the system timer
- implemented a generic system timer mechanism that can be used in
  conjunction with a timer interrupt.
- implemented system timers on LM3S (tested) and STM32 (not tested).
  Both are based on the Cortex M3 SysTick timer.
2011-10-08 20:07:14 +03:00
Bogdan Marinescu
ccd3a9bdab update code to match std_get_func's new signature 2011-10-08 02:40:48 +03:00
Bogdan Marinescu
a6a9829ff1 Started to modify the timer infrastructure
- added explicit support for the system timer in common_tmr.c
- all the functions in the tmr module will now use the system timer
  by default (if no id is specified)
- infinite timeout will be specified by using a special timer ID
  rather than using negative timeout values (this allows the timer
  data type to be unsigned and increases the timer range)
2011-10-07 17:19:51 +03:00
Martin Guy
4b6096a8dc Sort out declarations of ADC commons and platform-specific functions 2011-10-05 16:08:45 +02:00
James Snyder
f9eec264db Merge branch 'master' into lm3s_usb_cdc 2011-10-04 21:24:00 -05:00
James Snyder
6f6b272fd9 Clean up CDC-USB support 2011-09-13 19:44:08 -05:00
Martin Guy
1c1a59851d Split platform_pwm_op(id, op[, data]) into four distinct functions
platform_pwm_op( id, op, data ) did four unrelated tasks, switching on the
"op" parameter:
op==PLATFORM_PWM_OP_SET_CLOCK took a frequency and returned a frequency
op==PLATFORM_PWM_OP_GET_CLOCK took nothing returned a frequency
op==PLATFORM_PWM_OP_START and _STOP both took nothing and returned nothing

this patch replaces it with:
clock = platform_pwm_set_clock( id, clock)
clock = platform_pwm_get_clock( id )
platform_pwm_start( id ) and
platform_pwm_stop( id )

with resulting clarity in the documentation and smaller, faster code.

This does not affect the Lau interface.
2011-08-02 16:15:59 +02:00
James Snyder
06fa255251 add os module for desktop builds of Lua including LuaRPC binary 2011-07-25 19:31:29 -05:00
Martin Guy
158ce167ca Split platform_adc_op() into six separate functions
Previously, you called platform_adc_op(id, OPERATION, u32 arg) to achieve
six unrelated functions with different arg types and return values:

GET_MAXVAL takes nothing and returns an ADC conversion value
SET_SMOOTHING takes a power-of-two filter length and returns nothing
SET_BLOCKING takes a boolean and returns nothing
IS_DONE takes nothing and returns a boolean
SET_TIMER takes a timer ID and returns nothing
SET_CLOCK takes a frequency in Hz and returns a frequency in Hz.

This changes these to six independent functions, each with the right
parameters and return values.

This also makes the documentation more comprehensible, saves 26 bytes of
executable code and should be very slightly faster.
2011-07-23 20:04:32 +02:00
Martin Guy
a04fcd854e MMCFS_TICK_HZ needs to be the same as VTMR_FREQ_HZ
elua_mmc.c uses the virtual timer tick to implement its timeout delays,
and needs MMCFS_TICK_HZ to have the same value as VTMR_FREQ_HZ.
This corrects the mismatch on AVR32 platforms and adds a check to
validate.h to ensure that it remains so.
2011-07-13 23:02:33 +02:00
Martin Guy
2a6131ffe6 Eliminate all TAB characters in elua-specific code files.
Tabs have been creeping in to eLua's source files, sometimes representing
2 characters, sometimes 8.  This patch replaces them all with the appropriate
number of spaces, according to the context.
This only fixes files that were written specifically for eLua, not the
manufacturers' SDK source files that were simply imported into the tree.
2011-07-05 17:17:45 +02:00
James Snyder
ef1f485db6 Use linenoise instead of readline on POSIX platforms for desktop LuaRPC 2011-06-20 18:04:53 -05:00
James Snyder
ae856ae163 add bitarray, bit and pack modules to desktop luarpc build 2011-05-02 16:46:53 -05:00
Martin Guy
c0119c0908 Revert "Allow enabling/disabling of console buffer bu changing only BUF_ENABLE_CON"
This reverts commit a836ebeaaee9b3a84096f6f72213fa4a9d9f725a.

As requested by Bogdan
2011-04-25 13:52:10 +02:00
Martin Guy
a836ebeaae Allow enabling/disabling of console buffer bu changing only BUF_ENABLE_CON
(before, you had to change BUF_ENABLE_CON and CON_BUF_SIZE in parallel).
2011-04-23 18:05:50 +02:00
Dado Sutter
8dbeb972a3 - Changing .org to .net on the Copyright notice (at least until we start using www.eluaprojec.org domain) 2011-02-07 22:45:16 +00:00
Dado Sutter
3b14f52f52 - Copyright notice on shell prompt updated to 2011
- Community page changes irrelevant here, as this content will migrate to a CMS soon
2011-02-07 20:47:11 +00:00
Bogdan Marinescu
81e7f040fc merged remotefs_int branch on trunk, not fully tested yet 2011-01-16 00:23:19 +00:00
Bogdan Marinescu
cbd00c7a20 INT_TMR_MATCH support for STR9 platforms, so far tested ONLY on virtual timers. Note that if a physical timer is allocated to virtual timers it can't be the target of INT_TMR_MATCH 2011-01-05 20:32:26 +00:00
James Snyder
a4ae2bf4fb Apply misc fixes to LuaRPC:
- prevent premature helper gc
 - replace some MYASSERT statements with standard Lua functions for arg checking
2010-12-14 01:05:52 +00:00
Dado Sutter
a148d3956e Changing eLua version for the next release (v0.8) 2010-12-11 00:24:17 +00:00
James Snyder
1059c69245 Adjust CAN module to not block when receiving messages. recv
returns nothing (3 params will be nil) if no messages are waiting.
2010-12-06 23:26:29 +00:00
Bogdan Marinescu
ebfd94eb01 linenoise support extended to the eLua shell (it can be enabled separately in platform_conf.h). Documentation updated 2010-11-17 20:21:36 +00:00
Bogdan Marinescu
772b33c975 linenoise support for eLua. linenoise is a readline replacement which makes using the Lua interpreter much easier and also adds support for saving the 'history' of lines types in the interpreter. Documentation updated. Thanks go to James for suggesting this in the first place. 2010-11-16 22:53:06 +00:00
Bogdan Marinescu
aa228cfc7c added const to elua_int_table; added hw_cli/hw_sei in cpu module; various other fixes 2010-11-13 22:36:09 +00:00
Bogdan Marinescu
6302c1524e STR9 backend modified for the new interrupt structure, the STR9 port can now be compiled fine (but the interrupts were not tested on this particular platform) 2010-11-04 22:40:09 +00:00